Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Duplicate
-
1.8.6
-
None
-
Java:
java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.2) (ArchLinux-6.b24_1.11.2-1-i686)
OpenJDK Client VM (build 20.0-b12, mixed mode)
Groovy:
Groovy 1.8.6
Description
I've got a class that consistently throws an IncompatibleClassChangeError exception when run on OpenJDK6. The class is below and the exception it produces underneath it. The solution seems to be to not call the super call, but to explicitly set the thread's name using setName.
class RandomTask {
class TaskThread extends Thread {
private final int num
private final Object o
public TaskThread(String name, int num, Object o)
@Override
void run() {
println("Starting ${getName()}")
try {
while(!interrupted)
} catch(InterruptedException e)
{ // leave } println("Finish ${getName()}")
}
}
public void doSomething()
{ println("something") def t = new TaskThread("test", 100, new Object()) t.start() println("after start, sleep") Thread.sleep(5000) println("woke up, interrupt and wait") t.interrupt() t.join() println("done") }public static void main(String[] args)
{ def r = new RandomTask() r.doSomething() }}
Exception:
Exception in thread "main" java.lang.IncompatibleClassChangeError: the number of constructors during runtime and compile time for java.lang.Thread do not match. Expected 10 but got 8
at groovy.lang.MetaClassImpl.selectConstructorAndTransformArguments(MetaClassImpl.java:1381)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.selectConstructorAndTransformArguments(ScriptBytecodeAdapter.java:234)
at test.RandomTask$TaskThread.<init>(RandomTask.groovy:15)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:54)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:202)
at test.RandomTask.doSomething(RandomTask.groovy:37)
at test.RandomTask$doSomething.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
at test.RandomTask.main(RandomTask.groovy:49)