Skip to content
Permalink
Browse files
8271627: Use local field access in favor of Class.getClassLoader0
Reviewed-by: mchung
  • Loading branch information
cl4es committed Aug 2, 2021
1 parent 0a85236 commit e621cffa4fee0b403a8650519c70e0a6cb76b03c
Showing 1 changed file with 10 additions and 10 deletions.
@@ -892,7 +892,7 @@ public String getName() {
@CallerSensitive
@ForceInline // to ensure Reflection.getCallerClass optimization
public ClassLoader getClassLoader() {
ClassLoader cl = getClassLoader0();
ClassLoader cl = classLoader;
if (cl == null)
return null;
@SuppressWarnings("removal")
@@ -1041,7 +1041,7 @@ public Package getPackage() {
if (isPrimitive() || isArray()) {
return null;
}
ClassLoader cl = getClassLoader0();
ClassLoader cl = classLoader;
return cl != null ? cl.definePackage(this)
: BootLoader.definePackage(this);
}
@@ -2823,7 +2823,7 @@ public InputStream getResourceAsStream(String name) {

// resource not encapsulated or in package open to caller
String mn = thisModule.getName();
ClassLoader cl = getClassLoader0();
ClassLoader cl = classLoader;
try {

// special-case built-in class loaders to avoid the
@@ -2843,7 +2843,7 @@ public InputStream getResourceAsStream(String name) {
}

// unnamed module
ClassLoader cl = getClassLoader0();
ClassLoader cl = classLoader;
if (cl == null) {
return ClassLoader.getSystemResourceAsStream(name);
} else {
@@ -2919,7 +2919,7 @@ public URL getResource(String name) {

// resource not encapsulated or in package open to caller
String mn = thisModule.getName();
ClassLoader cl = getClassLoader0();
ClassLoader cl = classLoader;
try {
if (cl == null) {
return BootLoader.findResource(mn, name);
@@ -2932,7 +2932,7 @@ public URL getResource(String name) {
}

// unnamed module
ClassLoader cl = getClassLoader0();
ClassLoader cl = classLoader;
if (cl == null) {
return ClassLoader.getSystemResource(name);
} else {
@@ -3046,7 +3046,7 @@ private void checkMemberAccess(@SuppressWarnings("removal") SecurityManager sm,
*/
final ClassLoader ccl = ClassLoader.getClassLoader(caller);
if (which != Member.PUBLIC) {
final ClassLoader cl = getClassLoader0();
final ClassLoader cl = classLoader;
if (ccl != cl) {
sm.checkPermission(SecurityConstants.CHECK_MEMBER_ACCESS_PERMISSION);
}
@@ -3063,7 +3063,7 @@ private void checkMemberAccess(@SuppressWarnings("removal") SecurityManager sm,
*/
private void checkPackageAccess(@SuppressWarnings("removal") SecurityManager sm, final ClassLoader ccl,
boolean checkProxyInterfaces) {
final ClassLoader cl = getClassLoader0();
final ClassLoader cl = classLoader;

if (ReflectUtil.needsPackageAccessCheck(ccl, cl)) {
String pkg = this.getPackageName();
@@ -3092,7 +3092,7 @@ private void checkPackageAccess(@SuppressWarnings("removal") SecurityManager sm,
*/
private static void checkPackageAccessForPermittedSubclasses(@SuppressWarnings("removal") SecurityManager sm,
final ClassLoader ccl, Class<?>[] subClasses) {
final ClassLoader cl = subClasses[0].getClassLoader0();
final ClassLoader cl = subClasses[0].classLoader;

if (ReflectUtil.needsPackageAccessCheck(ccl, cl)) {
Set<String> packages = new HashSet<>();
@@ -3717,7 +3717,7 @@ private String methodToString(String name, Class<?>[] argTypes) {
* @since 1.4
*/
public boolean desiredAssertionStatus() {
ClassLoader loader = getClassLoader0();
ClassLoader loader = classLoader;
// If the loader is null this is a system class, so ask the VM
if (loader == null)
return desiredAssertionStatus0(this);

1 comment on commit e621cff

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on e621cff Aug 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.