diff -r a437b3f9d7f4 -r 6fe31bc95bbc jdk/src/share/classes/sun/nio/ch/Util.java --- a/jdk/src/share/classes/sun/nio/ch/Util.java Mon Mar 10 14:32:51 2008 -0700 +++ b/jdk/src/share/classes/sun/nio/ch/Util.java Mon Mar 10 15:07:09 2008 -0700 @@ -49,20 +49,21 @@ private static final int TEMP_BUF_POOL_SIZE = 3; // Per-thread soft cache of the last temporary direct buffer - private static ThreadLocal[] bufferPool; + private static ThreadLocal>[] bufferPool; static { - bufferPool = new ThreadLocal[TEMP_BUF_POOL_SIZE]; + bufferPool = (ThreadLocal>[]) + new ThreadLocal[TEMP_BUF_POOL_SIZE]; for (int i=0; i>(); } static ByteBuffer getTemporaryDirectBuffer(int size) { ByteBuffer buf = null; // Grab a buffer if available for (int i=0; i ref = bufferPool[i].get(); + if ((ref != null) && ((buf = ref.get()) != null) && (buf.capacity() >= size)) { buf.rewind(); buf.limit(size); @@ -80,18 +81,18 @@ return; // Put it in an empty slot if such exists for (int i=0; i ref = bufferPool[i].get(); if ((ref == null) || (ref.get() == null)) { - bufferPool[i].set(new SoftReference(buf)); + bufferPool[i].set(new SoftReference(buf)); return; } } // Otherwise replace a smaller one in the cache if such exists for (int i=0; i ref = bufferPool[i].get(); + ByteBuffer inCacheBuf = ref.get(); if ((inCacheBuf == null) || (buf.capacity() > inCacheBuf.capacity())) { - bufferPool[i].set(new SoftReference(buf)); + bufferPool[i].set(new SoftReference(buf)); return; } } @@ -120,10 +121,12 @@ } // Per-thread cached selector - private static ThreadLocal localSelector = new ThreadLocal(); + private static ThreadLocal> localSelector + = new ThreadLocal>(); // Hold a reference to the selWrapper object to prevent it from // being cleaned when the temporary selector wrapped is on lease. - private static ThreadLocal localSelectorWrapper = new ThreadLocal(); + private static ThreadLocal localSelectorWrapper + = new ThreadLocal(); // When finished, invoker must ensure that selector is empty // by cancelling any related keys and explicitly releasing @@ -131,15 +134,16 @@ static Selector getTemporarySelector(SelectableChannel sc) throws IOException { - SoftReference ref = (SoftReference)localSelector.get(); + SoftReference ref = localSelector.get(); SelectorWrapper selWrapper = null; Selector sel = null; if (ref == null - || ((selWrapper = (SelectorWrapper) ref.get()) == null) + || ((selWrapper = ref.get()) == null) || ((sel = selWrapper.get()) == null) || (sel.provider() != sc.provider())) { sel = sc.provider().openSelector(); - localSelector.set(new SoftReference(new SelectorWrapper(sel))); + localSelector.set(new SoftReference( + new SelectorWrapper(sel))); } else { localSelectorWrapper.set(selWrapper); } @@ -235,10 +239,10 @@ private static volatile Constructor directByteBufferConstructor = null; private static void initDBBConstructor() { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction() { + public Void run() { try { - Class cl = Class.forName("java.nio.DirectByteBuffer"); + Class cl = Class.forName("java.nio.DirectByteBuffer"); Constructor ctor = cl.getDeclaredConstructor( new Class[] { int.class, long.class, @@ -282,10 +286,10 @@ private static volatile Constructor directByteBufferRConstructor = null; private static void initDBBRConstructor() { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction() { + public Void run() { try { - Class cl = Class.forName("java.nio.DirectByteBufferR"); + Class cl = Class.forName("java.nio.DirectByteBufferR"); Constructor ctor = cl.getDeclaredConstructor( new Class[] { int.class, long.class,