以下のコードを4.2(juno)以降のeclipseでコンパイルするとeclipseがコンパウイルする際にエラーになる。
※コード自体は意味はなくエラーの発生を確認するために出来るだけ小さくしてる。
package hoge;
import java.io.StringWriter;
public class Test {
public static void main(String[] args) {
for (int a = 0; a < 2; a++) {
StringWriter b = null;
try {
} finally {
if (b != null) {
try {
b.close();
} catch (Exception e) {
}
}
for (int c = 0; c < 2; c++) {
try {
b.close();
} catch (Exception e) {
throw new RuntimeException();
}
}
}
}
}
}
発生するエラーは以下の様な内容。
Errors occurred during the build.
Errors running builder 'Java Builder' on project 'work'.
org.eclipse.jdt.internal.compiler.ast.ThrowStatement
たぶん、eclipse 4.2から追加されたnullチェックの機能が影響しているんだと思うけど、バグかなぁ。
そのうち解決してくれるといいけど・・・。
package hoge;
import java.io.StringWriter;
public class Test {
public static void main(String[] args) {
for (int a = 0; a < 2; a++) {
StringWriter b = null;
try {
} finally {
if (b != null) {
try {
b.close();
} catch (Exception e) {
}
}
for (int c = 0; c < 2; c++) {
try {
b.close();
} catch (Exception e) {
throw new RuntimeException();
}
}
}
}
}
}