--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/6558548/T6558548.java Wed Mar 16 11:12:26 2011 +0000
@@ -0,0 +1,300 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6558548
+ * @summary The compiler needs to be aligned with clarified specification of throws
+ * @compile/fail/ref=T6558548_latest.out -XDrawDiagnostics T6558548.java
+ * @compile/fail/ref=T6558548_6.out -source 6 -XDrawDiagnostics T6558548.java
+ */
+
+class T6558548 {
+
+ void nothing() {}
+ void checked() throws InterruptedException {}
+ void runtime() throws IllegalArgumentException {}
+
+ void m1() {
+ try {
+ throw new java.io.FileNotFoundException();
+ }
+ catch(java.io.FileNotFoundException exc) { }
+ catch(java.io.IOException exc) { } // 6: ok; latest: unreachable
+ }
+
+ void m1a() {
+ try {
+ throw new java.io.IOException();
+ }
+ catch(java.io.FileNotFoundException exc) { }
+ catch(java.io.IOException exc) { } //ok
+ }
+
+ void m2() {
+ try {
+ nothing();
+ }
+ catch(Exception exc) { } // ok
+ }
+
+ void m3() {
+ try {
+ checked();
+ }
+ catch(Exception exc) { } //ok
+ }
+
+ void m4() {
+ try {
+ runtime();
+ }
+ catch(Exception exc) { } //ok
+ }
+
+ void m5() {
+ try {
+ nothing();
+ }
+ catch(Throwable exc) { } //ok
+ }
+
+ void m6() {
+ try {
+ checked();
+ }
+ catch(Throwable exc) { } //ok
+ }
+
+ void m7() {
+ try {
+ runtime();
+ }
+ catch(Throwable exc) { } //ok
+ }
+
+ void m9() {
+ try {
+ checked();
+ }
+ catch(Error exc) { }
+ catch(Throwable exc) { } //ok
+ }
+
+ void m10() {
+ try {
+ runtime();
+ }
+ catch(Error exc) { }
+ catch(Throwable exc) { } //ok
+ }
+
+ void m11() {
+ try {
+ nothing();
+ }
+ catch(Error exc) { }
+ catch(Throwable exc) { } //ok
+ }
+
+ void m12() {
+ try {
+ checked();
+ }
+ catch(RuntimeException exc) { }
+ catch(Throwable exc) { } // ok
+ }
+
+ void m13() {
+ try {
+ runtime();
+ }
+ catch(RuntimeException exc) { }
+ catch(Throwable exc) { } // ok
+ }
+
+ void m14() {
+ try {
+ nothing();
+ }
+ catch(RuntimeException exc) { }
+ catch(Throwable exc) { } // ok
+ }
+
+ void m15() {
+ try {
+ checked();
+ }
+ catch(RuntimeException exc) { }
+ catch(Exception exc) { } //ok
+ }
+
+ void m16() {
+ try {
+ runtime();
+ }
+ catch(RuntimeException exc) { }
+ catch(Exception exc) { } //6: ok; latest: unreachable
+ }
+
+ void m17() {
+ try {
+ nothing();
+ }
+ catch(RuntimeException exc) { }
+ catch(Exception exc) { } //6: ok; latest: unreachable
+ }
+
+ void m18() {
+ try {
+ checked();
+ }
+ catch(RuntimeException exc) { }
+ catch(InterruptedException exc) { }
+ catch(Exception exc) { } //6: ok; latest: unreachable
+ }
+
+ void m19() {
+ try {
+ runtime();
+ }
+ catch(RuntimeException exc) { }
+ catch(InterruptedException exc) { } //never thrown in try
+ catch(Exception exc) { } //6: ok; latest: unreachable
+ }
+
+ void m20() {
+ try {
+ nothing();
+ }
+ catch(RuntimeException exc) { }
+ catch(InterruptedException exc) { } //never thrown in try
+ catch(Exception exc) { } //6: ok; latest: unreachable
+ }
+
+ void m21() {
+ try {
+ checked();
+ }
+ catch(RuntimeException exc) { }
+ catch(Exception exc) { } // ok
+ }
+
+ void m22() {
+ try {
+ runtime();
+ }
+ catch(RuntimeException exc) { }
+ catch(Exception exc) { } // 6: ok; latest: unreachable
+ }
+
+ void m23() {
+ try {
+ nothing();
+ }
+ catch(RuntimeException exc) { }
+ catch(Exception exc) { } // 6: ok; latest: unreachable
+ }
+
+ void m24() {
+ try {
+ checked();
+ }
+ catch(RuntimeException exc) { }
+ catch(Error exc) { }
+ catch(Throwable exc) { } //ok
+ }
+
+ void m25() {
+ try {
+ runtime();
+ }
+ catch(RuntimeException exc) { }
+ catch(Error exc) { }
+ catch(Throwable exc) { } //6: ok; latest: unreachable
+ }
+
+ void m26() {
+ try {
+ nothing();
+ }
+ catch(RuntimeException exc) { }
+ catch(Error exc) { }
+ catch(Throwable exc) { } //6: ok; latest: unreachable
+ }
+
+ void m27() {
+ try {
+ checked();
+ }
+ catch(RuntimeException exc) { }
+ catch(Error exc) { }
+ catch(InterruptedException exc) { }
+ catch(Throwable exc) { } //6: ok; latest: unreachable
+ }
+
+ void m28() {
+ try {
+ runtime();
+ }
+ catch(RuntimeException exc) { }
+ catch(Error exc) { }
+ catch(InterruptedException exc) { } //never thrown in try
+ catch(Throwable exc) { } //6: ok; latest: unreachable
+ }
+
+ void m29() {
+ try {
+ nothing();
+ }
+ catch(RuntimeException exc) { }
+ catch(Error exc) { }
+ catch(InterruptedException exc) { } //never thrown in try
+ catch(Throwable exc) { } //6: ok; latest: unreachable
+ }
+
+ void m30() {
+ try {
+ checked();
+ }
+ catch(RuntimeException exc) { }
+ catch(Error exc) { }
+ catch(Throwable exc) { } //ok
+ }
+
+ void m31() {
+ try {
+ runtime();
+ }
+ catch(RuntimeException exc) { }
+ catch(Error exc) { }
+ catch(Throwable exc) { } //6: ok; latest: unreachable
+ }
+
+ void m32() {
+ try {
+ nothing();
+ }
+ catch(RuntimeException exc) { }
+ catch(Error exc) { }
+ catch(Throwable exc) { } //6: ok; latest: unreachable
+ }
+
+ void m33() {
+ try {
+ checked();
+ }
+ catch(InterruptedException exc) { } //ok
+ }
+
+ void m34() {
+ try {
+ runtime();
+ }
+ catch(InterruptedException exc) { } //never thrown in try
+ }
+
+ void m35() {
+ try {
+ nothing();
+ }
+ catch(InterruptedException exc) { } //never thrown in try
+ }
+}