Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 e621cff
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/java.base/share/classes/java/lang/Class.java
Expand Up @@ -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")
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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);
Expand All @@ -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 {
Expand Down Expand Up @@ -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);
}
Expand All @@ -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();
Expand Down Expand Up @@ -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<>();
Expand Down Expand Up @@ -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);
Expand Down

1 comment on commit e621cff

@openjdk-notifier
Copy link

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.