langtools/test/tools/javac/6558548/T6558548.java
changeset 8849 4189ac38ddc9
child 9601 a1b1716231ca
equal deleted inserted replaced
8848:3f1b154379d6 8849:4189ac38ddc9
       
     1 /*
       
     2  * @test /nodynamiccopyright/
       
     3  * @bug     6558548
       
     4  * @summary The compiler needs to be aligned with clarified specification of throws
       
     5  * @compile/fail/ref=T6558548_latest.out -XDrawDiagnostics T6558548.java
       
     6  * @compile/fail/ref=T6558548_6.out -source 6 -XDrawDiagnostics T6558548.java
       
     7  */
       
     8 
       
     9 class T6558548 {
       
    10 
       
    11     void nothing() {}
       
    12     void checked() throws InterruptedException {}
       
    13     void runtime() throws IllegalArgumentException {}
       
    14 
       
    15     void m1() {
       
    16         try {
       
    17             throw new java.io.FileNotFoundException();
       
    18         }
       
    19         catch(java.io.FileNotFoundException exc) { }
       
    20         catch(java.io.IOException exc) { } // 6: ok; latest: unreachable
       
    21     }
       
    22 
       
    23     void m1a() {
       
    24         try {
       
    25             throw new java.io.IOException();
       
    26         }
       
    27         catch(java.io.FileNotFoundException exc) { }
       
    28         catch(java.io.IOException exc) { } //ok
       
    29     }
       
    30 
       
    31     void m2() {
       
    32         try {
       
    33             nothing();
       
    34         }
       
    35         catch(Exception exc) { } // ok
       
    36     }
       
    37 
       
    38     void m3() {
       
    39         try {
       
    40             checked();
       
    41         }
       
    42         catch(Exception exc) { } //ok
       
    43     }
       
    44 
       
    45     void m4() {
       
    46         try {
       
    47             runtime();
       
    48         }
       
    49         catch(Exception exc) { } //ok
       
    50     }
       
    51 
       
    52     void m5() {
       
    53         try {
       
    54             nothing();
       
    55         }
       
    56         catch(Throwable exc) { } //ok
       
    57     }
       
    58 
       
    59     void m6() {
       
    60         try {
       
    61             checked();
       
    62         }
       
    63         catch(Throwable exc) { } //ok
       
    64     }
       
    65 
       
    66     void m7() {
       
    67         try {
       
    68             runtime();
       
    69         }
       
    70         catch(Throwable exc) { } //ok
       
    71     }
       
    72 
       
    73     void m9() {
       
    74         try {
       
    75             checked();
       
    76         }
       
    77         catch(Error exc) { }
       
    78         catch(Throwable exc) { } //ok
       
    79     }
       
    80 
       
    81     void m10() {
       
    82         try {
       
    83             runtime();
       
    84         }
       
    85         catch(Error exc) { }
       
    86         catch(Throwable exc) { } //ok
       
    87     }
       
    88 
       
    89     void m11() {
       
    90         try {
       
    91             nothing();
       
    92         }
       
    93         catch(Error exc) { }
       
    94         catch(Throwable exc) { } //ok
       
    95     }
       
    96 
       
    97     void m12() {
       
    98         try {
       
    99             checked();
       
   100         }
       
   101         catch(RuntimeException exc) { }
       
   102         catch(Throwable exc) { } // ok
       
   103     }
       
   104 
       
   105     void m13() {
       
   106         try {
       
   107             runtime();
       
   108         }
       
   109         catch(RuntimeException exc) { }
       
   110         catch(Throwable exc) { } // ok
       
   111     }
       
   112 
       
   113     void m14() {
       
   114         try {
       
   115             nothing();
       
   116         }
       
   117         catch(RuntimeException exc) { }
       
   118         catch(Throwable exc) { } // ok
       
   119     }
       
   120 
       
   121     void m15() {
       
   122         try {
       
   123             checked();
       
   124         }
       
   125         catch(RuntimeException exc) { }
       
   126         catch(Exception exc) { } //ok
       
   127     }
       
   128 
       
   129     void m16() {
       
   130         try {
       
   131             runtime();
       
   132         }
       
   133         catch(RuntimeException exc) { }
       
   134         catch(Exception exc) { } //6: ok; latest: unreachable
       
   135     }
       
   136 
       
   137     void m17() {
       
   138         try {
       
   139             nothing();
       
   140         }
       
   141         catch(RuntimeException exc) { }
       
   142         catch(Exception exc) { } //6: ok; latest: unreachable
       
   143     }
       
   144 
       
   145     void m18() {
       
   146         try {
       
   147             checked();
       
   148         }
       
   149         catch(RuntimeException exc) { }
       
   150         catch(InterruptedException exc) { }
       
   151         catch(Exception exc) { } //6: ok; latest: unreachable
       
   152     }
       
   153 
       
   154     void m19() {
       
   155         try {
       
   156             runtime();
       
   157         }
       
   158         catch(RuntimeException exc) { }
       
   159         catch(InterruptedException exc) { } //never thrown in try
       
   160         catch(Exception exc) { } //6: ok; latest: unreachable
       
   161     }
       
   162 
       
   163     void m20() {
       
   164         try {
       
   165             nothing();
       
   166         }
       
   167         catch(RuntimeException exc) { }
       
   168         catch(InterruptedException exc) { } //never thrown in try
       
   169         catch(Exception exc) { } //6: ok; latest: unreachable
       
   170     }
       
   171 
       
   172     void m21() {
       
   173         try {
       
   174             checked();
       
   175         }
       
   176         catch(RuntimeException exc) { }
       
   177         catch(Exception exc) { } // ok
       
   178     }
       
   179 
       
   180     void m22() {
       
   181         try {
       
   182             runtime();
       
   183         }
       
   184         catch(RuntimeException exc) { }
       
   185         catch(Exception exc) { } // 6: ok; latest: unreachable
       
   186     }
       
   187 
       
   188     void m23() {
       
   189         try {
       
   190             nothing();
       
   191         }
       
   192         catch(RuntimeException exc) { }
       
   193         catch(Exception exc) { } // 6: ok; latest: unreachable
       
   194     }
       
   195 
       
   196     void m24() {
       
   197         try {
       
   198             checked();
       
   199         }
       
   200         catch(RuntimeException exc) { }
       
   201         catch(Error exc) { }
       
   202         catch(Throwable exc) { } //ok
       
   203     }
       
   204 
       
   205     void m25() {
       
   206         try {
       
   207             runtime();
       
   208         }
       
   209         catch(RuntimeException exc) { }
       
   210         catch(Error exc) { }
       
   211         catch(Throwable exc) { } //6: ok; latest: unreachable
       
   212     }
       
   213 
       
   214     void m26() {
       
   215         try {
       
   216             nothing();
       
   217         }
       
   218         catch(RuntimeException exc) { }
       
   219         catch(Error exc) { }
       
   220         catch(Throwable exc) { } //6: ok; latest: unreachable
       
   221     }
       
   222 
       
   223     void m27() {
       
   224         try {
       
   225             checked();
       
   226         }
       
   227         catch(RuntimeException exc) { }
       
   228         catch(Error exc) { }
       
   229         catch(InterruptedException exc) { }
       
   230         catch(Throwable exc) { } //6: ok; latest: unreachable
       
   231     }
       
   232 
       
   233     void m28() {
       
   234         try {
       
   235             runtime();
       
   236         }
       
   237         catch(RuntimeException exc) { }
       
   238         catch(Error exc) { }
       
   239         catch(InterruptedException exc) { } //never thrown in try
       
   240         catch(Throwable exc) { } //6: ok; latest: unreachable
       
   241     }
       
   242 
       
   243     void m29() {
       
   244         try {
       
   245             nothing();
       
   246         }
       
   247         catch(RuntimeException exc) { }
       
   248         catch(Error exc) { }
       
   249         catch(InterruptedException exc) { } //never thrown in try
       
   250         catch(Throwable exc) { } //6: ok; latest: unreachable
       
   251     }
       
   252 
       
   253     void m30() {
       
   254         try {
       
   255             checked();
       
   256         }
       
   257         catch(RuntimeException exc) { }
       
   258         catch(Error exc) { }
       
   259         catch(Throwable exc) { } //ok
       
   260     }
       
   261 
       
   262     void m31() {
       
   263         try {
       
   264             runtime();
       
   265         }
       
   266         catch(RuntimeException exc) { }
       
   267         catch(Error exc) { }
       
   268         catch(Throwable exc) { } //6: ok; latest: unreachable
       
   269     }
       
   270 
       
   271     void m32() {
       
   272         try {
       
   273             nothing();
       
   274         }
       
   275         catch(RuntimeException exc) { }
       
   276         catch(Error exc) { }
       
   277         catch(Throwable exc) { } //6: ok; latest: unreachable
       
   278     }
       
   279 
       
   280     void m33() {
       
   281         try {
       
   282             checked();
       
   283         }
       
   284         catch(InterruptedException exc) { } //ok
       
   285     }
       
   286 
       
   287     void m34() {
       
   288         try {
       
   289             runtime();
       
   290         }
       
   291         catch(InterruptedException exc) { } //never thrown in try
       
   292     }
       
   293 
       
   294     void m35() {
       
   295         try {
       
   296             nothing();
       
   297         }
       
   298         catch(InterruptedException exc) { } //never thrown in try
       
   299     }
       
   300 }