Possible Generics bug in Javac

Alex Lam S.L. alexlamsl at gmail.com
Thu Dec 8 19:17:44 PST 2011


In the second example, "T" is a type variable, whereas in the first
example it is the name of a class.

To me it would seem that ecj is at fault for not picking up the double
definition of "T" in the second example.


Alex.



On Mon, Dec 5, 2011 at 10:14 PM, Richard Warburton
<richard.warburton at gmail.com> wrote:
> 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