groovy

Groovy Console ClassCastException with groovy/ui/Console.groovy

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Blocker Blocker
  • Resolution: Fixed
  • Affects Version/s: 1.0-JSR-6
  • Fix Version/s: 1.0-JSR-6
  • Component/s: None
  • Labels:
    None
  • Environment:
    Tried with JRE 1.5.0_06 and 1.6.0-beta2-b81, WinXPSP2 and tested against CVS HEAD (as built by "maven"), Groovy reports itself as 1.0-RC-01-SNAPSHOT
  • Number of attachments :
    0

Description

1. cvs checkout
2. maven
3. wait
4. .\target\install\bin\groovyConsole.bat
5. observe the stack trace below trace
6. zip -d groovy-1.0-RC-01-SNAPSHOT.jar groovy/ui/Console.groovy
deleting: groovy/ui/Console.groovy
7. .\target\install\bin\groovyConsole.bat
8. observe that it starts now

java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:589)
at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:131)
at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:160)
Caused by: java.lang.ClassCastException: groovy.ui.Console cannot be cast to groovy.ui.Console
at gjdk.groovy.ui.Console_GroovyReflector.invoke(Unknown Source)
at groovy.lang.MetaMethod.invoke(MetaMethod.java:111)
at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:657)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:350)
at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:156)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:104)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethod(ScriptBytecodeAdapter.java:85)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeNoArgumentsMethod(ScriptBytecodeAdapter.java:175)
at groovy.ui.Console.main(Console.groovy:76)
... 6 more

Activity

Hide
Matthew Daniel added a comment -

Sorry to follow up my own bug, but I downloaded groovy-1.0-jsr-05 to ensure it wasn't something in my environment that was corrupt.

As it turns out, a jar from a reporting vendor contains antlr.* classes, which really jams up groovy. With the offending jar in the classpath, any statement (in groovysh or groovyconsole) will produce this lovely:

Caused by: java.lang.NoSuchMethodError: org.codehaus.groovy.antlr.parser.GroovyLexer.setTabSize(I)V
at org.codehaus.groovy.antlr.parser.GroovyLexer.<init>(GroovyLexer.java:61)
at org.codehaus.groovy.antlr.parser.GroovyLexer.<init>(GroovyLexer.java:295)
at org.codehaus.groovy.antlr.parser.GroovyLexer.<init>(GroovyLexer.java:292)
at org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST(AntlrParserPlugin.java:67)
at org.codehaus.groovy.control.SourceUnit.parse(SourceUnit.java:276)
at groovy.ui.InteractiveShell.parse(InteractiveShell.java:400)
at groovy.ui.InteractiveShell.read(InteractiveShell.java:305)
at groovy.ui.InteractiveShell.run(InteractiveShell.java:149)
at groovy.ui.InteractiveShell.main(InteractiveShell.java:95)
... 6 more

The actual problem may have been caused by groovy trying to reparse groovy/ui/Console.groovy on startup, which was failing because of the above error (obviously swallowed, since I didn't see it). When I nuked groovy/ui/Console.groovy, it fell back to the compiled version and started but any expression typed would cause the above error.

I believe the fix is to load the groovy classes into a "parent" classloader and load any specified classpath (command line or environment) in a dependent classloader.

Sorry for the rash post.

Show
Matthew Daniel added a comment - Sorry to follow up my own bug, but I downloaded groovy-1.0-jsr-05 to ensure it wasn't something in my environment that was corrupt. As it turns out, a jar from a reporting vendor contains antlr.* classes, which really jams up groovy. With the offending jar in the classpath, any statement (in groovysh or groovyconsole) will produce this lovely:
Caused by: java.lang.NoSuchMethodError: org.codehaus.groovy.antlr.parser.GroovyLexer.setTabSize(I)V at org.codehaus.groovy.antlr.parser.GroovyLexer.<init>(GroovyLexer.java:61) at org.codehaus.groovy.antlr.parser.GroovyLexer.<init>(GroovyLexer.java:295) at org.codehaus.groovy.antlr.parser.GroovyLexer.<init>(GroovyLexer.java:292) at org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST(AntlrParserPlugin.java:67) at org.codehaus.groovy.control.SourceUnit.parse(SourceUnit.java:276) at groovy.ui.InteractiveShell.parse(InteractiveShell.java:400) at groovy.ui.InteractiveShell.read(InteractiveShell.java:305) at groovy.ui.InteractiveShell.run(InteractiveShell.java:149) at groovy.ui.InteractiveShell.main(InteractiveShell.java:95) ... 6 more
The actual problem may have been caused by groovy trying to reparse groovy/ui/Console.groovy on startup, which was failing because of the above error (obviously swallowed, since I didn't see it). When I nuked groovy/ui/Console.groovy, it fell back to the compiled version and started but any expression typed would cause the above error. I believe the fix is to load the groovy classes into a "parent" classloader and load any specified classpath (command line or environment) in a dependent classloader. Sorry for the rash post.
Hide
blackdrag blackdrag added a comment -

the GroovyClassLoader now doesn't try to recompile as long as it isn't told otherwise. Your sugestion with the groovy clases is already done, but it didn't help you there.

Show
blackdrag blackdrag added a comment - the GroovyClassLoader now doesn't try to recompile as long as it isn't told otherwise. Your sugestion with the groovy clases is already done, but it didn't help you there.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: