Skip to content

Commit bb14dfa

Browse files
committed
Merge branch '6.0.x'
2 parents 8695fad + 8934eb8 commit bb14dfa

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

spring-core/src/main/java/org/springframework/util/ClassUtils.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
* @author Keith Donald
6464
* @author Rob Harrop
6565
* @author Sam Brannen
66+
* @author Sebastien Deleuze
6667
* @since 1.1
6768
* @see TypeUtils
6869
* @see ReflectionUtils
@@ -96,6 +97,12 @@ public abstract class ClassUtils {
9697
/** The ".class" file suffix. */
9798
public static final String CLASS_FILE_SUFFIX = ".class";
9899

100+
/** Precomputed value for the combination of private, static and final modifiers. */
101+
private static final int NON_OVERRIDABLE_MODIFIER = Modifier.PRIVATE | Modifier.STATIC | Modifier.FINAL;
102+
103+
/** Precomputed value for the combination of public and protected modifiers. */
104+
private static final int OVERRIDABLE_MODIFIER = Modifier.PUBLIC | Modifier.PROTECTED;
105+
99106

100107
/**
101108
* Map with primitive wrapper type as key and corresponding primitive
@@ -1448,10 +1455,10 @@ private static boolean isGroovyObjectMethod(Method method) {
14481455
* @param targetClass the target class to check against
14491456
*/
14501457
private static boolean isOverridable(Method method, @Nullable Class<?> targetClass) {
1451-
if (Modifier.isPrivate(method.getModifiers())) {
1458+
if ((method.getModifiers() & NON_OVERRIDABLE_MODIFIER) != 0) {
14521459
return false;
14531460
}
1454-
if (Modifier.isPublic(method.getModifiers()) || Modifier.isProtected(method.getModifiers())) {
1461+
if ((method.getModifiers() & OVERRIDABLE_MODIFIER) != 0) {
14551462
return true;
14561463
}
14571464
return (targetClass == null ||

0 commit comments

Comments
 (0)