Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » AJDT » Softening exception in try-with-resources
Softening exception in try-with-resources [message #901908] Tue, 14 August 2012 21:06 Go to previous message
Emanuel Rabina is currently offline Emanuel Rabina
Messages: 3
Registered: August 2012
Junior Member

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?
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic:Android/Aspectj w/Google Maps ant build fail
Next Topic:Help
Goto Forum:
  


Current Time: Sun May 19 20:02:50 EDT 2013

Powered by FUDForum. Page generated in 0.01685 seconds