なぜ Eclipse の場合、これは try-with アームで管理されるのですか?
BufferedReader reader = null;
try {
if (condition) {
try {
reader = method1();
} catch (Exception e) {
...
}
}
if (reader == null) {
reader = method2();
}
do things ...
} catch(Exception e) {
...
} finally {
if (reader != null) {
reader.close();
}
}
このケースを処理するためのより良い方法はありますか? または日食からのジャンク警告ですか?
このケースは無効です:
try (BufferedReader reader = null) {
if (condition) {
reader = method1();
} else {
reader = method2();
}
do things ...
}