Code Review 7104650: rawtype warnings in java.nio.charset.Charset and sun.nio.ch.Util

Chris Hegarty chris.hegarty at oracle.com
Tue Oct 25 14:32:43 UTC 2011


Alan,

I found the same problem in the net and security makefiles, incremental 
build fails because of raw type warnings.

I can file another CR or amend the category and description of this one, 
to be more generic.

The changes are similarity trivial:

hg diff src/share/classes/java/net/InetAddress.java 
src/share/classes/java/net/ServerSocket.java 
src/share/classes/java/security/Security.java make/sun/net/Makefile
diff -r 72666cd49ac3 make/sun/net/Makefile
--- a/make/sun/net/Makefile     Tue Oct 25 09:27:20 2011 +0100
+++ b/make/sun/net/Makefile     Tue Oct 25 15:31:19 2011 +0100
@@ -28,6 +28,7 @@ PRODUCT = sun
  PRODUCT = sun
  SUBDIRS_MAKEFLAGS += JAVAC_MAX_WARNINGS=true
  SUBDIRS_MAKEFLAGS += JAVAC_WARNINGS_FATAL=true
+SUBDIRS_MAKEFLAGS += JAVAC_LINT_OPTIONS=-Xlint:all,-deprecation,-path
  include $(BUILDDIR)/common/Defs.gmk

  SUBDIRS = others spi
diff -r 72666cd49ac3 src/share/classes/java/net/InetAddress.java
--- a/src/share/classes/java/net/InetAddress.java       Tue Oct 25 
09:27:20 2011 +0100
+++ b/src/share/classes/java/net/InetAddress.java       Tue Oct 25 
15:31:19 2011 +0100
@@ -876,10 +876,12 @@ class InetAddress implements java.io.Ser
                  nameService = java.security.AccessController.doPrivileged(
                      new 
java.security.PrivilegedExceptionAction<NameService>() {
                          public NameService run() {
-                            Iterator itr = 
Service.providers(NameServiceDescriptor.class);
+                            // sun.misc.Service.providers returns a raw 
Iterator
+                            @SuppressWarnings("unchecked")
+                            Iterator<NameServiceDescriptor> itr =
+ 
Service.providers(NameServiceDescriptor.class);
                              while (itr.hasNext()) {
-                                NameServiceDescriptor nsd
-                                    = (NameServiceDescriptor)itr.next();
+                                NameServiceDescriptor nsd = itr.next();
                                  if (providerName.
                                      equalsIgnoreCase(nsd.getType()+","
                                          +nsd.getProviderName())) {
diff -r 72666cd49ac3 src/share/classes/java/net/ServerSocket.java
--- a/src/share/classes/java/net/ServerSocket.java      Tue Oct 25 
09:27:20 2011 +0100
+++ b/src/share/classes/java/net/ServerSocket.java      Tue Oct 25 
15:31:19 2011 +0100
@@ -267,10 +267,9 @@ class ServerSocket implements java.io.Cl
              AccessController.doPrivileged(
                  new PrivilegedExceptionAction<Void>() {
                      public Void run() throws NoSuchMethodException {
-                        Class[] cl = new Class[2];
-                        cl[0] = SocketAddress.class;
-                        cl[1] = Integer.TYPE;
-                        impl.getClass().getDeclaredMethod("connect", cl);
+                        impl.getClass().getDeclaredMethod("connect",
+ 
SocketAddress.class,
+                                                          int.class);
                          return null;
                      }
                  });
diff -r 72666cd49ac3 src/share/classes/java/security/Security.java
--- a/src/share/classes/java/security/Security.java     Tue Oct 25 
09:27:20 2011 +0100
+++ b/src/share/classes/java/security/Security.java     Tue Oct 25 
15:31:19 2011 +0100
@@ -814,7 +814,7 @@ public final class Security {
                  public Void run() {
                      try {
                          /* Get the class via the bootstrap class 
loader. */
-                        Class cl = Class.forName(
+                        Class<?> cl = Class.forName(
                              "java.lang.SecurityManager", false, null);
                          Field f = null;
                          boolean accessible =

-Chris.

On 10/25/11 01:57 PM, Alan Bateman wrote:
> On 25/10/2011 13:36, Chris Hegarty wrote:
>> The changes to remove warnings from the NIO code (7068616) missed
>> java/nio/charset/Charset.java and sun/nio/ch/Util.java. This was not
>> spotted at the time as the compiler was not generating raw type
>> warnings for anonymous inner classes. It does now, see CR 7090499.
> Looks fine to me.
>
> -Alan



More information about the core-libs-dev mailing list