# public access on toplevel class or interface

tcltest::test 6.6.1-1 {A class declared public is accessible from outside
        the package} {
    compile [saveas T661_1a.java {
class T661_1a {
    pkg.T661_1b ref;
}
    }] [saveas pkg/T661_1b.java {
package pkg;
public class T661_1b {}
    }]
} PASS

tcltest::test 6.6.1-2 {A class declared public is accessible from outside
        the package when the .java source is loaded from the CLASSPATH} {
    saveas pkg/T661_2a.java {
package pkg;
public class T661_2a {}
    }
    compile -classpath . [saveas T661_2b.java {
class T661_2b {
    pkg.T661_2a ref;
}
    }]
} PASS

tcltest::test 6.6.1-3 {A class declared public is accessible from outside
        the package when the .class file is loaded from the CLASSPATH} {
    set result [compile [saveas pkg/T661_3a.java {
package pkg;
public class T661_3a {}
    }]]
    delete pkg/T661_3a.java
    list $result [compile -classpath . [saveas T661_3b.java {
class T661_3b {
    pkg.T661_3a ref;
}
    }]]
} {PASS PASS}

tcltest::test 6.6.1-4 {An interface declared public is accessible from outside
        the package} {
    compile [saveas T661_4a.java {
class T661_4a {
    pkg.T661_4b ref;
}
    }] [saveas pkg/T661_4b.java {
package pkg;
public interface T661_4b {}
    }]
} PASS

tcltest::test 6.6.1-5 {An interface declared public is accessible from outside
        the package when the .java source is loaded from the CLASSPATH} {
    saveas pkg/T661_5a.java {
package pkg;
public interface T661_5a {}
    }
    compile -classpath . [saveas T661_5b.java {
class T661_5b {
    pkg.T661_5a ref;
}
    }]
} PASS

tcltest::test 6.6.1-6 {An interface declared public is accessible from outside
        the package when the .class file is loaded from the CLASSPATH} {
    set result [compile [saveas pkg/T661_6a.java {
package pkg;
public interface T661_6a {}
    }]]
    delete pkg/T661_6a.java
    list $result [compile -classpath . [saveas T661_6b.java {
class T661_6b {
    pkg.T661_6a ref;
}
    }]]
} {PASS PASS}

tcltest::test 6.6.1-7 {Access a public class from inside the package} {
    compile [saveas pkg/T661_7a.java {
package pkg;
public class T661_7a {}
    }] [saveas pkg/T661_7b.java {
package pkg;
class T661_7b {
    pkg.T661_7a ref;
}
    }]
} PASS

# Default access on toplevel class or interface

tcltest::test 6.6.1-8 {A class with default access is inaccessible from outside
        the package} {
    compile [saveas T661_8a.java {
class T661_8a {
    pkg.T661_8b ref;
}
    }] [saveas pkg/T661_8b.java {
package pkg;
class T661_8b {}
    }]
} FAIL

tcltest::test 6.6.1-9 {A class with default access is inaccessible from outside
        the package when the .java source is loaded from the CLASSPATH} {
    saveas pkg/T661_9a.java {
package pkg;
class T661_9a {}
    }
    compile -classpath . [saveas T661_9b.java {
class T661_9b {
    pkg.T661_9a ref;
}
    }]
} FAIL

tcltest::test 6.6.1-10 {A class with default access is inaccessible from outside
        the package when the .class file is loaded from the CLASSPATH} {
    set result [compile [saveas pkg/T661_10a.java {
package pkg;
class T661_10a {}
    }]]
    delete pkg/T661_10a.java
    list $result [compile -classpath . [saveas T661_10b.java {
class T661_10b {
    pkg.T661_10a ref;
}
    }]]
} {PASS FAIL}

tcltest::test 6.6.1-11 {An interface with default access is inaccessible from
        outside the package} {
    compile [saveas T661_11a.java {
class T661_11a {
    pkg.T661_11b ref;
}
    }] [saveas pkg/T661_11b.java {
package pkg;
interface T661_11b {}
    }]
} FAIL

tcltest::test 6.6.1-12 {An interface with default access is inaccessible from
        outside the package when the .java source is loaded from the
        CLASSPATH} {
    saveas pkg/T661_12a.java {
package pkg;
interface T661_12a {}
    }
    compile -classpath . [saveas T661_12b.java {
class T661_12b {
    pkg.T661_12a ref;
}
    }]
} FAIL

tcltest::test 6.6.1-13 {An interface with default access is inaccessible from
        outside the package when the .class file is loaded from the CLASSPATH} {
    set result [compile [saveas pkg/T661_13a.java {
package pkg;
interface T661_13a {}
    }]]
    delete pkg/T661_13a.java
    list $result [compile -classpath . [saveas T661_13b.java {
class T661_13b {
    pkg.T661_13a ref;
}
    }]]
} {PASS FAIL}

tcltest::test 6.6.1-14 {Access a default class from inside the package} {
    compile [saveas pkg/T661_14a.java {
package pkg;
class T661_14a {}
    }] [saveas pkg/T661_14b.java {
package pkg;
class T661_14b {
    pkg.T661_14a ref;
}
    }]
} PASS

tcltest::test 6.6.1-15 {A class field declared public is accessible from
        outside the package} {
    compile [saveas pkg/T661_15.java {
package pkg;
public class T661_15 {
    public static int FIELD = 0;
}
    }] [saveas T661_15_Test.java {
class T661_15_Test {
    int i = pkg.T661_15.FIELD;
}
    }]
} PASS

tcltest::test 6.6.1-16 {A class field declared public is accessible from
        outside the package when the .java source is loaded from
        the CLASSPATH } {
    saveas pkg/T661_16.java {
package pkg;
public class T661_16 {
    public static int FIELD = 0;
}
    }
    compile -classpath . [saveas T661_16_Test.java {
class T661_16_Test {
    int i = pkg.T661_16.FIELD;
}
    }]
} PASS

tcltest::test 6.6.1-17 {A class field declared public is accessible from
        outside the package when the .class file is loaded from the
        CLASSPATH} {
    set result [compile [saveas pkg/T661_17.java {
package pkg;
public class T661_17 {
    public static int FIELD = 0;
}
    }]]
    delete pkg/T661_17.java
    list $result [compile -classpath . [saveas T661_17_Test.java {
class T661_17_Test {
    int i = pkg.T661_17.FIELD;
}
    }]]
} {PASS PASS}

# protected access should be covered in section 6.6.2

# Access of array types
tcltest::test 6.6.1-array-1 { Arrays are exactly as accessible as their
        component type } {
    compile [saveas T661a1.java {
class T661a1 {
    pkg.Array1[] ref;
}
    }] [saveas pkg/Array1.java {
package pkg;
public class Array1 {}
    }]
} PASS

tcltest::test 6.6.1-array-2 { Arrays are exactly as accessible as their
        component type } {
    compile [saveas T661a2.java {
class T661a2 {
    pkg.Array2[] ref;
}
    }] [saveas pkg/Array2.java {
package pkg;
class Array2 {}
    }]
} FAIL

tcltest::test 6.6.1-array-3 { Arrays are exactly as accessible as their
        component type } {
    compile [saveas T661a3.java {
class T661a3 {
    pkg.Array3.A[] ref;
}
    }] [saveas pkg/Array3.java {
package pkg;
public class Array3 {
    protected static class A {}
}
    }]
} FAIL

tcltest::test 6.6.1-array-4 { Arrays are exactly as accessible as their
        component type } {
    compile [saveas T661a4.java {
class T661a4 extends pkg.Array4 {
    pkg.Array4.A[] ref;
}
    }] [saveas pkg/Array4.java {
package pkg;
public class Array4 {
    protected static class A {}
}
    }]
} PASS

tcltest::test 6.6.1-array-5 { Arrays are exactly as accessible as their
        component type } {
    compile [saveas T661a5.java {
class T661a5 extends pkg.Array5 {
    pkg.Array5.A[] ref;
}
    }] [saveas pkg/Array5.java {
package pkg;
public class Array5 {
    private static class A {}
}
    }]
} FAIL

tcltest::test 6.6.1-array-6 { Arrays are exactly as accessible as their
        component type } {
    compile [saveas T661a6.java {
class T661a6 {
    Array6.A[] ref;
}
class Array6 {
    protected static class A {}
}
    }]
} PASS

tcltest::test 6.6.1-array-7 { Arrays are exactly as accessible as their
        component type } {
    compile [saveas T661a7.java {
class T661a7 {
    Array7.A[] ref;
}
class Array7 {
    static class A {}
}
    }]
} PASS

tcltest::test 6.6.1-array-8 { Arrays are exactly as accessible as their
        component type } {
    compile [saveas T661a8.java {
class T661a8 {
    Array8.A[] ref;
}
class Array8 {
    private static class A {}
}
    }]
} FAIL

tcltest::test 6.6.1-array-9 { Arrays are exactly as accessible as their
        component type } {
    empty_class T661a9 {
        class Inner {
            Array[] ref;
        }
        private static class Array {}
    }
} PASS

tcltest::test 6.6.1-array-10 { The public length field of an array is
        accessible only if the array class is accessible } {
    compile [saveas T661a10.java {
class T661a10 {
    int i = pkg.Array10.array.length;
}
    }] [saveas pkg/Array10.java {
package pkg;
public class Array10 {
    public static A[] array;
    public static class A {}
}
    }]
} PASS

tcltest::test 6.6.1-array-11 { The public length field of an array is
        accessible only if the array class is accessible } {
    compile [saveas T661a11.java {
class T661a11 {
    int i = pkg.Array11.array.length;
}
    }] [saveas pkg/Array11.java {
package pkg;
public class Array11 {
    public static A[] array;
    protected static class A {}
}
    }]
} FAIL

tcltest::test 6.6.1-array-12 { The public length field of an array is
        accessible only if the array class is accessible } {
    compile [saveas T661a12.java {
class T661a12 extends pkg.Array12 {
    int i = pkg.Array12.array.length;
}
    }] [saveas pkg/Array12.java {
package pkg;
public class Array12 {
    public static A[] array;
    protected static class A {}
}
    }]
} PASS

tcltest::test 6.6.1-array-13 { The public length field of an array is
        accessible only if the array class is accessible } {
    compile [saveas T661a13.java {
class T661a13 {
    int i = pkg.Array13.array.length;
}
    }] [saveas pkg/Array13.java {
package pkg;
public class Array13 {
    public static A[] array;
    static class A {}
}
    }]
} FAIL

tcltest::test 6.6.1-array-14 { The public length field of an array is
        accessible only if the array class is accessible } {
    compile [saveas T661a14.java {
class T661a14 {
    int i = pkg.Array14.array.length;
}
    }] [saveas pkg/Array14.java {
package pkg;
public class Array14 {
    public static A[] array;
    private static class A {}
}
    }]
} FAIL

tcltest::test 6.6.1-array-15 { The public length field of an array is
        accessible only if the array class is accessible } {
    compile [saveas T661a15.java {
class T661a15 {
    int i = Array15.array.length;
}
class Array15 {
    static A[] array;
    protected static class A {}
}
    }]
} PASS

tcltest::test 6.6.1-array-16 { The public length field of an array is
        accessible only if the array class is accessible } {
    compile [saveas T661a16.java {
class T661a16 {
    int i = Array16.array.length;
}
class Array16 {
    static A[] array;
    static class A {}
}
    }]
} PASS

tcltest::test 6.6.1-array-17 { The public length field of an array is
        accessible only if the array class is accessible } {
    compile [saveas T661a17.java {
class T661a17 {
    int i = Array17.array.length;
}
class Array17 {
    static A[] array;
    private static class A {}
}
    }]
} FAIL

tcltest::test 6.6.1-array-18 { The public length field of an array is
        accessible only if the array class is accessible } {
    empty_class T661a18 {
        class Inner {
            int i = Array18.array.length;
        }
        static class Array18 {
            static A[] array;
            private static class A {}
        }
    }
} PASS

tcltest::test 6.6.1-array-19 { A public member method of an array is
        accessible only if the array class is accessible } {
    compile [saveas T661a19.java {
class T661a19 {
    Object o = pkg.Array19.array.toString();
}
    }] [saveas pkg/Array19.java {
package pkg;
public class Array19 {
    public static A[] array;
    public static class A {}
}
    }]
} PASS

tcltest::test 6.6.1-array-20 { A public member method of an array is
        accessible only if the array class is accessible } {
    compile [saveas T661a20.java {
class T661a20 {
    Object o = pkg.Array20.array.toString();
}
    }] [saveas pkg/Array20.java {
package pkg;
public class Array20 {
    public static A[] array;
    protected static class A {}
}
    }]
} FAIL

tcltest::test 6.6.1-array-21 { A public member method of an array is
        accessible only if the array class is accessible } {
    compile [saveas T661a21.java {
class T661a21 extends pkg.Array21 {
    Object o = pkg.Array21.array.toString();
}
    }] [saveas pkg/Array21.java {
package pkg;
public class Array21 {
    public static A[] array;
    protected static class A {}
}
    }]
} PASS

tcltest::test 6.6.1-array-22 { A public member method of an array is
        accessible only if the array class is accessible } {
    compile [saveas T661a22.java {
class T661a22 {
    Object o = pkg.Array22.array.toString();
}
    }] [saveas pkg/Array22.java {
package pkg;
public class Array22 {
    public static A[] array;
    static class A {}
}
    }]
} FAIL

tcltest::test 6.6.1-array-23 { A public member method of an array is
        accessible only if the array class is accessible } {
    compile [saveas T661a23.java {
class T661a23 {
    Object o = pkg.Array23.array.toString();
}
    }] [saveas pkg/Array23.java {
package pkg;
public class Array23 {
    public static A[] array;
    private static class A {}
}
    }]
} FAIL

tcltest::test 6.6.1-array-24 { A public member method of an array is
        accessible only if the array class is accessible } {
    compile [saveas T661a24.java {
class T661a24 {
    Object o = Array24.array.toString();
}
class Array24 {
    static A[] array;
    protected static class A {}
}
    }]
} PASS

tcltest::test 6.6.1-array-25 { A public member method of an array is
        accessible only if the array class is accessible } {
    compile [saveas T661a25.java {
class T661a25 {
    Object o = Array25.array.toString();
}
class Array25 {
    static A[] array;
    static class A {}
}
    }]
} PASS

tcltest::test 6.6.1-array-26 { A public member method of an array is
        accessible only if the array class is accessible } {
    compile [saveas T661a26.java {
class T661a26 {
    Object o = Array26.array.toString();
}
class Array26 {
    static A[] array;
    private static class A {}
}
    }]
} FAIL

tcltest::test 6.6.1-array-27 { A public member method of an array is
        accessible only if the array class is accessible } {
    empty_class T661a27 {
        class Inner {
            Object o = Array27.array.toString();
        }
        static class Array27 {
            static A[] array;
            private static class A {}
        }
    }
} PASS

tcltest::test 6.6.1-array-28 { The public clone method of an array is
        accessible only if the array class is accessible } {
    compile [saveas T661a28.java {
class T661a28 {
    Object o = pkg.Array28.array.clone();
}
    }] [saveas pkg/Array28.java {
package pkg;
public class Array28 {
    public static A[] array;
    public static class A {}
}
    }]
} PASS

tcltest::test 6.6.1-array-29 { The public clone method of an array is
        accessible only if the array class is accessible } {
    compile [saveas T661a29.java {
class T661a29 {
    Object o = pkg.Array29.array.clone();
}
    }] [saveas pkg/Array29.java {
package pkg;
public class Array29 {
    public static A[] array;
    protected static class A {}
}
    }]
} FAIL

tcltest::test 6.6.1-array-30 { The public clone method of an array is
        accessible only if the array class is accessible } {
    compile [saveas T661a30.java {
class T661a30 extends pkg.Array30 {
    Object o = pkg.Array30.array.clone();
}
    }] [saveas pkg/Array30.java {
package pkg;
public class Array30 {
    public static A[] array;
    protected static class A {}
}
    }]
} PASS

tcltest::test 6.6.1-array-31 { The public clone method of an array is
        accessible only if the array class is accessible } {
    compile [saveas T661a31.java {
class T661a31 {
    Object o = pkg.Array31.array.clone();
}
    }] [saveas pkg/Array31.java {
package pkg;
public class Array31 {
    public static A[] array;
    static class A {}
}
    }]
} FAIL

tcltest::test 6.6.1-array-32 { The public clone method of an array is
        accessible only if the array class is accessible } {
    compile [saveas T661a32.java {
class T661a32 {
    Object o = pkg.Array32.array.clone();
}
    }] [saveas pkg/Array32.java {
package pkg;
public class Array32 {
    public static A[] array;
    private static class A {}
}
    }]
} FAIL

tcltest::test 6.6.1-array-33 { The public clone method of an array is
        accessible only if the array class is accessible } {
    compile [saveas T661a33.java {
class T661a33 {
    Object o = Array33.array.clone();
}
class Array33 {
    static A[] array;
    protected static class A {}
}
    }]
} PASS

tcltest::test 6.6.1-array-34 { The public clone method of an array is
        accessible only if the array class is accessible } {
    compile [saveas T661a34.java {
class T661a34 {
    Object o = Array34.array.clone();
}
class Array34 {
    static A[] array;
    static class A {}
}
    }]
} PASS

tcltest::test 6.6.1-array-35 { The public clone method of an array is
        accessible only if the array class is accessible } {
    compile [saveas T661a35.java {
class T661a35 {
    Object o = Array35.array.clone();
}
class Array35 {
    static A[] array;
    private static class A {}
}
    }]
} FAIL

tcltest::test 6.6.1-array-36 { The public clone method of an array is
        accessible only if the array class is accessible } {
    empty_class T661a36 {
        class Inner {
            Object o = Array36.array.clone();
        }
        static class Array36 {
            static A[] array;
            private static class A {}
        }
    }
} PASS
