Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 2.0.0alpha
-
Fix Version/s: 2.0.0m1
-
Component/s: None
-
Labels:None
-
Environment:HideGroovy Version: 1.6.4 JVM: 1.6.0_16
Eclipse 3.5 (Galilao) with plugins:
Groovy-Eclipse Feature 2.0.0.xx-20090910-1700-e3
5 org.codehaus.groovy.eclipse.feature.feature.group
Groovy-Eclipse JDT Patch Sources Feature 2.0.0.xx-2009
0910-1700-e35
org.codehaus.groovy.jdt.patch.source.feature
.group
Groovy-Eclipse Sources Feature 2.0.0.xx-20090910-
1700-e35
org.codehaus.groovy.eclipse.feature.source.featu
re.group
ShowGroovy Version: 1.6.4 JVM: 1.6.0_16 Eclipse 3.5 (Galilao) with plugins: Groovy-Eclipse Feature 2.0.0.xx-20090910-1700-e3 5 org.codehaus.groovy.eclipse.feature.feature.group Groovy-Eclipse JDT Patch Sources Feature 2.0.0.xx-2009 0910-1700-e35 org.codehaus.groovy.jdt.patch.source.feature .group Groovy-Eclipse Sources Feature 2.0.0.xx-20090910- 1700-e35 org.codehaus.groovy.eclipse.feature.source.featu re.group
-
Testcase included:yes
-
Number of attachments :
Description
I have attached 2 files, TrivialBug.groovy and TrivialBugTest.groovy. The first is a groovy class with a trivial bug.
The second is a groovy junit test which simply creates an instance of the first class. When I run the test I get:
Class not found org.sjb.sjblib.cmdline.TrivialBugTest
java.lang.ClassNotFoundException: org.sjb.sjblib.cmdline.TrivialBugTest
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:693)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:429)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
This is, of course, incorrect. The two classes are in the same directory and it makes no sense that it can find one and
not the other.
I this point I was stumped since the RunAs menu for the file with the error only allowed "GroovyShell" which, as I
have previously reported, doesn't work for me.
Fortunately, I had previously created java's runscript to run my selected file.When I ran the class with the error
this way I got:
script error in file C:\Users\SteveB\EclipseWorkspace2\sjblib\testSrc\org\sjb\sjblib\cmdline\TrivialBug.groovy : org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, General error during class generation: Cannot use return statement with an expression on a method that returns void.
Node: org.codehaus.groovy.ast.stmt.ReturnStatement. At [11:3] Script1.groovy
org.codehaus.groovy.syntax.RuntimeParserException: Cannot use return statement with an expression on a method that returns void.
Node: org.codehaus.groovy.ast.stmt.ReturnStatement. At [11:3] Script1.groovy
at org.codehaus.groovy.classgen.AsmClassGenerator.throwException(AsmClassGenerator.java:1543)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitReturnStatement(AsmClassGenerator.java:1249)
at org.codehaus.groovy.ast.stmt.ReturnStatement.visit(ReturnStatement.java:47)
at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:38)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:129)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:676)
at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:52)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:73)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:80)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:553)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:529)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:88)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:633)
at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1008)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:48)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:243)
at org.codehaus.groovy.control.CompilationUnit$10.call(CompilationUnit.java:717)
at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:924)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:462)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:278)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:249)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:244)
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.getScriptClass(GroovyScriptEngineImpl.java:321)
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:113)
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:107)
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:232)
at com.sun.tools.script.shell.Main.evaluateReader(Main.java:314)
at com.sun.tools.script.shell.Main.evaluateStream(Main.java:350)
at com.sun.tools.script.shell.Main.processSource(Main.java:267)
at com.sun.tools.script.shell.Main.access$100(Main.java:19)
at com.sun.tools.script.shell.Main$2.run(Main.java:182)
at com.sun.tools.script.shell.Main.main(Main.java:30)
1 error
At the end of the first, incredibly long, line (folded above) is the actual error. I don't know how a typical user
is suppossed to debug this trivial error. I spent a lot of time fooling with the classpath in the launch script
when I thought of trying runscript.
I doubt whether this has to do with the particular trivial error. It is probably more general. You should try other
errors that java would
catch at compile time but groovy doesn't catch until run time.
When I define your two files in a project, although I see no hard error in the problems view or editor window, I do see a compiler problem reported as a warning - both in the problems view and the editor window. In the editor it is recorded against the first line of the file (in TrivialBug.groovy). Do you see this warning?
It seems the problem is that for some reason the message from groovyc is being reported as a warning when it should be more serious than that.