Bug in ClassValue

Rémi Forax forax at univ-mlv.fr
Sun Mar 11 09:45:10 PDT 2012


Last week, Fredrik found that I've forgotten to implement ClassValue
in the backport of jsr292.

While struggling to implement it, I've found a bug in the implementation
of the JDK. This snippet creates an infinite loop :(

        java.lang.ClassValue<Integer> cv = new 
java.lang.ClassValue<Integer>() {
             @Override
             protected Integer computeValue(Class<?> type) {
                 remove(int.class);
                 return 1;
             }
         };
         cv.get(int.class);

while this code is naughty, I think it's a legal one.

cheers,
Rémi



More information about the mlvm-dev mailing list