diff -r 23b64ad3eec8 -r 9286a5d1fae3 test/tools/javac/generics/7015430/T7015430.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/7015430/T7015430.java Mon Feb 28 11:48:53 2011 +0000 @@ -0,0 +1,131 @@ +/* + * @test /nodynamiccopyright/ + * @bug 7015430 + * + * @summary Incorrect thrown type determined for unchecked invocations + * @author Daniel Smith + * @compile/fail/ref=T7015430.out -Xlint:unchecked -XDrawDiagnostics T7015430.java + * + */ + +class T7015430 { + static Iterable empty(Iterable arg) throws E { + return null; + } + + T7015430(Iterable arg) throws E { } + + static Iterable empty2(Iterable x) throws E { + return null; + } + + static class Foo { + Foo() throws X {} + } + + /** + * Method invocation, no unchecked + * inferred: RuntimeException - should pass + */ + void m1() { + Iterable i = java.util.Collections.emptyList(); + empty(i); + } + + /** + * Method invocation, unchecked, inferred arguments + * inferred: Exception - should fail + */ + void m2() { + Iterable i = java.util.Collections.EMPTY_LIST; + empty(i); + } + + /** + * Method invocation, unchecked, explicit arguments + * inferred: RuntimeException - should pass + */ + void m3() { + Iterable i = java.util.Collections.EMPTY_LIST; + T7015430.empty(i); + } + + /** + * Constructor invocation, no unchecked + * inferred: RuntimeException - should pass + */ + void m4() { + Iterable i = java.util.Collections.emptyList(); + new T7015430(i); + } + + /** + * Constructor invocation, unchecked, inferred arguments + * inferred: Exception - should fail + */ + void m5() { + Iterable i = java.util.Collections.EMPTY_LIST; + new T7015430(i); + } + + /** + * Constructor invocation, unchecked, explicit arguments + * inferred: RuntimeException - should pass + */ + void m6() { + Iterable i = java.util.Collections.EMPTY_LIST; + new T7015430(i); + } + + /** + * Method invocation, no unchecked, inferred arguments + * inferred: RuntimeException - should pass + */ + void m7() { + Iterable i = java.util.Collections.EMPTY_LIST; + Iterable e = empty2(i); + } + + /** + * Method invocation, no unchecked, inferred arguments + * inferred: Exception - should fail + */ + void m8() { + Iterable i = java.util.Collections.EMPTY_LIST; + empty2(i); + } + + /** + * Constructor invocation, unchecked, explicit arguments + * inferred: RuntimeException - should pass + */ + void m9() { + Iterable i = java.util.Collections.EMPTY_LIST; + new T7015430(i); + } + + /** + * Constructor invocation, unchecked, inferred arguments + * inferred: Exception - should fail + */ + void m10() { + Iterable i = java.util.Collections.EMPTY_LIST; + new T7015430(i); + } + + /** + * Constructor invocation, no unchecked, inferred arguments (diamond) + * inferred: RuntimeException - should pass + */ + void m11() { + Foo o = new Foo<>(); + } + + /** + * Constructor invocation, no unchecked, inferred arguments (diamond) + * inferred: Exception - should fail + */ + void m12() { + new Foo<>(); + } +}