< 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,789 ****
PrintWriter testLog = new PrintWriter(new AgentWriter(LOG, this));
PrintWriter testRef = new PrintWriter(new AgentWriter(REF, this));
try {
! Class c;
ClassLoader cl = null;
if (remoteClasses) {
cl = getAgentClassLoader(sharedClassLoader);
c = cl.loadClass(className);
} else {
--- 779,789 ----
PrintWriter testLog = new PrintWriter(new AgentWriter(LOG, this));
PrintWriter testRef = new PrintWriter(new AgentWriter(REF, this));
try {
! Class<?> c;
ClassLoader cl = null;
if (remoteClasses) {
cl = getAgentClassLoader(sharedClassLoader);
c = cl.loadClass(className);
} else {
*** 832,850 ****
testLog.close();
}
}
! 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,
PrintWriter testLog, PrintWriter testRef,
ClassLoader cl)
throws IOException, ClassNotFoundException, IllegalAccessException, InstantiationException {
notifier.execCommand(connection, tag, c.getName(), args);
--- 832,850 ----
testLog.close();
}
}
! 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,
PrintWriter testLog, PrintWriter testRef,
ClassLoader cl)
throws IOException, ClassNotFoundException, IllegalAccessException, InstantiationException {
notifier.execCommand(connection, tag, c.getName(), args);
*** 943,953 ****
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});
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) {
--- 943,953 ----
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});
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,1124 ****
return data;
}
private ClassLoader getAgentClassLoader(boolean useSharedClassLoader)
throws InstantiationException, IllegalAccessException {
! Class<?> classLoaderClass;
try {
String s = getClass().getName();
String pkg = s.substring(0, s.lastIndexOf('.'));
! classLoaderClass = Class.forName(pkg + ".AgentClassLoader2");
} catch (Throwable t) {
classLoaderClass = AgentClassLoader.class;
}
! Class[] argTypes = {Task.class};
if (useSharedClassLoader && factoryMethod == null) {
try {
factoryMethod = classLoaderClass.getDeclaredMethod("getInstance", argTypes);
} catch (NoSuchMethodException e) {
e.printStackTrace();
--- 1105,1124 ----
return data;
}
private ClassLoader getAgentClassLoader(boolean useSharedClassLoader)
throws InstantiationException, IllegalAccessException {
! Class<? extends ClassLoader> classLoaderClass;
try {
String s = getClass().getName();
String pkg = s.substring(0, s.lastIndexOf('.'));
! classLoaderClass = (Class<? extends ClassLoader>) Class.forName(pkg + ".AgentClassLoader2");
} catch (Throwable t) {
classLoaderClass = AgentClassLoader.class;
}
! Class<?>[] argTypes = {Task.class};
if (useSharedClassLoader && factoryMethod == null) {
try {
factoryMethod = classLoaderClass.getDeclaredMethod("getInstance", argTypes);
} catch (NoSuchMethodException e) {
e.printStackTrace();
*** 1137,1147 ****
try {
Object[] args = {this};
if (useSharedClassLoader && factoryMethod != null) {
return (ClassLoader) factoryMethod.invoke(null, args);
} else {
! return (ClassLoader) (classLoaderConstructor.newInstance(args));
}
} catch (InvocationTargetException e) {
Throwable t = e.getTargetException();
if (t instanceof RuntimeException) {
throw (RuntimeException) t;
--- 1137,1147 ----
try {
Object[] args = {this};
if (useSharedClassLoader && factoryMethod != null) {
return (ClassLoader) factoryMethod.invoke(null, args);
} else {
! return classLoaderConstructor.newInstance(args);
}
} catch (InvocationTargetException e) {
Throwable t = e.getTargetException();
if (t instanceof RuntimeException) {
throw (RuntimeException) t;
*** 1160,1170 ****
private String tag;
private String request;
private Integer timeoutValue;
}
! private static Constructor classLoaderConstructor;
private static Method factoryMethod = null;
}
--- 1160,1170 ----
private String tag;
private String request;
private Integer timeoutValue;
}
! private static Constructor<? extends ClassLoader> classLoaderConstructor;
private static Method factoryMethod = null;
}
< prev index next >