jdk/src/share/classes/sun/rmi/server/LoaderHandler.java
changeset 12040 558b0e0d5910
parent 11039 4ee27839f531
child 14342 8435a30053c1
--- a/jdk/src/share/classes/sun/rmi/server/LoaderHandler.java	Fri Mar 02 17:24:08 2012 +0000
+++ b/jdk/src/share/classes/sun/rmi/server/LoaderHandler.java	Fri Mar 02 13:48:43 2012 -0800
@@ -112,11 +112,11 @@
      * garbage collected.
      */
     private static final HashMap<LoaderKey, LoaderEntry> loaderTable
-        = new HashMap<LoaderKey, LoaderEntry>(5);
+        = new HashMap<>(5);
 
     /** reference queue for cleared class loader entries */
     private static final ReferenceQueue<Loader> refQueue
-        = new ReferenceQueue<Loader>();
+        = new ReferenceQueue<>();
 
     /*
      * Disallow anyone from creating one of these.
@@ -149,8 +149,8 @@
      * but first try to resolve the named class through the given
      * "default loader".
      */
-    public static Class loadClass(String codebase, String name,
-                                  ClassLoader defaultLoader)
+    public static Class<?> loadClass(String codebase, String name,
+                                     ClassLoader defaultLoader)
         throws MalformedURLException, ClassNotFoundException
     {
         if (loaderLog.isLoggable(Log.BRIEF)) {
@@ -170,7 +170,7 @@
 
         if (defaultLoader != null) {
             try {
-                Class c = Class.forName(name, false, defaultLoader);
+                Class<?> c = Class.forName(name, false, defaultLoader);
                 if (loaderLog.isLoggable(Log.VERBOSE)) {
                     loaderLog.log(Log.VERBOSE,
                         "class \"" + name + "\" found via defaultLoader, " +
@@ -189,7 +189,7 @@
      * a class) that RMI will use to annotate the call stream when
      * marshalling objects of the given class.
      */
-    public static String getClassAnnotation(Class cl) {
+    public static String getClassAnnotation(Class<?> cl) {
         String name = cl.getName();
 
         /*
@@ -261,15 +261,13 @@
 
                     annotation = urlsToPath(urls);
                 }
-            } catch (SecurityException e) {
+            } catch (SecurityException | IOException e) {
                 /*
-                 * If access was denied to the knowledge of the class
-                 * loader's URLs, fall back to the default behavior.
-                 */
-            } catch (IOException e) {
-                /*
-                 * This shouldn't happen, although it is declared to be
-                 * thrown by openConnection() and getPermission().  If it
+                 * SecurityException: If access was denied to the knowledge of
+                 * the class loader's URLs, fall back to the default behavior.
+                 *
+                 * IOException: This shouldn't happen, although it is declared
+                 * to be thrown by openConnection() and getPermission().  If it
                  * does happen, forget about this class loader's URLs and
                  * fall back to the default behavior.
                  */
@@ -358,7 +356,7 @@
      * Load a class from the RMI class loader corresponding to the given
      * codebase URL path in the current execution context.
      */
-    private static Class loadClass(URL[] urls, String name)
+    private static Class<?> loadClass(URL[] urls, String name)
         throws ClassNotFoundException
     {
         ClassLoader parent = getRMIContextClassLoader();
@@ -375,7 +373,7 @@
         SecurityManager sm = System.getSecurityManager();
         if (sm == null) {
             try {
-                Class c = Class.forName(name, false, parent);
+                Class<?> c = Class.forName(name, false, parent);
                 if (loaderLog.isLoggable(Log.VERBOSE)) {
                     loaderLog.log(Log.VERBOSE,
                         "class \"" + name + "\" found via " +
@@ -424,7 +422,7 @@
                  * resolved without the security-offending codebase anyway;
                  * if so, return successfully (see bugids 4191926 & 4349670).
                  */
-                Class c = Class.forName(name, false, parent);
+                Class<?> c = Class.forName(name, false, parent);
                 if (loaderLog.isLoggable(Log.VERBOSE)) {
                     loaderLog.log(Log.VERBOSE,
                         "class \"" + name + "\" found via " +
@@ -450,7 +448,7 @@
         }
 
         try {
-            Class c = Class.forName(name, false, loader);
+            Class<?> c = Class.forName(name, false, loader);
             if (loaderLog.isLoggable(Log.VERBOSE)) {
                 loaderLog.log(Log.VERBOSE,
                     "class \"" + name + "\" " + "found via codebase, " +
@@ -472,8 +470,8 @@
      * implement interface classes named by the given array of
      * interface names.
      */
-    public static Class loadProxyClass(String codebase, String[] interfaces,
-                                       ClassLoader defaultLoader)
+    public static Class<?> loadProxyClass(String codebase, String[] interfaces,
+                                          ClassLoader defaultLoader)
         throws MalformedURLException, ClassNotFoundException
     {
         if (loaderLog.isLoggable(Log.BRIEF)) {
@@ -537,7 +535,7 @@
         SecurityManager sm = System.getSecurityManager();
         if (sm == null) {
             try {
-                Class c = loadProxyClass(interfaces, defaultLoader, parent,
+                Class<?> c = loadProxyClass(interfaces, defaultLoader, parent,
                                          false);
                 if (loaderLog.isLoggable(Log.VERBOSE)) {
                     loaderLog.log(Log.VERBOSE,
@@ -584,8 +582,8 @@
                  * resolved without the security-offending codebase anyway;
                  * if so, return successfully (see bugids 4191926 & 4349670).
                  */
-                Class c = loadProxyClass(interfaces, defaultLoader, parent,
-                                         false);
+                Class<?> c = loadProxyClass(interfaces, defaultLoader, parent,
+                                            false);
                 if (loaderLog.isLoggable(Log.VERBOSE)) {
                     loaderLog.log(Log.VERBOSE,
                         "(access to codebase denied) " +
@@ -608,7 +606,7 @@
         }
 
         try {
-            Class c = loadProxyClass(interfaces, defaultLoader, loader, true);
+            Class<?> c = loadProxyClass(interfaces, defaultLoader, loader, true);
             if (loaderLog.isLoggable(Log.VERBOSE)) {
                 loaderLog.log(Log.VERBOSE,
                               "proxy class defined by " + c.getClassLoader());
@@ -629,14 +627,14 @@
      * class will implement classes which are named in the supplied
      * interfaceNames.
      */
-    private static Class loadProxyClass(String[] interfaceNames,
-                                        ClassLoader defaultLoader,
-                                        ClassLoader codebaseLoader,
-                                        boolean preferCodebase)
+    private static Class<?> loadProxyClass(String[] interfaceNames,
+                                           ClassLoader defaultLoader,
+                                           ClassLoader codebaseLoader,
+                                           boolean preferCodebase)
         throws ClassNotFoundException
     {
         ClassLoader proxyLoader = null;
-        Class[] classObjs = new Class[interfaceNames.length];
+        Class<?>[] classObjs = new Class<?>[interfaceNames.length];
         boolean[] nonpublic = { false };
 
       defaultLoaderCase:
@@ -692,7 +690,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 {
@@ -727,7 +725,7 @@
         ClassLoader nonpublicLoader = null;
 
         for (int i = 0; i < interfaces.length; i++) {
-            Class cl =
+            Class<?> cl =
                 (classObjs[i] = Class.forName(interfaces[i], false, loader));
 
             if (!Modifier.isPublic(cl.getModifiers())) {
@@ -778,7 +776,7 @@
 
     /** map from weak(key=string) to [URL[], soft(key)] */
     private static final Map<String, Object[]> pathToURLsCache
-        = new WeakHashMap<String, Object[]>(5);
+        = new WeakHashMap<>(5);
 
     /**
      * Convert an array of URL objects into a corresponding string
@@ -1171,9 +1169,9 @@
         private void checkPermissions() {
             SecurityManager sm = System.getSecurityManager();
             if (sm != null) {           // should never be null?
-                Enumeration enum_ = permissions.elements();
+                Enumeration<Permission> enum_ = permissions.elements();
                 while (enum_.hasMoreElements()) {
-                    sm.checkPermission((Permission) enum_.nextElement());
+                    sm.checkPermission(enum_.nextElement());
                 }
             }
         }