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

ClassFormatError when using the name including "-" sign

    XMLWordPrintableJSON

Details

    Description

      I'm not sure if there any constraint with the name parameter before passing to GroovyCodeSource but it is raising an exception if the name includes "-" sign :

      GroovyCodeSource gcs = new GroovyCodeSource(inputStream, "file-name.gtmpl", "/groovy/shell");

      Here is the exception :

      Caused by: java.lang.ClassFormatError: Illegal class name "File-name" in class file File-name
      at java.lang.ClassLoader.defineClass1(Native Method)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
      at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
      at groovy.lang.GroovyClassLoader.access$200(GroovyClassLoader.java:54)
      at groovy.lang.GroovyClassLoader$ClassCollector.createClass(GroovyClassLoader.java:482)
      at groovy.lang.GroovyClassLoader$ClassCollector.onClassNode(GroovyClassLoader.java:499)
      at groovy.lang.GroovyClassLoader$ClassCollector.call(GroovyClassLoader.java:503)
      at org.codehaus.groovy.control.CompilationUnit$10.call(CompilationUnit.java:728)
      at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:925)
      at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:462)
      at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:278)

      It seems that the name parameter is used for createing Class in Java, so it must be a binary name as defined by the Java Language Specification. If so, the name would be validated and converted to good one ? Or I must to take care of that myself before using GroovyCodeSource ?

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              trongtt Tran The Trong
              Votes:
              4 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: