[ 
https://issues.apache.org/jira/browse/GROOVY-7670?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15090959#comment-15090959
 ] 

Jochen Theodorou commented on GROOVY-7670:
------------------------------------------

The problem is that the dash is not a valid part of a class name in the JVM. 
And it has been like that since early versions of the JDK, so I wonder what you 
mean with that being a regression from quite a recent Groovy version Jamie.  It 
is of course always possible that the name check in the JVM did not always 
catch all invalid cases, thus allowing illegal class names sometimes. But it 
would help if you could tell me what Groovy version you had in mind, just in 
case. Because we did add some name mangling, which could be reused here as well.

Anyway... my suggestion for a fix would be to use the existing name mangling 
and apply it to script class names.

> CLONE - dash in script filename
> -------------------------------
>
>                 Key: GROOVY-7670
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7670
>             Project: Groovy
>          Issue Type: Bug
>          Components: class generator
>    Affects Versions: 2.4.5
>         Environment: Oracle Java 8, Windows (although OS is not relevant IMHO)
>            Reporter: Christoph Grothaus
>            Priority: Minor
>         Attachments: fibonacci-numbers.groovy, fibonacci_numbers.groovy
>
>
> Cannot create script with dash ("-") in filename.
> Please try to run the two attached groovy scripts. The one with an underscore 
> in the filename runs happily (don't wonder, it gives no output). The one with 
> a dash in the filename gives this error: {noformat}$ groovy 
> fibonacci-numbers.groovy
> Caught: java.lang.ClassFormatError: Illegal class name 
> "fibonacci-numbers$fib" in class file fibonacci-numbers$fib
> java.lang.ClassFormatError: Illegal class name "fibonacci-numbers$fib" in 
> class file fibonacci-numbers$fib
>         at fibonacci-numbers.run(fibonacci-numbers.groovy:5){noformat}
> It really took me some time to figure out that the dash was causing this. I 
> would like to see Groovy allowing dashes in script filenames. If that should 
> be impossible, at least the error message should cleary indicate that I have 
> used an illegal character in the script filename.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to