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