< prev index next >

src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java

Print this page




  52 
  53     private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess();
  54 
  55     // the built-in class loaders
  56     private static final BootClassLoader BOOT_LOADER;
  57     private static final PlatformClassLoader PLATFORM_LOADER;
  58     private static final AppClassLoader APP_LOADER;
  59 
  60     /**
  61      * Creates the built-in class loaders
  62      */
  63     static {
  64 
  65         // -Xbootclasspth/a or -javaagent Boot-Class-Path
  66         URLClassPath bcp = null;
  67         String s = VM.getSavedProperty("jdk.boot.class.path.append");
  68         if (s != null && s.length() > 0)
  69             bcp = toURLClassPath(s);
  70 
  71         // we have a class path if -cp is specified or -m is not specified.
  72         // If neither is specified then default to -cp <working directory>.


  73         URLClassPath ucp = null;
  74         String mainMid = System.getProperty("jdk.module.main");
  75         String cp = System.getProperty("java.class.path");
  76         if (mainMid == null && cp == null)
  77             cp = "";
  78         if (cp != null)
  79             ucp = toURLClassPath(cp);
  80 
  81 
  82         // create the class loaders
  83         BOOT_LOADER = new BootClassLoader(bcp);
  84         PLATFORM_LOADER = new PlatformClassLoader(BOOT_LOADER);
  85         APP_LOADER = new AppClassLoader(PLATFORM_LOADER, ucp);
  86     }
  87 
  88     /**
  89      * Returns the class loader that is used to find resources in modules
  90      * defined to the boot class loader.
  91      *
  92      * @apiNote This method is not public, it should instead be used via
  93      * the BootLoader class that provides a restricted API to this class
  94      * loader.
  95      */
  96     static BuiltinClassLoader bootLoader() {
  97         return BOOT_LOADER;
  98     }
  99 
 100     /**
 101      * Returns the platform class loader.




  52 
  53     private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess();
  54 
  55     // the built-in class loaders
  56     private static final BootClassLoader BOOT_LOADER;
  57     private static final PlatformClassLoader PLATFORM_LOADER;
  58     private static final AppClassLoader APP_LOADER;
  59 
  60     /**
  61      * Creates the built-in class loaders
  62      */
  63     static {
  64 
  65         // -Xbootclasspth/a or -javaagent Boot-Class-Path
  66         URLClassPath bcp = null;
  67         String s = VM.getSavedProperty("jdk.boot.class.path.append");
  68         if (s != null && s.length() > 0)
  69             bcp = toURLClassPath(s);
  70 
  71         // we have a class path if -cp is specified or -m is not specified.
  72         // If neither is specified then default to -cp <working directory>
  73         // If -cp is not specified and -m is specified, the value of
  74         // java.class.path is an empty string, then no class path.
  75         URLClassPath ucp = null;
  76         String mainMid = System.getProperty("jdk.module.main");
  77         String cp = System.getProperty("java.class.path");
  78         if (cp == null)
  79             cp = "";
  80         if (mainMid == null || cp.length() > 0)
  81             ucp = toURLClassPath(cp);
  82 

  83         // create the class loaders
  84         BOOT_LOADER = new BootClassLoader(bcp);
  85         PLATFORM_LOADER = new PlatformClassLoader(BOOT_LOADER);
  86         APP_LOADER = new AppClassLoader(PLATFORM_LOADER, ucp);
  87     }
  88 
  89     /**
  90      * Returns the class loader that is used to find resources in modules
  91      * defined to the boot class loader.
  92      *
  93      * @apiNote This method is not public, it should instead be used via
  94      * the BootLoader class that provides a restricted API to this class
  95      * loader.
  96      */
  97     static BuiltinClassLoader bootLoader() {
  98         return BOOT_LOADER;
  99     }
 100 
 101     /**
 102      * Returns the platform class loader.


< prev index next >