jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • groovy
  • GROOVY-3054

ClassFormatError: Illegal class name Exception when running a script from a folder with dot in its name

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.5.6
  • Fix Version/s: 1.6-rc-1, 1.5.8, 1.7-beta-1
  • Component/s: bytecode
  • Labels:
    None
  • Environment:
    Ubuntu 7.10
    SunOS 5.10

Description

To reproduce this error just generate a folder with the name "test-7.2"
and generate in it an easy script file named Test:

//script file
println 'foo'

When you run this script the following Exception is thrown:
Caught: java.lang.ClassFormatError: Illegal class name "test-7" in class file test-7

If you rename the file to something with a dot extension (e.g. Test.groovy or Test.test) it works.

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Paul King added a comment - 14/Nov/08 4:17 PM

Doesn't appear to be a problem on Windows on trunk using the batch startup script

Show
Paul King added a comment - 14/Nov/08 4:17 PM Doesn't appear to be a problem on Windows on trunk using the batch startup script
Hide
Permalink
blackdrag blackdrag added a comment - 14/Nov/08 6:46 PM - edited

the environment is Ubuntu, so it is the shell scripts for linux. We source the startGroovy script using ".", maybe that is the reason.. I think there is an alternative way to do that.... on the other hand I don't see a direct relation

Show
blackdrag blackdrag added a comment - 14/Nov/08 6:46 PM - edited the environment is Ubuntu, so it is the shell scripts for linux. We source the startGroovy script using ".", maybe that is the reason.. I think there is an alternative way to do that.... on the other hand I don't see a direct relation
Hide
Permalink
Marcel Szalbach added a comment - 15/Nov/08 8:25 AM

Hi,

thanks for the reply and the hint with the sourcing with the dot.
I did some debugging and testing with the linux commands.

Here are some points I found out:

I changed the "groovy" script to a bash function and use the source command, to test if its a problem of sh only, but it also occurs.

I checked the parameters given to the java command and the end of the startGroovy script. They are the same for a groovy script in an folder with dot in its name and not and for a script ending with .groovy in a dot folder (which will also work).

I also tested this behavior on Windows Vista and the problem occurs also with groovy 1.5.6.

Mr King could you please test it again with windows and the following settings:
Folder name: "test-7.2"
File name: "Test"
It is important that the file has no file extension (check if maybe your Windows hides the extensions, because this is default setting)
The script should not have any class definition in it, just:

Test
//script file
println 'foo'

From this tests I would say that the problem is not related to Linux or the start shell scripts. The Problem lies in the conversion from a classless groovy script to a java class file. I also think this problem affects Windows XP ( I did not test it, but if you wish, I can deliver test results for this too.)

Currently the only workaround I have found is to give the file an extension(".groovy", ".script" etc.) or to define a class in the groovy file:

Test
class Script{
  def main( args ) {
      println 'foo'
  }
}
Show
Marcel Szalbach added a comment - 15/Nov/08 8:25 AM Hi, thanks for the reply and the hint with the sourcing with the dot. I did some debugging and testing with the linux commands. Here are some points I found out: I changed the "groovy" script to a bash function and use the source command, to test if its a problem of sh only, but it also occurs. I checked the parameters given to the java command and the end of the startGroovy script. They are the same for a groovy script in an folder with dot in its name and not and for a script ending with .groovy in a dot folder (which will also work). I also tested this behavior on Windows Vista and the problem occurs also with groovy 1.5.6. Mr King could you please test it again with windows and the following settings: Folder name: "test-7.2" File name: "Test" It is important that the file has no file extension (check if maybe your Windows hides the extensions, because this is default setting) The script should not have any class definition in it, just:
Test
//script file
println 'foo'
From this tests I would say that the problem is not related to Linux or the start shell scripts. The Problem lies in the conversion from a classless groovy script to a java class file. I also think this problem affects Windows XP ( I did not test it, but if you wish, I can deliver test results for this too.) Currently the only workaround I have found is to give the file an extension(".groovy", ".script" etc.) or to define a class in the groovy file:
Test
class Script{
  def main( args ) {
      println 'foo'
  }
}
Hide
Permalink
Paul King added a comment - 15/Nov/08 1:59 PM

Interesting. I was using test.7 as my folder name before. I just tried these names:

C:\temp> groovy test.7.2\Script
Sun Nov 16 05:39:51 EST 2008

C:\temp> groovy test-7-2\Script
Sun Nov 16 05:39:57 EST 2008

C:\temp> groovy test.7-2\Script
Sun Nov 16 05:43:48 EST 2008

C:\temp> groovy test-7.2\Script
Caught: java.lang.ClassFormatError: Illegal class name "test-7" in class file test-7

Then when I try groovyc instead of groovy I notice that the test.7.2 variation creates a directory test containing a class 7.class which I can run while the test-7.2 variation creates a class called test-7.class in the current directory which I can't run. I assumed that '-' was the problem in the name but it seems to have replaced that under the covers. The internal name is test_2D_7 and it appears to find it but then stops with:

Exception in thread "main" java.lang.ClassFormatError: Field "this" in class test-7 has illegal signature "Ltest-7;"
Show
Paul King added a comment - 15/Nov/08 1:59 PM Interesting. I was using test.7 as my folder name before. I just tried these names:
C:\temp> groovy test.7.2\Script
Sun Nov 16 05:39:51 EST 2008

C:\temp> groovy test-7-2\Script
Sun Nov 16 05:39:57 EST 2008

C:\temp> groovy test.7-2\Script
Sun Nov 16 05:43:48 EST 2008

C:\temp> groovy test-7.2\Script
Caught: java.lang.ClassFormatError: Illegal class name "test-7" in class file test-7
Then when I try groovyc instead of groovy I notice that the test.7.2 variation creates a directory test containing a class 7.class which I can run while the test-7.2 variation creates a class called test-7.class in the current directory which I can't run. I assumed that '-' was the problem in the name but it seems to have replaced that under the covers. The internal name is test_2D_7 and it appears to find it but then stops with:
Exception in thread "main" java.lang.ClassFormatError: Field "this" in class test-7 has illegal signature "Ltest-7;"
Hide
Permalink
Paul King added a comment - 15/Nov/08 2:48 PM

OK, I have a fix for this. Will commit soon.

Show
Paul King added a comment - 15/Nov/08 2:48 PM OK, I have a fix for this. Will commit soon.
Hide
Permalink
Paul King added a comment - 16/Nov/08 12:53 AM

fixed

Show
Paul King added a comment - 16/Nov/08 12:53 AM fixed
Hide
Permalink
Andrew Diller added a comment - 16/Sep/09 4:19 PM

This is broken in Mac OSX 10.6 with Groovy Shell (1.6.4, JVM: 1.6.0_15)

DIVWL-9KQHK92:~/work/local_src [508]$ groovy tc-info.groovy 
Caught: java.lang.ClassFormatError: Illegal class name "groovyx/net/http/tc-info" in class file groovyx/net/http/tc-info
Show
Andrew Diller added a comment - 16/Sep/09 4:19 PM This is broken in Mac OSX 10.6 with Groovy Shell (1.6.4, JVM: 1.6.0_15)
DIVWL-9KQHK92:~/work/local_src [508]$ groovy tc-info.groovy 
Caught: java.lang.ClassFormatError: Illegal class name "groovyx/net/http/tc-info" in class file groovyx/net/http/tc-info

People

  • Assignee:
    Paul King
    Reporter:
    Marcel Szalbach
Vote (0)
Watch (2)

Dates

  • Created:
    24/Sep/08 5:57 AM
    Updated:
    16/Sep/09 4:19 PM
    Resolved:
    16/Nov/08 12:53 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.