1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/test/tools/javac/6558548/T6558548.java Wed Apr 27 01:34:52 2016 +0800 1.3 @@ -0,0 +1,309 @@ 1.4 +/* 1.5 + * @test /nodynamiccopyright/ 1.6 + * @bug 6558548 7039937 1.7 + * @summary The compiler needs to be aligned with clarified specification of throws 1.8 + * @compile/fail/ref=T6558548_latest.out -XDrawDiagnostics T6558548.java 1.9 + * @compile/fail/ref=T6558548_6.out -source 6 -Xlint:-options -XDrawDiagnostics T6558548.java 1.10 + */ 1.11 + 1.12 +class T6558548 { 1.13 + 1.14 + void nothing() {} 1.15 + void checked() throws InterruptedException {} 1.16 + void runtime() throws IllegalArgumentException {} 1.17 + 1.18 + void m1a() { 1.19 + try { 1.20 + throw new java.io.FileNotFoundException(); 1.21 + } 1.22 + catch(java.io.FileNotFoundException exc) { } 1.23 + catch(java.io.IOException exc) { } // 6: ok; latest: unreachable 1.24 + } 1.25 + 1.26 + void m1b() { 1.27 + try { 1.28 + throw new java.io.IOException(); 1.29 + } 1.30 + catch(java.io.FileNotFoundException exc) { } 1.31 + catch(java.io.IOException exc) { } //ok 1.32 + } 1.33 + 1.34 + void m1c() { 1.35 + try { 1.36 + throw new java.io.FileNotFoundException(); 1.37 + } 1.38 + catch(java.io.FileNotFoundException exc) { } 1.39 + catch(Exception ex) { } //ok (Exception/Throwable always allowed) 1.40 + } 1.41 + 1.42 + void m1d() { 1.43 + try { 1.44 + throw new java.io.FileNotFoundException(); 1.45 + } 1.46 + catch(java.io.FileNotFoundException exc) { } 1.47 + catch(Throwable ex) { } //ok (Exception/Throwable always allowed) 1.48 + } 1.49 + 1.50 + void m3() { 1.51 + try { 1.52 + checked(); 1.53 + } 1.54 + catch(Exception exc) { } //ok 1.55 + } 1.56 + 1.57 + void m4() { 1.58 + try { 1.59 + runtime(); 1.60 + } 1.61 + catch(Exception exc) { } //ok 1.62 + } 1.63 + 1.64 + void m5() { 1.65 + try { 1.66 + nothing(); 1.67 + } 1.68 + catch(Throwable exc) { } //ok 1.69 + } 1.70 + 1.71 + void m6() { 1.72 + try { 1.73 + checked(); 1.74 + } 1.75 + catch(Throwable exc) { } //ok 1.76 + } 1.77 + 1.78 + void m7() { 1.79 + try { 1.80 + runtime(); 1.81 + } 1.82 + catch(Throwable exc) { } //ok 1.83 + } 1.84 + 1.85 + void m9() { 1.86 + try { 1.87 + checked(); 1.88 + } 1.89 + catch(Error exc) { } 1.90 + catch(Throwable exc) { } //ok 1.91 + } 1.92 + 1.93 + void m10() { 1.94 + try { 1.95 + runtime(); 1.96 + } 1.97 + catch(Error exc) { } 1.98 + catch(Throwable exc) { } //ok 1.99 + } 1.100 + 1.101 + void m11() { 1.102 + try { 1.103 + nothing(); 1.104 + } 1.105 + catch(Error exc) { } 1.106 + catch(Throwable exc) { } //ok 1.107 + } 1.108 + 1.109 + void m12() { 1.110 + try { 1.111 + checked(); 1.112 + } 1.113 + catch(RuntimeException exc) { } 1.114 + catch(Throwable exc) { } // ok 1.115 + } 1.116 + 1.117 + void m13() { 1.118 + try { 1.119 + runtime(); 1.120 + } 1.121 + catch(RuntimeException exc) { } 1.122 + catch(Throwable exc) { } // ok 1.123 + } 1.124 + 1.125 + void m14() { 1.126 + try { 1.127 + nothing(); 1.128 + } 1.129 + catch(RuntimeException exc) { } 1.130 + catch(Throwable exc) { } // ok 1.131 + } 1.132 + 1.133 + void m15() { 1.134 + try { 1.135 + checked(); 1.136 + } 1.137 + catch(RuntimeException exc) { } 1.138 + catch(Exception exc) { } //ok 1.139 + } 1.140 + 1.141 + void m16() { 1.142 + try { 1.143 + runtime(); 1.144 + } 1.145 + catch(RuntimeException exc) { } 1.146 + catch(Exception exc) { } //6: ok; latest: ok (Exception/Throwable always allowed) 1.147 + } 1.148 + 1.149 + void m17() { 1.150 + try { 1.151 + nothing(); 1.152 + } 1.153 + catch(RuntimeException exc) { } 1.154 + catch(Exception exc) { } //6: ok; latest: ok (Exception/Throwable always allowed) 1.155 + } 1.156 + 1.157 + void m18() { 1.158 + try { 1.159 + checked(); 1.160 + } 1.161 + catch(RuntimeException exc) { } 1.162 + catch(InterruptedException exc) { } 1.163 + catch(Exception exc) { } //6: ok; latest: ok (Exception/Throwable always allowed) 1.164 + } 1.165 + 1.166 + void m19() { 1.167 + try { 1.168 + runtime(); 1.169 + } 1.170 + catch(RuntimeException exc) { } 1.171 + catch(InterruptedException exc) { } //never thrown in try 1.172 + catch(Exception exc) { } //6: ok; latest: ok (Exception/Throwable always allowed) 1.173 + } 1.174 + 1.175 + void m20() { 1.176 + try { 1.177 + nothing(); 1.178 + } 1.179 + catch(RuntimeException exc) { } 1.180 + catch(InterruptedException exc) { } //never thrown in try 1.181 + catch(Exception exc) { } //6: ok; latest: ok (Exception/Throwable always allowed) 1.182 + } 1.183 + 1.184 + void m21() { 1.185 + try { 1.186 + checked(); 1.187 + } 1.188 + catch(RuntimeException exc) { } 1.189 + catch(Exception exc) { } // ok 1.190 + } 1.191 + 1.192 + void m22() { 1.193 + try { 1.194 + runtime(); 1.195 + } 1.196 + catch(RuntimeException exc) { } 1.197 + catch(Exception exc) { } // 6: ok; latest: ok (Exception/Throwable always allowed) 1.198 + } 1.199 + 1.200 + void m23() { 1.201 + try { 1.202 + nothing(); 1.203 + } 1.204 + catch(RuntimeException exc) { } 1.205 + catch(Exception exc) { } // 6: ok; latest: ok (Exception/Throwable always allowed) 1.206 + } 1.207 + 1.208 + void m24() { 1.209 + try { 1.210 + checked(); 1.211 + } 1.212 + catch(RuntimeException exc) { } 1.213 + catch(Error exc) { } 1.214 + catch(Throwable exc) { } //ok 1.215 + } 1.216 + 1.217 + void m25() { 1.218 + try { 1.219 + runtime(); 1.220 + } 1.221 + catch(RuntimeException exc) { } 1.222 + catch(Error exc) { } 1.223 + catch(Throwable exc) { } //6: ok; latest: ok (Exception/Throwable always allowed) 1.224 + } 1.225 + 1.226 + void m26() { 1.227 + try { 1.228 + nothing(); 1.229 + } 1.230 + catch(RuntimeException exc) { } 1.231 + catch(Error exc) { } 1.232 + catch(Throwable exc) { } //6: ok; latest: ok (Exception/Throwable always allowed) 1.233 + } 1.234 + 1.235 + void m27() { 1.236 + try { 1.237 + checked(); 1.238 + } 1.239 + catch(RuntimeException exc) { } 1.240 + catch(Error exc) { } 1.241 + catch(InterruptedException exc) { } 1.242 + catch(Throwable exc) { } //6: ok; latest: ok (Exception/Throwable always allowed) 1.243 + } 1.244 + 1.245 + void m28() { 1.246 + try { 1.247 + runtime(); 1.248 + } 1.249 + catch(RuntimeException exc) { } 1.250 + catch(Error exc) { } 1.251 + catch(InterruptedException exc) { } //never thrown in try 1.252 + catch(Throwable exc) { } //6: ok; latest: ok (Exception/Throwable always allowed) 1.253 + } 1.254 + 1.255 + void m29() { 1.256 + try { 1.257 + nothing(); 1.258 + } 1.259 + catch(RuntimeException exc) { } 1.260 + catch(Error exc) { } 1.261 + catch(InterruptedException exc) { } //never thrown in try 1.262 + catch(Throwable exc) { } //6: ok; latest: ok (Exception/Throwable always allowed) 1.263 + } 1.264 + 1.265 + void m30() { 1.266 + try { 1.267 + checked(); 1.268 + } 1.269 + catch(RuntimeException exc) { } 1.270 + catch(Error exc) { } 1.271 + catch(Throwable exc) { } //ok 1.272 + } 1.273 + 1.274 + void m31() { 1.275 + try { 1.276 + runtime(); 1.277 + } 1.278 + catch(RuntimeException exc) { } 1.279 + catch(Error exc) { } 1.280 + catch(Throwable exc) { } //6: ok; latest: ok (Exception/Throwable always allowed) 1.281 + } 1.282 + 1.283 + void m32() { 1.284 + try { 1.285 + nothing(); 1.286 + } 1.287 + catch(RuntimeException exc) { } 1.288 + catch(Error exc) { } 1.289 + catch(Throwable exc) { } //6: ok; latest: ok (Exception/Throwable always allowed) 1.290 + } 1.291 + 1.292 + void m33() { 1.293 + try { 1.294 + checked(); 1.295 + } 1.296 + catch(InterruptedException exc) { } //ok 1.297 + } 1.298 + 1.299 + void m34() { 1.300 + try { 1.301 + runtime(); 1.302 + } 1.303 + catch(InterruptedException exc) { } //never thrown in try 1.304 + } 1.305 + 1.306 + void m35() { 1.307 + try { 1.308 + nothing(); 1.309 + } 1.310 + catch(InterruptedException exc) { } //never thrown in try 1.311 + } 1.312 +}