Possible Generics bug in Javac

Richard Warburton richard.warburton at gmail.com
Mon Dec 5 14:14:40 PST 2011


I'm not entirely sure whether this is a bug - but it does look like one 
to me, the first example below compiles, and runs as expected, the 
second raises a compile error in javac, but not in ecj.

-----------------------------------
class Test {
     static T q;
     static class T { }

     public static void main(String[] args) throws Exception {
         System.out.println(Test.class.getDeclaredField("q").getType());
     }
}
-----------------------------------
class Test <T> {
     static T q;
     static class T { }

     public static void main(String[] args) throws Exception {
         System.out.println(Test.class.getDeclaredField("q").getType());
     }
}
-----------------------------------

regards,

   Richard



More information about the compiler-dev mailing list