Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-432

Groovy Reflection problem for unknown classes

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.0-JSR-3
    • Groovlet / GSP
    • None

    Description

      Groovy can't reflect classes which are unknown to the its ClassLoader when using MetaClass.setUseReflection(false) even if it could cast to a known interface.

      For example Tomcat will replace System.out with a custom PrintStream instead of the default and when you try to use System.out and setUseReflection is set to false every call to System.out will fail with:

      java.lang.NoClassDefFoundError: org/apache/tomcat/util/log/SystemLogHandler
      gjdk.org.apache.tomcat.util.log.SystemLogHandler_GroovyReflector.invoke(SystemLogHandler_GroovyReflector.java)
      groovy.lang.MetaMethod.invoke(MetaMethod.java:110)
      groovy.lang.MetaClass.doMethodInvoke(MetaClass.java:996)

      I packaged a complete war file to show the behaviour.

      It can be found at http://home.mx4k.com/test.war

      You should be able to call: http://yourhost/test/test.groovy to see the problem. If you use the default groovy.servlet.GroovyServlet the example works but I couldn't come up with an "easier" test to show this behaviour.

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            blackdrag Jochen Theodorou
            maniax Thomas Heller
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment