< prev index next >

src/com/sun/javatest/agent/Agent.java

Print this page
rev 145 : 7902237: Fixing raw use of parameterized class
Reviewed-by: jjg

@@ -779,11 +779,11 @@
 
             PrintWriter testLog = new PrintWriter(new AgentWriter(LOG, this));
             PrintWriter testRef = new PrintWriter(new AgentWriter(REF, this));
 
             try {
-                Class c;
+                Class<?> c;
                 ClassLoader cl = null;
                 if (remoteClasses) {
                     cl = getAgentClassLoader(sharedClassLoader);
                     c = cl.loadClass(className);
                 } else {

@@ -832,19 +832,19 @@
 
                 testLog.close();
             }
         }
 
-        private Status executeTest(Class c, String[] args,
+        private Status executeTest(Class<?> c, String[] args,
                 PrintWriter testLog, PrintWriter testRef)
                 throws IOException, ClassNotFoundException, IllegalAccessException, InstantiationException {
             notifier.execTest(connection, tag, c.getName(), args);
             Test t = (Test)(c.newInstance());
             return t.run(args, testLog, testRef);
         }
 
-        private Status executeCommand(Class c, String[] args,
+        private Status executeCommand(Class<?> c, String[] args,
                 PrintWriter testLog, PrintWriter testRef,
                 ClassLoader cl)
                 throws IOException, ClassNotFoundException, IllegalAccessException, InstantiationException {
             notifier.execCommand(connection, tag, c.getName(), args);
 

@@ -943,11 +943,11 @@
 
             PrintStream out = Deprecated.createPrintStream(new WriterStream(testRef));
             PrintStream err = Deprecated.createPrintStream(new WriterStream(testLog));
             try {
                 setSystemStreams(this, out, err);
-                Method main = c.getDeclaredMethod("main", new Class[] {String[].class});
+                Method main = c.getDeclaredMethod("main", new Class<?>[] {String[].class});
                 main.invoke(null, new Object[] {args});
                 return Status.passed("OK");
             } catch (NoSuchMethodException e) {
                 return Status.error("Can't find `public static void main(String[] args)' for `" + c.getName() + "'");
             } catch (InvocationTargetException e) {

@@ -1105,20 +1105,20 @@
             return data;
         }
 
         private ClassLoader getAgentClassLoader(boolean useSharedClassLoader)
                 throws InstantiationException, IllegalAccessException {
-            Class<?> classLoaderClass;
+            Class<? extends ClassLoader> classLoaderClass;
             try {
                 String s = getClass().getName();
                 String pkg = s.substring(0, s.lastIndexOf('.'));
-                classLoaderClass = Class.forName(pkg + ".AgentClassLoader2");
+                classLoaderClass = (Class<? extends ClassLoader>) Class.forName(pkg + ".AgentClassLoader2");
             } catch (Throwable t) {
                 classLoaderClass = AgentClassLoader.class;
             }
 
-            Class[] argTypes = {Task.class};
+            Class<?>[] argTypes = {Task.class};
             if (useSharedClassLoader && factoryMethod == null) {
                 try {
                     factoryMethod = classLoaderClass.getDeclaredMethod("getInstance", argTypes);
                 } catch (NoSuchMethodException e) {
                     e.printStackTrace();

@@ -1137,11 +1137,11 @@
             try {
                 Object[] args = {this};
                 if (useSharedClassLoader && factoryMethod != null) {
                     return (ClassLoader) factoryMethod.invoke(null, args);
                 } else {
-                    return (ClassLoader) (classLoaderConstructor.newInstance(args));
+                    return classLoaderConstructor.newInstance(args);
                 }
             } catch (InvocationTargetException e) {
                 Throwable t = e.getTargetException();
                 if (t instanceof RuntimeException) {
                     throw (RuntimeException) t;

@@ -1160,11 +1160,11 @@
         private String tag;
         private String request;
         private Integer timeoutValue;
     }
 
-    private static Constructor classLoaderConstructor;
+    private static Constructor<? extends ClassLoader> classLoaderConstructor;
     private static Method factoryMethod = null;
 }
 
 
 
< prev index next >