Path: blob/master/test/langtools/tools/javac/6558548/T6558548.java
41149 views
/*1* @test /nodynamiccopyright/2* @bug 6558548 70399373* @summary The compiler needs to be aligned with clarified specification of throws4* @compile/fail/ref=T6558548_latest.out -XDrawDiagnostics T6558548.java5*/67class T6558548 {89void nothing() {}10void checked() throws InterruptedException {}11void runtime() throws IllegalArgumentException {}1213void m1a() {14try {15throw new java.io.FileNotFoundException();16}17catch(java.io.FileNotFoundException exc) { }18catch(java.io.IOException exc) { } // 6: ok; latest: unreachable19}2021void m1b() {22try {23throw new java.io.IOException();24}25catch(java.io.FileNotFoundException exc) { }26catch(java.io.IOException exc) { } //ok27}2829void m1c() {30try {31throw new java.io.FileNotFoundException();32}33catch(java.io.FileNotFoundException exc) { }34catch(Exception ex) { } //ok (Exception/Throwable always allowed)35}3637void m1d() {38try {39throw new java.io.FileNotFoundException();40}41catch(java.io.FileNotFoundException exc) { }42catch(Throwable ex) { } //ok (Exception/Throwable always allowed)43}4445void m3() {46try {47checked();48}49catch(Exception exc) { } //ok50}5152void m4() {53try {54runtime();55}56catch(Exception exc) { } //ok57}5859void m5() {60try {61nothing();62}63catch(Throwable exc) { } //ok64}6566void m6() {67try {68checked();69}70catch(Throwable exc) { } //ok71}7273void m7() {74try {75runtime();76}77catch(Throwable exc) { } //ok78}7980void m9() {81try {82checked();83}84catch(Error exc) { }85catch(Throwable exc) { } //ok86}8788void m10() {89try {90runtime();91}92catch(Error exc) { }93catch(Throwable exc) { } //ok94}9596void m11() {97try {98nothing();99}100catch(Error exc) { }101catch(Throwable exc) { } //ok102}103104void m12() {105try {106checked();107}108catch(RuntimeException exc) { }109catch(Throwable exc) { } // ok110}111112void m13() {113try {114runtime();115}116catch(RuntimeException exc) { }117catch(Throwable exc) { } // ok118}119120void m14() {121try {122nothing();123}124catch(RuntimeException exc) { }125catch(Throwable exc) { } // ok126}127128void m15() {129try {130checked();131}132catch(RuntimeException exc) { }133catch(Exception exc) { } //ok134}135136void m16() {137try {138runtime();139}140catch(RuntimeException exc) { }141catch(Exception exc) { } //6: ok; latest: ok (Exception/Throwable always allowed)142}143144void m17() {145try {146nothing();147}148catch(RuntimeException exc) { }149catch(Exception exc) { } //6: ok; latest: ok (Exception/Throwable always allowed)150}151152void m18() {153try {154checked();155}156catch(RuntimeException exc) { }157catch(InterruptedException exc) { }158catch(Exception exc) { } //6: ok; latest: ok (Exception/Throwable always allowed)159}160161void m19() {162try {163runtime();164}165catch(RuntimeException exc) { }166catch(InterruptedException exc) { } //never thrown in try167catch(Exception exc) { } //6: ok; latest: ok (Exception/Throwable always allowed)168}169170void m20() {171try {172nothing();173}174catch(RuntimeException exc) { }175catch(InterruptedException exc) { } //never thrown in try176catch(Exception exc) { } //6: ok; latest: ok (Exception/Throwable always allowed)177}178179void m21() {180try {181checked();182}183catch(RuntimeException exc) { }184catch(Exception exc) { } // ok185}186187void m22() {188try {189runtime();190}191catch(RuntimeException exc) { }192catch(Exception exc) { } // 6: ok; latest: ok (Exception/Throwable always allowed)193}194195void m23() {196try {197nothing();198}199catch(RuntimeException exc) { }200catch(Exception exc) { } // 6: ok; latest: ok (Exception/Throwable always allowed)201}202203void m24() {204try {205checked();206}207catch(RuntimeException exc) { }208catch(Error exc) { }209catch(Throwable exc) { } //ok210}211212void m25() {213try {214runtime();215}216catch(RuntimeException exc) { }217catch(Error exc) { }218catch(Throwable exc) { } //6: ok; latest: ok (Exception/Throwable always allowed)219}220221void m26() {222try {223nothing();224}225catch(RuntimeException exc) { }226catch(Error exc) { }227catch(Throwable exc) { } //6: ok; latest: ok (Exception/Throwable always allowed)228}229230void m27() {231try {232checked();233}234catch(RuntimeException exc) { }235catch(Error exc) { }236catch(InterruptedException exc) { }237catch(Throwable exc) { } //6: ok; latest: ok (Exception/Throwable always allowed)238}239240void m28() {241try {242runtime();243}244catch(RuntimeException exc) { }245catch(Error exc) { }246catch(InterruptedException exc) { } //never thrown in try247catch(Throwable exc) { } //6: ok; latest: ok (Exception/Throwable always allowed)248}249250void m29() {251try {252nothing();253}254catch(RuntimeException exc) { }255catch(Error exc) { }256catch(InterruptedException exc) { } //never thrown in try257catch(Throwable exc) { } //6: ok; latest: ok (Exception/Throwable always allowed)258}259260void m30() {261try {262checked();263}264catch(RuntimeException exc) { }265catch(Error exc) { }266catch(Throwable exc) { } //ok267}268269void m31() {270try {271runtime();272}273catch(RuntimeException exc) { }274catch(Error exc) { }275catch(Throwable exc) { } //6: ok; latest: ok (Exception/Throwable always allowed)276}277278void m32() {279try {280nothing();281}282catch(RuntimeException exc) { }283catch(Error exc) { }284catch(Throwable exc) { } //6: ok; latest: ok (Exception/Throwable always allowed)285}286287void m33() {288try {289checked();290}291catch(InterruptedException exc) { } //ok292}293294void m34() {295try {296runtime();297}298catch(InterruptedException exc) { } //never thrown in try299}300301void m35() {302try {303nothing();304}305catch(InterruptedException exc) { } //never thrown in try306}307}308309310