11// vim: et:ts=4:sw=4
22
3+ import boot .bin .ParentClassLoader ;
4+
35import java .io .*;
46import java .net .*;
57import java .util .*;
1315@ SuppressWarnings ("unchecked" )
1416public class Boot {
1517
16- public static final String initialVersion = "2.5.2" ;
17- public static final File homedir = new File (System .getProperty ("user.home" ));
18- public static final File workdir = new File (System .getProperty ("user.dir" ));
18+ public static final String initialVersion = "2.7.2" ;
19+ public static final File homedir = new File (System .getProperty ("user.home" ));
20+ public static final File workdir = new File (System .getProperty ("user.dir" ));
21+ public static final ParentClassLoader loader = new ParentClassLoader (Boot .class .getClassLoader ());
1922
2023 public static File
2124 mkFile (File parent , String ... kids ) throws Exception {
@@ -225,13 +228,8 @@ public class Boot {
225228
226229 public static URLClassLoader
227230 loadJar (File jar ) throws Exception {
228- URLClassLoader cl = (URLClassLoader ) ClassLoader .getSystemClassLoader ();
229- Class sc = URLClassLoader .class ;
230- Method cm = sc .getDeclaredMethod ("addURL" , URL .class );
231-
232- cm .setAccessible (true );
233- cm .invoke (cl , new Object []{jar .toURI ().toURL ()});
234- return cl ; }
231+ loader .addURL (jar .toURI ().toURL ());
232+ return loader ; }
235233
236234 public static void
237235 main (String [] args ) throws Exception {
@@ -251,8 +249,9 @@ public class Boot {
251249 System .setProperty ("BOOT_VERSION" , initialVersion );
252250 System .err .println ("Running for the first time, BOOT_VERSION not set: updating to latest." ); }
253251
254- URLClassLoader cl = loadJar (f );
255- Class c = Class .forName ("boot.App" , true , cl );
256- Method m = c .getMethod ("main" , String [].class );
252+ loadJar (f );
253+ tccl (loader );
254+ Class c = Class .forName ("boot.App" , true , loader );
255+ Method m = c .getMethod ("main" , String [].class );
257256
258257 m .invoke (null , new Object []{a }); }}
0 commit comments