64
64
import jdk .internal .reflect .CallerSensitiveAdapter ;
65
65
import jdk .internal .reflect .Reflection ;
66
66
import jdk .internal .util .StaticProperty ;
67
- import sun .security .util .SecurityConstants ;
68
67
69
68
/**
70
69
* A class loader is an object that is responsible for loading classes. The
@@ -357,12 +356,6 @@ private static Void checkCreateClassLoader(String name) {
357
356
if (name != null && name .isEmpty ()) {
358
357
throw new IllegalArgumentException ("name must be non-empty or null" );
359
358
}
360
-
361
- @ SuppressWarnings ("removal" )
362
- SecurityManager security = System .getSecurityManager ();
363
- if (security != null ) {
364
- security .checkCreateClassLoader ();
365
- }
366
359
return null ;
367
360
}
368
361
@@ -1735,18 +1728,7 @@ public static InputStream getSystemResourceAsStream(String name) {
1735
1728
*
1736
1729
* @since 1.2
1737
1730
*/
1738
- @ CallerSensitive
1739
1731
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
- }
1750
1732
return parent ;
1751
1733
}
1752
1734
@@ -1774,15 +1756,8 @@ public final Module getUnnamedModule() {
1774
1756
*
1775
1757
* @since 9
1776
1758
*/
1777
- @ CallerSensitive
1778
1759
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 ();
1786
1761
}
1787
1762
1788
1763
/**
@@ -1853,7 +1828,6 @@ public static ClassLoader getPlatformClassLoader() {
1853
1828
* underlying cause of the error can be retrieved via the
1854
1829
* {@link Throwable#getCause()} method.
1855
1830
*/
1856
- @ CallerSensitive
1857
1831
public static ClassLoader getSystemClassLoader () {
1858
1832
switch (VM .initLevel ()) {
1859
1833
case 0 :
@@ -1867,11 +1841,6 @@ public static ClassLoader getSystemClassLoader() {
1867
1841
default :
1868
1842
// system fully initialized
1869
1843
assert VM .isBooted () && scl != null ;
1870
- @ SuppressWarnings ("removal" )
1871
- SecurityManager sm = System .getSecurityManager ();
1872
- if (sm != null ) {
1873
- checkClassLoaderPermission (scl , Reflection .getCallerClass ());
1874
- }
1875
1844
return scl ;
1876
1845
}
1877
1846
}
@@ -1902,8 +1871,6 @@ static synchronized ClassLoader initSystemClassLoader() {
1902
1871
}
1903
1872
1904
1873
ClassLoader builtinLoader = getBuiltinAppClassLoader ();
1905
-
1906
- // All are privileged frames. No need to call doPrivileged.
1907
1874
String cn = System .getProperty ("java.system.class.loader" );
1908
1875
if (cn != null ) {
1909
1876
try {
@@ -1930,36 +1897,6 @@ static synchronized ClassLoader initSystemClassLoader() {
1930
1897
return scl ;
1931
1898
}
1932
1899
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
-
1963
1900
// Returns the class's class loader, or null if none.
1964
1901
static ClassLoader getClassLoader (Class <?> caller ) {
1965
1902
// This can be null if the VM is requesting it
@@ -1970,23 +1907,6 @@ static ClassLoader getClassLoader(Class<?> caller) {
1970
1907
return caller .getClassLoader0 ();
1971
1908
}
1972
1909
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
-
1990
1910
// The system class loader
1991
1911
// @GuardedBy("ClassLoader.class")
1992
1912
private static volatile ClassLoader scl ;
0 commit comments