Community
Participate
Working Groups
Eclipse(I20110514-0800) compiles the following code fine, but generates invalid bytecode which fails at runtime with a java.lang.IllegalAccessError. A.java ---------- package p1; class A { A() { } } ------------ B.java ------------ package p1; import java.io.*; public class B extends A { public B() {} public void foo(A... args) { System.out.println(args); } } ----------- C.java ---------- package p2; import p1.B; public class C { public static final void main(String[] args) { (new B()).foo(new B(), new B()); } } javac7b138 correctly complains at compile time C:\Documents and Settings\Administrator\Desktop\Eclipse builds\eclipse-SDK-I2011 0514-0800-win32\eclipse\workspace\A\src\p2\C.java:6: error: method foo in class B cannot be applied to given types; (new B()).foo(new B(), new B()); ^ required: A[] found: B,B reason: formal varargs element type A is not accessible from class C 1 error -------------------------------------------------------------------- This was a javac bug which is fixed with http://bugs.sun.com/view_bug.do?bug_id=6313164
I would target 3.7.1 to match the Java 7 behavior when the Java 7 support is released.
Don't expect to get to this before 3.8. Retargetting.
Released fix for 3.8 M4 via commit b8b8ddf64dedf8c9c31f5a6a372768428e737f63. We now issue a near identical message as javac. For the case in comment#0 we report "The method foo(A...) of type B is not applicable as the formal varargs element type A is not accessible here"
Verified for 3.8M4 with build I20111204-2000.