test/java/util/logging/ClassLoaderLeakTest.java

Print this page
rev 6099 : 8003380: Compiler warnings in logging test code
Summary: Use generics, suppress warnings where appropriate, remove unused imports, etc.
Reviewed-by: lancea, chegar

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2012, 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
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -38,11 +38,10 @@
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.util.concurrent.CountDownLatch;
 import java.util.logging.Logger;
-import java.util.logging.Logger;
 
 public class ClassLoaderLeakTest {
 
     private static CountDownLatch doneSignal;
     private static CountDownLatch launchSignal;

@@ -57,15 +56,15 @@
         Runnable launcher = new Runnable() {
             public void run() {
                 try {
                     ClassLoader cl =
                         Thread.currentThread().getContextClassLoader();
-                    Class appMain = cl.loadClass("AppTest");
+                    Class<?> appMain = cl.loadClass("AppTest");
                     Method launch =
                         appMain.getDeclaredMethod("launch", doneSignal.getClass());
 
-                    Constructor c = appMain.getConstructor();
+                    Constructor<?> c = appMain.getConstructor();
 
                     Object o = c.newInstance();
 
                     launch.invoke(o, doneSignal);
 

@@ -78,12 +77,11 @@
         };
 
         /* prepare test  class loader */
         URL pwd = null;
         try {
-
-            pwd = new File(System.getProperty("test.classes",".")).toURL();
+            pwd = new File(System.getProperty("test.classes",".")).toURI().toURL();
         } catch (MalformedURLException e) {
             throw new RuntimeException("Test failed.", e);
         }
         URL[] urls = new URL[] { pwd };
 

@@ -137,11 +135,11 @@
             super(urls);
 
             uniqClassName = uniq;
         }
 
-        public Class loadClass(String name) throws ClassNotFoundException {
+        public Class<?> loadClass(String name) throws ClassNotFoundException {
             if (verbose) {
                 System.out.printf("%s: load class %s\n", uniqClassName, name);
             }
             if (uniqClassName.equals(name)) {
                 return Object.class;