groovy
  1. groovy
  2. GROOVY-4020

java.lang.ClassFormatError when using the name including "-" sign

    Details

    • Type: Bug Bug
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.6.5
    • Fix Version/s: None
    • Component/s: Compiler
    • Labels:
      None
    • Number of attachments :
      0

      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 ?

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            Tran The Trong
          • Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: