1925 */ 1926 private static void initPhase2() { 1927 // initialize the module system 1928 System.bootLayer = ModuleBootstrap.boot(); 1929 1930 // module system initialized 1931 VM.initLevel(2); 1932 } 1933 1934 /* 1935 * Invoked by VM. Phase 3 is the final system initialization: 1936 * 1. set security manager 1937 * 2. set system class loader 1938 * 3. set TCCL 1939 * 1940 * This method must be called after the module system initialization. 1941 * The security manager and system class loader may be custom class from 1942 * the application classpath or modulepath. 1943 */ 1944 private static void initPhase3() { 1945 // Initialize publicLookup early, to avoid bootstrapping circularities 1946 // with security manager using java.lang.invoke infrastructure. 1947 java.lang.invoke.MethodHandles.publicLookup(); 1948 1949 // set security manager 1950 String cn = System.getProperty("java.security.manager"); 1951 if (cn != null) { 1952 if (cn.isEmpty() || "default".equals(cn)) { 1953 System.setSecurityManager(new SecurityManager()); 1954 } else { 1955 try { 1956 Class<?> c = Class.forName(cn, false, ClassLoader.getBuiltinAppClassLoader()); 1957 Constructor<?> ctor = c.getConstructor(); 1958 // Must be a public subclass of SecurityManager with 1959 // a public no-arg constructor 1960 if (!SecurityManager.class.isAssignableFrom(c) || 1961 !Modifier.isPublic(c.getModifiers()) || 1962 !Modifier.isPublic(ctor.getModifiers())) { 1963 throw new Error("Could not create SecurityManager: " + ctor.toString()); 1964 } 1965 // custom security manager implementation may be in unnamed module 1966 // or a named module but non-exported package 1967 ctor.setAccessible(true); 1968 SecurityManager sm = (SecurityManager) ctor.newInstance(); 2036 return bootLayer; 2037 } 2038 public ConcurrentHashMap<?, ?> createOrGetClassLoaderValueMap(ClassLoader cl) { 2039 return cl.createOrGetClassLoaderValueMap(); 2040 } 2041 public Class<?> findBootstrapClassOrNull(ClassLoader cl, String name) { 2042 return cl.findBootstrapClassOrNull(name); 2043 } 2044 public URL findResource(ClassLoader cl, String mn, String name) throws IOException { 2045 return cl.findResource(mn, name); 2046 } 2047 public Stream<Package> packages(ClassLoader cl) { 2048 return cl.packages(); 2049 } 2050 public Package definePackage(ClassLoader cl, String name, Module module) { 2051 return cl.definePackage(name, module); 2052 } 2053 public String fastUUID(long lsb, long msb) { 2054 return Long.fastUUID(lsb, msb); 2055 } 2056 }); 2057 } 2058 } | 1925 */ 1926 private static void initPhase2() { 1927 // initialize the module system 1928 System.bootLayer = ModuleBootstrap.boot(); 1929 1930 // module system initialized 1931 VM.initLevel(2); 1932 } 1933 1934 /* 1935 * Invoked by VM. Phase 3 is the final system initialization: 1936 * 1. set security manager 1937 * 2. set system class loader 1938 * 3. set TCCL 1939 * 1940 * This method must be called after the module system initialization. 1941 * The security manager and system class loader may be custom class from 1942 * the application classpath or modulepath. 1943 */ 1944 private static void initPhase3() { 1945 // set security manager 1946 String cn = System.getProperty("java.security.manager"); 1947 if (cn != null) { 1948 if (cn.isEmpty() || "default".equals(cn)) { 1949 System.setSecurityManager(new SecurityManager()); 1950 } else { 1951 try { 1952 Class<?> c = Class.forName(cn, false, ClassLoader.getBuiltinAppClassLoader()); 1953 Constructor<?> ctor = c.getConstructor(); 1954 // Must be a public subclass of SecurityManager with 1955 // a public no-arg constructor 1956 if (!SecurityManager.class.isAssignableFrom(c) || 1957 !Modifier.isPublic(c.getModifiers()) || 1958 !Modifier.isPublic(ctor.getModifiers())) { 1959 throw new Error("Could not create SecurityManager: " + ctor.toString()); 1960 } 1961 // custom security manager implementation may be in unnamed module 1962 // or a named module but non-exported package 1963 ctor.setAccessible(true); 1964 SecurityManager sm = (SecurityManager) ctor.newInstance(); 2032 return bootLayer; 2033 } 2034 public ConcurrentHashMap<?, ?> createOrGetClassLoaderValueMap(ClassLoader cl) { 2035 return cl.createOrGetClassLoaderValueMap(); 2036 } 2037 public Class<?> findBootstrapClassOrNull(ClassLoader cl, String name) { 2038 return cl.findBootstrapClassOrNull(name); 2039 } 2040 public URL findResource(ClassLoader cl, String mn, String name) throws IOException { 2041 return cl.findResource(mn, name); 2042 } 2043 public Stream<Package> packages(ClassLoader cl) { 2044 return cl.packages(); 2045 } 2046 public Package definePackage(ClassLoader cl, String name, Module module) { 2047 return cl.definePackage(name, module); 2048 } 2049 public String fastUUID(long lsb, long msb) { 2050 return Long.fastUUID(lsb, msb); 2051 } 2052 public void invalidatePackageAccessCache() { 2053 SecurityManager.invalidatePackageAccessCache(); 2054 } 2055 }); 2056 } 2057 } |