Problem With Subclass of HashSet
--------------------------------

                 Key: CDV-422
                 URL: https://jira.terracotta.org/jira//browse/CDV-422
             Project: Community Development
          Issue Type: Bug
    Affects Versions: 2.4.3
            Reporter: Geir Ove Grønmo
            Assignee: Issue Review Board


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

Exception in thread "main" java.lang.IncompatibleClassChangeError
        at 
tutorial.HelloWorldIncompatibleClassChangeError$MySet.<init>(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();
  }

}



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
https://jira.terracotta.org/jira//secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
_______________________________________________
tc-dev mailing list
[email protected]
http://lists.terracotta.org/mailman/listinfo/tc-dev

Reply via email to