7068616: NIO libraries do not build with javac -Xlint:all,-deprecation -Werror
authorjjg
Thu, 28 Jul 2011 13:34:31 -0700
changeset 10137 d92637d3d673
parent 10136 af9631156b25
child 10138 b7572da25d15
7068616: NIO libraries do not build with javac -Xlint:all,-deprecation -Werror Reviewed-by: alanb, chegar Contributed-by: alexandre.boulgakov@oracle.com
jdk/make/com/sun/nio/Makefile
jdk/make/com/sun/nio/sctp/Makefile
jdk/make/java/nio/Makefile
jdk/make/java/sun_nio/Makefile
jdk/make/sun/nio/Makefile
jdk/make/sun/nio/cs/Makefile
jdk/src/share/classes/java/nio/X-Buffer.java.template
jdk/src/share/classes/java/nio/channels/AsynchronousFileChannel.java
jdk/src/share/classes/java/nio/channels/FileChannel.java
jdk/src/share/classes/java/nio/charset/Charset.java
jdk/src/share/classes/sun/nio/ch/DatagramSocketAdaptor.java
jdk/src/share/classes/sun/nio/ch/Reflect.java
jdk/src/share/classes/sun/nio/ch/SelectorImpl.java
jdk/src/share/classes/sun/nio/ch/Util.java
jdk/src/share/classes/sun/nio/cs/FastCharsetProvider.java
jdk/src/share/classes/sun/nio/cs/StreamDecoder.java
jdk/src/share/classes/sun/nio/cs/ThreadLocalCoders.java
jdk/src/share/classes/sun/nio/fs/Util.java
jdk/src/solaris/classes/sun/nio/ch/SctpChannelImpl.java
jdk/src/solaris/classes/sun/nio/ch/SctpMultiChannelImpl.java
jdk/src/solaris/classes/sun/nio/ch/SctpNet.java
jdk/src/solaris/classes/sun/nio/ch/SctpServerChannelImpl.java
jdk/src/windows/classes/sun/nio/ch/PendingIoCache.java
jdk/src/windows/classes/sun/nio/ch/WindowsAsynchronousFileChannelImpl.java
jdk/src/windows/classes/sun/nio/ch/WindowsAsynchronousSocketChannelImpl.java
--- a/jdk/make/com/sun/nio/Makefile	Wed Jul 27 18:10:10 2011 +0100
+++ b/jdk/make/com/sun/nio/Makefile	Thu Jul 28 13:34:31 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2009, 2011, 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
@@ -28,6 +28,8 @@
 #
 
 BUILDDIR = ../../..
+SUBDIRS_MAKEFLAGS += JAVAC_MAX_WARNINGS=true
+SUBDIRS_MAKEFLAGS += JAVAC_WARNINGS_FATAL=true
 include $(BUILDDIR)/common/Defs.gmk
 
 SUBDIRS = sctp
--- a/jdk/make/com/sun/nio/sctp/Makefile	Wed Jul 27 18:10:10 2011 +0100
+++ b/jdk/make/com/sun/nio/sctp/Makefile	Thu Jul 28 13:34:31 2011 -0700
@@ -31,7 +31,6 @@
 PACKAGE = com.sun.nio.sctp
 LIBRARY = sctp
 PRODUCT = sun
-#OTHER_JAVACFLAGS += -Xmaxwarns 1000 -Xlint
 include $(BUILDDIR)/common/Defs.gmk
 
 #
--- a/jdk/make/java/nio/Makefile	Wed Jul 27 18:10:10 2011 +0100
+++ b/jdk/make/java/nio/Makefile	Thu Jul 28 13:34:31 2011 -0700
@@ -31,7 +31,8 @@
 PACKAGE = java.nio
 LIBRARY = nio
 PRODUCT = java
-OTHER_JAVACFLAGS += -Xmaxwarns 1000 -Xlint:serial -Werror
+JAVAC_MAX_WARNINGS = true
+JAVAC_WARNINGS_FATAL = true
 include $(BUILDDIR)/common/Defs.gmk
 
 NIO_SRC = $(SHARE_SRC)/classes/java/nio
--- a/jdk/make/java/sun_nio/Makefile	Wed Jul 27 18:10:10 2011 +0100
+++ b/jdk/make/java/sun_nio/Makefile	Thu Jul 28 13:34:31 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2003, 2011, 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
@@ -31,7 +31,9 @@
 PACKAGE = sun.nio
 PRODUCT = sun
 
-OTHER_JAVACFLAGS += -Xlint:serial,-deprecation -Werror
+JAVAC_MAX_WARNINGS = false
+JAVAC_LINT_OPTIONS = -Xlint:all,-deprecation
+JAVAC_WARNINGS_FATAL = true
 include $(BUILDDIR)/common/Defs.gmk
 
 #
--- a/jdk/make/sun/nio/Makefile	Wed Jul 27 18:10:10 2011 +0100
+++ b/jdk/make/sun/nio/Makefile	Thu Jul 28 13:34:31 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2009, 2011, 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
@@ -26,6 +26,8 @@
 BUILDDIR = ../..
 PACKAGE = sun.nio
 PRODUCT = sun
+SUBDIRS_MAKEFLAGS += JAVAC_MAX_WARNINGS=true
+SUBDIRS_MAKEFLAGS += JAVAC_WARNINGS_FATAL=true
 include $(BUILDDIR)/common/Defs.gmk
 
 SUBDIRS = cs
--- a/jdk/make/sun/nio/cs/Makefile	Wed Jul 27 18:10:10 2011 +0100
+++ b/jdk/make/sun/nio/cs/Makefile	Thu Jul 28 13:34:31 2011 -0700
@@ -36,7 +36,9 @@
 # This re-directs all the class files to a separate location
 CLASSDESTDIR = $(TEMPDIR)/classes
 
-OTHER_JAVACFLAGS += -Xlint:serial,-deprecation -Werror
+JAVAC_MAX_WARNINGS = false
+JAVAC_LINT_OPTIONS = -Xlint:all,-deprecation
+JAVAC_WARNINGS_FATAL = true
 include $(BUILDDIR)/common/Defs.gmk
 
 #
--- a/jdk/src/share/classes/java/nio/X-Buffer.java.template	Wed Jul 27 18:10:10 2011 +0100
+++ b/jdk/src/share/classes/java/nio/X-Buffer.java.template	Thu Jul 28 13:34:31 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, 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
@@ -1080,7 +1080,11 @@
         int h = 1;
         int p = position();
         for (int i = limit() - 1; i >= p; i--)
+#if[int]
+            h = 31 * h + get(i);
+#else[int]
             h = 31 * h + (int)get(i);
+#end[int]
         return h;
     }
 
--- a/jdk/src/share/classes/java/nio/channels/AsynchronousFileChannel.java	Wed Jul 27 18:10:10 2011 +0100
+++ b/jdk/src/share/classes/java/nio/channels/AsynchronousFileChannel.java	Thu Jul 28 13:34:31 2011 -0700
@@ -248,6 +248,7 @@
         return provider.newAsynchronousFileChannel(file, options, executor, attrs);
     }
 
+    @SuppressWarnings({ "unchecked", "rawtypes" }) // generic array construction
     private static final FileAttribute<?>[] NO_ATTRIBUTES = new FileAttribute[0];
 
     /**
--- a/jdk/src/share/classes/java/nio/channels/FileChannel.java	Wed Jul 27 18:10:10 2011 +0100
+++ b/jdk/src/share/classes/java/nio/channels/FileChannel.java	Thu Jul 28 13:34:31 2011 -0700
@@ -287,6 +287,7 @@
         return provider.newFileChannel(path, options, attrs);
     }
 
+    @SuppressWarnings({ "unchecked", "rawtypes" }) // generic array construction
     private static final FileAttribute<?>[] NO_ATTRIBUTES = new FileAttribute[0];
 
     /**
--- a/jdk/src/share/classes/java/nio/charset/Charset.java	Wed Jul 27 18:10:10 2011 +0100
+++ b/jdk/src/share/classes/java/nio/charset/Charset.java	Thu Jul 28 13:34:31 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, 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
@@ -29,7 +29,6 @@
 import java.nio.CharBuffer;
 import java.nio.charset.spi.CharsetProvider;
 import java.security.AccessController;
-import java.security.AccessControlException;
 import java.security.PrivilegedAction;
 import java.util.Collections;
 import java.util.HashSet;
@@ -339,15 +338,15 @@
     // those whose lookup or instantiation causes a security exception to be
     // thrown.  Should be invoked with full privileges.
     //
-    private static Iterator providers() {
-        return new Iterator() {
+    private static Iterator<CharsetProvider> providers() {
+        return new Iterator<CharsetProvider>() {
 
                 ClassLoader cl = ClassLoader.getSystemClassLoader();
                 ServiceLoader<CharsetProvider> sl =
                     ServiceLoader.load(CharsetProvider.class, cl);
                 Iterator<CharsetProvider> i = sl.iterator();
 
-                Object next = null;
+                CharsetProvider next = null;
 
                 private boolean getNext() {
                     while (next == null) {
@@ -370,10 +369,10 @@
                     return getNext();
                 }
 
-                public Object next() {
+                public CharsetProvider next() {
                     if (!getNext())
                         throw new NoSuchElementException();
-                    Object n = next;
+                    CharsetProvider n = next;
                     next = null;
                     return n;
                 }
@@ -386,7 +385,8 @@
     }
 
     // Thread-local gate to prevent recursive provider lookups
-    private static ThreadLocal<ThreadLocal> gate = new ThreadLocal<ThreadLocal>();
+    private static ThreadLocal<ThreadLocal<?>> gate =
+            new ThreadLocal<ThreadLocal<?>>();
 
     private static Charset lookupViaProviders(final String charsetName) {
 
@@ -410,8 +410,9 @@
             return AccessController.doPrivileged(
                 new PrivilegedAction<Charset>() {
                     public Charset run() {
-                        for (Iterator i = providers(); i.hasNext();) {
-                            CharsetProvider cp = (CharsetProvider)i.next();
+                        for (Iterator<CharsetProvider> i = providers();
+                             i.hasNext();) {
+                            CharsetProvider cp = i.next();
                             Charset cs = cp.charsetForName(charsetName);
                             if (cs != null)
                                 return cs;
@@ -588,8 +589,8 @@
                         new TreeMap<String,Charset>(
                             ASCIICaseInsensitiveComparator.CASE_INSENSITIVE_ORDER);
                     put(standardProvider.charsets(), m);
-                    for (Iterator i = providers(); i.hasNext();) {
-                        CharsetProvider cp = (CharsetProvider)i.next();
+                    for (Iterator<CharsetProvider> i = providers(); i.hasNext();) {
+                        CharsetProvider cp = i.next();
                         put(cp.charsets(), m);
                     }
                     return Collections.unmodifiableSortedMap(m);
--- a/jdk/src/share/classes/sun/nio/ch/DatagramSocketAdaptor.java	Wed Jul 27 18:10:10 2011 +0100
+++ b/jdk/src/share/classes/sun/nio/ch/DatagramSocketAdaptor.java	Thu Jul 28 13:34:31 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, 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
@@ -390,8 +390,10 @@
 
        protected void receive(DatagramPacket p) throws IOException {}
 
+       @Deprecated
        protected void setTTL(byte ttl) throws IOException {}
 
+       @Deprecated
        protected byte getTTL() throws IOException { return 0; }
 
        protected void setTimeToLive(int ttl) throws IOException {}
--- a/jdk/src/share/classes/sun/nio/ch/Reflect.java	Wed Jul 27 18:10:10 2011 +0100
+++ b/jdk/src/share/classes/sun/nio/ch/Reflect.java	Thu Jul 28 13:34:31 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, 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
@@ -50,29 +50,25 @@
                 }});
     }
 
-    static Constructor lookupConstructor(String className,
-                                         Class[] paramTypes)
+    static Constructor<?> lookupConstructor(String className,
+                                            Class<?>[] paramTypes)
     {
         try {
             Class<?> cl = Class.forName(className);
             Constructor<?> c = cl.getDeclaredConstructor(paramTypes);
             setAccessible(c);
             return c;
-        } catch (ClassNotFoundException x) {
-            throw new ReflectionError(x);
-        } catch (NoSuchMethodException x) {
+        } catch (ClassNotFoundException | NoSuchMethodException x) {
             throw new ReflectionError(x);
         }
     }
 
-    static Object invoke(Constructor c, Object[] args) {
+    static Object invoke(Constructor<?> c, Object[] args) {
         try {
             return c.newInstance(args);
-        } catch (InstantiationException x) {
-            throw new ReflectionError(x);
-        } catch (IllegalAccessException x) {
-            throw new ReflectionError(x);
-        } catch (InvocationTargetException x) {
+        } catch (InstantiationException |
+                 IllegalAccessException |
+                 InvocationTargetException x) {
             throw new ReflectionError(x);
         }
     }
@@ -86,9 +82,7 @@
             Method m = cl.getDeclaredMethod(methodName, paramTypes);
             setAccessible(m);
             return m;
-        } catch (ClassNotFoundException x) {
-            throw new ReflectionError(x);
-        } catch (NoSuchMethodException x) {
+        } catch (ClassNotFoundException | NoSuchMethodException x) {
             throw new ReflectionError(x);
         }
     }
@@ -96,9 +90,7 @@
     static Object invoke(Method m, Object ob, Object[] args) {
         try {
             return m.invoke(ob, args);
-        } catch (IllegalAccessException x) {
-            throw new ReflectionError(x);
-        } catch (InvocationTargetException x) {
+        } catch (IllegalAccessException | InvocationTargetException x) {
             throw new ReflectionError(x);
         }
     }
@@ -119,13 +111,11 @@
 
     static Field lookupField(String className, String fieldName) {
         try {
-            Class cl = Class.forName(className);
+            Class<?> cl = Class.forName(className);
             Field f = cl.getDeclaredField(fieldName);
             setAccessible(f);
             return f;
-        } catch (ClassNotFoundException x) {
-            throw new ReflectionError(x);
-        } catch (NoSuchFieldException x) {
+        } catch (ClassNotFoundException | NoSuchFieldException x) {
             throw new ReflectionError(x);
         }
     }
--- a/jdk/src/share/classes/sun/nio/ch/SelectorImpl.java	Wed Jul 27 18:10:10 2011 +0100
+++ b/jdk/src/share/classes/sun/nio/ch/SelectorImpl.java	Thu Jul 28 13:34:31 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, 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
@@ -30,7 +30,6 @@
 import java.nio.channels.spi.*;
 import java.net.SocketException;
 import java.util.*;
-import sun.misc.*;
 
 
 /**
@@ -140,19 +139,16 @@
 
     void processDeregisterQueue() throws IOException {
         // Precondition: Synchronized on this, keys, and selectedKeys
-        Set cks = cancelledKeys();
+        Set<SelectionKey> cks = cancelledKeys();
         synchronized (cks) {
             if (!cks.isEmpty()) {
-                Iterator i = cks.iterator();
+                Iterator<SelectionKey> i = cks.iterator();
                 while (i.hasNext()) {
                     SelectionKeyImpl ski = (SelectionKeyImpl)i.next();
                     try {
                         implDereg(ski);
                     } catch (SocketException se) {
-                        IOException ioe = new IOException(
-                            "Error deregistering key");
-                        ioe.initCause(se);
-                        throw ioe;
+                        throw new IOException("Error deregistering key", se);
                     } finally {
                         i.remove();
                     }
--- a/jdk/src/share/classes/sun/nio/ch/Util.java	Wed Jul 27 18:10:10 2011 +0100
+++ b/jdk/src/share/classes/sun/nio/ch/Util.java	Thu Jul 28 13:34:31 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, 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
@@ -355,27 +355,24 @@
         return pageSize;
     }
 
-    private static volatile Constructor directByteBufferConstructor = null;
+    private static volatile Constructor<?> directByteBufferConstructor = null;
 
     private static void initDBBConstructor() {
         AccessController.doPrivileged(new PrivilegedAction<Void>() {
                 public Void run() {
                     try {
                         Class<?> cl = Class.forName("java.nio.DirectByteBuffer");
-                        Constructor ctor = cl.getDeclaredConstructor(
+                        Constructor<?> ctor = cl.getDeclaredConstructor(
                             new Class[] { int.class,
                                           long.class,
                                           FileDescriptor.class,
                                           Runnable.class });
                         ctor.setAccessible(true);
                         directByteBufferConstructor = ctor;
-                    } catch (ClassNotFoundException x) {
-                        throw new InternalError();
-                    } catch (NoSuchMethodException x) {
-                        throw new InternalError();
-                    } catch (IllegalArgumentException x) {
-                        throw new InternalError();
-                    } catch (ClassCastException x) {
+                    } catch (ClassNotFoundException   |
+                             NoSuchMethodException    |
+                             IllegalArgumentException |
+                             ClassCastException x) {
                         throw new InternalError();
                     }
                     return null;
@@ -395,37 +392,32 @@
                              new Long(addr),
                              fd,
                              unmapper });
-        } catch (InstantiationException e) {
-            throw new InternalError();
-        } catch (IllegalAccessException e) {
-            throw new InternalError();
-        } catch (InvocationTargetException e) {
+        } catch (InstantiationException |
+                 IllegalAccessException |
+                 InvocationTargetException e) {
             throw new InternalError();
         }
         return dbb;
     }
 
-    private static volatile Constructor directByteBufferRConstructor = null;
+    private static volatile Constructor<?> directByteBufferRConstructor = null;
 
     private static void initDBBRConstructor() {
         AccessController.doPrivileged(new PrivilegedAction<Void>() {
                 public Void run() {
                     try {
                         Class<?> cl = Class.forName("java.nio.DirectByteBufferR");
-                        Constructor ctor = cl.getDeclaredConstructor(
+                        Constructor<?> ctor = cl.getDeclaredConstructor(
                             new Class[] { int.class,
                                           long.class,
                                           FileDescriptor.class,
                                           Runnable.class });
                         ctor.setAccessible(true);
                         directByteBufferRConstructor = ctor;
-                    } catch (ClassNotFoundException x) {
-                        throw new InternalError();
-                    } catch (NoSuchMethodException x) {
-                        throw new InternalError();
-                    } catch (IllegalArgumentException x) {
-                        throw new InternalError();
-                    } catch (ClassCastException x) {
+                    } catch (ClassNotFoundException |
+                             NoSuchMethodException |
+                             IllegalArgumentException |
+                             ClassCastException x) {
                         throw new InternalError();
                     }
                     return null;
@@ -445,11 +437,9 @@
                              new Long(addr),
                              fd,
                              unmapper });
-        } catch (InstantiationException e) {
-            throw new InternalError();
-        } catch (IllegalAccessException e) {
-            throw new InternalError();
-        } catch (InvocationTargetException e) {
+        } catch (InstantiationException |
+                 IllegalAccessException |
+                 InvocationTargetException e) {
             throw new InternalError();
         }
         return dbb;
--- a/jdk/src/share/classes/sun/nio/cs/FastCharsetProvider.java	Wed Jul 27 18:10:10 2011 +0100
+++ b/jdk/src/share/classes/sun/nio/cs/FastCharsetProvider.java	Thu Jul 28 13:34:31 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2011, 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,7 +25,6 @@
 
 package sun.nio.cs;
 
-import java.lang.ref.SoftReference;
 import java.nio.charset.Charset;
 import java.nio.charset.spi.CharsetProvider;
 import java.util.Iterator;
@@ -116,17 +115,15 @@
 
         // Instantiate the charset and cache it
         try {
-            Class c = Class.forName(packagePrefix + "." + cln,
+            Class<?> c = Class.forName(packagePrefix + "." + cln,
                                     true,
                                     this.getClass().getClassLoader());
             cs = (Charset)c.newInstance();
             cache.put(csn, cs);
             return cs;
-        } catch (ClassNotFoundException x) {
-            return null;
-        } catch (IllegalAccessException x) {
-            return null;
-        } catch (InstantiationException x) {
+        } catch (ClassNotFoundException |
+                 IllegalAccessException |
+                 InstantiationException x) {
             return null;
         }
     }
--- a/jdk/src/share/classes/sun/nio/cs/StreamDecoder.java	Wed Jul 27 18:10:10 2011 +0100
+++ b/jdk/src/share/classes/sun/nio/cs/StreamDecoder.java	Thu Jul 28 13:34:31 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, 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
@@ -112,6 +112,7 @@
         return read0();
     }
 
+    @SuppressWarnings("fallthrough")
     private int read0() throws IOException {
         synchronized (lock) {
 
--- a/jdk/src/share/classes/sun/nio/cs/ThreadLocalCoders.java	Wed Jul 27 18:10:10 2011 +0100
+++ b/jdk/src/share/classes/sun/nio/cs/ThreadLocalCoders.java	Thu Jul 28 13:34:31 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, 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
@@ -26,7 +26,6 @@
 
 package sun.nio.cs;
 
-import java.nio.*;
 import java.nio.charset.*;
 
 
@@ -41,7 +40,7 @@
     private static abstract class Cache {
 
         // Thread-local reference to array of cached objects, in LRU order
-        private ThreadLocal cache = new ThreadLocal();
+        private ThreadLocal<Object[]> cache = new ThreadLocal<>();
         private final int size;
 
         Cache(int size) {
@@ -60,7 +59,7 @@
         abstract boolean hasName(Object ob, Object name);
 
         Object forName(Object name) {
-            Object[] oa = (Object[])cache.get();
+            Object[] oa = cache.get();
             if (oa == null) {
                 oa = new Object[size];
                 cache.set(oa);
--- a/jdk/src/share/classes/sun/nio/fs/Util.java	Wed Jul 27 18:10:10 2011 +0100
+++ b/jdk/src/share/classes/sun/nio/fs/Util.java	Thu Jul 28 13:34:31 2011 -0700
@@ -62,6 +62,7 @@
     /**
      * Returns a Set containing the given elements.
      */
+    @SafeVarargs
     static <E> Set<E> newSet(E... elements) {
         HashSet<E> set = new HashSet<>();
         for (E e: elements) {
@@ -74,6 +75,7 @@
      * Returns a Set containing all the elements of the given Set plus
      * the given elements.
      */
+    @SafeVarargs
     static <E> Set<E> newSet(Set<E> other, E... elements) {
         HashSet<E> set = new HashSet<>(other);
         for (E e: elements) {
--- a/jdk/src/solaris/classes/sun/nio/ch/SctpChannelImpl.java	Wed Jul 27 18:10:10 2011 +0100
+++ b/jdk/src/solaris/classes/sun/nio/ch/SctpChannelImpl.java	Thu Jul 28 13:34:31 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011, 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
@@ -53,8 +53,6 @@
 import com.sun.nio.sctp.NotificationHandler;
 import com.sun.nio.sctp.SctpChannel;
 import com.sun.nio.sctp.SctpSocketOption;
-import sun.nio.ch.PollArrayWrapper;
-import sun.nio.ch.SelChImpl;
 import static com.sun.nio.sctp.SctpStandardSocketOptions.*;
 import static sun.nio.ch.SctpResultContainer.SEND_FAILED;
 import static sun.nio.ch.SctpResultContainer.ASSOCIATION_CHANGED;
@@ -118,7 +116,7 @@
 
     private Association association;
 
-    private Set<SocketAddress> remoteAddresses = Collections.EMPTY_SET;
+    private Set<SocketAddress> remoteAddresses = Collections.emptySet();
 
     /* -- End of fields protected by stateLock -- */
 
@@ -853,7 +851,7 @@
         return n;
     }
 
-    private InternalNotificationHandler<?> internalNotificationHandler =
+    private InternalNotificationHandler internalNotificationHandler =
             new InternalNotificationHandler();
 
     private void handleNotificationInternal(SctpResultContainer resultContainer)
@@ -862,12 +860,12 @@
                 internalNotificationHandler, null);
     }
 
-    private class InternalNotificationHandler<T>
-            extends AbstractNotificationHandler<T>
+    private class InternalNotificationHandler
+            extends AbstractNotificationHandler<Object>
     {
         @Override
         public HandlerResult handleNotification(
-                AssociationChangeNotification not, T unused) {
+                AssociationChangeNotification not, Object unused) {
             if (not.event().equals(
                     AssociationChangeNotification.AssocChangeEvent.COMM_UP) &&
                     association == null) {
@@ -893,8 +891,8 @@
         }
 
         /* AbstractNotificationHandler */
-        AbstractNotificationHandler absHandler =
-                (AbstractNotificationHandler)handler;
+        AbstractNotificationHandler<T> absHandler =
+                (AbstractNotificationHandler<T>)handler;
         switch(resultContainer.type()) {
             case ASSOCIATION_CHANGED :
                 return absHandler.handleNotification(
@@ -1053,7 +1051,7 @@
             if (!isOpen())
                 throw new ClosedChannelException();
             if (!isBound())
-                return Collections.EMPTY_SET;
+                return Collections.emptySet();
 
             return SctpNet.getLocalAddresses(fdVal);
         }
@@ -1066,7 +1064,7 @@
             if (!isOpen())
                 throw new ClosedChannelException();
             if (!isConnected() || isShutdown)
-                return Collections.EMPTY_SET;
+                return Collections.emptySet();
 
             try {
                 return SctpNet.getRemoteAddresses(fdVal, 0/*unused*/);
--- a/jdk/src/solaris/classes/sun/nio/ch/SctpMultiChannelImpl.java	Wed Jul 27 18:10:10 2011 +0100
+++ b/jdk/src/solaris/classes/sun/nio/ch/SctpMultiChannelImpl.java	Thu Jul 28 13:34:31 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011, 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
@@ -586,12 +586,12 @@
                 internalNotificationHandler, null);
     }
 
-    private class InternalNotificationHandler<T>
-            extends AbstractNotificationHandler<T>
+    private class InternalNotificationHandler
+            extends AbstractNotificationHandler<Object>
     {
         @Override
         public HandlerResult handleNotification(
-                AssociationChangeNotification not, T unused) {
+                AssociationChangeNotification not, Object unused) {
             SctpAssocChange sac = (SctpAssocChange) not;
 
             /* Update map to reflect change in association */
@@ -622,8 +622,8 @@
         if (!(handler instanceof AbstractNotificationHandler)) {
             result = handler.handleNotification(notification, attachment);
         } else { /* AbstractNotificationHandler */
-            AbstractNotificationHandler absHandler =
-                    (AbstractNotificationHandler)handler;
+            AbstractNotificationHandler<T> absHandler =
+                    (AbstractNotificationHandler<T>)handler;
             switch(resultContainer.type()) {
                 case ASSOCIATION_CHANGED :
                     result = absHandler.handleNotification(
@@ -912,7 +912,7 @@
             if (!isOpen())
                 throw new ClosedChannelException();
             if (!isBound())
-                return Collections.EMPTY_SET;
+                return Collections.emptySet();
 
             return SctpNet.getLocalAddresses(fdVal);
         }
@@ -931,7 +931,7 @@
             } catch (SocketException se) {
                 /* a valid association should always have remote addresses */
                 Set<SocketAddress> addrs = associationMap.get(association);
-                return addrs != null ? addrs : Collections.EMPTY_SET;
+                return addrs != null ? addrs : Collections.<SocketAddress>emptySet();
             }
         }
     }
--- a/jdk/src/solaris/classes/sun/nio/ch/SctpNet.java	Wed Jul 27 18:10:10 2011 +0100
+++ b/jdk/src/solaris/classes/sun/nio/ch/SctpNet.java	Thu Jul 28 13:34:31 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011, 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
@@ -118,18 +118,14 @@
         return set;
     }
 
-    static void setSocketOption(int fd,
-                                SctpSocketOption name,
-                                Object value,
-                                int assocId)
+    static <T> void setSocketOption(int fd,
+                                    SctpSocketOption<T> name,
+                                    T value,
+                                    int assocId)
             throws IOException {
         if (value == null)
             throw new IllegalArgumentException("Invalid option value");
 
-        Class<?> type = name.type();
-        if (!type.isInstance(value))
-            throw new IllegalArgumentException("Invalid option value");
-
         if (name.equals(SCTP_INIT_MAXSTREAMS)) {
             InitMaxStreams maxStreamValue = (InitMaxStreams)value;
             SctpNet.setInitMsgOption0(fd,
@@ -169,7 +165,7 @@
         }
     }
 
-    static Object getSocketOption(int fd, SctpSocketOption name, int assocId)
+    static Object getSocketOption(int fd, SctpSocketOption<?> name, int assocId)
              throws IOException {
          if (name.equals(SCTP_SET_PEER_PRIMARY_ADDR)) {
             throw new IllegalArgumentException(
@@ -194,7 +190,7 @@
         }
     }
 
-    static void setIntOption(int fd, SctpSocketOption name, Object value)
+    static void setIntOption(int fd, SctpSocketOption<?> name, Object value)
             throws IOException {
         if (value == null)
             throw new IllegalArgumentException("Invalid option value");
@@ -234,7 +230,7 @@
         setIntOption0(fd, ((SctpStdSocketOption)name).constValue(), arg);
     }
 
-    static Object getIntOption(int fd, SctpSocketOption name)
+    static Object getIntOption(int fd, SctpSocketOption<?> name)
             throws IOException {
         Class<?> type = name.type();
 
--- a/jdk/src/solaris/classes/sun/nio/ch/SctpServerChannelImpl.java	Wed Jul 27 18:10:10 2011 +0100
+++ b/jdk/src/solaris/classes/sun/nio/ch/SctpServerChannelImpl.java	Thu Jul 28 13:34:31 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011, 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
@@ -367,6 +367,7 @@
     }
 
     @Override
+    @SuppressWarnings("unchecked")
     public <T> T getOption(SctpSocketOption<T> name) throws IOException {
         if (name == null)
             throw new NullPointerException();
@@ -403,7 +404,7 @@
             if (!isOpen())
                 throw new ClosedChannelException();
             if (!isBound())
-                return Collections.EMPTY_SET;
+                return Collections.emptySet();
 
             return SctpNet.getLocalAddresses(fdVal);
         }
--- a/jdk/src/windows/classes/sun/nio/ch/PendingIoCache.java	Wed Jul 27 18:10:10 2011 +0100
+++ b/jdk/src/windows/classes/sun/nio/ch/PendingIoCache.java	Thu Jul 28 13:34:31 2011 -0700
@@ -60,6 +60,7 @@
     private boolean closePending;
 
     // maps OVERLAPPED to PendingFuture
+    @SuppressWarnings("rawtypes")
     private final Map<Long,PendingFuture> pendingIoMap =
         new HashMap<Long,PendingFuture>();
 
--- a/jdk/src/windows/classes/sun/nio/ch/WindowsAsynchronousFileChannelImpl.java	Wed Jul 27 18:10:10 2011 +0100
+++ b/jdk/src/windows/classes/sun/nio/ch/WindowsAsynchronousFileChannelImpl.java	Thu Jul 28 13:34:31 2011 -0700
@@ -314,7 +314,7 @@
         // create Future and task that will be invoked to acquire lock
         PendingFuture<FileLock,A> result =
             new PendingFuture<FileLock,A>(this, handler, attachment);
-        LockTask lockTask = new LockTask<A>(position, fli, result);
+        LockTask<A> lockTask = new LockTask<A>(position, fli, result);
         result.setContext(lockTask);
 
         // initiate I/O
@@ -552,7 +552,7 @@
         // create Future and task that initiates read
         PendingFuture<Integer,A> result =
             new PendingFuture<Integer,A>(this, handler, attachment);
-        ReadTask readTask = new ReadTask<A>(dst, pos, rem, position, result);
+        ReadTask<A> readTask = new ReadTask<A>(dst, pos, rem, position, result);
         result.setContext(readTask);
 
         // initiate I/O
@@ -726,7 +726,7 @@
         // create Future and task to initiate write
         PendingFuture<Integer,A> result =
             new PendingFuture<Integer,A>(this, handler, attachment);
-        WriteTask writeTask = new WriteTask<A>(src, pos, rem, position, result);
+        WriteTask<A> writeTask = new WriteTask<A>(src, pos, rem, position, result);
         result.setContext(writeTask);
 
         // initiate I/O
--- a/jdk/src/windows/classes/sun/nio/ch/WindowsAsynchronousSocketChannelImpl.java	Wed Jul 27 18:10:10 2011 +0100
+++ b/jdk/src/windows/classes/sun/nio/ch/WindowsAsynchronousSocketChannelImpl.java	Thu Jul 28 13:34:31 2011 -0700
@@ -351,7 +351,7 @@
         // setup task
         PendingFuture<Void,A> result =
             new PendingFuture<Void,A>(this, handler, attachment);
-        ConnectTask task = new ConnectTask<A>(isa, result);
+        ConnectTask<A> task = new ConnectTask<A>(isa, result);
         result.setContext(task);
 
         // initiate I/O
@@ -615,7 +615,8 @@
             bufs = new ByteBuffer[1];
             bufs[0] = dst;
         }
-        final ReadTask readTask = new ReadTask<V,A>(bufs, isScatteringRead, result);
+        final ReadTask<V,A> readTask =
+                new ReadTask<V,A>(bufs, isScatteringRead, result);
         result.setContext(readTask);
 
         // schedule timeout
@@ -872,7 +873,8 @@
             bufs = new ByteBuffer[1];
             bufs[0] = src;
         }
-        final WriteTask writeTask = new WriteTask<V,A>(bufs, gatheringWrite, result);
+        final WriteTask<V,A> writeTask =
+                new WriteTask<V,A>(bufs, gatheringWrite, result);
         result.setContext(writeTask);
 
         // schedule timeout