Hi All:
Constructor of EnumMap -- EnumMap(Class<K> keyType) behaves a little odd:

I first synthesis an enum type with class body as below:
enum color {
       blue{},
       red{},
}

Then constructs java.util.EnumMap(Class<K>) using this Enum type:

import java.util.EnumMap;


public class ConstructEnumMap {
   enum color {
       blue{},
       red{},
   }
enum fruit {
       apple,
   }
@SuppressWarnings("unchecked")
   public static void main(String[] args) {
       new EnumMap(fruit.apple.getClass());
       *new EnumMap(color.blue.getClass());*
   }

}

NullPointerException will be thrown out from the bolded line. While using enum type without a class body, no such exception will be thrown out. This behavior is unspecified on spec. IMO, this is a bug of RI.

What is your opinion about this behavior?

Best regards

--
Spark Shen
China Software Development Lab, IBM


---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to