2

Consider the following simple class:

public class Bean {

    private int i;

    public static <T extends Bean> void o(T t) {
        System.out.println(t.i);
    }

}

In Eclipse, this just compiles fine. But with javac, i got the following error:

Bean.java:8: error: i has private access in Bean
       System.out.println(t.i);
                           ^

Is this a bug in Eclipse compiler? And why i cannot access i in this way? If i remove generics, this compiles fine with javac, too.

EDIT: It seems the problem is with m2e (maven eclipse integration). A simple eclipse project does not reproduce this problem. I use m2e 1.4

WonderCsabo
  • 11,947
  • 13
  • 63
  • 105

0 Answers0