Softening exception in try-with-resources [message #901908] |
Tue, 14 August 2012 21:06  |
Eclipse User |
|
|
|
I've been making use of the new try-with-resources syntax when I upgraded to AJDT 2.2.0 a few weeks back (and could start using Java 7 in my AspectJ projects), but the aspects I wrote to soften IOException don't seem to catch the automatic close() created by the new syntax:
try (BufferedReader reader = new BufferedReader(new FileReader("test.txt"))) {
System.out.println(reader.readLine());
}
...
declare soft: IOException: within(*)
Eclipse reports a compile error on the try... line, saying: "Unhandled exception type IOException thrown by automatic close() invocation on reader". The only way I've managed to get around this is to add a catch clause to the try for the IOException, or to have the method throw IOException, which kind of goes against the reason I did the exception softening in the first place (to cut down on throws or catch clauses).
Is there another way to soften the automatic close while using the new syntax?
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.07088 seconds