@@ -13,19 +13,27 @@ public class ChildJVMMain {
1313 static final String MessageEnd = "##THIS IS THE END FOR ME, GOODBYE##" ;
1414
1515 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 ;
2717 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+ System .out .println (MessageStart );
34+ e .printStackTrace ();
35+ throw e ;
36+ }
2937 System .out .println (MessageStart );
3038
3139 meth .invoke (null , args );
0 commit comments