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


##########
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:
   For `size()` on JDK `List` implementations, the public declaration is on 
`java.util.Collection`, not `java.util.List` (List inherits it). 
`getAccessibleMethodFromInterfaceNest` will typically resolve to 
`Collection.size()`, so these assertions are likely brittle / incorrect.



-- 
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