tcltest::test 15.12.2.1-jls-example-1 { example code,
        should fail since two(int) is private } {
    compile [saveas T151221je1.java {
class Doubler {
    static int two() { return two(1); }
    private static int two(int i) { return 2*i; }
}
class Test extends Doubler {    
    public static long two(long j) {return j+j; }
    public static void main(String[] args) {
        System.out.println(two(3));
        System.out.println(Doubler.two(3)); // compile-time error
    }
}
    }]
} FAIL


tcltest::test 15.12.2.1-jls-example-2 { example code,
         The type of the literal 37 is int, and int
         cannot be converted to byte by method invocation
         conversion } {
    compile [saveas T151221je2.java {
class ColoredPoint {
    int x, y;
    byte color;
    void setColor(byte color) { this.color = color; }
}
class Test {
    public static void main(String[] args) {
        ColoredPoint cp = new ColoredPoint();
        byte color = 37;
        cp.setColor(color);
        cp.setColor(37);  // compile-time error
    }
}
    }]
} FAIL

tcltest::test 15.12.2.1-accessibility-constructor-1 {
        A constructor must be applicable and accessible,
        in this case the constructor is private so it
        is not accessible even though it is applicable } {
    compile [saveas T151221ac1.java {
class T151221ac1 {
    public T151221ac1(String s) {}
    private T151221ac1(Integer i) {}
}
class T151221ac1_Test {
    Object o = new T151221ac1(null);
}
    }]
} PASS

tcltest::test 15.12.2.1-accessibility-constructor-2 {
        A private constructor is not accessible } {
    compile [saveas T151221ac2.java {
class T151221ac2 {
    public T151221ac2(String x, String y) {}
    private T151221ac2(String x, char[] y) {}
}
class T151221ac2_Test {
    Object o = new T151221ac2("hi", null);
}
    }]
} PASS

tcltest::test 15.12.2.1-accessibility-method-1 {
        A method must be applicable and accessible,
        in this case the method is private so it
        is not accessible even though it is applicable } {
    compile [saveas T151221am1.java {
class T151221am1 {
    public int foo(String s) { return 0; }
    private int foo(Integer i) { return 0; }
}
class T151221am1_Test {
    int i = new T151221am1().foo(null);
}
    }]
} PASS

tcltest::test 15.12.2.1-accessibility-method-2 { A method must be applicable
        and accessible } {
    compile [saveas p1/T151221am2c.java {
package p1;
abstract class T151221am2a {
    abstract void m(); // note non-public accessibility
}
interface T151221am2b {
    void m() throws Exception;
}
public abstract class T151221am2c extends T151221am2a implements T151221am2b {
    // inherits 2 versions of m()
}
    }] [saveas T151221am2d.java {
abstract class T151221am2d extends p1.T151221am2c {
    // a concrete subclass of c will necessarily have an implementation of m
    // that does not throw, in order to implement a.m; but only b.m was
    // inherited here because of accessibility. Since b.m throws, this call
    // is illegal
    { m(); }
}
    }]
} FAIL

tcltest::test 15.12.2.1-accessibility-method-3 { A method must be applicable
        and accessible } {
    compile [saveas p1/T151221am3c.java {
package p1;
abstract class T151221am3a {
    abstract void m(); // note non-public accessibility
}
interface T151221am3b {
    void m() throws Exception;
}
public abstract class T151221am3c extends T151221am3a implements T151221am3b {
    // inherits 2 versions of m()
}
    }] [saveas T151221am3d.java {
abstract class T151221am3d extends p1.T151221am3c {
    // a concrete subclass of c will necessarily have an implementation of m
    // that does not throw, in order to implement a.m; but only b.m was
    // inherited here because of accessibility. Since b.m throws, the catch
    // clause is reachable
    {
	try {
	    m();
	} catch (Exception e) {
	}
    }
}
    }]
} PASS

tcltest::test 15.12.2.1-accessibility-method-4 { A method must be applicable
        and accessible } {
    compile [saveas p1/T151221am4c.java {
package p1;
abstract class T151221am4a {
    abstract void m(); // note non-public accessibility
}
interface T151221am4b {
    void m() throws Exception;
}
public abstract class T151221am4c extends T151221am4a implements T151221am4b {
    // inherits 2 versions of m()
}
    }] [saveas T151221am4d.java {
class T151221am4d {
    // a concrete subclass of c will necessarily have an implementation of m
    // that does not throw, in order to implement a.m; but since only b.m is
    // accessible here, and it throws, this call is illegal
    void m(p1.T151221am4c t) {
	t.m();
    }
}
    }]
} FAIL

tcltest::test 15.12.2.1-accessibility-method-5 { A method must be applicable
        and accessible } {
    compile [saveas p1/T151221am5c.java {
package p1;
abstract class T151221am5a {
    abstract void m(); // note non-public accessibility
}
interface T151221am5b {
    void m() throws Exception;
}
public abstract class T151221am5c extends T151221am5a implements T151221am5b {
    // inherits 2 versions of m()
}
    }] [saveas T151221am5d.java {
class T151221am5d {
    // a concrete subclass of c will necessarily have an implementation of m
    // that does not throw, in order to implement a.m; but since only b.m is
    // accessible here, the catch clause is reachable
    void m(p1.T151221am5c t) {
	try {
	    t.m();
	} catch (Exception e) {
	}
    }
}
    }]
} PASS

tcltest::test 15.12.2.1-accessibility-method-6 { A method must be applicable
        and accessible } {
    compile [saveas p1/T151221am6a.java {
package p1;
public class T151221am6a {
    public static class E1 extends Exception {}
    public static class E2 extends Exception {}
    public static abstract class A {
	protected abstract void m() throws E1; // note non-public accessibility
    }
}
    }] [saveas T151221am6b.java {
class T151221am6b extends p1.T151221am6a {
    interface B {
	void m() throws E2;
    }
    static abstract class C extends A implements B {
	// c inherits two versions of m
    }
    static abstract class D extends C {
	// likewise, d inherits two versions of m, but protected accessibility
	// rules state that access to a.m is only possible when the qualifier
	// is d or below. When both methods are accessible, the method cannot
	// throw either exception; but alone, b.m may throw.
	{
	    m(); // merged throws clause
	    try {
		((C) this).m(); // only b.m accessible
	    } catch (E2 e) {
	    }
	}
    }
}
    }]
} PASS

tcltest::test 15.12.2.1-accessibility-method-7 { A method must be applicable
        and accessible } {
    compile [saveas p1/T151221am7a.java {
package p1;
public class T151221am7a {
    public static class E1 extends Exception {}
    public static class E2 extends Exception {}
    public static abstract class A {
	protected abstract void m() throws E1; // note non-public accessibility
    }
}
    }] [saveas T151221am7b.java {
class T151221am7b extends p1.T151221am7a {
    interface B {
	void m() throws E2;
    }
    static abstract class C extends A implements B {
	// c inherits two versions of m
    }
    static abstract class D extends C {
	// likewise, d inherits two versions of m, but protected accessibility
	// rules state that access to a.m is only possible when the qualifier
	// is d or below. When both methods are accessible, the method cannot
	// throw either exception; but alone, b.m may throw.
	{
	    try {
		m(); // merged throws clause
	    } catch (E2 e) {
	    }
	}
    }
}
    }]
} FAIL

tcltest::test 15.12.2.1-accessibility-method-8 { A method must be applicable
        and accessible } {
    compile [saveas p1/T151221am8a.java {
package p1;
public class T151221am8a {
    public static class E1 extends Exception {}
    public static class E2 extends Exception {}
    public static abstract class A {
	protected abstract void m() throws E1; // note non-public accessibility
    }
}
    }] [saveas T151221am8b.java {
class T151221am8b extends p1.T151221am8a {
    interface B {
	void m() throws E2;
    }
    static abstract class C extends A implements B {
	// c inherits two versions of m
    }
    static abstract class D extends C {
	// likewise, d inherits two versions of m, but protected accessibility
	// rules state that access to a.m is only possible when the qualifier
	// is d or below. When both methods are accessible, the method cannot
	// throw either exception; but alone, b.m may throw.
	{
	    ((C) this).m(); // only b.m accessible
	}
    }
}
    }]
} FAIL
