test/tools/javac/QualifiedAccess/QualifiedAccess_2.java

Sat, 01 Dec 2007 00:00:00 +0000

author
duke
date
Sat, 01 Dec 2007 00:00:00 +0000
changeset 1
9a66ca7c79fa
child 69
82c7aa6fe50a
permissions
-rw-r--r--

Initial load

     1 /**
     2  * @test  /nodynamiccopyright/
     3  * @bug 4094658 4277300 4785453
     4  * @summary Test enforcement of JLS 6.6.1 and 6.6.2 rules requiring that
     5  * the type to which a component member belongs be accessible in qualified
     6  * names.
     7  *
     8  * @run shell QualifiedAccess_2.sh
     9  */
    11 import pack1.P1;
    13 class A {
    14     private static class B {
    15         static class Inner {}
    16     }
    17 }
    19 class X extends pack1.P1 {
    20     X() { super("bar"); }
    21     void foo() {
    22         /*-----------------*
    23         // BOGUS: Reports matching constructor not found.
    24         // OK if 'Q' is made a public constructor.
    25         Object y = new Q("foo");// ERROR - protected constructor Q inaccessible
    26         *------------------*/
    27         // Reports 'P1.R.S' not found at all. (private)
    28         Object z = new R.S.T();         // ERROR - S is inaccessible
    29     }
    30 }
    32 class Y {
    34     class Foo {
    35         class Bar {}
    36     }
    38     class C extends A.B {}              // ERROR - B is inaccessible
    39     class D extends A.B.Inner {}        // ERROR - B is inaccessible
    41     static class Quux {
    42         private static class Quem {
    43             P1.Foo.Bar x;               // ERROR - Foo is inaccessible
    44             static class MyError extends Error {}
    45         }
    46     }
    47 }
    49 class Z {
    50     void foo() throws Y.Quux.Quem.MyError {
    51                                 // ERROR - type of Quux not accesible (private)
    52         throw new Y.Quux.Quem.MyError();
    53                                 // ERROR - type of Quux not accesible (private)
    54     }
    55 }

mercurial