Advertisement
DulcetAirman

Eclipse type problem

Apr 3rd, 2014
191
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // WARNING: THIS CAN CRASH YOUR IDE (Eclipse)!!!!
  2.  
  3. package com.example.foo;
  4.  
  5. import java.math.RoundingMode;
  6.  
  7. public class SomeClass {
  8.  
  9.   static <T extends Enum<T>> void doEnumStuff(final Class<T> type) {
  10.     for (final T constant : type.getEnumConstants())
  11.       System.out.println(constant);
  12.   }
  13.  
  14.   static <T> void doStuff(final Class<T> type) {
  15.     System.out.println("Type: " + type);
  16.     if (type.isEnum())
  17.       doEnumStuff((Class) type);// <- eclipse crashes when you remove the cast!
  18.   }
  19.  
  20.   public static void main(final String[] args) throws Throwable {
  21.     doStuff(String.class);
  22.     doStuff(RoundingMode.class);
  23.   }
  24. }
  25.  
  26. --------------------------------------------------------------------
  27. From "<workspace>/.metadata/.log":
  28.  
  29. java.lang.StackOverflowError
  30.     at org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding.nullAnnotatedReadableName(TypeVariableBinding.java:728)
  31.     at org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding.nullAnnotatedReadableName(ParameterizedTypeBinding.java:1116)
  32.     at org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding.nullAnnotatedReadableName(ParameterizedTypeBinding.java:1085)
  33.     at org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding.nullAnnotatedReadableName(TypeVariableBinding.java:728)
  34.     at org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding.nullAnnotatedReadableName(ParameterizedTypeBinding.java:1116)
  35.     at org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding.nullAnnotatedReadableName(ParameterizedTypeBinding.java:1085)
  36.  
  37. (Naturally this repeats endlessly)
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement