harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Spark Shen <smallsmallor...@gmail.com>
Subject [classlib][luni] Suspicious behavior of java.util.EnumSet
Date Sat, 19 Aug 2006 08:48:11 GMT
Hi All:
The following behavior of RI java.util.EnumSet seems odd. Do you have 
any opinion on whether  it is a bug of RI?

import java.util.EnumSet;
import java.util.Iterator;
public class Test {
    static enum EnumFoo {
        a, b,
    }

    public static void main(String[] args){
        EnumSet<EnumFoo> set = EnumSet.noneOf(EnumFoo.class);
        set.add(EnumFoo.a);
        Iterator<EnumFoo> iterator = set.iterator();
        iterator.next();
       
        set.remove(EnumFoo.a);
        iterator.remove();   (1)
        // The output value is true
        System.out.println(set.contains(EnumFoo.a));
        // The output value is 64
        System.out.println(set.size());
    }
}
IMHO,  when (1) is executed, an IllegalStateException should be thrown 
out, since the element EnumFoo.a does not exist at the moment.
Any thoughts?

Best regards

-- 
Spark Shen
China Software Development Lab, IBM


---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Mime
View raw message