@@ -256,7 +256,7 @@ public static ClassLoader overrideThreadContextClassLoader(@Nullable ClassLoader
256
256
* style (e.g. "java.lang.Thread.State" instead of "java.lang.Thread$State").
257
257
* @param name the name of the Class
258
258
* @param classLoader the class loader to use
259
- * (may be {@code null}, which indicates the default class loader)
259
+ * (can be {@code null}, which indicates the default class loader)
260
260
* @return a class instance for the supplied name
261
261
* @throws ClassNotFoundException if the class was not found
262
262
* @throws LinkageError if the class file could not be loaded
@@ -328,7 +328,7 @@ public static Class<?> forName(String name, @Nullable ClassLoader classLoader)
328
328
* the exceptions thrown in case of class loading failure.
329
329
* @param className the name of the Class
330
330
* @param classLoader the class loader to use
331
- * (may be {@code null}, which indicates the default class loader)
331
+ * (can be {@code null}, which indicates the default class loader)
332
332
* @return a class instance for the supplied name
333
333
* @throws IllegalArgumentException if the class name was not resolvable
334
334
* (that is, the class could not be found or the class file could not be loaded)
@@ -362,7 +362,7 @@ public static Class<?> resolveClassName(String className, @Nullable ClassLoader
362
362
* one of its dependencies is not present or cannot be loaded.
363
363
* @param className the name of the class to check
364
364
* @param classLoader the class loader to use
365
- * (may be {@code null} which indicates the default class loader)
365
+ * (can be {@code null} which indicates the default class loader)
366
366
* @return whether the specified class is present (including all of its
367
367
* superclasses and interfaces)
368
368
* @throws IllegalStateException if the corresponding class is resolvable but
@@ -389,7 +389,7 @@ public static boolean isPresent(String className, @Nullable ClassLoader classLoa
389
389
* Check whether the given class is visible in the given ClassLoader.
390
390
* @param clazz the class to check (typically an interface)
391
391
* @param classLoader the ClassLoader to check against
392
- * (may be {@code null} in which case this method will always return {@code true})
392
+ * (can be {@code null} in which case this method will always return {@code true})
393
393
*/
394
394
public static boolean isVisible (Class <?> clazz , @ Nullable ClassLoader classLoader ) {
395
395
if (classLoader == null ) {
@@ -413,7 +413,7 @@ public static boolean isVisible(Class<?> clazz, @Nullable ClassLoader classLoade
413
413
* i.e. whether it is loaded by the given ClassLoader or a parent of it.
414
414
* @param clazz the class to analyze
415
415
* @param classLoader the ClassLoader to potentially cache metadata in
416
- * (may be {@code null} which indicates the system class loader)
416
+ * (can be {@code null} which indicates the system class loader)
417
417
*/
418
418
public static boolean isCacheSafe (Class <?> clazz , @ Nullable ClassLoader classLoader ) {
419
419
Assert .notNull (clazz , "Class must not be null" );
@@ -727,7 +727,7 @@ public static String classNamesToString(Class<?>... classes) {
727
727
* in the given collection.
728
728
* <p>Basically like {@code AbstractCollection.toString()}, but stripping
729
729
* the "class "/"interface " prefix before every class name.
730
- * @param classes a Collection of Class objects (may be {@code null})
730
+ * @param classes a Collection of Class objects (can be {@code null})
731
731
* @return a String of form "[com.foo.Bar, com.foo.Baz]"
732
732
* @see java.util.AbstractCollection#toString()
733
733
*/
@@ -782,7 +782,7 @@ public static Class<?>[] getAllInterfacesForClass(Class<?> clazz) {
782
782
* <p>If the class itself is an interface, it gets returned as sole interface.
783
783
* @param clazz the class to analyze for interfaces
784
784
* @param classLoader the ClassLoader that the interfaces need to be visible in
785
- * (may be {@code null} when accepting all declared interfaces)
785
+ * (can be {@code null} when accepting all declared interfaces)
786
786
* @return all interfaces that the given object implements as an array
787
787
*/
788
788
public static Class <?>[] getAllInterfacesForClass (Class <?> clazz , @ Nullable ClassLoader classLoader ) {
@@ -817,7 +817,7 @@ public static Set<Class<?>> getAllInterfacesForClassAsSet(Class<?> clazz) {
817
817
* <p>If the class itself is an interface, it gets returned as sole interface.
818
818
* @param clazz the class to analyze for interfaces
819
819
* @param classLoader the ClassLoader that the interfaces need to be visible in
820
- * (may be {@code null} when accepting all declared interfaces)
820
+ * (can be {@code null} when accepting all declared interfaces)
821
821
* @return all interfaces that the given object implements as a Set
822
822
*/
823
823
public static Set <Class <?>> getAllInterfacesForClassAsSet (Class <?> clazz , @ Nullable ClassLoader classLoader ) {
@@ -1146,7 +1146,7 @@ public static String getQualifiedMethodName(Method method) {
1146
1146
* fully qualified interface/class name + "." + method name.
1147
1147
* @param method the method
1148
1148
* @param clazz the clazz that the method is being invoked on
1149
- * (may be {@code null} to indicate the method's declaring class)
1149
+ * (can be {@code null} to indicate the method's declaring class)
1150
1150
* @return the qualified name of the method
1151
1151
* @since 4.3.4
1152
1152
*/
@@ -1227,7 +1227,7 @@ public static boolean hasMethod(Class<?> clazz, String methodName, Class<?>... p
1227
1227
* @param clazz the clazz to analyze
1228
1228
* @param methodName the name of the method
1229
1229
* @param paramTypes the parameter types of the method
1230
- * (may be {@code null} to indicate any signature)
1230
+ * (can be {@code null} to indicate any signature)
1231
1231
* @return the method (never {@code null})
1232
1232
* @throws IllegalStateException if the method has not been found
1233
1233
* @see Class#getMethod
@@ -1266,7 +1266,7 @@ else if (candidates.isEmpty()) {
1266
1266
* @param clazz the clazz to analyze
1267
1267
* @param methodName the name of the method
1268
1268
* @param paramTypes the parameter types of the method
1269
- * (may be {@code null} to indicate any signature)
1269
+ * (can be {@code null} to indicate any signature)
1270
1270
* @return the method, or {@code null} if not found
1271
1271
* @see Class#getMethod
1272
1272
*/
@@ -1355,13 +1355,14 @@ public static boolean hasAtLeastOneMethodWithName(Class<?> clazz, String methodN
1355
1355
* implementation will fall back to returning the originally provided method.
1356
1356
* @param method the method to be invoked, which may come from an interface
1357
1357
* @param targetClass the target class for the current invocation
1358
- * (may be {@code null} or may not even implement the method)
1358
+ * (can be {@code null} or may not even implement the method)
1359
1359
* @return the specific target method, or the original method if the
1360
1360
* {@code targetClass} does not implement it
1361
1361
* @see #getInterfaceMethodIfPossible(Method, Class)
1362
1362
*/
1363
1363
public static Method getMostSpecificMethod (Method method , @ Nullable Class <?> targetClass ) {
1364
- if (targetClass != null && targetClass != method .getDeclaringClass () && isOverridable (method , targetClass )) {
1364
+ if (targetClass != null && targetClass != method .getDeclaringClass () &&
1365
+ (isOverridable (method , targetClass ) || !method .getDeclaringClass ().isAssignableFrom (targetClass ))) {
1365
1366
try {
1366
1367
if (Modifier .isPublic (method .getModifiers ())) {
1367
1368
try {
0 commit comments