From 9e1f90c70adac7b86fc9ba6c543fcf36e93834ad Mon Sep 17 00:00:00 2001 From: Daniel Sun Date: Sun, 12 Jan 2025 05:00:15 +0900 Subject: [PATCH] Trivial refactoring: extract variables --- .../java/org/codehaus/groovy/reflection/CachedClass.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/codehaus/groovy/reflection/CachedClass.java b/src/main/java/org/codehaus/groovy/reflection/CachedClass.java index a80d27ceb43..574770ce5b3 100644 --- a/src/main/java/org/codehaus/groovy/reflection/CachedClass.java +++ b/src/main/java/org/codehaus/groovy/reflection/CachedClass.java @@ -58,10 +58,12 @@ private static T doPrivileged(java.security.PrivilegedAction action) { } private static boolean isAccessibleOrCanSetAccessible(M m) { - if (isPublic(m.getModifiers()) && m.getDeclaringClass().getPackageName().startsWith("sun.")) { + final int modifiers = m.getModifiers(); + final Class declaringClass = m.getDeclaringClass(); + if (isPublic(modifiers) && declaringClass.getPackageName().startsWith("sun.")) { return false; } - if (isProtected(m.getModifiers()) && isPublic(m.getDeclaringClass().getModifiers())) { + if (isProtected(modifiers) && isPublic(declaringClass.getModifiers())) { return true; } return ReflectionUtils.checkCanSetAccessible(m, CachedClass.class);