changeset 26358:abfc0d4035bf

Merge
author prr
date Mon, 25 Aug 2014 10:43:59 -0700
parents bd702816164f 743de4ce28cc
children 50d45d375866 2713482c0fd3
files
diffstat 23 files changed, 591 insertions(+), 558 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/make/profile-rtjar-includes.txt	Fri Aug 22 11:02:00 2014 -0700
+++ b/jdk/make/profile-rtjar-includes.txt	Mon Aug 25 10:43:59 2014 -0700
@@ -201,6 +201,7 @@
     sun/audio \
     sun/awt \
     sun/corba \
+    sun/datatransfer \
     sun/dc \
     sun/font \
     sun/java2d \
--- a/jdk/src/java.base/share/classes/java/net/InetAddress.java	Fri Aug 22 11:02:00 2014 -0700
+++ b/jdk/src/java.base/share/classes/java/net/InetAddress.java	Mon Aug 25 10:43:59 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,11 +25,8 @@
 
 package java.net;
 
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Random;
+import java.util.NavigableSet;
 import java.util.Iterator;
-import java.util.LinkedList;
 import java.util.List;
 import java.util.ArrayList;
 import java.util.ServiceLoader;
@@ -41,6 +38,11 @@
 import java.io.ObjectInputStream.GetField;
 import java.io.ObjectOutputStream;
 import java.io.ObjectOutputStream.PutField;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ConcurrentSkipListSet;
+import java.util.concurrent.atomic.AtomicLong;
+
 import sun.security.action.*;
 import sun.net.InetAddressCachePolicy;
 import sun.net.util.IPAddressUtil;
@@ -705,194 +707,129 @@
             + "/" + getHostAddress();
     }
 
-    /*
-     * Cached addresses - our own litle nis, not!
-     */
-    private static Cache addressCache = new Cache(Cache.Type.Positive);
+    // mapping from host name to Addresses - either NameServiceAddresses (while
+    // still being looked-up by NameService(s)) or CachedAddresses when cached
+    private static final ConcurrentMap<String, Addresses> cache =
+        new ConcurrentHashMap<>();
 
-    private static Cache negativeCache = new Cache(Cache.Type.Negative);
+    // CachedAddresses that have to expire are kept ordered in this NavigableSet
+    // which is scanned on each access
+    private static final NavigableSet<CachedAddresses> expirySet =
+        new ConcurrentSkipListSet<>();
 
-    private static boolean addressCacheInit = false;
+    // common interface
+    private interface Addresses {
+        InetAddress[] get() throws UnknownHostException;
+    }
 
-    static InetAddress[]    unknown_array; // put THIS in cache
+    // a holder for cached addresses with required metadata
+    private static final class CachedAddresses  implements Addresses, Comparable<CachedAddresses> {
+        private static final AtomicLong seq = new AtomicLong();
+        final String host;
+        final InetAddress[] inetAddresses;
+        final long expiryTime; // time of expiry (in terms of System.nanoTime())
+        final long id = seq.incrementAndGet(); // each instance is unique
 
-    static InetAddressImpl  impl;
-
-    private static final HashMap<String, Void> lookupTable = new HashMap<>();
-
-    /**
-     * Represents a cache entry
-     */
-    static final class CacheEntry {
-
-        CacheEntry(InetAddress[] addresses, long expiration) {
-            this.addresses = addresses;
-            this.expiration = expiration;
+        CachedAddresses(String host, InetAddress[] inetAddresses, long expiryTime) {
+            this.host = host;
+            this.inetAddresses = inetAddresses;
+            this.expiryTime = expiryTime;
         }
 
-        InetAddress[] addresses;
-        long expiration;
-    }
-
-    /**
-     * A cache that manages entries based on a policy specified
-     * at creation time.
-     */
-    static final class Cache {
-        private LinkedHashMap<String, CacheEntry> cache;
-        private Type type;
-
-        enum Type {Positive, Negative};
-
-        /**
-         * Create cache
-         */
-        public Cache(Type type) {
-            this.type = type;
-            cache = new LinkedHashMap<String, CacheEntry>();
+        @Override
+        public InetAddress[] get() throws UnknownHostException {
+            if (inetAddresses == null) {
+                throw new UnknownHostException(host);
+            }
+            return inetAddresses;
         }
 
-        private int getPolicy() {
-            if (type == Type.Positive) {
-                return InetAddressCachePolicy.get();
-            } else {
-                return InetAddressCachePolicy.getNegative();
-            }
-        }
-
-        /**
-         * Add an entry to the cache. If there's already an
-         * entry then for this host then the entry will be
-         * replaced.
-         */
-        public Cache put(String host, InetAddress[] addresses) {
-            int policy = getPolicy();
-            if (policy == InetAddressCachePolicy.NEVER) {
-                return this;
-            }
-
-            // purge any expired entries
-
-            if (policy != InetAddressCachePolicy.FOREVER) {
-
-                // As we iterate in insertion order we can
-                // terminate when a non-expired entry is found.
-                LinkedList<String> expired = new LinkedList<>();
-                long now = System.currentTimeMillis();
-                for (String key : cache.keySet()) {
-                    CacheEntry entry = cache.get(key);
-
-                    if (entry.expiration >= 0 && entry.expiration < now) {
-                        expired.add(key);
-                    } else {
-                        break;
-                    }
-                }
-
-                for (String key : expired) {
-                    cache.remove(key);
-                }
-            }
-
-            // create new entry and add it to the cache
-            // -- as a HashMap replaces existing entries we
-            //    don't need to explicitly check if there is
-            //    already an entry for this host.
-            long expiration;
-            if (policy == InetAddressCachePolicy.FOREVER) {
-                expiration = -1;
-            } else {
-                expiration = System.currentTimeMillis() + (policy * 1000);
-            }
-            CacheEntry entry = new CacheEntry(addresses, expiration);
-            cache.put(host, entry);
-            return this;
-        }
-
-        /**
-         * Query the cache for the specific host. If found then
-         * return its CacheEntry, or null if not found.
-         */
-        public CacheEntry get(String host) {
-            int policy = getPolicy();
-            if (policy == InetAddressCachePolicy.NEVER) {
-                return null;
-            }
-            CacheEntry entry = cache.get(host);
-
-            // check if entry has expired
-            if (entry != null && policy != InetAddressCachePolicy.FOREVER) {
-                if (entry.expiration >= 0 &&
-                    entry.expiration < System.currentTimeMillis()) {
-                    cache.remove(host);
-                    entry = null;
-                }
-            }
-
-            return entry;
+        @Override
+        public int compareTo(CachedAddresses other) {
+            // natural order is expiry time -
+            // compare difference of expiry times rather than
+            // expiry times directly, to avoid possible overflow.
+            // (see System.nanoTime() recommendations...)
+            long diff = this.expiryTime - other.expiryTime;
+            if (diff < 0L) return -1;
+            if (diff > 0L) return 1;
+            // ties are broken using unique id
+            return Long.compare(this.id, other.id);
         }
     }
 
-    /*
-     * Initialize cache and insert anyLocalAddress into the
-     * unknown array with no expiry.
-     */
-    private static void cacheInitIfNeeded() {
-        assert Thread.holdsLock(addressCache);
-        if (addressCacheInit) {
-            return;
+    // a name service lookup based Addresses implementation which replaces itself
+    // in cache when the result is obtained
+    private static final class NameServiceAddresses implements Addresses {
+        private final String host;
+        private final InetAddress reqAddr;
+
+        NameServiceAddresses(String host, InetAddress reqAddr) {
+            this.host = host;
+            this.reqAddr = reqAddr;
         }
-        unknown_array = new InetAddress[1];
-        unknown_array[0] = impl.anyLocalAddress();
 
-        addressCache.put(impl.anyLocalAddress().getHostName(),
-                         unknown_array);
-
-        addressCacheInit = true;
-    }
-
-    /*
-     * Cache the given hostname and addresses.
-     */
-    private static void cacheAddresses(String hostname,
-                                       InetAddress[] addresses,
-                                       boolean success) {
-        hostname = hostname.toLowerCase();
-        synchronized (addressCache) {
-            cacheInitIfNeeded();
-            if (success) {
-                addressCache.put(hostname, addresses);
-            } else {
-                negativeCache.put(hostname, addresses);
+        @Override
+        public InetAddress[] get() throws UnknownHostException {
+            Addresses addresses;
+            // only one thread is doing lookup to name service
+            // for particular host at any time.
+            synchronized (this) {
+                // re-check that we are still us + re-install us if slot empty
+                addresses = cache.putIfAbsent(host, this);
+                if (addresses == null) {
+                    // this can happen when we were replaced by CachedAddresses in
+                    // some other thread, then CachedAddresses expired and were
+                    // removed from cache while we were waiting for lock...
+                    addresses = this;
+                }
+                // still us ?
+                if (addresses == this) {
+                    // lookup name services
+                    InetAddress[] inetAddresses;
+                    UnknownHostException ex;
+                    int cachePolicy;
+                    try {
+                        inetAddresses = getAddressesFromNameService(host, reqAddr);
+                        ex = null;
+                        cachePolicy = InetAddressCachePolicy.get();
+                    } catch (UnknownHostException uhe) {
+                        inetAddresses = null;
+                        ex = uhe;
+                        cachePolicy = InetAddressCachePolicy.getNegative();
+                    }
+                    // remove or replace us with cached addresses according to cachePolicy
+                    if (cachePolicy == InetAddressCachePolicy.NEVER) {
+                        cache.remove(host, this);
+                    } else {
+                        CachedAddresses cachedAddresses = new CachedAddresses(
+                            host,
+                            inetAddresses,
+                            cachePolicy == InetAddressCachePolicy.FOREVER
+                            ? 0L
+                            // cachePolicy is in [s] - we need [ns]
+                            : System.nanoTime() + 1000_000_000L * cachePolicy
+                        );
+                        if (cache.replace(host, this, cachedAddresses) &&
+                            cachePolicy != InetAddressCachePolicy.FOREVER) {
+                            // schedule expiry
+                            expirySet.add(cachedAddresses);
+                        }
+                    }
+                    if (inetAddresses == null) {
+                        throw ex == null ? new UnknownHostException(host) : ex;
+                    }
+                    return inetAddresses;
+                }
+                // else addresses != this
             }
+            // delegate to different addresses when we are already replaced
+            // but outside of synchronized block to avoid any chance of dead-locking
+            return addresses.get();
         }
     }
 
-    /*
-     * Lookup hostname in cache (positive & negative cache). If
-     * found return addresses, null if not found.
-     */
-    private static InetAddress[] getCachedAddresses(String hostname) {
-        hostname = hostname.toLowerCase();
-
-        // search both positive & negative caches
-
-        synchronized (addressCache) {
-            cacheInitIfNeeded();
-
-            CacheEntry entry = addressCache.get(hostname);
-            if (entry == null) {
-                entry = negativeCache.get(hostname);
-            }
-
-            if (entry != null) {
-                return entry.addresses;
-            }
-        }
-
-        // not found
-        return null;
-    }
+    static InetAddressImpl  impl;
 
     private static NameService createNSProvider(String provider) {
         if (provider == null)
@@ -1168,7 +1105,7 @@
             // We were expecting an IPv6 Litteral, but got something else
             throw new UnknownHostException("["+host+"]");
         }
-        return getAllByName0(host, reqAddr, true);
+        return getAllByName0(host, reqAddr, true, true);
     }
 
     /**
@@ -1229,14 +1166,27 @@
      */
     static InetAddress[] getAllByName0 (String host, boolean check)
         throws UnknownHostException  {
-        return getAllByName0 (host, null, check);
+        return getAllByName0 (host, null, check, true);
     }
 
-    private static InetAddress[] getAllByName0 (String host, InetAddress reqAddr, boolean check)
+    /**
+     * Designated lookup method.
+     *
+     * @param host host name to look up
+     * @param reqAddr requested address to be the 1st in returned array
+     * @param check perform security check
+     * @param useCache use cached value if not expired else always
+     *                 perform name service lookup (and cache the result)
+     * @return array of InetAddress(es)
+     * @throws UnknownHostException if host name is not found
+     */
+    private static InetAddress[] getAllByName0(String host,
+                                               InetAddress reqAddr,
+                                               boolean check,
+                                               boolean useCache)
         throws UnknownHostException  {
 
         /* If it gets here it is presumed to be a hostname */
-        /* Cache.get can return: null, unknownAddress, or InetAddress[] */
 
         /* make sure the connection to the host is allowed, before we
          * give out a hostname
@@ -1248,155 +1198,106 @@
             }
         }
 
-        InetAddress[] addresses = getCachedAddresses(host);
-
-        /* If no entry in cache, then do the host lookup */
-        if (addresses == null) {
-            addresses = getAddressesFromNameService(host, reqAddr);
+        // remove expired addresses from cache - expirySet keeps them ordered
+        // by expiry time so we only need to iterate the prefix of the NavigableSet...
+        long now = System.nanoTime();
+        for (CachedAddresses caddrs : expirySet) {
+            // compare difference of time instants rather than
+            // time instants directly, to avoid possible overflow.
+            // (see System.nanoTime() recommendations...)
+            if ((caddrs.expiryTime - now) < 0L) {
+                // ConcurrentSkipListSet uses weakly consistent iterator,
+                // so removing while iterating is OK...
+                if (expirySet.remove(caddrs)) {
+                    // ... remove from cache
+                    cache.remove(caddrs.host, caddrs);
+                }
+            } else {
+                // we encountered 1st element that expires in future
+                break;
+            }
         }
 
-        if (addresses == unknown_array)
-            throw new UnknownHostException(host);
+        // look-up or remove from cache
+        Addresses addrs;
+        if (useCache) {
+            addrs = cache.get(host);
+        } else {
+            addrs = cache.remove(host);
+            if (addrs != null) {
+                if (addrs instanceof CachedAddresses) {
+                    // try removing from expirySet too if CachedAddresses
+                    expirySet.remove(addrs);
+                }
+                addrs = null;
+            }
+        }
 
-        return addresses.clone();
+        if (addrs == null) {
+            // create a NameServiceAddresses instance which will look up
+            // the name service and install it within cache...
+            Addresses oldAddrs = cache.putIfAbsent(
+                host,
+                addrs = new NameServiceAddresses(host, reqAddr)
+            );
+            if (oldAddrs != null) { // lost putIfAbsent race
+                addrs = oldAddrs;
+            }
+        }
+
+        // ask Addresses to get an array of InetAddress(es) and clone it
+        return addrs.get().clone();
     }
 
-    private static InetAddress[] getAddressesFromNameService(String host, InetAddress reqAddr)
+    static InetAddress[] getAddressesFromNameService(String host, InetAddress reqAddr)
         throws UnknownHostException
     {
         InetAddress[] addresses = null;
-        boolean success = false;
         UnknownHostException ex = null;
 
-        // Check whether the host is in the lookupTable.
-        // 1) If the host isn't in the lookupTable when
-        //    checkLookupTable() is called, checkLookupTable()
-        //    would add the host in the lookupTable and
-        //    return null. So we will do the lookup.
-        // 2) If the host is in the lookupTable when
-        //    checkLookupTable() is called, the current thread
-        //    would be blocked until the host is removed
-        //    from the lookupTable. Then this thread
-        //    should try to look up the addressCache.
-        //     i) if it found the addresses in the
-        //        addressCache, checkLookupTable()  would
-        //        return the addresses.
-        //     ii) if it didn't find the addresses in the
-        //         addressCache for any reason,
-        //         it should add the host in the
-        //         lookupTable and return null so the
-        //         following code would do  a lookup itself.
-        if ((addresses = checkLookupTable(host)) == null) {
+        for (NameService nameService : nameServices) {
             try {
-                // This is the first thread which looks up the addresses
-                // this host or the cache entry for this host has been
-                // expired so this thread should do the lookup.
-                for (NameService nameService : nameServices) {
-                    try {
-                        /*
-                         * Do not put the call to lookup() inside the
-                         * constructor.  if you do you will still be
-                         * allocating space when the lookup fails.
-                         */
+                addresses = nameService.lookupAllHostAddr(host);
+                break;
+            } catch (UnknownHostException uhe) {
+                if (host.equalsIgnoreCase("localhost")) {
+                    addresses = new InetAddress[] { impl.loopbackAddress() };
+                    break;
+                }
+                else {
+                    ex = uhe;
+                }
+            }
+        }
 
-                        addresses = nameService.lookupAllHostAddr(host);
-                        success = true;
-                        break;
-                    } catch (UnknownHostException uhe) {
-                        if (host.equalsIgnoreCase("localhost")) {
-                            InetAddress[] local = new InetAddress[] { impl.loopbackAddress() };
-                            addresses = local;
-                            success = true;
-                            break;
-                        }
-                        else {
-                            addresses = unknown_array;
-                            success = false;
-                            ex = uhe;
-                        }
-                    }
+        if (addresses == null) {
+            throw ex == null ? new UnknownHostException(host) : ex;
+        }
+
+        // More to do?
+        if (reqAddr != null && addresses.length > 1 && !addresses[0].equals(reqAddr)) {
+            // Find it?
+            int i = 1;
+            for (; i < addresses.length; i++) {
+                if (addresses[i].equals(reqAddr)) {
+                    break;
                 }
-
-                // More to do?
-                if (reqAddr != null && addresses.length > 1 && !addresses[0].equals(reqAddr)) {
-                    // Find it?
-                    int i = 1;
-                    for (; i < addresses.length; i++) {
-                        if (addresses[i].equals(reqAddr)) {
-                            break;
-                        }
-                    }
-                    // Rotate
-                    if (i < addresses.length) {
-                        InetAddress tmp, tmp2 = reqAddr;
-                        for (int j = 0; j < i; j++) {
-                            tmp = addresses[j];
-                            addresses[j] = tmp2;
-                            tmp2 = tmp;
-                        }
-                        addresses[i] = tmp2;
-                    }
+            }
+            // Rotate
+            if (i < addresses.length) {
+                InetAddress tmp, tmp2 = reqAddr;
+                for (int j = 0; j < i; j++) {
+                    tmp = addresses[j];
+                    addresses[j] = tmp2;
+                    tmp2 = tmp;
                 }
-                // Cache the address.
-                cacheAddresses(host, addresses, success);
-
-                if (!success && ex != null)
-                    throw ex;
-
-            } finally {
-                // Delete host from the lookupTable and notify
-                // all threads waiting on the lookupTable monitor.
-                updateLookupTable(host);
+                addresses[i] = tmp2;
             }
         }
 
         return addresses;
     }
 
-
-    private static InetAddress[] checkLookupTable(String host) {
-        synchronized (lookupTable) {
-            // If the host isn't in the lookupTable, add it in the
-            // lookuptable and return null. The caller should do
-            // the lookup.
-            if (lookupTable.containsKey(host) == false) {
-                lookupTable.put(host, null);
-                return null;
-            }
-
-            // If the host is in the lookupTable, it means that another
-            // thread is trying to look up the addresses of this host.
-            // This thread should wait.
-            while (lookupTable.containsKey(host)) {
-                try {
-                    lookupTable.wait();
-                } catch (InterruptedException e) {
-                }
-            }
-        }
-
-        // The other thread has finished looking up the addresses of
-        // the host. This thread should retry to get the addresses
-        // from the addressCache. If it doesn't get the addresses from
-        // the cache, it will try to look up the addresses itself.
-        InetAddress[] addresses = getCachedAddresses(host);
-        if (addresses == null) {
-            synchronized (lookupTable) {
-                lookupTable.put(host, null);
-                return null;
-            }
-        }
-
-        return addresses;
-    }
-
-    private static void updateLookupTable(String host) {
-        synchronized (lookupTable) {
-            lookupTable.remove(host);
-            lookupTable.notifyAll();
-        }
-    }
-
     /**
      * Returns an {@code InetAddress} object given the raw IP address .
      * The argument is in network byte order: the highest order
@@ -1418,10 +1319,18 @@
         return getByAddress(null, addr);
     }
 
-    private static InetAddress cachedLocalHost = null;
-    private static long cacheTime = 0;
-    private static final long maxCacheTime = 5000L;
-    private static final Object cacheLock = new Object();
+    private static final class CachedLocalHost {
+        final String host;
+        final InetAddress addr;
+        final long expiryTime = System.nanoTime() + 5000_000_000L; // now + 5s;
+
+        CachedLocalHost(String host, InetAddress addr) {
+            this.host = host;
+            this.addr = addr;
+        }
+    }
+
+    private static volatile CachedLocalHost cachedLocalHost;
 
     /**
      * Returns the address of the local host. This is achieved by retrieving
@@ -1450,47 +1359,41 @@
 
         SecurityManager security = System.getSecurityManager();
         try {
+            // is cached data still valid?
+            CachedLocalHost clh = cachedLocalHost;
+            if (clh != null && (clh.expiryTime - System.nanoTime()) >= 0L) {
+                if (security != null) {
+                    security.checkConnect(clh.host, -1);
+                }
+                return clh.addr;
+            }
+
             String local = impl.getLocalHostName();
 
             if (security != null) {
                 security.checkConnect(local, -1);
             }
 
+            InetAddress localAddr;
             if (local.equals("localhost")) {
-                return impl.loopbackAddress();
-            }
-
-            InetAddress ret = null;
-            synchronized (cacheLock) {
-                long now = System.currentTimeMillis();
-                if (cachedLocalHost != null) {
-                    if ((now - cacheTime) < maxCacheTime) // Less than 5s old?
-                        ret = cachedLocalHost;
-                    else
-                        cachedLocalHost = null;
-                }
-
-                // we are calling getAddressesFromNameService directly
-                // to avoid getting localHost from cache
-                if (ret == null) {
-                    InetAddress[] localAddrs;
-                    try {
-                        localAddrs =
-                            InetAddress.getAddressesFromNameService(local, null);
-                    } catch (UnknownHostException uhe) {
-                        // Rethrow with a more informative error message.
-                        UnknownHostException uhe2 =
-                            new UnknownHostException(local + ": " +
-                                                     uhe.getMessage());
-                        uhe2.initCause(uhe);
-                        throw uhe2;
-                    }
-                    cachedLocalHost = localAddrs[0];
-                    cacheTime = now;
-                    ret = localAddrs[0];
+                // shortcut for "localhost" host name
+                localAddr = impl.loopbackAddress();
+            } else {
+                // call getAllByName0 without security checks and
+                // without using cached data
+                try {
+                    localAddr = getAllByName0(local, null, false, false)[0];
+                } catch (UnknownHostException uhe) {
+                    // Rethrow with a more informative error message.
+                    UnknownHostException uhe2 =
+                        new UnknownHostException(local + ": " +
+                                                 uhe.getMessage());
+                    uhe2.initCause(uhe);
+                    throw uhe2;
                 }
             }
-            return ret;
+            cachedLocalHost = new CachedLocalHost(local, localAddr);
+            return localAddr;
         } catch (java.lang.SecurityException e) {
             return impl.loopbackAddress();
         }
--- a/jdk/src/java.base/share/classes/sun/net/InetAddressCachePolicy.java	Fri Aug 22 11:02:00 2014 -0700
+++ b/jdk/src/java.base/share/classes/sun/net/InetAddressCachePolicy.java	Mon Aug 25 10:43:59 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -56,7 +56,7 @@
      * caching. For security reasons, this caching is made forever when
      * a security manager is set.
      */
-    private static int cachePolicy = FOREVER;
+    private static volatile int cachePolicy = FOREVER;
 
     /* The Java-level namelookup cache policy for negative lookups:
      *
@@ -66,7 +66,7 @@
      * default value is 0. It can be set to some other value for
      * performance reasons.
      */
-    private static int negativeCachePolicy = NEVER;
+    private static volatile int negativeCachePolicy = NEVER;
 
     /*
      * Whether or not the cache policy for successful lookups was set
@@ -110,10 +110,7 @@
           });
 
         if (tmp != null) {
-            cachePolicy = tmp.intValue();
-            if (cachePolicy < 0) {
-                cachePolicy = FOREVER;
-            }
+            cachePolicy = tmp < 0 ? FOREVER : tmp;
             propertySet = true;
         } else {
             /* No properties defined for positive caching. If there is no
@@ -148,19 +145,16 @@
           });
 
         if (tmp != null) {
-            negativeCachePolicy = tmp.intValue();
-            if (negativeCachePolicy < 0) {
-                negativeCachePolicy = FOREVER;
-            }
+            negativeCachePolicy = tmp < 0 ? FOREVER : tmp;
             propertyNegativeSet = true;
         }
     }
 
-    public static synchronized int get() {
+    public static int get() {
         return cachePolicy;
     }
 
-    public static synchronized int getNegative() {
+    public static int getNegative() {
         return negativeCachePolicy;
     }
 
@@ -190,7 +184,7 @@
      * @param newPolicy the value in seconds for how long the lookup
      * should be cached
      */
-    public static synchronized void setNegativeIfNotSet(int newPolicy) {
+    public static void setNegativeIfNotSet(int newPolicy) {
         /*
          * When setting the new value we may want to signal that the
          * cache should be flushed, though this doesn't seem strictly
@@ -200,7 +194,8 @@
             // Negative caching does not seem to have any security
             // implications.
             // checkValue(newPolicy, negativeCachePolicy);
-            negativeCachePolicy = newPolicy;
+            // but we should normalize negative policy
+            negativeCachePolicy = newPolicy < 0 ? FOREVER : newPolicy;
         }
     }
 
--- a/jdk/test/java/lang/Double/BitwiseConversion.java	Fri Aug 22 11:02:00 2014 -0700
+++ b/jdk/test/java/lang/Double/BitwiseConversion.java	Mon Aug 25 10:43:59 2014 -0700
@@ -25,21 +25,23 @@
  * @test
  * @bug 5037596
  * @summary Verify bitwise conversion works for non-canonical NaN values
+ * @library ../Math
+ * @build DoubleConsts
+ * @run main BitwiseConversion
  * @author Joseph D. Darcy
  */
 
 import static java.lang.Double.*;
-import static sun.misc.DoubleConsts.*;
 
 public class BitwiseConversion {
     static int testNanCase(long x) {
         int errors  = 0;
         // Strip out sign and exponent bits
-        long y = x & SIGNIF_BIT_MASK;
+        long y = x & DoubleConsts.SIGNIF_BIT_MASK;
 
         double values[] = {
-            longBitsToDouble(EXP_BIT_MASK | y),
-            longBitsToDouble(SIGN_BIT_MASK | EXP_BIT_MASK | y)
+            longBitsToDouble(DoubleConsts.EXP_BIT_MASK | y),
+            longBitsToDouble(DoubleConsts.SIGN_BIT_MASK | DoubleConsts.EXP_BIT_MASK | y)
         };
 
         for(double value: values) {
@@ -60,7 +62,7 @@
     public static void main(String... argv) {
         int errors = 0;
 
-        for (int i = 0; i < SIGNIFICAND_WIDTH-1; i++) {
+        for (int i = 0; i < DoubleConsts.SIGNIFICAND_WIDTH-1; i++) {
             errors += testNanCase(1L<<i);
         }
 
--- a/jdk/test/java/lang/Double/ParseHexFloatingPoint.java	Fri Aug 22 11:02:00 2014 -0700
+++ b/jdk/test/java/lang/Double/ParseHexFloatingPoint.java	Mon Aug 25 10:43:59 2014 -0700
@@ -30,7 +30,6 @@
 
 
 import java.util.regex.*;
-import sun.misc.DoubleConsts;
 
 public class ParseHexFloatingPoint {
     private ParseHexFloatingPoint(){}
@@ -158,8 +157,8 @@
         }
 
         long bigExponents [] = {
-            2*DoubleConsts.MAX_EXPONENT,
-            2*DoubleConsts.MIN_EXPONENT,
+            2*Double.MAX_EXPONENT,
+            2*Double.MIN_EXPONENT,
 
             (long)Integer.MAX_VALUE-1,
             (long)Integer.MAX_VALUE,
@@ -226,11 +225,11 @@
             new PairSD("0x1.000000000000001p-1075",     Double.MIN_VALUE),
 
             // More subnormal rounding tests
-            new PairSD("0x0.fffffffffffff7fffffp-1022", Math.nextDown(DoubleConsts.MIN_NORMAL)),
-            new PairSD("0x0.fffffffffffff8p-1022",      DoubleConsts.MIN_NORMAL),
-            new PairSD("0x0.fffffffffffff800000001p-1022",DoubleConsts.MIN_NORMAL),
-            new PairSD("0x0.fffffffffffff80000000000000001p-1022",DoubleConsts.MIN_NORMAL),
-            new PairSD("0x1.0p-1022",                   DoubleConsts.MIN_NORMAL),
+            new PairSD("0x0.fffffffffffff7fffffp-1022", Math.nextDown(Double.MIN_NORMAL)),
+            new PairSD("0x0.fffffffffffff8p-1022",      Double.MIN_NORMAL),
+            new PairSD("0x0.fffffffffffff800000001p-1022",Double.MIN_NORMAL),
+            new PairSD("0x0.fffffffffffff80000000000000001p-1022",Double.MIN_NORMAL),
+            new PairSD("0x1.0p-1022",                   Double.MIN_NORMAL),
 
 
             // Large value and overflow rounding tests
--- a/jdk/test/java/lang/Double/ToHexString.java	Fri Aug 22 11:02:00 2014 -0700
+++ b/jdk/test/java/lang/Double/ToHexString.java	Mon Aug 25 10:43:59 2014 -0700
@@ -25,11 +25,13 @@
  * @test
  * @bug 4826774 4926547
  * @summary Tests for {Float, Double}.toHexString methods
+ * @library ../Math
+ * @build DoubleConsts
+ * @run main ToHexString
  * @author Joseph D. Darcy
  */
 
 import java.util.regex.*;
-import sun.misc.DoubleConsts;
 
 public class ToHexString {
     private ToHexString() {}
@@ -83,7 +85,7 @@
                     DoubleConsts.EXP_BIAS;
                 result.append("0x");
 
-                if (exponent == DoubleConsts.MIN_EXPONENT - 1) { // zero or subnormal
+                if (exponent == Double.MIN_EXPONENT - 1) { // zero or subnormal
                     if(signifString.equals("0000000000000")) {
                         result.append("0.0p0");
                     }
--- a/jdk/test/java/lang/Float/BitwiseConversion.java	Fri Aug 22 11:02:00 2014 -0700
+++ b/jdk/test/java/lang/Float/BitwiseConversion.java	Mon Aug 25 10:43:59 2014 -0700
@@ -25,21 +25,23 @@
  * @test
  * @bug 5037596
  * @summary Verify bitwise conversion works for non-canonical NaN values
+ * @library ../Math
+ * @build FloatConsts
+ * @run main BitwiseConversion
  * @author Joseph D. Darcy
  */
 
 import static java.lang.Float.*;
-import static sun.misc.FloatConsts.*;
 
 public class BitwiseConversion {
     static int testNanCase(int x) {
         int errors  = 0;
         // Strip out sign and exponent bits
-        int y = x & SIGNIF_BIT_MASK;
+        int y = x & FloatConsts.SIGNIF_BIT_MASK;
 
         float values[] = {
-            intBitsToFloat(EXP_BIT_MASK | y),
-            intBitsToFloat(SIGN_BIT_MASK | EXP_BIT_MASK | y)
+            intBitsToFloat(FloatConsts.EXP_BIT_MASK | y),
+            intBitsToFloat(FloatConsts.SIGN_BIT_MASK | FloatConsts.EXP_BIT_MASK | y)
         };
 
         for(float value: values) {
@@ -60,7 +62,7 @@
     public static void main(String... argv) {
         int errors = 0;
 
-        for (int i = 0; i < SIGNIFICAND_WIDTH-1; i++) {
+        for (int i = 0; i < FloatConsts.SIGNIFICAND_WIDTH-1; i++) {
             errors += testNanCase(1<<i);
         }
 
--- a/jdk/test/java/lang/Math/CeilAndFloorTests.java	Fri Aug 22 11:02:00 2014 -0700
+++ b/jdk/test/java/lang/Math/CeilAndFloorTests.java	Mon Aug 25 10:43:59 2014 -0700
@@ -27,8 +27,6 @@
  * @summary Check for correct implementation of Math.ceil and Math.floor
  */
 
-import sun.misc.DoubleConsts;
-
 public class CeilAndFloorTests {
     private static int testCeilCase(double input, double expected) {
         int failures = 0;
@@ -139,10 +137,10 @@
         double [][] testCases = {
             { Double.MIN_VALUE,                           1.0},
             {-Double.MIN_VALUE,                          -0.0},
-            { Math.nextDown(DoubleConsts.MIN_NORMAL),     1.0},
-            {-Math.nextDown(DoubleConsts.MIN_NORMAL),    -0.0},
-            { DoubleConsts.MIN_NORMAL,                    1.0},
-            {-DoubleConsts.MIN_NORMAL,                   -0.0},
+            { Math.nextDown(Double.MIN_NORMAL),           1.0},
+            {-Math.nextDown(Double.MIN_NORMAL),          -0.0},
+            { Double.MIN_NORMAL,                          1.0},
+            {-Double.MIN_NORMAL,                         -0.0},
 
             { 0.1,                                        1.0},
             {-0.1,                                       -0.0},
--- a/jdk/test/java/lang/Math/CubeRootTests.java	Fri Aug 22 11:02:00 2014 -0700
+++ b/jdk/test/java/lang/Math/CubeRootTests.java	Mon Aug 25 10:43:59 2014 -0700
@@ -28,8 +28,6 @@
  * @author Joseph D. Darcy
  */
 
-import sun.misc.DoubleConsts;
-
 public class CubeRootTests {
     private CubeRootTests(){}
 
@@ -93,7 +91,7 @@
         }
 
         // Test cbrt(2^(3n)) = 2^n.
-        for(int i = 18; i <= DoubleConsts.MAX_EXPONENT/3; i++) {
+        for(int i = 18; i <= Double.MAX_EXPONENT/3; i++) {
             failures += testCubeRootCase(Math.scalb(1.0, 3*i),
                                          Math.scalb(1.0, i) );
         }
@@ -240,7 +238,7 @@
             double pcNeighborsStrictCbrt[] = new double[5];
 
             // Test near cbrt(2^(3n)) = 2^n.
-            for(int i = 18; i <= DoubleConsts.MAX_EXPONENT/3; i++) {
+            for(int i = 18; i <= Double.MAX_EXPONENT/3; i++) {
                 double pc = Math.scalb(1.0, 3*i);
 
                 pcNeighbors[2] = pc;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/Math/DoubleConsts.java	Mon Aug 25 10:43:59 2014 -0700
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Common library for additional constants of the {@code double} type.
+ */
+public final class DoubleConsts {
+    /**
+     * Don't let anyone instantiate this class.
+     */
+    private DoubleConsts() {}
+
+    /**
+     * Bias used in representing a {@code double} exponent.
+     */
+    public static final int     EXP_BIAS        = 1023;
+
+    /**
+     * Bit mask to isolate the exponent field of a {@code double}.
+     */
+    public static final long    EXP_BIT_MASK    = 0x7FF0000000000000L;
+
+    /**
+     * Bit mask to isolate the sign bit of a {@code double}.
+     */
+    public static final long    SIGN_BIT_MASK   = 0x8000000000000000L;
+
+    /**
+     * Bit mask to isolate the significand field of a {@code double}.
+     */
+    public static final long    SIGNIF_BIT_MASK = 0x000FFFFFFFFFFFFFL;
+
+    /**
+     * The number of logical bits in the significand of a
+     * {@code double} number, including the implicit bit.
+     */
+    public static final int SIGNIFICAND_WIDTH   = 53;
+
+    /**
+     * The exponent the smallest positive {@code double}
+     * subnormal value would have if it could be normalized.
+     */
+    public static final int     MIN_SUB_EXPONENT = Double.MIN_EXPONENT -
+                                                   (SIGNIFICAND_WIDTH - 1);
+
+    static {
+        // verify bit masks cover all bit positions and that the bit
+        // masks are non-overlapping
+        assert(((SIGN_BIT_MASK | EXP_BIT_MASK | SIGNIF_BIT_MASK) == ~0L) &&
+               (((SIGN_BIT_MASK & EXP_BIT_MASK) == 0L) &&
+                ((SIGN_BIT_MASK & SIGNIF_BIT_MASK) == 0L) &&
+                ((EXP_BIT_MASK & SIGNIF_BIT_MASK) == 0L)));
+    }
+}
--- a/jdk/test/java/lang/Math/Expm1Tests.java	Fri Aug 22 11:02:00 2014 -0700
+++ b/jdk/test/java/lang/Math/Expm1Tests.java	Mon Aug 25 10:43:59 2014 -0700
@@ -28,8 +28,6 @@
  * @author Joseph D. Darcy
  */
 
-import sun.misc.DoubleConsts;
-
 /*
  * The Taylor expansion of expxm1(x) = exp(x) -1 is
  *
@@ -99,7 +97,7 @@
         }
 
         // For x > 710, expm1(x) should be infinity
-        for(int i = 10; i <= DoubleConsts.MAX_EXPONENT; i++) {
+        for(int i = 10; i <= Double.MAX_EXPONENT; i++) {
             double d = Math.scalb(2, i);
             failures += testExpm1Case(d, infinityD);
         }
@@ -116,7 +114,7 @@
                                                  reachedLimit);
         }
 
-        for(int i = 7; i <= DoubleConsts.MAX_EXPONENT; i++) {
+        for(int i = 7; i <= Double.MAX_EXPONENT; i++) {
             double d = -Math.scalb(2, i);
             failures += testExpm1CaseWithUlpDiff(d, -1.0, 1, reachedLimit);
         }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/Math/FloatConsts.java	Mon Aug 25 10:43:59 2014 -0700
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Common library for additional constants of the {@code float} type.
+ */
+public final class FloatConsts {
+    /**
+     * Don't let anyone instantiate this class.
+     */
+    private FloatConsts() {}
+
+    /**
+     * Bias used in representing a {@code float} exponent.
+     */
+    public static final int     EXP_BIAS        = 127;
+
+    /**
+     * Bit mask to isolate the exponent field of a {@code float}.
+     */
+    public static final int     EXP_BIT_MASK    = 0x7F800000;
+
+    /**
+     * Bit mask to isolate the sign bit of a {@code float}.
+     */
+    public static final int     SIGN_BIT_MASK   = 0x80000000;
+
+    /**
+     * Bit mask to isolate the significand field of a {@code float}.
+     */
+    public static final int     SIGNIF_BIT_MASK = 0x007FFFFF;
+
+    /**
+     * The number of logical bits in the significand of a
+     * {@code float} number, including the implicit bit.
+     */
+    public static final int SIGNIFICAND_WIDTH   = 24;
+
+    /**
+     * The exponent the smallest positive {@code float} subnormal
+     * value would have if it could be normalized.
+     */
+    public static final int     MIN_SUB_EXPONENT = Float.MIN_EXPONENT -
+                                                   (SIGNIFICAND_WIDTH - 1);
+
+    static {
+        // verify bit masks cover all bit positions and that the bit
+        // masks are non-overlapping
+        assert(((SIGN_BIT_MASK | EXP_BIT_MASK | SIGNIF_BIT_MASK) == ~0) &&
+               (((SIGN_BIT_MASK & EXP_BIT_MASK) == 0) &&
+                ((SIGN_BIT_MASK & SIGNIF_BIT_MASK) == 0) &&
+                ((EXP_BIT_MASK & SIGNIF_BIT_MASK) == 0)));
+    }
+}
--- a/jdk/test/java/lang/Math/HyperbolicTests.java	Fri Aug 22 11:02:00 2014 -0700
+++ b/jdk/test/java/lang/Math/HyperbolicTests.java	Mon Aug 25 10:43:59 2014 -0700
@@ -28,8 +28,6 @@
  * @author Joseph D. Darcy
  */
 
-import sun.misc.DoubleConsts;
-
 public class HyperbolicTests {
     private HyperbolicTests(){}
 
@@ -342,7 +340,7 @@
 
         // sinh(x) overflows for values greater than 710; in
         // particular, it overflows for all 2^i, i > 10.
-        for(int i = 10; i <= DoubleConsts.MAX_EXPONENT; i++) {
+        for(int i = 10; i <= Double.MAX_EXPONENT; i++) {
             double d = Math.scalb(2.0, i);
 
             // Result and expected are the same.
@@ -701,7 +699,7 @@
 
         // cosh(x) overflows for values greater than 710; in
         // particular, it overflows for all 2^i, i > 10.
-        for(int i = 10; i <= DoubleConsts.MAX_EXPONENT; i++) {
+        for(int i = 10; i <= Double.MAX_EXPONENT; i++) {
             double d = Math.scalb(2.0, i);
 
             // Result and expected are the same.
@@ -996,7 +994,7 @@
             failures += testTanhCaseWithUlpDiff(i, 1.0, 2.5);
         }
 
-        for(int i = 5; i <= DoubleConsts.MAX_EXPONENT; i++) {
+        for(int i = 5; i <= Double.MAX_EXPONENT; i++) {
             double d = Math.scalb(2.0, i);
 
             failures += testTanhCaseWithUlpDiff(d, 1.0, 2.5);
--- a/jdk/test/java/lang/Math/HypotTests.java	Fri Aug 22 11:02:00 2014 -0700
+++ b/jdk/test/java/lang/Math/HypotTests.java	Mon Aug 25 10:43:59 2014 -0700
@@ -28,8 +28,6 @@
  * @author Joseph D. Darcy
  */
 
-import sun.misc.DoubleConsts;
-
 public class HypotTests {
     private HypotTests(){}
 
@@ -87,7 +85,7 @@
         // Verify hypot(x, 0.0) is close to x over the entire exponent
         // range.
         for(int i = DoubleConsts.MIN_SUB_EXPONENT;
-            i <= DoubleConsts.MAX_EXPONENT;
+            i <= Double.MAX_EXPONENT;
             i++) {
             double input = Math.scalb(2, i);
             failures += testHypotCase(input, 0.0, input);
@@ -125,7 +123,7 @@
         for(int i = 0; i < 1000; i++) {
             double d = rand.nextDouble();
             // Scale d to have an exponent equal to MAX_EXPONENT -15
-            d = Math.scalb(d, DoubleConsts.MAX_EXPONENT
+            d = Math.scalb(d, Double.MAX_EXPONENT
                                  -15 - Tests.ilogb(d));
             for(int j = 0; j <= 13; j += 1) {
                 failures += testHypotCase(3*d, 4*d, 5*d, 2.5);
--- a/jdk/test/java/lang/Math/IeeeRecommendedTests.java	Fri Aug 22 11:02:00 2014 -0700
+++ b/jdk/test/java/lang/Math/IeeeRecommendedTests.java	Mon Aug 25 10:43:59 2014 -0700
@@ -28,9 +28,6 @@
  * @author Joseph D. Darcy
  */
 
-import sun.misc.DoubleConsts;
-import sun.misc.FloatConsts;
-
 public class IeeeRecommendedTests {
     private IeeeRecommendedTests(){}
 
@@ -54,7 +51,7 @@
      * Returns a floating-point power of two in the normal range.
      */
     static double powerOfTwoD(int n) {
-        return Double.longBitsToDouble((((long)n + (long)DoubleConsts.MAX_EXPONENT) <<
+        return Double.longBitsToDouble((((long)n + (long)Double.MAX_EXPONENT) <<
                                         (DoubleConsts.SIGNIFICAND_WIDTH-1))
                                        & DoubleConsts.EXP_BIT_MASK);
     }
@@ -63,7 +60,7 @@
      * Returns a floating-point power of two in the normal range.
      */
     static float powerOfTwoF(int n) {
-        return Float.intBitsToFloat(((n + FloatConsts.MAX_EXPONENT) <<
+        return Float.intBitsToFloat(((n + Float.MAX_EXPONENT) <<
                                      (FloatConsts.SIGNIFICAND_WIDTH-1))
                                     & FloatConsts.EXP_BIT_MASK);
     }
@@ -129,7 +126,7 @@
                                   +16.0f,
                                   +Float.MIN_VALUE,
                                   +Float_MAX_SUBNORMAL,
-                                  +FloatConsts.MIN_NORMAL,
+                                  +Float.MIN_NORMAL,
                                   +Float.MAX_VALUE
         };
 
@@ -139,10 +136,10 @@
                                  0,
                                  1,
                                  4,
-                                 FloatConsts.MIN_EXPONENT - 1,
-                                 -FloatConsts.MAX_EXPONENT,
-                                 FloatConsts.MIN_EXPONENT,
-                                 FloatConsts.MAX_EXPONENT
+                                 Float.MIN_EXPONENT - 1,
+                                 -Float.MAX_EXPONENT,
+                                 Float.MIN_EXPONENT,
+                                 Float.MAX_EXPONENT
         };
 
         // Special value tests
@@ -152,7 +149,7 @@
 
 
         // Normal exponent tests
-        for(int i = FloatConsts.MIN_EXPONENT; i <= FloatConsts.MAX_EXPONENT; i++) {
+        for(int i = Float.MIN_EXPONENT; i <= Float.MAX_EXPONENT; i++) {
             int result;
 
             // Create power of two
@@ -175,7 +172,7 @@
                 failures += testGetExponentCase(randFloat, i);
             }
 
-            if (i > FloatConsts.MIN_EXPONENT) {
+            if (i > Float.MIN_EXPONENT) {
                 float po2minus = Math.nextAfter(po2,
                                                  Float.NEGATIVE_INFINITY);
                 failures += testGetExponentCase(po2minus, i-1);
@@ -199,13 +196,13 @@
             i++, top *= 2.0f) {
 
             failures += testGetExponentCase(top,
-                                            FloatConsts.MIN_EXPONENT - 1);
+                                            Float.MIN_EXPONENT - 1);
 
             // Test largest value in next smaller binade
             if (i >= 3) {// (i == 1) would test 0.0;
                          // (i == 2) would just retest MIN_VALUE
                 testGetExponentCase(Math.nextAfter(top, 0.0f),
-                                    FloatConsts.MIN_EXPONENT - 1);
+                                    Float.MIN_EXPONENT - 1);
 
                 if( i >= 10) {
                     // create a bit mask with (i-1) 1's in the low order
@@ -217,7 +214,7 @@
                                                  (rand.nextInt() & mask ) ) ;
 
                     failures += testGetExponentCase(randFloat,
-                                                    FloatConsts.MIN_EXPONENT - 1);
+                                                    Float.MIN_EXPONENT - 1);
                 }
             }
         }
@@ -236,7 +233,7 @@
                                    +16.0,
                                    +Double.MIN_VALUE,
                                    +Double_MAX_SUBNORMAL,
-                                   +DoubleConsts.MIN_NORMAL,
+                                   +Double.MIN_NORMAL,
                                    +Double.MAX_VALUE
         };
 
@@ -246,10 +243,10 @@
                                  0,
                                  1,
                                  4,
-                                 DoubleConsts.MIN_EXPONENT - 1,
-                                 -DoubleConsts.MAX_EXPONENT,
-                                 DoubleConsts.MIN_EXPONENT,
-                                 DoubleConsts.MAX_EXPONENT
+                                 Double.MIN_EXPONENT - 1,
+                                 -Double.MAX_EXPONENT,
+                                 Double.MIN_EXPONENT,
+                                 Double.MAX_EXPONENT
         };
 
         // Special value tests
@@ -259,7 +256,7 @@
 
 
         // Normal exponent tests
-        for(int i = DoubleConsts.MIN_EXPONENT; i <= DoubleConsts.MAX_EXPONENT; i++) {
+        for(int i = Double.MIN_EXPONENT; i <= Double.MAX_EXPONENT; i++) {
             int result;
 
             // Create power of two
@@ -282,7 +279,7 @@
                 failures += testGetExponentCase(randFloat, i);
             }
 
-            if (i > DoubleConsts.MIN_EXPONENT) {
+            if (i > Double.MIN_EXPONENT) {
                 double po2minus = Math.nextAfter(po2,
                                                     Double.NEGATIVE_INFINITY);
                 failures += testGetExponentCase(po2minus, i-1);
@@ -306,13 +303,13 @@
             i++, top *= 2.0f) {
 
             failures += testGetExponentCase(top,
-                                            DoubleConsts.MIN_EXPONENT - 1);
+                                            Double.MIN_EXPONENT - 1);
 
             // Test largest value in next smaller binade
             if (i >= 3) {// (i == 1) would test 0.0;
                          // (i == 2) would just retest MIN_VALUE
                 testGetExponentCase(Math.nextAfter(top, 0.0),
-                                    DoubleConsts.MIN_EXPONENT - 1);
+                                    Double.MIN_EXPONENT - 1);
 
                 if( i >= 10) {
                     // create a bit mask with (i-1) 1's in the low order
@@ -324,7 +321,7 @@
                                                  (rand.nextLong() & mask ) ) ;
 
                     failures += testGetExponentCase(randFloat,
-                                                    DoubleConsts.MIN_EXPONENT - 1);
+                                                    Double.MIN_EXPONENT - 1);
                 }
             }
         }
@@ -400,15 +397,15 @@
             {Float_MAX_VALUEmm, infinityF,              Float.MAX_VALUE},
             {Float_MAX_VALUEmm, Float_MAX_VALUEmm,      Float_MAX_VALUEmm},
 
-            {FloatConsts.MIN_NORMAL,    infinityF,              FloatConsts.MIN_NORMAL+
+            {Float.MIN_NORMAL,          infinityF,              Float.MIN_NORMAL+
                                                                 Float.MIN_VALUE},
-            {FloatConsts.MIN_NORMAL,    -infinityF,             Float_MAX_SUBNORMAL},
-            {FloatConsts.MIN_NORMAL,    1.0f,                   FloatConsts.MIN_NORMAL+
+            {Float.MIN_NORMAL,          -infinityF,             Float_MAX_SUBNORMAL},
+            {Float.MIN_NORMAL,          1.0f,                   Float.MIN_NORMAL+
                                                                 Float.MIN_VALUE},
-            {FloatConsts.MIN_NORMAL,    -1.0f,                  Float_MAX_SUBNORMAL},
-            {FloatConsts.MIN_NORMAL,    FloatConsts.MIN_NORMAL, FloatConsts.MIN_NORMAL},
+            {Float.MIN_NORMAL,          -1.0f,                  Float_MAX_SUBNORMAL},
+            {Float.MIN_NORMAL,          Float.MIN_NORMAL,       Float.MIN_NORMAL},
 
-            {Float_MAX_SUBNORMAL,       FloatConsts.MIN_NORMAL, FloatConsts.MIN_NORMAL},
+            {Float_MAX_SUBNORMAL,       Float.MIN_NORMAL,       Float.MIN_NORMAL},
             {Float_MAX_SUBNORMAL,       Float_MAX_SUBNORMAL,    Float_MAX_SUBNORMAL},
             {Float_MAX_SUBNORMAL,       0.0f,                   Float_MAX_SUBNORMALmm},
 
@@ -472,15 +469,15 @@
             {Double_MAX_VALUEmm,        infinityD,              Double.MAX_VALUE},
             {Double_MAX_VALUEmm,        Double_MAX_VALUEmm,     Double_MAX_VALUEmm},
 
-            {DoubleConsts.MIN_NORMAL,   infinityD,              DoubleConsts.MIN_NORMAL+
+            {Double.MIN_NORMAL,         infinityD,              Double.MIN_NORMAL+
                                                                 Double.MIN_VALUE},
-            {DoubleConsts.MIN_NORMAL,   -infinityD,             Double_MAX_SUBNORMAL},
-            {DoubleConsts.MIN_NORMAL,   1.0f,                   DoubleConsts.MIN_NORMAL+
+            {Double.MIN_NORMAL,         -infinityD,             Double_MAX_SUBNORMAL},
+            {Double.MIN_NORMAL,         1.0f,                   Double.MIN_NORMAL+
                                                                 Double.MIN_VALUE},
-            {DoubleConsts.MIN_NORMAL,   -1.0f,                  Double_MAX_SUBNORMAL},
-            {DoubleConsts.MIN_NORMAL,   DoubleConsts.MIN_NORMAL,DoubleConsts.MIN_NORMAL},
+            {Double.MIN_NORMAL,         -1.0f,                  Double_MAX_SUBNORMAL},
+            {Double.MIN_NORMAL,         Double.MIN_NORMAL,      Double.MIN_NORMAL},
 
-            {Double_MAX_SUBNORMAL,      DoubleConsts.MIN_NORMAL,DoubleConsts.MIN_NORMAL},
+            {Double_MAX_SUBNORMAL,      Double.MIN_NORMAL,      Double.MIN_NORMAL},
             {Double_MAX_SUBNORMAL,      Double_MAX_SUBNORMAL,   Double_MAX_SUBNORMAL},
             {Double_MAX_SUBNORMAL,      0.0d,                   Double_MAX_SUBNORMALmm},
 
@@ -529,15 +526,15 @@
             {NaNf,                      NaNf},
             {-infinityF,                -Float.MAX_VALUE},
             {-Float.MAX_VALUE,          -Float_MAX_VALUEmm},
-            {-FloatConsts.MIN_NORMAL,   -Float_MAX_SUBNORMAL},
+            {-Float.MIN_NORMAL,         -Float_MAX_SUBNORMAL},
             {-Float_MAX_SUBNORMAL,      -Float_MAX_SUBNORMALmm},
             {-Float.MIN_VALUE,          -0.0f},
             {-0.0f,                     Float.MIN_VALUE},
             {+0.0f,                     Float.MIN_VALUE},
             {Float.MIN_VALUE,           Float.MIN_VALUE*2},
             {Float_MAX_SUBNORMALmm,     Float_MAX_SUBNORMAL},
-            {Float_MAX_SUBNORMAL,       FloatConsts.MIN_NORMAL},
-            {FloatConsts.MIN_NORMAL,    FloatConsts.MIN_NORMAL+Float.MIN_VALUE},
+            {Float_MAX_SUBNORMAL,       Float.MIN_NORMAL},
+            {Float.MIN_NORMAL,          Float.MIN_NORMAL+Float.MIN_VALUE},
             {Float_MAX_VALUEmm,         Float.MAX_VALUE},
             {Float.MAX_VALUE,           infinityF},
             {infinityF,                 infinityF}
@@ -567,15 +564,15 @@
             {NaNd,                      NaNd},
             {-infinityD,                -Double.MAX_VALUE},
             {-Double.MAX_VALUE,         -Double_MAX_VALUEmm},
-            {-DoubleConsts.MIN_NORMAL,  -Double_MAX_SUBNORMAL},
+            {-Double.MIN_NORMAL,        -Double_MAX_SUBNORMAL},
             {-Double_MAX_SUBNORMAL,     -Double_MAX_SUBNORMALmm},
             {-Double.MIN_VALUE,         -0.0d},
             {-0.0d,                     Double.MIN_VALUE},
             {+0.0d,                     Double.MIN_VALUE},
             {Double.MIN_VALUE,          Double.MIN_VALUE*2},
             {Double_MAX_SUBNORMALmm,    Double_MAX_SUBNORMAL},
-            {Double_MAX_SUBNORMAL,      DoubleConsts.MIN_NORMAL},
-            {DoubleConsts.MIN_NORMAL,   DoubleConsts.MIN_NORMAL+Double.MIN_VALUE},
+            {Double_MAX_SUBNORMAL,      Double.MIN_NORMAL},
+            {Double.MIN_NORMAL,         Double.MIN_NORMAL+Double.MIN_VALUE},
             {Double_MAX_VALUEmm,        Double.MAX_VALUE},
             {Double.MAX_VALUE,          infinityD},
             {infinityD,                 infinityD}
@@ -607,16 +604,16 @@
             {-infinityF,                -infinityF},
             {-Float.MAX_VALUE,          -infinityF},
             {-Float_MAX_VALUEmm,        -Float.MAX_VALUE},
-            {-Float_MAX_SUBNORMAL,      -FloatConsts.MIN_NORMAL},
+            {-Float_MAX_SUBNORMAL,      -Float.MIN_NORMAL},
             {-Float_MAX_SUBNORMALmm,    -Float_MAX_SUBNORMAL},
             {-0.0f,                     -Float.MIN_VALUE},
             {+0.0f,                     -Float.MIN_VALUE},
             {Float.MIN_VALUE,           0.0f},
             {Float.MIN_VALUE*2,         Float.MIN_VALUE},
             {Float_MAX_SUBNORMAL,       Float_MAX_SUBNORMALmm},
-            {FloatConsts.MIN_NORMAL,    Float_MAX_SUBNORMAL},
-            {FloatConsts.MIN_NORMAL+
-             Float.MIN_VALUE,           FloatConsts.MIN_NORMAL},
+            {Float.MIN_NORMAL,          Float_MAX_SUBNORMAL},
+            {Float.MIN_NORMAL+
+             Float.MIN_VALUE,           Float.MIN_NORMAL},
             {Float.MAX_VALUE,           Float_MAX_VALUEmm},
             {infinityF,                 Float.MAX_VALUE},
         };
@@ -646,16 +643,16 @@
             {-infinityD,                -infinityD},
             {-Double.MAX_VALUE,         -infinityD},
             {-Double_MAX_VALUEmm,       -Double.MAX_VALUE},
-            {-Double_MAX_SUBNORMAL,     -DoubleConsts.MIN_NORMAL},
+            {-Double_MAX_SUBNORMAL,     -Double.MIN_NORMAL},
             {-Double_MAX_SUBNORMALmm,   -Double_MAX_SUBNORMAL},
             {-0.0d,                     -Double.MIN_VALUE},
             {+0.0d,                     -Double.MIN_VALUE},
             {Double.MIN_VALUE,          0.0d},
             {Double.MIN_VALUE*2,        Double.MIN_VALUE},
             {Double_MAX_SUBNORMAL,      Double_MAX_SUBNORMALmm},
-            {DoubleConsts.MIN_NORMAL,   Double_MAX_SUBNORMAL},
-            {DoubleConsts.MIN_NORMAL+
-             Double.MIN_VALUE,          DoubleConsts.MIN_NORMAL},
+            {Double.MIN_NORMAL,         Double_MAX_SUBNORMAL},
+            {Double.MIN_NORMAL+
+             Double.MIN_VALUE,          Double.MIN_NORMAL},
             {Double.MAX_VALUE,          Double_MAX_VALUEmm},
             {infinityD,                 Double.MAX_VALUE},
         };
@@ -689,7 +686,7 @@
             -Float.MAX_VALUE,
             -3.0f,
             -1.0f,
-            -FloatConsts.MIN_NORMAL,
+            -Float.MIN_NORMAL,
             -Float_MAX_SUBNORMALmm,
             -Float_MAX_SUBNORMAL,
             -Float.MIN_VALUE,
@@ -698,7 +695,7 @@
             Float.MIN_VALUE,
             Float_MAX_SUBNORMALmm,
             Float_MAX_SUBNORMAL,
-            FloatConsts.MIN_NORMAL,
+            Float.MIN_NORMAL,
             1.0f,
             3.0f,
             Float_MAX_VALUEmm,
@@ -739,7 +736,7 @@
             -Double.MAX_VALUE,
             -3.0d,
             -1.0d,
-            -DoubleConsts.MIN_NORMAL,
+            -Double.MIN_NORMAL,
             -Double_MAX_SUBNORMALmm,
             -Double_MAX_SUBNORMAL,
             -Double.MIN_VALUE,
@@ -748,7 +745,7 @@
             Double.MIN_VALUE,
             Double_MAX_SUBNORMALmm,
             Double_MAX_SUBNORMAL,
-            DoubleConsts.MIN_NORMAL,
+            Double.MIN_NORMAL,
             1.0d,
             3.0d,
             Double_MAX_VALUEmm,
@@ -790,7 +787,7 @@
              Float.MIN_VALUE,
              Float_MAX_SUBNORMALmm,
              Float_MAX_SUBNORMAL,
-             FloatConsts.MIN_NORMAL,
+             Float.MIN_NORMAL,
              1.0f,
              3.0f,
              Float_MAX_VALUEmm,
@@ -801,7 +798,7 @@
              -Float.MAX_VALUE,
              -3.0f,
              -1.0f,
-             -FloatConsts.MIN_NORMAL,
+             -Float.MIN_NORMAL,
              -Float_MAX_SUBNORMALmm,
              -Float_MAX_SUBNORMAL,
              -Float.MIN_VALUE,
@@ -864,7 +861,7 @@
              Double.MIN_VALUE,
              Double_MAX_SUBNORMALmm,
              Double_MAX_SUBNORMAL,
-             DoubleConsts.MIN_NORMAL,
+             Double.MIN_NORMAL,
              1.0d,
              3.0d,
              Double_MAX_VALUEmm,
@@ -875,7 +872,7 @@
              -Double.MAX_VALUE,
              -3.0d,
              -1.0d,
-             -DoubleConsts.MIN_NORMAL,
+             -Double.MIN_NORMAL,
              -Double_MAX_SUBNORMALmm,
              -Double_MAX_SUBNORMAL,
              -Double.MIN_VALUE,
@@ -964,7 +961,7 @@
 
     public static int testFloatScalb() {
         int failures=0;
-        int MAX_SCALE = FloatConsts.MAX_EXPONENT + -FloatConsts.MIN_EXPONENT +
+        int MAX_SCALE = Float.MAX_EXPONENT + -Float.MIN_EXPONENT +
                         FloatConsts.SIGNIFICAND_WIDTH + 1;
 
 
@@ -988,7 +985,7 @@
             3.0f*Float.MIN_VALUE,
             Float_MAX_SUBNORMALmm,
             Float_MAX_SUBNORMAL,
-            FloatConsts.MIN_NORMAL,
+            Float.MIN_NORMAL,
             1.0f,
             2.0f,
             3.0f,
@@ -998,8 +995,8 @@
         };
 
         int [] oneMultiplyScalingFactors = {
-            FloatConsts.MIN_EXPONENT,
-            FloatConsts.MIN_EXPONENT+1,
+            Float.MIN_EXPONENT,
+            Float.MIN_EXPONENT+1,
             -3,
             -2,
             -1,
@@ -1007,8 +1004,8 @@
             1,
             2,
             3,
-            FloatConsts.MAX_EXPONENT-1,
-            FloatConsts.MAX_EXPONENT
+            Float.MAX_EXPONENT-1,
+            Float.MAX_EXPONENT
         };
 
         int [] manyScalingFactors = {
@@ -1018,14 +1015,14 @@
             -MAX_SCALE,
             -MAX_SCALE+1,
 
-            2*FloatConsts.MIN_EXPONENT-1,       // -253
-            2*FloatConsts.MIN_EXPONENT,         // -252
-            2*FloatConsts.MIN_EXPONENT+1,       // -251
+            2*Float.MIN_EXPONENT-1,       // -253
+            2*Float.MIN_EXPONENT,         // -252
+            2*Float.MIN_EXPONENT+1,       // -251
 
-            FloatConsts.MIN_EXPONENT - FloatConsts.SIGNIFICAND_WIDTH,
+            Float.MIN_EXPONENT - FloatConsts.SIGNIFICAND_WIDTH,
             FloatConsts.MIN_SUB_EXPONENT,
-            -FloatConsts.MAX_EXPONENT,          // -127
-            FloatConsts.MIN_EXPONENT,           // -126
+            -Float.MAX_EXPONENT,          // -127
+            Float.MIN_EXPONENT,           // -126
 
             -2,
             -1,
@@ -1033,13 +1030,13 @@
             1,
             2,
 
-            FloatConsts.MAX_EXPONENT-1,         // 126
-            FloatConsts.MAX_EXPONENT,           // 127
-            FloatConsts.MAX_EXPONENT+1,         // 128
+            Float.MAX_EXPONENT-1,         // 126
+            Float.MAX_EXPONENT,           // 127
+            Float.MAX_EXPONENT+1,         // 128
 
-            2*FloatConsts.MAX_EXPONENT-1,       // 253
-            2*FloatConsts.MAX_EXPONENT,         // 254
-            2*FloatConsts.MAX_EXPONENT+1,       // 255
+            2*Float.MAX_EXPONENT-1,       // 253
+            2*Float.MAX_EXPONENT,         // 254
+            2*Float.MAX_EXPONENT+1,       // 255
 
             MAX_SCALE-1,
             MAX_SCALE,
@@ -1086,7 +1083,7 @@
 
         // Create 2^MAX_EXPONENT
         float twoToTheMaxExp = 1.0f; // 2^0
-        for(int i = 0; i < FloatConsts.MAX_EXPONENT; i++)
+        for(int i = 0; i < Float.MAX_EXPONENT; i++)
             twoToTheMaxExp *=2.0f;
 
         // Scale-up subnormal values until they all overflow
@@ -1094,12 +1091,12 @@
             float scale = 1.0f; // 2^j
             float value = subnormalTestCases[i];
 
-            for(int j=FloatConsts.MAX_EXPONENT*2; j < MAX_SCALE; j++) { // MAX_SCALE -1 should cause overflow
+            for(int j=Float.MAX_EXPONENT*2; j < MAX_SCALE; j++) { // MAX_SCALE -1 should cause overflow
                 int scaleFactor = j;
 
                 failures+=testScalbCase(value,
                                         scaleFactor,
-                                        (Tests.ilogb(value) +j > FloatConsts.MAX_EXPONENT ) ?
+                                        (Tests.ilogb(value) +j > Float.MAX_EXPONENT ) ?
                                         Math.copySign(infinityF, value) : // overflow
                                         // calculate right answer
                                         twoToTheMaxExp*(twoToTheMaxExp*(scale*value)) );
@@ -1172,7 +1169,7 @@
 
     public static int testDoubleScalb() {
         int failures=0;
-        int MAX_SCALE = DoubleConsts.MAX_EXPONENT + -DoubleConsts.MIN_EXPONENT +
+        int MAX_SCALE = Double.MAX_EXPONENT + -Double.MIN_EXPONENT +
                         DoubleConsts.SIGNIFICAND_WIDTH + 1;
 
 
@@ -1195,7 +1192,7 @@
             3.0d*Double.MIN_VALUE,
             Double_MAX_SUBNORMALmm,
             Double_MAX_SUBNORMAL,
-            DoubleConsts.MIN_NORMAL,
+            Double.MIN_NORMAL,
             1.0d,
             2.0d,
             3.0d,
@@ -1205,8 +1202,8 @@
         };
 
         int [] oneMultiplyScalingFactors = {
-            DoubleConsts.MIN_EXPONENT,
-            DoubleConsts.MIN_EXPONENT+1,
+            Double.MIN_EXPONENT,
+            Double.MIN_EXPONENT+1,
             -3,
             -2,
             -1,
@@ -1214,8 +1211,8 @@
             1,
             2,
             3,
-            DoubleConsts.MAX_EXPONENT-1,
-            DoubleConsts.MAX_EXPONENT
+            Double.MAX_EXPONENT-1,
+            Double.MAX_EXPONENT
         };
 
         int [] manyScalingFactors = {
@@ -1225,15 +1222,15 @@
             -MAX_SCALE,
             -MAX_SCALE+1,
 
-            2*DoubleConsts.MIN_EXPONENT-1,      // -2045
-            2*DoubleConsts.MIN_EXPONENT,        // -2044
-            2*DoubleConsts.MIN_EXPONENT+1,      // -2043
+            2*Double.MIN_EXPONENT-1,      // -2045
+            2*Double.MIN_EXPONENT,        // -2044
+            2*Double.MIN_EXPONENT+1,      // -2043
 
-            DoubleConsts.MIN_EXPONENT,          // -1022
-            DoubleConsts.MIN_EXPONENT - DoubleConsts.SIGNIFICAND_WIDTH,
+            Double.MIN_EXPONENT,          // -1022
+            Double.MIN_EXPONENT - DoubleConsts.SIGNIFICAND_WIDTH,
             DoubleConsts.MIN_SUB_EXPONENT,
-            -DoubleConsts.MAX_EXPONENT,         // -1023
-            DoubleConsts.MIN_EXPONENT,          // -1022
+            -Double.MAX_EXPONENT,         // -1023
+            Double.MIN_EXPONENT,          // -1022
 
             -2,
             -1,
@@ -1241,13 +1238,13 @@
             1,
             2,
 
-            DoubleConsts.MAX_EXPONENT-1,        // 1022
-            DoubleConsts.MAX_EXPONENT,          // 1023
-            DoubleConsts.MAX_EXPONENT+1,        // 1024
+            Double.MAX_EXPONENT-1,        // 1022
+            Double.MAX_EXPONENT,          // 1023
+            Double.MAX_EXPONENT+1,        // 1024
 
-            2*DoubleConsts.MAX_EXPONENT-1,      // 2045
-            2*DoubleConsts.MAX_EXPONENT,        // 2046
-            2*DoubleConsts.MAX_EXPONENT+1,      // 2047
+            2*Double.MAX_EXPONENT-1,      // 2045
+            2*Double.MAX_EXPONENT,        // 2046
+            2*Double.MAX_EXPONENT+1,      // 2047
 
             MAX_SCALE-1,
             MAX_SCALE,
@@ -1294,7 +1291,7 @@
 
         // Create 2^MAX_EXPONENT
         double twoToTheMaxExp = 1.0; // 2^0
-        for(int i = 0; i < DoubleConsts.MAX_EXPONENT; i++)
+        for(int i = 0; i < Double.MAX_EXPONENT; i++)
             twoToTheMaxExp *=2.0;
 
         // Scale-up subnormal values until they all overflow
@@ -1302,12 +1299,12 @@
             double scale = 1.0; // 2^j
             double value = subnormalTestCases[i];
 
-            for(int j=DoubleConsts.MAX_EXPONENT*2; j < MAX_SCALE; j++) { // MAX_SCALE -1 should cause overflow
+            for(int j=Double.MAX_EXPONENT*2; j < MAX_SCALE; j++) { // MAX_SCALE -1 should cause overflow
                 int scaleFactor = j;
 
                 failures+=testScalbCase(value,
                                         scaleFactor,
-                                        (Tests.ilogb(value) +j > DoubleConsts.MAX_EXPONENT ) ?
+                                        (Tests.ilogb(value) +j > Double.MAX_EXPONENT ) ?
                                         Math.copySign(infinityD, value) : // overflow
                                         // calculate right answer
                                         twoToTheMaxExp*(twoToTheMaxExp*(scale*value)) );
@@ -1345,7 +1342,7 @@
 
         double value = 0x1.000000000000bP-1;
         expected     = 0x0.2000000000001P-1022;
-        for(int i = 0; i < DoubleConsts.MAX_EXPONENT+2; i++) {
+        for(int i = 0; i < Double.MAX_EXPONENT+2; i++) {
             failures+=testScalbCase(value,
                                     -1024-i,
                                     expected);
@@ -1401,7 +1398,7 @@
                                   +16.0f,
                                   +Float.MIN_VALUE,
                                   +Float_MAX_SUBNORMAL,
-                                  +FloatConsts.MIN_NORMAL,
+                                  +Float.MIN_NORMAL,
                                   +Float.MAX_VALUE
         };
 
@@ -1424,7 +1421,7 @@
 
 
         // Normal exponent tests
-        for(int i = FloatConsts.MIN_EXPONENT; i <= FloatConsts.MAX_EXPONENT; i++) {
+        for(int i = Float.MIN_EXPONENT; i <= Float.MAX_EXPONENT; i++) {
             float expected;
 
             // Create power of two
@@ -1448,7 +1445,7 @@
                 failures += testUlpCase(randFloat, expected);
             }
 
-            if (i > FloatConsts.MIN_EXPONENT) {
+            if (i > Float.MIN_EXPONENT) {
                 float po2minus = Math.nextAfter(po2,
                                                    Float.NEGATIVE_INFINITY);
                 failures += testUlpCase(po2minus, expected/2.0f);
@@ -1506,7 +1503,7 @@
                                   +16.0d,
                                   +Double.MIN_VALUE,
                                   +Double_MAX_SUBNORMAL,
-                                  +DoubleConsts.MIN_NORMAL,
+                                  +Double.MIN_NORMAL,
                                   +Double.MAX_VALUE
         };
 
@@ -1529,7 +1526,7 @@
 
 
         // Normal exponent tests
-        for(int i = DoubleConsts.MIN_EXPONENT; i <= DoubleConsts.MAX_EXPONENT; i++) {
+        for(int i = Double.MIN_EXPONENT; i <= Double.MAX_EXPONENT; i++) {
             double expected;
 
             // Create power of two
@@ -1553,7 +1550,7 @@
                 failures += testUlpCase(randDouble, expected);
             }
 
-            if (i > DoubleConsts.MIN_EXPONENT) {
+            if (i > Double.MIN_EXPONENT) {
                 double po2minus = Math.nextAfter(po2,
                                                     Double.NEGATIVE_INFINITY);
                 failures += testUlpCase(po2minus, expected/2.0f);
@@ -1607,7 +1604,7 @@
             {NaNf,                      NaNf},
             {-infinityF,                -1.0f},
             {-Float.MAX_VALUE,          -1.0f},
-            {-FloatConsts.MIN_NORMAL,   -1.0f},
+            {-Float.MIN_NORMAL,         -1.0f},
             {-1.0f,                     -1.0f},
             {-2.0f,                     -1.0f},
             {-Float_MAX_SUBNORMAL,      -1.0f},
@@ -1617,7 +1614,7 @@
             {Float.MIN_VALUE,            1.0f},
             {Float_MAX_SUBNORMALmm,      1.0f},
             {Float_MAX_SUBNORMAL,        1.0f},
-            {FloatConsts.MIN_NORMAL,     1.0f},
+            {Float.MIN_NORMAL,           1.0f},
             {1.0f,                       1.0f},
             {2.0f,                       1.0f},
             {Float_MAX_VALUEmm,          1.0f},
@@ -1641,7 +1638,7 @@
             {NaNd,                      NaNd},
             {-infinityD,                -1.0},
             {-Double.MAX_VALUE,         -1.0},
-            {-DoubleConsts.MIN_NORMAL,  -1.0},
+            {-Double.MIN_NORMAL,        -1.0},
             {-1.0,                      -1.0},
             {-2.0,                      -1.0},
             {-Double_MAX_SUBNORMAL,     -1.0},
@@ -1651,7 +1648,7 @@
             {Double.MIN_VALUE,           1.0},
             {Double_MAX_SUBNORMALmm,     1.0},
             {Double_MAX_SUBNORMAL,       1.0},
-            {DoubleConsts.MIN_NORMAL,    1.0},
+            {Double.MIN_NORMAL,          1.0},
             {1.0,                        1.0},
             {2.0,                        1.0},
             {Double_MAX_VALUEmm,         1.0},
--- a/jdk/test/java/lang/Math/Log10Tests.java	Fri Aug 22 11:02:00 2014 -0700
+++ b/jdk/test/java/lang/Math/Log10Tests.java	Mon Aug 25 10:43:59 2014 -0700
@@ -28,8 +28,6 @@
  * @author Joseph D. Darcy
  */
 
-import sun.misc.DoubleConsts;
-
 public class Log10Tests {
     private Log10Tests(){}
 
@@ -70,7 +68,7 @@
             {Double.NEGATIVE_INFINITY,  NaNd},
             {-8.0,                      NaNd},
             {-1.0,                      NaNd},
-            {-DoubleConsts.MIN_NORMAL,  NaNd},
+            {-Double.MIN_NORMAL,        NaNd},
             {-Double.MIN_VALUE,         NaNd},
             {-0.0,                      -infinityD},
             {+0.0,                      -infinityD},
--- a/jdk/test/java/lang/Math/Log1pTests.java	Fri Aug 22 11:02:00 2014 -0700
+++ b/jdk/test/java/lang/Math/Log1pTests.java	Mon Aug 25 10:43:59 2014 -0700
@@ -28,8 +28,6 @@
  * @author Joseph D. Darcy
  */
 
-import sun.misc.DoubleConsts;
-
 public class Log1pTests {
     private Log1pTests(){}
 
@@ -93,7 +91,7 @@
         }
 
         // For x > 2^53 log1p(x) ~= log(x)
-        for(int i = 53; i <= DoubleConsts.MAX_EXPONENT; i++) {
+        for(int i = 53; i <= Double.MAX_EXPONENT; i++) {
             double d = Math.scalb(2, i);
             failures += testLog1pCaseWithUlpDiff(d, StrictMath.log(d), 2.001);
         }
--- a/jdk/test/java/lang/Math/Rint.java	Fri Aug 22 11:02:00 2014 -0700
+++ b/jdk/test/java/lang/Math/Rint.java	Mon Aug 25 10:43:59 2014 -0700
@@ -27,8 +27,6 @@
  * @summary Check for correct implementation of Math.rint(double)
  */
 
-import sun.misc.DoubleConsts;
-
 public class Rint {
 
     static int testRintCase(double input, double expected) {
@@ -51,8 +49,8 @@
         double [][] testCases = {
             {0.0,                               0.0},
             {Double.MIN_VALUE,                  0.0},
-            {Math.nextDown(DoubleConsts.MIN_NORMAL), 0.0},
-            {DoubleConsts.MIN_NORMAL,           0.0},
+            {Math.nextDown(Double.MIN_NORMAL),  0.0},
+            {Double.MIN_NORMAL,                 0.0},
 
             {0.2,                               0.0},
 
--- a/jdk/test/java/lang/Math/Tests.java	Fri Aug 22 11:02:00 2014 -0700
+++ b/jdk/test/java/lang/Math/Tests.java	Mon Aug 25 10:43:59 2014 -0700
@@ -30,9 +30,6 @@
  * and finally the expected result.
  */
 
-import sun.misc.FloatConsts;
-import sun.misc.DoubleConsts;
-
 public class Tests {
     private Tests(){}; // do not instantiate
 
@@ -81,13 +78,13 @@
         int exponent = Math.getExponent(d);
 
         switch (exponent) {
-        case DoubleConsts.MAX_EXPONENT+1:       // NaN or infinity
+        case Double.MAX_EXPONENT+1:       // NaN or infinity
             if( Double.isNaN(d) )
                 return (1<<30);         // 2^30
             else // infinite value
                 return (1<<28);         // 2^28
 
-        case DoubleConsts.MIN_EXPONENT-1:       // zero or subnormal
+        case Double.MIN_EXPONENT-1:       // zero or subnormal
             if(d == 0.0) {
                 return -(1<<28);        // -(2^28)
             }
@@ -117,14 +114,14 @@
                 }
                 exponent++;
                 assert( exponent >=
-                        DoubleConsts.MIN_EXPONENT - (DoubleConsts.SIGNIFICAND_WIDTH-1) &&
-                        exponent < DoubleConsts.MIN_EXPONENT);
+                        Double.MIN_EXPONENT - (DoubleConsts.SIGNIFICAND_WIDTH-1) &&
+                        exponent < Double.MIN_EXPONENT);
                 return exponent;
             }
 
         default:
-            assert( exponent >= DoubleConsts.MIN_EXPONENT &&
-                    exponent <= DoubleConsts.MAX_EXPONENT);
+            assert( exponent >= Double.MIN_EXPONENT &&
+                    exponent <= Double.MAX_EXPONENT);
             return exponent;
         }
     }
@@ -150,13 +147,13 @@
         int exponent = Math.getExponent(f);
 
         switch (exponent) {
-        case FloatConsts.MAX_EXPONENT+1:        // NaN or infinity
+        case Float.MAX_EXPONENT+1:        // NaN or infinity
             if( Float.isNaN(f) )
                 return (1<<30);         // 2^30
             else // infinite value
                 return (1<<28);         // 2^28
 
-        case FloatConsts.MIN_EXPONENT-1:        // zero or subnormal
+        case Float.MIN_EXPONENT-1:        // zero or subnormal
             if(f == 0.0f) {
                 return -(1<<28);        // -(2^28)
             }
@@ -186,14 +183,14 @@
                 }
                 exponent++;
                 assert( exponent >=
-                        FloatConsts.MIN_EXPONENT - (FloatConsts.SIGNIFICAND_WIDTH-1) &&
-                        exponent < FloatConsts.MIN_EXPONENT);
+                        Float.MIN_EXPONENT - (FloatConsts.SIGNIFICAND_WIDTH-1) &&
+                        exponent < Float.MIN_EXPONENT);
                 return exponent;
             }
 
         default:
-            assert( exponent >= FloatConsts.MIN_EXPONENT &&
-                    exponent <= FloatConsts.MAX_EXPONENT);
+            assert( exponent >= Float.MIN_EXPONENT &&
+                    exponent <= Float.MAX_EXPONENT);
             return exponent;
         }
     }
--- a/jdk/test/java/util/Formatter/BasicDouble.java	Fri Aug 22 11:02:00 2014 -0700
+++ b/jdk/test/java/util/Formatter/BasicDouble.java	Mon Aug 25 10:43:59 2014 -0700
@@ -36,9 +36,6 @@
 import java.text.DateFormatSymbols;
 import java.util.*;
 
-import sun.misc.DoubleConsts;
-
-
 import static java.util.Calendar.*;
 
 
@@ -1313,12 +1310,12 @@
         test("%.1a", "-0x1.0p0", -1.0);
         test("%.11a", "0x1.80000000000p1", 3.0);
         test("%.1a", "0x1.8p1", 3.0);
-        test("%.11a", "0x1.00000000000p-1022", DoubleConsts.MIN_NORMAL);
-        test("%.1a", "0x1.0p-1022", DoubleConsts.MIN_NORMAL);
+        test("%.11a", "0x1.00000000000p-1022", Double.MIN_NORMAL);
+        test("%.1a", "0x1.0p-1022", Double.MIN_NORMAL);
         test("%.11a", "0x1.00000000000p-1022",
-             Math.nextDown(DoubleConsts.MIN_NORMAL));
+             Math.nextDown(Double.MIN_NORMAL));
         test("%.1a", "0x1.0p-1022",
-             Math.nextDown(DoubleConsts.MIN_NORMAL));
+             Math.nextDown(Double.MIN_NORMAL));
         test("%.11a", "0x1.ffffffffffep-1023", 0x0.fffffffffffp-1022);
         test("%.1a", "0x1.0p-1022", 0x0.fffffffffffp-1022);
         test("%.30a", "0x0.000000000000100000000000000000p-1022", Double.MIN_VALUE);
--- a/jdk/test/sun/misc/FloatingDecimal/OldFloatingDecimalForTest.java	Fri Aug 22 11:02:00 2014 -0700
+++ b/jdk/test/sun/misc/FloatingDecimal/OldFloatingDecimalForTest.java	Mon Aug 25 10:43:59 2014 -0700
@@ -23,8 +23,6 @@
 
 //package sun.misc;
 
-import sun.misc.DoubleConsts;
-import sun.misc.FloatConsts;
 import java.util.regex.*;
 
 public class OldFloatingDecimalForTest{
@@ -2217,12 +2215,12 @@
 
             // Check for overflow and update exponent accordingly.
 
-            if (exponent > DoubleConsts.MAX_EXPONENT) {         // Infinite result
+            if (exponent > Double.MAX_EXPONENT) {         // Infinite result
                 // overflow to properly signed infinity
                 return new OldFloatingDecimalForTest(sign * Double.POSITIVE_INFINITY);
             } else {  // Finite return value
-                if (exponent <= DoubleConsts.MAX_EXPONENT && // (Usually) normal result
-                    exponent >= DoubleConsts.MIN_EXPONENT) {
+                if (exponent <= Double.MAX_EXPONENT && // (Usually) normal result
+                    exponent >= Double.MIN_EXPONENT) {
 
                     // The result returned in this block cannot be a
                     // zero or subnormal; however after the
@@ -2242,7 +2240,7 @@
                         (DoubleConsts.SIGNIF_BIT_MASK & significand);
 
                 }  else  {  // Subnormal or zero
-                    // (exponent < DoubleConsts.MIN_EXPONENT)
+                    // (exponent < Double.MIN_EXPONENT)
 
                     if (exponent < (DoubleConsts.MIN_SUB_EXPONENT -1 )) {
                         // No way to round back to nonzero value
@@ -2282,7 +2280,7 @@
                         // Now, discard the bits
                         significand = significand >> bitsDiscarded;
 
-                        significand = (( ((long)(DoubleConsts.MIN_EXPONENT -1) + // subnorm exp.
+                        significand = (( ((long)(Double.MIN_EXPONENT -1) + // subnorm exp.
                                           (long)DoubleConsts.EXP_BIAS) <<
                                          (DoubleConsts.SIGNIFICAND_WIDTH-1))
                                        & DoubleConsts.EXP_BIT_MASK) |
@@ -2350,7 +2348,7 @@
                  * information must be preserved (i.e. case 1).
                  */
                 if ((exponent >= FloatConsts.MIN_SUB_EXPONENT-1) &&
-                    (exponent <= FloatConsts.MAX_EXPONENT ) ){
+                    (exponent <= Float.MAX_EXPONENT ) ){
                     // Outside above exponent range, the float value
                     // will be zero or infinity.
 
--- a/jdk/test/sun/misc/FloatingDecimal/TestFloatingDecimal.java	Fri Aug 22 11:02:00 2014 -0700
+++ b/jdk/test/sun/misc/FloatingDecimal/TestFloatingDecimal.java	Mon Aug 25 10:43:59 2014 -0700
@@ -58,6 +58,9 @@
  * @test
  * @bug 7032154
  * @summary unit tests of sun.misc.FloatingDecimal
+ * @library ../../../java/lang/Math
+ * @build DoubleConsts FloatConsts
+ * @run main TestFloatingDecimal
  * @author Brian Burkhalter
  */
 public class TestFloatingDecimal {
--- a/jdk/test/sun/security/smartcardio/TestDirect.java	Fri Aug 22 11:02:00 2014 -0700
+++ b/jdk/test/sun/security/smartcardio/TestDirect.java	Mon Aug 25 10:43:59 2014 -0700
@@ -30,6 +30,7 @@
 
 // This test requires special hardware.
 
+import java.util.List;
 import javax.smartcardio.Card;
 import javax.smartcardio.CardTerminal;
 import javax.smartcardio.CardTerminals;
@@ -38,8 +39,12 @@
 public class TestDirect {
     public static void main(String[] args) throws Exception {
         TerminalFactory terminalFactory = TerminalFactory.getDefault();
-        CardTerminals cardTerminals = terminalFactory.terminals();
-        CardTerminal cardTerminal = cardTerminals.list().get(0);
+        List<CardTerminal> cardTerminals = terminalFactory.terminals().list();
+        System.out.println("Terminals: " + cardTerminals);
+        if (cardTerminals.isEmpty()) {
+            throw new Exception("No card terminals available");
+        }
+        CardTerminal cardTerminal = cardTerminals.get(0);
         Card card = cardTerminal.connect("DIRECT");
         card.disconnect(true);