IllegalAccessError on runtime with inaccessible vararg type

anna.kozlova at jetbrains.com anna.kozlova at jetbrains.com
Mon Aug 17 17:46:56 UTC 2015


Hi,

Given package local abstract class with 2 public inheritors:

package p;
abstract class A {}

public class B extends A {}
public class C extends A {}

and usage in another package:

Arrays.asList(new B(), new C())

compiles with javac 1.8.0_51 with target 1.8
(at runtime: Exception in thread "main" java.lang.IllegalAccessError: 
tried to access class p.A from class p1.MyClass);

though with target 1.7 javac produces
Error:(11, 15) java: method asList in class java.util.Arrays cannot be 
applied to given types;
   required: T[]
   found: p.B,p.C
   reason: formal varargs element type p.A is not accessible from class 
p1.MyClass

which looks correct.

Is it a known issue or is it a desired behaviour?

Thanks,
Anna




More information about the compiler-dev mailing list