Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.6.5
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
- is duplicated by
-
GROOVY-7670 CLONE - dash in script filename
- Closed
- is related to
-
GROOVY-5760 CLONE - dash in script filename
- Closed