-
Bug
-
Resolution: Not an Issue
-
P1
-
None
-
8u60
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 afterJDK-8075520 no compiler time error or runtime exception occurs.
//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
- relates to
-
JDK-8075520 Varargs access check mishandles capture variables
- Closed
-
JDK-8077786 Check varargs access against inferred signature
- Closed