Community
Participate
Working Groups
Fix to go in ExceptionOccurrencesFinder. Essentially the changes already done for UnionType and twr do not fix the case when an exception in throws declaration is selected.
In the following snippet select void (the return type), and exit points will be marked including the closing } of twr and resource constructors. These are not marked when Throwable is selected in the throws clause. -------------------------------------------------------------------------------- void foo5() throws Throwable { FileReader reader = new FileReader("file1"); try (FileReader reader1 = new FileReader("file1"); FileReader reader2 = new FileReader("file2")) { int ch; while ((ch = reader1.read()) != -1) { reader.read(); } } } -------------------------------------------------------------------------------- While looking into this I also ran into an older issue. In the following snippet select 'Exception' in the throws clause => all three throw statements are marked even though 2 of the exceptions are caught. This is slightly different (and simpler to fix) than bug 75878 and bug 68305. ---------------------------------------------------------------------------- void foo(String s) throws Exception { try { if (s == null) throw new NullPointerException(); else if (s.length() > 10) throw new IllegalArgumentException(); else throw new Exception(); } catch (NullPointerException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } } ----------------------------------------------------------------------------
Looks the same as bug 68305. Here, the outer scope is the "throws" clause whereas in bug 68305, it's the outer "try" statement. Necessary analysis is exactly the same.
Created attachment 199369 [details] fix + test (In reply to comment #1) > In the following snippet select void (the return type), and exit points will be > marked including the closing } of twr and resource constructors. These are not > marked when Throwable is selected in the throws clause. > -------------------------------------------------------------------------------- > void foo5() throws Throwable { > FileReader reader = new FileReader("file1"); > try (FileReader reader1 = new FileReader("file1"); > FileReader reader2 = new FileReader("file2")) { > int ch; > while ((ch = reader1.read()) != -1) { > reader.read(); > } > } > } > -------------------------------------------------------------------------------- For now I have fixed the above problem. Bug 68305 is an older issue, which I think we should fix for 3.7.1.
.
Verified using JDT feature patch v20110714-1300.