• Bug
  • Status: Closed
  • 2 Major
  • Resolution: Fixed
  • hhuynh
  • Reporter: grove
  • September 19, 2007
  • 0
  • Watchers: 0
  • September 24, 2007
  • September 20, 2007

Description

The following test class triggers a java.lang.IncompatibleClassChangeError like this:

Exception in thread “main” java.lang.IncompatibleClassChangeError at tutorial.HelloWorldIncompatibleClassChangeError$MySet.(HelloWorldIncompatibleClassChangeError.java:19) at tutorial.HelloWorldIncompatibleClassChangeError.sayHello(HelloWorldIncompatibleClassChangeError.java:35) at tutorial.HelloWorldIncompatibleClassChangeError.main(HelloWorldIncompatibleClassChangeError.java:47)


package tutorial;

import java.util.List; import java.util.ArrayList; import java.util.Collection; import java.util.Set; import java.util.HashSet; import java.util.Iterator;

public class HelloWorldIncompatibleClassChangeError {

class MySet extends HashSet {

protected String something;

public MySet(String something, Collection c) {
  super(c.size());      
  Iterator iter = c.iterator();
  while (iter.hasNext()) {
    super.add(iter.next());
  }
  this.something = something;
}   \}

private List hellos = new ArrayList();

public void sayHello(){ synchronized(hellos){ Set abc = new HashSet(); abc.add(“A”); abc.add(“B”); abc.add(“C”); hellos.add(abc); Set myset = new MySet(“xxx”, abc); myset.add(“E”); hellos.add(myset);

  for(Iterator it = hellos.iterator();it.hasNext();) {
    Object o = it.next();
    System.out.println(o);
  }
}   \}

public static void main(String[] args) { new HelloWorldIncompatibleClassChangeError().sayHello(); }

}

Comments

Geir+Ove Gr%C3%B8nmo 2007-09-19

The workaround of using a private synchronized init() method described in CDV-199 does work, but the bug seem to be similar to the one described there.

Taylor Gautier 2007-09-19

Can you change the inner class to static I would guess the problem has to do with the hidden pointer in the non-static inner class. At least if it still happens after the change we can isolate the problem.

Geir+Ove Gr%C3%B8nmo 2007-09-19

Making the inner class static *does* not help. The same error is still being thrown.

Tim Eck 2007-09-19

If you’re familiar with bytecode, you can add -Dtc.classloader.writeToDisk=true to your VM and get the result of our terracotta instrumentation. Judging by the stack trace, it looks like it is getting mad about the field set on line 19. From that I might guess that the type of the PUTFIELD is being inappropriately modified.

I’ll have a look at this with one the bytecode guys here later today. A million thanks for providing a standalone test case!

Antonio Si 2007-09-20

Add a new test for this test case.

Thanks.