Issue Details (XML | Word | Printable)

Key: GROOVY-1867
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Jochen Theodorou
Reporter: Nathan Finstein
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
groovy

java.lang.ClassCastException: gjdk.org.codehaus.groovy.tools.RootLoader_GroovyReflector

Created: 01/May/07 10:00 AM   Updated: 02/Jul/07 08:31 AM
Component/s: None
Affects Version/s: 1.1-beta-1
Fix Version/s: 1.1-beta-2

Time Tracking:
Not Specified

Environment: Linux, Fedora


 Description  « Hide
given the file betabug.groovy:

def rloader = new javax.xml.namespace.QName("","").getClass().getClassLoader()
java.lang.Package[] pkgs = rloader.getPackages()

running the following shell script

export JAVA_HOME=/home/nate/java/jdk1.6.0
export GROOVY_HOME=/home/nate/java/groovy/groovy-1.1-BETA-1
export CLASSPATH=/home/nate/java/groovy/groovy-1.1-BETA-1/lib/groovy-1.1-BETA-1.jar

PATH=$PATH:$GROOVY_HOME/bin

/home/nate/java/groovy/groovy-1.1-BETA-1/bin/groovy -d /home/nate/CVSROOT/indivo-script/betabug.groovy

get the following exception:

Caught: java.lang.ClassCastException: gjdk.org.codehaus.groovy.tools.RootLoader_GroovyReflector cannot be cast to org.codehaus.groovy.runtime.Reflector
java.lang.ClassCastException: gjdk.org.codehaus.groovy.tools.RootLoader_GroovyReflector cannot be cast to org.codehaus.groovy.runtime.Reflector
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.loadReflector(MetaClassRegistryImpl.java:281)
at groovy.lang.MetaClassImpl.generateReflector(MetaClassImpl.java:2143)
at groovy.lang.MetaClassImpl.initialize(MetaClassImpl.java:2025)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.getMetaClass(MetaClassRegistryImpl.java:142)
at org.codehaus.groovy.runtime.Invoker.invokePojoMethod(Invoker.java:132)
at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:106)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:111)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:187)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethod0(ScriptBytecodeAdapter.java:211)
at betabug.run(betabug.groovy:2)
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:597)
at org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:506)
at org.codehaus.groovy.runtime.Invoker.invokePogoMethod(Invoker.java:144)
at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:110)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:111)
at org.codehaus.groovy.runtime.InvokerHelper.runScript(InvokerHelper.java:406)
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:597)
at org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:721)
at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:100)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:111)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:187)
at betabug.main(betabug.groovy)
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:597)
at org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:721)
at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:100)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:111)
at groovy.lang.GroovyShell.runMainOrTestOrRunnable(GroovyShell.java:270)
at groovy.lang.GroovyShell.run(GroovyShell.java:244)
at groovy.lang.GroovyShell.run(GroovyShell.java:173)
at groovy.ui.GroovyMain.processOnce(GroovyMain.java:484)
at groovy.ui.GroovyMain.run(GroovyMain.java:294)
at groovy.ui.GroovyMain.process(GroovyMain.java:280)
at groovy.ui.GroovyMain.processArgs(GroovyMain.java:140)
at groovy.ui.GroovyMain.main(GroovyMain.java:121)
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:597)
at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:131)
at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:160)



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Jochen Theodorou added a comment - 01/May/07 11:02 AM
I am closing this because the bug is only partly related to Groovy. You have two versions of Groovy in your classpath. One is loaded by the rootloader, one is on the classpath. You should have only one version in the path or things like the mentioned ClassCastException is happening.So either do not use the $classpath variable or remove the groovy jar from the lib directory

Nathan Finstein added a comment - 01/May/07 11:15 AM
Just tried again with a modified shell script:
export JAVA_HOME=/home/nate/java/jdk1.6.0
export GROOVY_HOME=/home/nate/java/groovy/groovy-1.1-BETA-1
export CLASSPATH=

PATH=$PATH:$GROOVY_HOME/bin

groovy -d /home/nate/CVSROOT/indivo-script/betabug.groovy

Still get the exception.

Nate


Jochen Theodorou added a comment - 02/Jul/07 08:29 AM
I decided it is better to have an solution for this

Jochen Theodorou added a comment - 02/Jul/07 08:31 AM
The ReflectorLoader knows now two modes, one to define the Reflector class and and one to do the usual class loading stuff. In the definition mode the Reflector loader will now resolve the request to load the class "Reflector" with the class Reflector known by the runtime, other classloaders are not even asked. With this it should be possible to have multiple runtimes of Groovy without getting the reflector problem