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