You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2022/05/22 19:44:00 UTC
[jira] [Resolved] (GROOVY-4020) ClassFormatError when using the name including "-" sign
[ https://issues.apache.org/jira/browse/GROOVY-4020?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles resolved GROOVY-4020.
---------------------------------
Fix Version/s: 5.0.0-alpha-1
Resolution: Fixed
https://github.com/apache/groovy/commit/2691fb0d2b745a7cc6647edd09a71a3831ffa460
> ClassFormatError when using the name including "-" sign
> -------------------------------------------------------
>
> Key: GROOVY-4020
> URL: https://issues.apache.org/jira/browse/GROOVY-4020
> Project: Groovy
> Issue Type: Bug
> Components: Compiler
> Affects Versions: 1.6.5
> Reporter: Tran The Trong
> Assignee: Eric Milles
> Priority: Major
> Labels: ClassFormatError
> Fix For: 5.0.0-alpha-1
>
>
> 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 ?
--
This message was sent by Atlassian Jira
(v8.20.7#820007)