52 // the built-in class loaders |
52 // the built-in class loaders |
53 private static final BootClassLoader BOOT_LOADER; |
53 private static final BootClassLoader BOOT_LOADER; |
54 private static final PlatformClassLoader PLATFORM_LOADER; |
54 private static final PlatformClassLoader PLATFORM_LOADER; |
55 private static final AppClassLoader APP_LOADER; |
55 private static final AppClassLoader APP_LOADER; |
56 |
56 |
57 /** |
57 // Creates the built-in class loaders. |
58 * Creates the built-in class loaders |
|
59 */ |
|
60 static { |
58 static { |
61 |
|
62 // -Xbootclasspath/a or -javaagent with Boot-Class-Path attribute |
59 // -Xbootclasspath/a or -javaagent with Boot-Class-Path attribute |
63 URLClassPath bcp = null; |
60 String append = VM.getSavedProperty("jdk.boot.class.path.append"); |
64 String s = VM.getSavedProperty("jdk.boot.class.path.append"); |
61 BOOT_LOADER = |
65 if (s != null && s.length() > 0) |
62 new BootClassLoader((append != null && append.length() > 0) |
66 bcp = new URLClassPath(s, true); |
63 ? new URLClassPath(append, true) |
67 |
64 : null); |
68 // we have a class path if -cp is specified or -m is not specified. |
65 PLATFORM_LOADER = new PlatformClassLoader(BOOT_LOADER); |
69 // If neither is specified then default to -cp <working directory> |
66 |
70 // If -cp is not specified and -m is specified, the value of |
67 // A class path is required when no initial module is specified. |
71 // java.class.path is an empty string, then no class path. |
68 // In this case the class path defaults to "", meaning the current |
72 String mainMid = System.getProperty("jdk.module.main"); |
69 // working directory. When an initial module is specified, on the |
|
70 // contrary, we drop this historic interpretation of the empty |
|
71 // string and instead treat it as unspecified. |
73 String cp = System.getProperty("java.class.path"); |
72 String cp = System.getProperty("java.class.path"); |
74 if (mainMid == null) { |
73 if (cp == null || cp.length() == 0) { |
75 // no main module specified so class path required |
74 String initialModuleName = System.getProperty("jdk.module.main"); |
76 if (cp == null) { |
75 cp = (initialModuleName == null) ? "" : null; |
77 cp = ""; |
|
78 } |
|
79 } else { |
|
80 // main module specified, ignore empty class path |
|
81 if (cp != null && cp.length() == 0) { |
|
82 cp = null; |
|
83 } |
|
84 } |
76 } |
85 URLClassPath ucp = new URLClassPath(cp, false); |
77 URLClassPath ucp = new URLClassPath(cp, false); |
86 |
|
87 // create the class loaders |
|
88 BOOT_LOADER = new BootClassLoader(bcp); |
|
89 PLATFORM_LOADER = new PlatformClassLoader(BOOT_LOADER); |
|
90 APP_LOADER = new AppClassLoader(PLATFORM_LOADER, ucp); |
78 APP_LOADER = new AppClassLoader(PLATFORM_LOADER, ucp); |
91 } |
79 } |
92 |
80 |
93 /** |
81 /** |
94 * Returns the class loader that is used to find resources in modules |
82 * Returns the class loader that is used to find resources in modules |