mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8271627: Use local field access in favor of Class.getClassLoader0
Reviewed-by: mchung
This commit is contained in:
parent
0a85236396
commit
e621cffa4f
1 changed files with 10 additions and 10 deletions
|
@ -892,7 +892,7 @@ public final class Class<T> implements java.io.Serializable,
|
||||||
@CallerSensitive
|
@CallerSensitive
|
||||||
@ForceInline // to ensure Reflection.getCallerClass optimization
|
@ForceInline // to ensure Reflection.getCallerClass optimization
|
||||||
public ClassLoader getClassLoader() {
|
public ClassLoader getClassLoader() {
|
||||||
ClassLoader cl = getClassLoader0();
|
ClassLoader cl = classLoader;
|
||||||
if (cl == null)
|
if (cl == null)
|
||||||
return null;
|
return null;
|
||||||
@SuppressWarnings("removal")
|
@SuppressWarnings("removal")
|
||||||
|
@ -1041,7 +1041,7 @@ public final class Class<T> implements java.io.Serializable,
|
||||||
if (isPrimitive() || isArray()) {
|
if (isPrimitive() || isArray()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
ClassLoader cl = getClassLoader0();
|
ClassLoader cl = classLoader;
|
||||||
return cl != null ? cl.definePackage(this)
|
return cl != null ? cl.definePackage(this)
|
||||||
: BootLoader.definePackage(this);
|
: BootLoader.definePackage(this);
|
||||||
}
|
}
|
||||||
|
@ -2823,7 +2823,7 @@ public final class Class<T> implements java.io.Serializable,
|
||||||
|
|
||||||
// resource not encapsulated or in package open to caller
|
// resource not encapsulated or in package open to caller
|
||||||
String mn = thisModule.getName();
|
String mn = thisModule.getName();
|
||||||
ClassLoader cl = getClassLoader0();
|
ClassLoader cl = classLoader;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// special-case built-in class loaders to avoid the
|
// special-case built-in class loaders to avoid the
|
||||||
|
@ -2843,7 +2843,7 @@ public final class Class<T> implements java.io.Serializable,
|
||||||
}
|
}
|
||||||
|
|
||||||
// unnamed module
|
// unnamed module
|
||||||
ClassLoader cl = getClassLoader0();
|
ClassLoader cl = classLoader;
|
||||||
if (cl == null) {
|
if (cl == null) {
|
||||||
return ClassLoader.getSystemResourceAsStream(name);
|
return ClassLoader.getSystemResourceAsStream(name);
|
||||||
} else {
|
} else {
|
||||||
|
@ -2919,7 +2919,7 @@ public final class Class<T> implements java.io.Serializable,
|
||||||
|
|
||||||
// resource not encapsulated or in package open to caller
|
// resource not encapsulated or in package open to caller
|
||||||
String mn = thisModule.getName();
|
String mn = thisModule.getName();
|
||||||
ClassLoader cl = getClassLoader0();
|
ClassLoader cl = classLoader;
|
||||||
try {
|
try {
|
||||||
if (cl == null) {
|
if (cl == null) {
|
||||||
return BootLoader.findResource(mn, name);
|
return BootLoader.findResource(mn, name);
|
||||||
|
@ -2932,7 +2932,7 @@ public final class Class<T> implements java.io.Serializable,
|
||||||
}
|
}
|
||||||
|
|
||||||
// unnamed module
|
// unnamed module
|
||||||
ClassLoader cl = getClassLoader0();
|
ClassLoader cl = classLoader;
|
||||||
if (cl == null) {
|
if (cl == null) {
|
||||||
return ClassLoader.getSystemResource(name);
|
return ClassLoader.getSystemResource(name);
|
||||||
} else {
|
} else {
|
||||||
|
@ -3046,7 +3046,7 @@ public final class Class<T> implements java.io.Serializable,
|
||||||
*/
|
*/
|
||||||
final ClassLoader ccl = ClassLoader.getClassLoader(caller);
|
final ClassLoader ccl = ClassLoader.getClassLoader(caller);
|
||||||
if (which != Member.PUBLIC) {
|
if (which != Member.PUBLIC) {
|
||||||
final ClassLoader cl = getClassLoader0();
|
final ClassLoader cl = classLoader;
|
||||||
if (ccl != cl) {
|
if (ccl != cl) {
|
||||||
sm.checkPermission(SecurityConstants.CHECK_MEMBER_ACCESS_PERMISSION);
|
sm.checkPermission(SecurityConstants.CHECK_MEMBER_ACCESS_PERMISSION);
|
||||||
}
|
}
|
||||||
|
@ -3063,7 +3063,7 @@ public final class Class<T> implements java.io.Serializable,
|
||||||
*/
|
*/
|
||||||
private void checkPackageAccess(@SuppressWarnings("removal") SecurityManager sm, final ClassLoader ccl,
|
private void checkPackageAccess(@SuppressWarnings("removal") SecurityManager sm, final ClassLoader ccl,
|
||||||
boolean checkProxyInterfaces) {
|
boolean checkProxyInterfaces) {
|
||||||
final ClassLoader cl = getClassLoader0();
|
final ClassLoader cl = classLoader;
|
||||||
|
|
||||||
if (ReflectUtil.needsPackageAccessCheck(ccl, cl)) {
|
if (ReflectUtil.needsPackageAccessCheck(ccl, cl)) {
|
||||||
String pkg = this.getPackageName();
|
String pkg = this.getPackageName();
|
||||||
|
@ -3092,7 +3092,7 @@ public final class Class<T> implements java.io.Serializable,
|
||||||
*/
|
*/
|
||||||
private static void checkPackageAccessForPermittedSubclasses(@SuppressWarnings("removal") SecurityManager sm,
|
private static void checkPackageAccessForPermittedSubclasses(@SuppressWarnings("removal") SecurityManager sm,
|
||||||
final ClassLoader ccl, Class<?>[] subClasses) {
|
final ClassLoader ccl, Class<?>[] subClasses) {
|
||||||
final ClassLoader cl = subClasses[0].getClassLoader0();
|
final ClassLoader cl = subClasses[0].classLoader;
|
||||||
|
|
||||||
if (ReflectUtil.needsPackageAccessCheck(ccl, cl)) {
|
if (ReflectUtil.needsPackageAccessCheck(ccl, cl)) {
|
||||||
Set<String> packages = new HashSet<>();
|
Set<String> packages = new HashSet<>();
|
||||||
|
@ -3717,7 +3717,7 @@ public final class Class<T> implements java.io.Serializable,
|
||||||
* @since 1.4
|
* @since 1.4
|
||||||
*/
|
*/
|
||||||
public boolean desiredAssertionStatus() {
|
public boolean desiredAssertionStatus() {
|
||||||
ClassLoader loader = getClassLoader0();
|
ClassLoader loader = classLoader;
|
||||||
// If the loader is null this is a system class, so ask the VM
|
// If the loader is null this is a system class, so ask the VM
|
||||||
if (loader == null)
|
if (loader == null)
|
||||||
return desiredAssertionStatus0(this);
|
return desiredAssertionStatus0(this);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue