// WARNING: THIS CAN CRASH YOUR IDE (Eclipse)!!!!
package com.example.foo;
import java.math.RoundingMode;
public class SomeClass {
static <T extends Enum<T>> void doEnumStuff(final Class<T> type) {
for (final T constant : type.getEnumConstants())
System.out.println(constant);
}
static <T> void doStuff(final Class<T> type) {
System.out.println("Type: " + type);
if (type.isEnum())
doEnumStuff((Class) type);// <- eclipse crashes when you remove the cast!
}
public static void main(final String[] args) throws Throwable {
doStuff(String.class);
doStuff(RoundingMode.class);
}
}
--------------------------------------------------------------------
From "<workspace>/.metadata/.log":
java.lang.StackOverflowError
at org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding.nullAnnotatedReadableName(TypeVariableBinding.java:728)
at org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding.nullAnnotatedReadableName(ParameterizedTypeBinding.java:1116)
at org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding.nullAnnotatedReadableName(ParameterizedTypeBinding.java:1085)
at org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding.nullAnnotatedReadableName(TypeVariableBinding.java:728)
at org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding.nullAnnotatedReadableName(ParameterizedTypeBinding.java:1116)
at org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding.nullAnnotatedReadableName(ParameterizedTypeBinding.java:1085)
(Naturally this repeats endlessly)
Comments
0 B
|👍
/👎