@@ -13,19 +13,28 @@ public class ChildJVMMain {
13
13
static final String MessageEnd = "##THIS IS THE END FOR ME, GOODBYE##" ;
14
14
15
15
private static void runMain (String dir ) throws Exception {
16
- String jcp = System .getProperty ("java.class.path" );
17
- String sep = File .pathSeparator ;
18
- System .setProperty ("java.class.path" , jcp == null ? dir : dir + sep + jcp );
19
-
20
- ArrayList <URL > cp = new ArrayList <>();
21
- for (String path : dir .split (sep ))
22
- cp .add (new File (path ).toURI ().toURL ());
23
-
24
- URLClassLoader ucl = new URLClassLoader (cp .toArray (new URL [cp .size ()]));
25
- Class <?> cls = ucl .loadClass ("Test" );
26
- Method meth = cls .getMethod ("main" , String [].class );
16
+ Method meth = null ;
27
17
Object [] args = new Object []{ new String []{ "jvm" } };
28
-
18
+ try {
19
+ String jcp = System .getProperty ("java.class.path" );
20
+ String sep = File .pathSeparator ;
21
+ System .setProperty ("java.class.path" , jcp == null ? dir : dir + sep + jcp );
22
+
23
+ ArrayList <URL > cp = new ArrayList <>();
24
+ for (String path : dir .split (sep ))
25
+ cp .add (new File (path ).toURI ().toURL ());
26
+
27
+ URLClassLoader ucl = new URLClassLoader (cp .toArray (new URL [cp .size ()]));
28
+
29
+ Class <?> cls = ucl .loadClass ("Test" );
30
+ meth = cls .getMethod ("main" , String [].class );
31
+ }
32
+ catch (Throwable e ) {
33
+ // Include the failure stack trace to the test output
34
+ System .out .println (MessageStart );
35
+ e .printStackTrace ();
36
+ throw e ;
37
+ }
29
38
System .out .println (MessageStart );
30
39
31
40
meth .invoke (null , args );
0 commit comments