# HG changeset patch # User alanb # Date 1216900001 -3600 # Node ID 67f1dc69ad100b2ca9d6b66f40965153f9725fb7 # Parent 15e617238139ef805cb5dff14e49781f57de4366 6726309: Compiler warnings in nio code Reviewed-by: sherman, iris diff -r 15e617238139 -r 67f1dc69ad10 jdk/src/share/classes/java/nio/channels/spi/AbstractSelector.java --- a/jdk/src/share/classes/java/nio/channels/spi/AbstractSelector.java Thu Jul 24 12:40:30 2008 +0100 +++ b/jdk/src/share/classes/java/nio/channels/spi/AbstractSelector.java Thu Jul 24 12:46:41 2008 +0100 @@ -82,7 +82,7 @@ this.provider = provider; } - private final Set cancelledKeys = new HashSet(); + private final Set cancelledKeys = new HashSet(); void cancel(SelectionKey k) { // package-private synchronized (cancelledKeys) { diff -r 15e617238139 -r 67f1dc69ad10 jdk/src/share/classes/java/nio/charset/Charset-X-Coder.java --- a/jdk/src/share/classes/java/nio/charset/Charset-X-Coder.java Thu Jul 24 12:40:30 2008 +0100 +++ b/jdk/src/share/classes/java/nio/charset/Charset-X-Coder.java Thu Jul 24 12:46:41 2008 +0100 @@ -303,7 +303,7 @@ #if[encoder] - private WeakReference cachedDecoder = null; + private WeakReference cachedDecoder = null; /** * Tells whether or not the given byte array is a legal replacement value @@ -322,13 +322,13 @@ * is a legal replacement value for this encoder */ public boolean isLegalReplacement(byte[] repl) { - WeakReference wr = cachedDecoder; + WeakReference wr = cachedDecoder; CharsetDecoder dec = null; - if ((wr == null) || ((dec = (CharsetDecoder)wr.get()) == null)) { + if ((wr == null) || ((dec = wr.get()) == null)) { dec = charset().newDecoder(); dec.onMalformedInput(CodingErrorAction.REPORT); dec.onUnmappableCharacter(CodingErrorAction.REPORT); - cachedDecoder = new WeakReference(dec); + cachedDecoder = new WeakReference(dec); } else { dec.reset(); } diff -r 15e617238139 -r 67f1dc69ad10 jdk/src/share/classes/java/nio/charset/Charset.java --- a/jdk/src/share/classes/java/nio/charset/Charset.java Thu Jul 24 12:40:30 2008 +0100 +++ b/jdk/src/share/classes/java/nio/charset/Charset.java Thu Jul 24 12:46:41 2008 +0100 @@ -379,7 +379,7 @@ } // Thread-local gate to prevent recursive provider lookups - private static ThreadLocal gate = new ThreadLocal(); + private static ThreadLocal gate = new ThreadLocal(); private static Charset lookupViaProviders(final String charsetName) { @@ -539,9 +539,9 @@ // Fold charsets from the given iterator into the given map, ignoring // charsets whose names already have entries in the map. // - private static void put(Iterator i, Map m) { + private static void put(Iterator i, Map m) { while (i.hasNext()) { - Charset cs = (Charset)i.next(); + Charset cs = i.next(); if (!m.containsKey(cs.name())) m.put(cs.name(), cs); } @@ -623,7 +623,7 @@ private final String name; // tickles a bug in oldjavac private final String[] aliases; // tickles a bug in oldjavac - private Set aliasSet = null; + private Set aliasSet = null; /** * Initializes a new charset with the given canonical name and alias @@ -665,7 +665,7 @@ if (aliasSet != null) return aliasSet; int n = aliases.length; - HashSet hs = new HashSet(n); + HashSet hs = new HashSet(n); for (int i = 0; i < n; i++) hs.add(aliases[i]); aliasSet = Collections.unmodifiableSet(hs); diff -r 15e617238139 -r 67f1dc69ad10 jdk/src/share/classes/java/nio/charset/CoderResult.java --- a/jdk/src/share/classes/java/nio/charset/CoderResult.java Thu Jul 24 12:40:30 2008 +0100 +++ b/jdk/src/share/classes/java/nio/charset/CoderResult.java Thu Jul 24 12:46:41 2008 +0100 @@ -194,7 +194,7 @@ private static abstract class Cache { - private Map cache = null; + private Map> cache = null; protected abstract CoderResult create(int len); @@ -202,16 +202,16 @@ if (len <= 0) throw new IllegalArgumentException("Non-positive length"); Integer k = new Integer(len); - WeakReference w; + WeakReference w; CoderResult e = null; if (cache == null) { - cache = new HashMap(); - } else if ((w = (WeakReference)cache.get(k)) != null) { - e = (CoderResult)w.get(); + cache = new HashMap>(); + } else if ((w = cache.get(k)) != null) { + e = w.get(); } if (e == null) { e = create(len); - cache.put(k, new WeakReference(e)); + cache.put(k, new WeakReference(e)); } return e; } diff -r 15e617238139 -r 67f1dc69ad10 jdk/src/share/classes/sun/nio/ch/SelectorImpl.java --- a/jdk/src/share/classes/sun/nio/ch/SelectorImpl.java Thu Jul 24 12:40:30 2008 +0100 +++ b/jdk/src/share/classes/sun/nio/ch/SelectorImpl.java Thu Jul 24 12:46:41 2008 +0100 @@ -42,19 +42,19 @@ { // The set of keys with data ready for an operation - protected Set selectedKeys; + protected Set selectedKeys; // The set of keys registered with this Selector - protected HashSet keys; + protected HashSet keys; // Public views of the key sets - private Set publicKeys; // Immutable - private Set publicSelectedKeys; // Removal allowed, but not addition + private Set publicKeys; // Immutable + private Set publicSelectedKeys; // Removal allowed, but not addition protected SelectorImpl(SelectorProvider sp) { super(sp); - keys = new HashSet(); - selectedKeys = new HashSet(); + keys = new HashSet(); + selectedKeys = new HashSet(); if (Util.atBugLevel("1.4")) { publicKeys = keys; publicSelectedKeys = selectedKeys; @@ -64,13 +64,13 @@ } } - public Set keys() { + public Set keys() { if (!isOpen() && !Util.atBugLevel("1.4")) throw new ClosedSelectorException(); return publicKeys; } - public Set selectedKeys() { + public Set selectedKeys() { if (!isOpen() && !Util.atBugLevel("1.4")) throw new ClosedSelectorException(); return publicSelectedKeys; diff -r 15e617238139 -r 67f1dc69ad10 jdk/src/share/classes/sun/nio/ch/Util.java --- a/jdk/src/share/classes/sun/nio/ch/Util.java Thu Jul 24 12:40:30 2008 +0100 +++ b/jdk/src/share/classes/sun/nio/ch/Util.java Thu Jul 24 12:46:41 2008 +0100 @@ -51,9 +51,13 @@ // Per-thread soft cache of the last temporary direct buffer private static ThreadLocal>[] bufferPool; + @SuppressWarnings("unchecked") + static ThreadLocal>[] createThreadLocalBufferPool() { + return new ThreadLocal[TEMP_BUF_POOL_SIZE]; + } + static { - bufferPool = (ThreadLocal>[]) - new ThreadLocal[TEMP_BUF_POOL_SIZE]; + bufferPool = createThreadLocalBufferPool(); for (int i=0; i>(); } diff -r 15e617238139 -r 67f1dc69ad10 jdk/src/share/native/java/nio/Bits.c --- a/jdk/src/share/native/java/nio/Bits.c Thu Jul 24 12:40:30 2008 +0100 +++ b/jdk/src/share/native/java/nio/Bits.c Thu Jul 24 12:46:41 2008 +0100 @@ -116,7 +116,7 @@ jshort *srcShort, *dstShort, *endShort; jshort tmpShort; - dstShort = (jshort *)dstAddr; + dstShort = (jshort *)jlong_to_ptr(dstAddr); while (length > 0) { /* do not change this if-else statement, see WARNING above */ @@ -151,7 +151,7 @@ jshort *srcShort, *dstShort, *endShort; jshort tmpShort; - srcShort = (jshort *)srcAddr; + srcShort = (jshort *)jlong_to_ptr(srcAddr); while (length > 0) { /* do not change this if-else statement, see WARNING above */ @@ -186,7 +186,7 @@ jint *srcInt, *dstInt, *endInt; jint tmpInt; - dstInt = (jint *)dstAddr; + dstInt = (jint *)jlong_to_ptr(dstAddr); while (length > 0) { /* do not change this code, see WARNING above */ @@ -221,7 +221,7 @@ jint *srcInt, *dstInt, *endInt; jint tmpInt; - srcInt = (jint *)srcAddr; + srcInt = (jint *)jlong_to_ptr(srcAddr); while (length > 0) { /* do not change this code, see WARNING above */ @@ -256,7 +256,7 @@ jlong *srcLong, *dstLong, *endLong; jlong tmpLong; - dstLong = (jlong *)dstAddr; + dstLong = (jlong *)jlong_to_ptr(dstAddr); while (length > 0) { /* do not change this code, see WARNING above */ @@ -291,7 +291,7 @@ jlong *srcLong, *dstLong, *endLong; jlong tmpLong; - srcLong = (jlong *)srcAddr; + srcLong = (jlong *)jlong_to_ptr(srcAddr); while (length > 0) { /* do not change this code, see WARNING above */ diff -r 15e617238139 -r 67f1dc69ad10 jdk/src/solaris/classes/sun/nio/ch/DevPollSelectorImpl.java --- a/jdk/src/solaris/classes/sun/nio/ch/DevPollSelectorImpl.java Thu Jul 24 12:40:30 2008 +0100 +++ b/jdk/src/solaris/classes/sun/nio/ch/DevPollSelectorImpl.java Thu Jul 24 12:46:41 2008 +0100 @@ -50,7 +50,7 @@ private int totalChannels; // Maps from file descriptors to keys - private HashMap fdToKey; + private Map fdToKey; // True if this Selector has been closed private boolean closed = false; @@ -71,7 +71,7 @@ fd1 = fdes[1]; pollWrapper = new DevPollArrayWrapper(); pollWrapper.initInterrupt(fd0, fd1); - fdToKey = new HashMap(); + fdToKey = new HashMap(); totalChannels = 1; } @@ -110,8 +110,7 @@ int numKeysUpdated = 0; for (int i=0; i= 0); int fd = ski.channel.getFDVal(); - fdToKey.remove(new Integer(fd)); + fdToKey.remove(Integer.valueOf(fd)); pollWrapper.release(fd); totalChannels--; ski.setIndex(-1); diff -r 15e617238139 -r 67f1dc69ad10 jdk/src/solaris/classes/sun/nio/ch/EPollSelectorImpl.java --- a/jdk/src/solaris/classes/sun/nio/ch/EPollSelectorImpl.java Thu Jul 24 12:40:30 2008 +0100 +++ b/jdk/src/solaris/classes/sun/nio/ch/EPollSelectorImpl.java Thu Jul 24 12:46:41 2008 +0100 @@ -48,7 +48,7 @@ EPollArrayWrapper pollWrapper; // Maps from file descriptors to keys - private HashMap fdToKey; + private Map fdToKey; // True if this Selector has been closed private boolean closed = false; @@ -69,7 +69,7 @@ fd1 = fdes[1]; pollWrapper = new EPollArrayWrapper(); pollWrapper.initInterrupt(fd0, fd1); - fdToKey = new HashMap(); + fdToKey = new HashMap(); } protected int doSelect(long timeout) @@ -107,8 +107,7 @@ int numKeysUpdated = 0; for (int i=0; i= 0); int fd = ski.channel.getFDVal(); - fdToKey.remove(new Integer(fd)); + fdToKey.remove(Integer.valueOf(fd)); pollWrapper.release(fd); ski.setIndex(-1); keys.remove(ski); diff -r 15e617238139 -r 67f1dc69ad10 jdk/src/solaris/native/java/nio/MappedByteBuffer.c --- a/jdk/src/solaris/native/java/nio/MappedByteBuffer.c Thu Jul 24 12:40:30 2008 +0100 +++ b/jdk/src/solaris/native/java/nio/MappedByteBuffer.c Thu Jul 24 12:46:41 2008 +0100 @@ -43,7 +43,11 @@ int result = 0; int i = 0; void *a = (void *) jlong_to_ptr(address); - char * vec = (char *)malloc(numPages * sizeof(char)); +#ifdef __linux__ + unsigned char *vec = (unsigned char *)malloc(numPages * sizeof(char)); +#else + char *vec = (char *)malloc(numPages * sizeof(char)); +#endif if (vec == NULL) { JNU_ThrowOutOfMemoryError(env, NULL); diff -r 15e617238139 -r 67f1dc69ad10 jdk/src/solaris/native/sun/nio/ch/DatagramChannelImpl.c --- a/jdk/src/solaris/native/sun/nio/ch/DatagramChannelImpl.c Thu Jul 24 12:40:30 2008 +0100 +++ b/jdk/src/solaris/native/sun/nio/ch/DatagramChannelImpl.c Thu Jul 24 12:46:41 2008 +0100 @@ -123,7 +123,7 @@ jint fd = fdval(env, fdo); void *buf = (void *)jlong_to_ptr(address); SOCKADDR sa; - int sa_len = SOCKADDR_LEN; + socklen_t sa_len = SOCKADDR_LEN; jboolean retry = JNI_FALSE; jint n = 0; jobject senderAddr; diff -r 15e617238139 -r 67f1dc69ad10 jdk/src/solaris/native/sun/nio/ch/InheritedChannel.c --- a/jdk/src/solaris/native/sun/nio/ch/InheritedChannel.c Thu Jul 24 12:40:30 2008 +0100 +++ b/jdk/src/solaris/native/sun/nio/ch/InheritedChannel.c Thu Jul 24 12:46:41 2008 +0100 @@ -88,7 +88,8 @@ JNIEXPORT jint JNICALL Java_sun_nio_ch_InheritedChannel_soType0(JNIEnv *env, jclass cla, jint fd) { - int sotype, arglen=sizeof(sotype); + int sotype; + socklen_t arglen=sizeof(sotype); if (getsockopt(fd, SOL_SOCKET, SO_TYPE, (void *)&sotype, &arglen) == 0) { if (sotype == SOCK_STREAM) return sun_nio_ch_InheritedChannel_SOCK_STREAM; diff -r 15e617238139 -r 67f1dc69ad10 jdk/src/solaris/native/sun/nio/ch/Net.c --- a/jdk/src/solaris/native/sun/nio/ch/Net.c Thu Jul 24 12:40:30 2008 +0100 +++ b/jdk/src/solaris/native/sun/nio/ch/Net.c Thu Jul 24 12:46:41 2008 +0100 @@ -138,7 +138,7 @@ Java_sun_nio_ch_Net_localPort(JNIEnv *env, jclass clazz, jobject fdo) { SOCKADDR sa; - int sa_len = SOCKADDR_LEN; + socklen_t sa_len = SOCKADDR_LEN; if (getsockname(fdval(env, fdo), (struct sockaddr *)&sa, &sa_len) < 0) { handleSocketError(env, errno); return -1; @@ -150,7 +150,7 @@ Java_sun_nio_ch_Net_localInetAddress(JNIEnv *env, jclass clazz, jobject fdo) { SOCKADDR sa; - int sa_len = SOCKADDR_LEN; + socklen_t sa_len = SOCKADDR_LEN; int port; if (getsockname(fdval(env, fdo), (struct sockaddr *)&sa, &sa_len) < 0) { handleSocketError(env, errno); diff -r 15e617238139 -r 67f1dc69ad10 jdk/src/solaris/native/sun/nio/ch/ServerSocketChannelImpl.c --- a/jdk/src/solaris/native/sun/nio/ch/ServerSocketChannelImpl.c Thu Jul 24 12:40:30 2008 +0100 +++ b/jdk/src/solaris/native/sun/nio/ch/ServerSocketChannelImpl.c Thu Jul 24 12:46:41 2008 +0100 @@ -81,12 +81,12 @@ jint ssfd = (*env)->GetIntField(env, ssfdo, fd_fdID); jint newfd; struct sockaddr *sa; - int sa_len; + int alloc_len; jobject remote_ia = 0; jobject isa; jint remote_port; - NET_AllocSockaddr(&sa, &sa_len); + NET_AllocSockaddr(&sa, &alloc_len); /* * accept connection but ignore ECONNABORTED indicating that @@ -94,6 +94,7 @@ * accept() was called. */ for (;;) { + socklen_t sa_len = alloc_len; newfd = accept(ssfd, sa, &sa_len); if (newfd >= 0) { break; diff -r 15e617238139 -r 67f1dc69ad10 jdk/src/solaris/native/sun/nio/ch/SocketChannelImpl.c --- a/jdk/src/solaris/native/sun/nio/ch/SocketChannelImpl.c Thu Jul 24 12:40:30 2008 +0100 +++ b/jdk/src/solaris/native/sun/nio/ch/SocketChannelImpl.c Thu Jul 24 12:46:41 2008 +0100 @@ -55,7 +55,7 @@ jboolean ready) { int error = 0; - int n = sizeof(int); + socklen_t n = sizeof(int); jint fd = fdval(env, fdo); int result = 0; struct pollfd poller; diff -r 15e617238139 -r 67f1dc69ad10 jdk/src/windows/classes/sun/nio/ch/PipeImpl.java --- a/jdk/src/windows/classes/sun/nio/ch/PipeImpl.java Thu Jul 24 12:40:30 2008 +0100 +++ b/jdk/src/windows/classes/sun/nio/ch/PipeImpl.java Thu Jul 24 12:46:41 2008 +0100 @@ -67,7 +67,7 @@ } private class Initializer - implements PrivilegedExceptionAction + implements PrivilegedExceptionAction { private final SelectorProvider sp; @@ -76,7 +76,7 @@ this.sp = sp; } - public Object run() throws IOException { + public Void run() throws IOException { ServerSocketChannel ssc = null; SocketChannel sc1 = null; SocketChannel sc2 = null; diff -r 15e617238139 -r 67f1dc69ad10 jdk/src/windows/classes/sun/nio/ch/WindowsSelectorImpl.java --- a/jdk/src/windows/classes/sun/nio/ch/WindowsSelectorImpl.java Thu Jul 24 12:40:30 2008 +0100 +++ b/jdk/src/windows/classes/sun/nio/ch/WindowsSelectorImpl.java Thu Jul 24 12:46:41 2008 +0100 @@ -72,7 +72,7 @@ private int threadsCount = 0; // A list of helper threads for select. - private final List threads = new ArrayList(); + private final List threads = new ArrayList(); //Pipe used as a wakeup object. private final Pipe wakeupPipe; @@ -82,6 +82,7 @@ // Maps file descriptors to their indices in pollArray private final static class FdMap extends HashMap { + static final long serialVersionUID = 0L; private MapEntry get(int desc) { return get(new Integer(desc)); }