JDK-8078175 : Calling vararg method when inferred parameter type not accessible doesn't cause compilation error
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8u60
  • Priority: P1
  • Status: Resolved
  • Resolution: Not an Issue
  • Submitted: 2015-04-20
  • Updated: 2015-04-21
  • Resolved: 2015-04-20
Related Reports
Relates :  
Relates :  
Please consider next source code: 
//file A.java
package outer;

public class A {

    protected static class InnerA

//file B.java
package outer;

public class B extends A.InnerA {

    public <T extends A.InnerA> void foo(T... args)

//file Test.java
package outer.test;

import outer.B;

public class Test {

    public static void main(String[] args) {
        B b = new B();
        b.foo(new B());

JLS 15.12.3 says that "If the compile-time declaration is applicable by variable arity invocation, then where the last formal parameter type of the invocation type of the method is Fn[], it is a compile-time error if the type which is the erasure of Fn is not accessible at the point of invocation."

Since A.InnerA is not accessible at the point of invocation, compilation should fail but after JDK-8075520 no compiler time error or runtime exception occurs. 

Evaluation: not a bug. "Invocation type" is defined in JLS 8 In this case, the invocation type of 'foo' is '(B[])void', so Fn=B and the erased type that needs to be accessible is B. The same check is defined in JLS 7, (the timing is different, but the check is the same). Again, Sn=B and the erased type that needs to be accessible is B. Note that javac 7 and 8 up to 8u40 (that is, the initial 8 release and 8u20) compile the above program without error. 8u40 began rejecting the program, but this was a bug (JDK-8077786).