test/tools/javac/6558548/T6558548.java

Wed, 16 Mar 2011 11:12:26 +0000

author
mcimadamore
date
Wed, 16 Mar 2011 11:12:26 +0000
changeset 935
5b29f2a85085
child 990
9a847a77205d
permissions
-rw-r--r--

6558548: The compiler needs to be aligned with clarified specification of throws
Summary: Javac should issue unconditional warnings when 'dead' catch clauses are detected
Reviewed-by: jjg

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

mercurial