lenamonj commented on code in PR #1783:
URL: https://github.com/apache/commons-lang/pull/1783#discussion_r3963339988


##########
src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java:
##########
@@ -605,6 +607,39 @@ void testGetAccessibleInterfaceMethodFromDescription(final 
Class<?> clazz) {
         }
     }
 
+    @ParameterizedTest
+    @ValueSource(classes = {TestMutable.class, TestMutableSubclass.class})
+    void testGetMatchingAccessibleMethodOnNonPublicClass(final Class<?> clazz) 
{
+        assertSame(Mutable.class, 
MethodUtils.getMatchingAccessibleMethod(clazz, "getValue").getDeclaringClass());
+        assertSame(Mutable.class,
+                MethodUtils.getMatchingAccessibleMethod(clazz, "setValue", 
Object.class).getDeclaringClass());
+    }
+
+    @Test
+    void testGetMatchingAccessibleMethodOnNonPublicJdkClass() {
+        assertSame(List.class,
+                
MethodUtils.getMatchingAccessibleMethod(Collections.emptyList().getClass(), 
"size").getDeclaringClass());
+        assertSame(List.class,
+                MethodUtils.getMatchingAccessibleMethod(Arrays.asList(1, 
2).getClass(), "size").getDeclaringClass());

Review Comment:
   `java.util.List` declares `size()` itself, so the interface walk in 
`getAccessibleMethodFromInterfaceNest` stops at `List` before it reaches 
`Collection`, and `Map` declares its own `size()` the same way. The assertions 
hold on every JDK in the matrix, 8 through 27.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to