Re: [PR] VELOCITY-984: Velocity calls method of abstract s uperclass leading to an IllegalAccessException [velocity-engine ]

tmortagne (via GitHub) <[email protected]>
Newsgroups gmane.comp.jakarta.velocity.devel
Message-ID <PR_kwDOAN72MM59-hKK-9e3a4f0d-1e77-4618-b03c-e8a8404664b5@gitbox.apache.org>
tmortagne commented on code in PR #54:
URL: https://github.com/apache/velocity-engine/pull/54#discussion_r1793108303


##########
velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/MethodMap.java:
##########
@@ -387,9 +393,52 @@ public static Method getTopMostMethodDeclaration(Method method)
             }
             clazz = superClass;
         }
+
         return method;
     }
 
+    private static boolean canAccess(Method method)
+    {
+        // Check if the method is public
+        if (Modifier.isPublic(method.getModifiers())) {
+            if (method.isAccessible()) {
+                // The method accessible flag was already set to true so we assume we can call it
+                return true;
+            } else {
+                try {
+                    // Check if we are able to change the accessible flag
+                    if (trySetAccessible(method)) {
+                        // Restore the accessible flag to its former value
+                        method.setAccessible(false);

Review Comment:
   Just a reflex to keep things as they were before I start messing with it for what is supposed to be just a check. Just in case.



-- 
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]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.