0N/A/**
0N/A * @test /nodynamiccopyright/
0N/A * @bug 4094658 4277296 4785453
0N/A * @summary Test enforcement of JLS 6.6.1 and 6.6.2 rules requiring that
0N/A * the type to which a component member belongs be accessible in qualified
0N/A * names.
0N/A *
68N/A * @compile pack1/P1.java
68N/A * @compile pack1/P2.java
610N/A * @compile/fail/ref=QualifiedAccess_1.out -XDrawDiagnostics QualifiedAccess_1.java
0N/A */
0N/A
0N/Aimport pack1.P1;
0N/A
0N/Apublic class QualifiedAccess_1 {
0N/A
0N/A // Inaccessible types in member declarations.
0N/A // These exercise 'Env.resolve'.
0N/A // Errors are localized poorly.
0N/A //
0N/A // Fields 'P3' and 'P5' are inaccessible.
0N/A
0N/A P1 foo;
0N/A P1.P3 bar; // ERROR
0N/A P1.P3.P4 baz; // ERROR
0N/A P1.P3.P4.P5 quux; // ERROR
0N/A
0N/A P1 m11() {return null;}
0N/A P1.P3 m12() {return null;} // ERROR
0N/A P1.P3.P4 m13() {return null;} // ERROR
0N/A P1.P3.P4.P5 m14() {return null;} // ERROR
0N/A
0N/A void m21(P1 x) {}
0N/A void m22(P1.P3 x) {} // ERROR
0N/A void m23(P1.P3.P4 x) {} // ERROR
0N/A void m24(P1.P3.P4.P5 x) {} // ERROR
0N/A
0N/A void test1() {
0N/A
0N/A // Inaccessible types in local variable declarations.
0N/A // These exercise 'FieldExpression.checkCommon'.
0N/A //
0N/A // Fields 'P3' and 'P5' are inaccessible.
0N/A
0N/A P1 foo = null;
0N/A P1.P3 bar = null; // ERROR
0N/A P1.P3.P4 baz = null; // ERROR
0N/A P1.P3.P4.P5 quux = null; // ERROR
0N/A }
0N/A
0N/A void test2() {
0N/A
0N/A // Inaccessible types in casts.
0N/A // These exercise 'FieldExpression.checkCommon'.
0N/A //
0N/A // Fields 'P3' and 'P5' are inaccessible.
0N/A
0N/A Object foo = (P1)null;
0N/A Object bar = (P1.P3)null; // ERROR
0N/A Object baz = (P1.P3.P4)null; // ERROR
0N/A Object quux = (P1.P3.P4.P5)null; // ERROR
0N/A }
0N/A
0N/A void test3() {
0N/A
0N/A // Inaccessible types in 'instanceof' expressions.
0N/A // These exercise 'FieldExpression.checkCommon'.
0N/A //
0N/A // Fields 'P3' and 'P5' are inaccessible.
0N/A
0N/A boolean foo = null instanceof P1;
0N/A boolean bar = null instanceof P1.P3; // ERROR
0N/A boolean baz = null instanceof P1.P3.P4; // ERROR
0N/A boolean quux = null instanceof P1.P3.P4.P5; // ERROR
0N/A }
0N/A
0N/A}