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] On RI, constructor of EnumMap -- EnumMap(Class<K> keyType) throws unspecified NullPointerException
Date Tue, 15 Aug 2006 03:50:09 GMT
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: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Mime
View raw message