zemiles commented on code in PR #1810:
URL: https://github.com/apache/commons-lang/pull/1810#discussion_r4237772532


##########
src/main/java/org/apache/commons/lang3/AnnotationUtils.java:
##########
@@ -217,7 +218,7 @@ public static boolean equals(final Annotation a1, final 
Annotation a2) {
         }
         try {
             for (final Method m : type1.getDeclaredMethods()) {
-                if (m.getParameterTypes().length == 0
+                if (isAnnotationMember(m) && m.getParameterTypes().length == 0
                         && isValidAnnotationMemberType(m.getReturnType())) {
                     
AbstractReflection.setAccessible(AbstractReflection.getForceAccessible(), m);

Review Comment:
   Thanks for the suggestion. I updated equals(), hashCode(), and toString() to 
try normal invocation first, adjusting accessibility and retrying only after 
IllegalAccessException when permitted by the existing forceAccessible setting.
   
   This preserves support for non-public annotation types and Java 8 
compatibility without using canAccess(), which was introduced in Java 9.
   
   All 22 related tests pass on Java 8, 11, 17, 21, 25, and 27. The full 
default Maven build also passes on Java 21, with no Checkstyle violations.



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