JDK 8 RFR: more core libs raw warnings cleanup

Chris Hegarty chris.hegarty at oracle.com
Tue Nov 12 09:51:19 UTC 2013


Looks ok to me Joe.

-Chris.

On 12/11/13 09:28, Joe Darcy wrote:
> Hello,
>
> Please review the patch below which would remove another batch of raw
> type javac lint warnings from the core libraries.
>
> No signatures of public or protected methods in the Java SE
> specification have been modified. Regression tests in affected areas pass.
>
> Thanks,
>
> -Joe
>
> diff -r 9fcb07df1c92 src/share/classes/java/io/ObjectOutputStream.java
> --- a/src/share/classes/java/io/ObjectOutputStream.java    Sat Nov 09
> 04:21:28 2013 +0400
> +++ b/src/share/classes/java/io/ObjectOutputStream.java    Tue Nov 12
> 00:51:15 2013 -0800
> @@ -1248,7 +1248,7 @@
>           handles.assign(unshared ? null : desc);
>
>           Class<?> cl = desc.forClass();
> -        Class[] ifaces = cl.getInterfaces();
> +        Class<?>[] ifaces = cl.getInterfaces();
>           bout.writeInt(ifaces.length);
>           for (int i = 0; i < ifaces.length; i++) {
>               bout.writeUTF(ifaces[i].getName());
> diff -r 9fcb07df1c92 src/share/classes/java/io/ObjectStreamClass.java
> --- a/src/share/classes/java/io/ObjectStreamClass.java    Sat Nov 09
> 04:21:28 2013 +0400
> +++ b/src/share/classes/java/io/ObjectStreamClass.java    Tue Nov 12
> 00:51:15 2013 -0800
> @@ -1,5 +1,5 @@
>   /*
> - * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights
> reserved.
> + * Copyright (c) 1996, 2013, 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
> @@ -1746,7 +1746,7 @@
>                   dout.writeUTF("()V");
>               }
>
> -            Constructor[] cons = cl.getDeclaredConstructors();
> +            Constructor<?>[] cons = cl.getDeclaredConstructors();
>               MemberSignature[] consSigs = new
> MemberSignature[cons.length];
>               for (int i = 0; i < cons.length; i++) {
>                   consSigs[i] = new MemberSignature(cons[i]);
> diff -r 9fcb07df1c92 src/share/classes/java/lang/reflect/Proxy.java
> --- a/src/share/classes/java/lang/reflect/Proxy.java    Sat Nov 09
> 04:21:28 2013 +0400
> +++ b/src/share/classes/java/lang/reflect/Proxy.java    Tue Nov 12
> 00:51:15 2013 -0800
> @@ -494,9 +494,10 @@
>           private final int hash;
>           private final WeakReference<Class<?>>[] refs;
>
> +        @SuppressWarnings({"rawtypes", "unchecked"})
>           KeyX(Class<?>[] interfaces) {
>               hash = Arrays.hashCode(interfaces);
> -            refs = new WeakReference[interfaces.length];
> +            refs = (WeakReference<Class<?>>[])new
> WeakReference[interfaces.length];
>               for (int i = 0; i < interfaces.length; i++) {
>                   refs[i] = new WeakReference<>(interfaces[i]);
>               }
> diff -r 9fcb07df1c92 src/share/classes/java/nio/file/TempFileHelper.java
> --- a/src/share/classes/java/nio/file/TempFileHelper.java    Sat Nov 09
> 04:21:28 2013 +0400
> +++ b/src/share/classes/java/nio/file/TempFileHelper.java    Tue Nov 12
> 00:51:15 2013 -0800
> @@ -81,7 +81,7 @@
>                                  String prefix,
>                                  String suffix,
>                                  boolean createDirectory,
> -                               FileAttribute[] attrs)
> +                               FileAttribute<?>[] attrs)
>           throws IOException
>       {
>           if (prefix == null)
> @@ -155,7 +155,7 @@
>       static Path createTempFile(Path dir,
>                                  String prefix,
>                                  String suffix,
> -                               FileAttribute[] attrs)
> +                               FileAttribute<?>[] attrs)
>           throws IOException
>       {
>           return create(dir, prefix, suffix, false, attrs);
> @@ -167,7 +167,7 @@
>        */
>       static Path createTempDirectory(Path dir,
>                                       String prefix,
> -                                    FileAttribute[] attrs)
> +                                    FileAttribute<?>[] attrs)
>           throws IOException
>       {
>           return create(dir, prefix, null, true, attrs);
> diff -r 9fcb07df1c92 src/share/classes/java/util/IdentityHashMap.java
> --- a/src/share/classes/java/util/IdentityHashMap.java    Sat Nov 09
> 04:21:28 2013 +0400
> +++ b/src/share/classes/java/util/IdentityHashMap.java    Tue Nov 12
> 00:51:15 2013 -0800
> @@ -1243,7 +1243,7 @@
>                       if (ti >= size) {
>                           throw new ConcurrentModificationException();
>                       }
> -                    a[ti++] = (T) new
> AbstractMap.SimpleEntry(unmaskNull(key), tab[si + 1]);
> +                    a[ti++] = (T) new
> AbstractMap.SimpleEntry<>(unmaskNull(key), tab[si + 1]);
>                   }
>               }
>               // fewer elements than expected or concurrent modification
> from other thread detected
> diff -r 9fcb07df1c92 src/share/classes/java/util/logging/Logger.java
> --- a/src/share/classes/java/util/logging/Logger.java    Sat Nov 09
> 04:21:28 2013 +0400
> +++ b/src/share/classes/java/util/logging/Logger.java    Tue Nov 12
> 00:51:15 2013 -0800
> @@ -351,7 +351,7 @@
>                                            ? caller.getClassLoader()
>                                            : null);
>           if (callersClassLoader != null) {
> -            this.callersClassLoaderRef = new
> WeakReference(callersClassLoader);
> +            this.callersClassLoaderRef = new
> WeakReference<>(callersClassLoader);
>           }
>       }
>
> diff -r 9fcb07df1c92 src/share/classes/java/util/logging/Logging.java
> --- a/src/share/classes/java/util/logging/Logging.java    Sat Nov 09
> 04:21:28 2013 +0400
> +++ b/src/share/classes/java/util/logging/Logging.java    Tue Nov 12
> 00:51:15 2013 -0800
> @@ -1,5 +1,5 @@
>   /*
> - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights
> reserved.
> + * Copyright (c) 2003, 2013, 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
> @@ -55,11 +55,11 @@
>       }
>
>       public List<String> getLoggerNames() {
> -        Enumeration loggers = logManager.getLoggerNames();
> +        Enumeration<String> loggers = logManager.getLoggerNames();
>           ArrayList<String> array = new ArrayList<>();
>
>           for (; loggers.hasMoreElements();) {
> -            array.add((String) loggers.nextElement());
> +            array.add(loggers.nextElement());
>           }
>           return array;
>       }
> diff -r 9fcb07df1c92 src/share/classes/sun/misc/Cleaner.java
> --- a/src/share/classes/sun/misc/Cleaner.java    Sat Nov 09 04:21:28
> 2013 +0400
> +++ b/src/share/classes/sun/misc/Cleaner.java    Tue Nov 12 00:51:15
> 2013 -0800
> @@ -1,5 +1,5 @@
>   /*
> - * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights
> reserved.
> + * Copyright (c) 2003, 2013, 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
> @@ -57,14 +57,14 @@
>    */
>
>   public class Cleaner
> -    extends PhantomReference
> +    extends PhantomReference<Object>
>   {
>
>       // Dummy reference queue, needed because the PhantomReference
> constructor
>       // insists that we pass a queue.  Nothing will ever be placed on
> this queue
>       // since the reference handler invokes cleaners explicitly.
>       //
> -    private static final ReferenceQueue dummyQueue = new ReferenceQueue();
> +    private static final ReferenceQueue<Object> dummyQueue = new
> ReferenceQueue<>();
>
>       // Doubly-linked list of live cleaners, which prevents the cleaners
>       // themselves from being GC'd before their referents
> @@ -119,6 +119,7 @@
>       /**
>        * Creates a new cleaner.
>        *
> +     * @param  ob the referent object to be cleaned
>        * @param  thunk
>        *         The cleanup code to be run when the cleaner is
> invoked.  The
>        *         cleanup code is run directly from the reference-handler
> thread,
> diff -r 9fcb07df1c92 src/share/classes/sun/misc/ProxyGenerator.java
> --- a/src/share/classes/sun/misc/ProxyGenerator.java    Sat Nov 09
> 04:21:28 2013 +0400
> +++ b/src/share/classes/sun/misc/ProxyGenerator.java    Tue Nov 12
> 00:51:15 2013 -0800
> @@ -384,7 +384,7 @@
>       private String className;
>
>       /** proxy interfaces */
> -    private Class[] interfaces;
> +    private Class<?>[] interfaces;
>
>       /** proxy class access flags */
>       private int accessFlags;
> diff -r 9fcb07df1c92 src/share/classes/sun/rmi/rmic/Main.java
> --- a/src/share/classes/sun/rmi/rmic/Main.java    Sat Nov 09 04:21:28
> 2013 +0400
> +++ b/src/share/classes/sun/rmi/rmic/Main.java    Tue Nov 12 00:51:15
> 2013 -0800
> @@ -494,7 +494,7 @@
>                                                extDirsArg);
>           BatchEnvironment result = null;
>           try {
> -            Class[] ctorArgTypes =
> {OutputStream.class,ClassPath.class,Main.class};
> +            Class<?>[] ctorArgTypes =
> {OutputStream.class,ClassPath.class,Main.class};
>               Object[] ctorArgs = {out,classPath,this};
>               Constructor<? extends BatchEnvironment> constructor =
>                   environmentClass.getConstructor(ctorArgTypes);
> diff -r 9fcb07df1c92 src/share/classes/sun/rmi/server/LoaderHandler.java
> --- a/src/share/classes/sun/rmi/server/LoaderHandler.java    Sat Nov 09
> 04:21:28 2013 +0400
> +++ b/src/share/classes/sun/rmi/server/LoaderHandler.java    Tue Nov 12
> 00:51:15 2013 -0800
> @@ -692,7 +692,7 @@
>        * Define a proxy class in the given class loader.  The proxy
>        * class will implement the given interfaces Classes.
>        */
> -    private static Class<?> loadProxyClass(ClassLoader loader, Class[]
> interfaces)
> +    private static Class<?> loadProxyClass(ClassLoader loader,
> Class<?>[] interfaces)
>           throws ClassNotFoundException
>       {
>           try {
> @@ -719,7 +719,7 @@
>        */
>       private static ClassLoader loadProxyInterfaces(String[] interfaces,
>                                                      ClassLoader loader,
> -                                                   Class[] classObjs,
> +                                                   Class<?>[] classObjs,
>                                                      boolean[] nonpublic)
>           throws ClassNotFoundException
>       {
> diff -r 9fcb07df1c92 src/share/classes/sun/rmi/server/UnicastServerRef.java
> --- a/src/share/classes/sun/rmi/server/UnicastServerRef.java    Sat Nov
> 09 04:21:28 2013 +0400
> +++ b/src/share/classes/sun/rmi/server/UnicastServerRef.java    Tue Nov
> 12 00:51:15 2013 -0800
> @@ -299,7 +299,7 @@
>               logCall(obj, method);
>
>               // unmarshal parameters
> -            Class[] types = method.getParameterTypes();
> +            Class<?>[] types = method.getParameterTypes();
>               Object[] params = new Object[types.length];
>
>               try {
> diff -r 9fcb07df1c92 src/share/classes/sun/rmi/server/Util.java
> --- a/src/share/classes/sun/rmi/server/Util.java    Sat Nov 09 04:21:28
> 2013 +0400
> +++ b/src/share/classes/sun/rmi/server/Util.java    Tue Nov 12 00:51:15
> 2013 -0800
> @@ -87,7 +87,7 @@
>           Collections.synchronizedMap(new WeakHashMap<Class<?>, Void>(11));
>
>       /** parameter types for stub constructor */
> -    private static final Class[] stubConsParamTypes = { RemoteRef.class };
> +    private static final Class<?>[] stubConsParamTypes = {
> RemoteRef.class };
>
>       private Util() {
>       }
> @@ -143,7 +143,7 @@
>           }
>
>           final ClassLoader loader = implClass.getClassLoader();
> -        final Class[] interfaces = getRemoteInterfaces(implClass);
> +        final Class<?>[] interfaces = getRemoteInterfaces(implClass);
>           final InvocationHandler handler =
>               new RemoteObjectInvocationHandler(clientRef);
>



More information about the core-libs-dev mailing list