Velocity
  1. Velocity
  2. VELOCITY-745

Modify ClassMap.java to use getMethods() rather than get getDeclaredMethods()

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.6.2
    • Fix Version/s: None
    • Component/s: Engine
    • Labels:
      None
    • Environment:
      All

      Description

      The code that recurses up the super classes to find all public methods using getDeclaredMethods() is now redundant and can be replaced with a single call to getMethods() - this intrinsically provides all inherited public methods.

        Issue Links

          Activity

          Hide
          Nathan Bubna added a comment -

          Hmm. First attempt failed (JDK1.5):

          Testcase: Foreach-introspect took 0.015 sec
          Caused an ERROR
          ASTMethod.execute() : exception invoking method 'next' in class java.util.AbstractList$Itr
          org.apache.velocity.exception.VelocityException: ASTMethod.execute() : exception invoking method 'next' in class java.util.AbstractList$Itr
          at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:208)
          at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:280)
          at org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:369)
          at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:72)
          at org.apache.velocity.runtime.directive.Foreach.render(Foreach.java:420)
          at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:207)
          at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:342)
          at org.apache.velocity.Template.merge(Template.java:356)
          at org.apache.velocity.Template.merge(Template.java:260)
          at org.apache.velocity.test.TemplateTestCase.runTest(TemplateTestCase.java:205)
          Caused by: java.lang.IllegalAccessException: Class org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl can not access a member of class java.util.AbstractList$Itr with modifiers "public"
          at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.doInvoke(UberspectImpl.java:395)
          at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:384)
          at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:173)

          Clearly, this is not as simple as it seems. getMethods() appears to return the implementing methods of public interfaces, which are not necessarily in public classes (e.g above). This then causes trouble when you go to invoke. I don't think it should do this, but it does.

          Anyone have any insight into this? I'm in newborn-baby-sleep-deprivation-mode, so i may be missing something obvious.

          Show
          Nathan Bubna added a comment - Hmm. First attempt failed (JDK1.5): Testcase: Foreach-introspect took 0.015 sec Caused an ERROR ASTMethod.execute() : exception invoking method 'next' in class java.util.AbstractList$Itr org.apache.velocity.exception.VelocityException: ASTMethod.execute() : exception invoking method 'next' in class java.util.AbstractList$Itr at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:208) at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:280) at org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:369) at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:72) at org.apache.velocity.runtime.directive.Foreach.render(Foreach.java:420) at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:207) at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:342) at org.apache.velocity.Template.merge(Template.java:356) at org.apache.velocity.Template.merge(Template.java:260) at org.apache.velocity.test.TemplateTestCase.runTest(TemplateTestCase.java:205) Caused by: java.lang.IllegalAccessException: Class org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl can not access a member of class java.util.AbstractList$Itr with modifiers "public" at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.doInvoke(UberspectImpl.java:395) at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:384) at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:173) Clearly, this is not as simple as it seems. getMethods() appears to return the implementing methods of public interfaces, which are not necessarily in public classes (e.g above). This then causes trouble when you go to invoke. I don't think it should do this, but it does. Anyone have any insight into this? I'm in newborn-baby-sleep-deprivation-mode, so i may be missing something obvious.
          Hide
          Nathan Bubna added a comment -

          If there were once reasons for doing it as it currently is done, i've been unable to think of them so far. I'll aim to deal with this before any 1.7 release. It ought to simplify things, and simply trying it is probably the best way to see if there's something i'm overlooking.

          Show
          Nathan Bubna added a comment - If there were once reasons for doing it as it currently is done, i've been unable to think of them so far. I'll aim to deal with this before any 1.7 release. It ought to simplify things, and simply trying it is probably the best way to see if there's something i'm overlooking.

            People

            • Assignee:
              Unassigned
              Reporter:
              Steve O'Hara
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:

                Development