6464import jdk .internal .reflect .CallerSensitiveAdapter ;
6565import jdk .internal .reflect .Reflection ;
6666import jdk .internal .util .StaticProperty ;
67- import sun .security .util .SecurityConstants ;
6867
6968/**
7069 * A class loader is an object that is responsible for loading classes. The
@@ -357,12 +356,6 @@ private static Void checkCreateClassLoader(String name) {
357356 if (name != null && name .isEmpty ()) {
358357 throw new IllegalArgumentException ("name must be non-empty or null" );
359358 }
360-
361- @ SuppressWarnings ("removal" )
362- SecurityManager security = System .getSecurityManager ();
363- if (security != null ) {
364- security .checkCreateClassLoader ();
365- }
366359 return null ;
367360 }
368361
@@ -1735,18 +1728,7 @@ public static InputStream getSystemResourceAsStream(String name) {
17351728 *
17361729 * @since 1.2
17371730 */
1738- @ CallerSensitive
17391731 public final ClassLoader getParent () {
1740- if (parent == null )
1741- return null ;
1742- @ SuppressWarnings ("removal" )
1743- SecurityManager sm = System .getSecurityManager ();
1744- if (sm != null ) {
1745- // Check access to the parent class loader
1746- // If the caller's class loader is same as this class loader,
1747- // permission check is performed.
1748- checkClassLoaderPermission (parent , Reflection .getCallerClass ());
1749- }
17501732 return parent ;
17511733 }
17521734
@@ -1774,15 +1756,8 @@ public final Module getUnnamedModule() {
17741756 *
17751757 * @since 9
17761758 */
1777- @ CallerSensitive
17781759 public static ClassLoader getPlatformClassLoader () {
1779- @ SuppressWarnings ("removal" )
1780- SecurityManager sm = System .getSecurityManager ();
1781- ClassLoader loader = getBuiltinPlatformClassLoader ();
1782- if (sm != null ) {
1783- checkClassLoaderPermission (loader , Reflection .getCallerClass ());
1784- }
1785- return loader ;
1760+ return getBuiltinPlatformClassLoader ();
17861761 }
17871762
17881763 /**
@@ -1853,7 +1828,6 @@ public static ClassLoader getPlatformClassLoader() {
18531828 * underlying cause of the error can be retrieved via the
18541829 * {@link Throwable#getCause()} method.
18551830 */
1856- @ CallerSensitive
18571831 public static ClassLoader getSystemClassLoader () {
18581832 switch (VM .initLevel ()) {
18591833 case 0 :
@@ -1867,11 +1841,6 @@ public static ClassLoader getSystemClassLoader() {
18671841 default :
18681842 // system fully initialized
18691843 assert VM .isBooted () && scl != null ;
1870- @ SuppressWarnings ("removal" )
1871- SecurityManager sm = System .getSecurityManager ();
1872- if (sm != null ) {
1873- checkClassLoaderPermission (scl , Reflection .getCallerClass ());
1874- }
18751844 return scl ;
18761845 }
18771846 }
@@ -1902,8 +1871,6 @@ static synchronized ClassLoader initSystemClassLoader() {
19021871 }
19031872
19041873 ClassLoader builtinLoader = getBuiltinAppClassLoader ();
1905-
1906- // All are privileged frames. No need to call doPrivileged.
19071874 String cn = System .getProperty ("java.system.class.loader" );
19081875 if (cn != null ) {
19091876 try {
@@ -1930,36 +1897,6 @@ static synchronized ClassLoader initSystemClassLoader() {
19301897 return scl ;
19311898 }
19321899
1933- // Returns true if the specified class loader can be found in this class
1934- // loader's delegation chain.
1935- boolean isAncestor (ClassLoader cl ) {
1936- ClassLoader acl = this ;
1937- do {
1938- acl = acl .parent ;
1939- if (cl == acl ) {
1940- return true ;
1941- }
1942- } while (acl != null );
1943- return false ;
1944- }
1945-
1946- // Tests if class loader access requires "getClassLoader" permission
1947- // check. A class loader 'from' can access class loader 'to' if
1948- // class loader 'from' is same as class loader 'to' or an ancestor
1949- // of 'to'. The class loader in a system domain can access
1950- // any class loader.
1951- private static boolean needsClassLoaderPermissionCheck (ClassLoader from ,
1952- ClassLoader to )
1953- {
1954- if (from == to )
1955- return false ;
1956-
1957- if (from == null )
1958- return false ;
1959-
1960- return !to .isAncestor (from );
1961- }
1962-
19631900 // Returns the class's class loader, or null if none.
19641901 static ClassLoader getClassLoader (Class <?> caller ) {
19651902 // This can be null if the VM is requesting it
@@ -1970,23 +1907,6 @@ static ClassLoader getClassLoader(Class<?> caller) {
19701907 return caller .getClassLoader0 ();
19711908 }
19721909
1973- /*
1974- * Checks RuntimePermission("getClassLoader") permission
1975- * if caller's class loader is not null and caller's class loader
1976- * is not the same as or an ancestor of the given cl argument.
1977- */
1978- static void checkClassLoaderPermission (ClassLoader cl , Class <?> caller ) {
1979- @ SuppressWarnings ("removal" )
1980- SecurityManager sm = System .getSecurityManager ();
1981- if (sm != null ) {
1982- // caller can be null if the VM is requesting it
1983- ClassLoader ccl = getClassLoader (caller );
1984- if (needsClassLoaderPermissionCheck (ccl , cl )) {
1985- sm .checkPermission (SecurityConstants .GET_CLASSLOADER_PERMISSION );
1986- }
1987- }
1988- }
1989-
19901910 // The system class loader
19911911 // @GuardedBy("ClassLoader.class")
19921912 private static volatile ClassLoader scl ;
0 commit comments