Summary: | Unexpected 'The final local variable obj may already have been assigned' reported | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Dani Megert <daniel_megert> |
Component: | Core | Assignee: | Philipe Mulet <philippe_mulet> |
Status: | VERIFIED INVALID | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | CC: | jerome_lanneluc, mauromol, philippe_mulet |
Version: | 3.5 | ||
Target Milestone: | 3.5 M4 | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Whiteboard: |
Description
Dani Megert
2008-10-30 11:35:32 EDT
This behavior is expected from JLS 16.2.15 and the fact that ArithmeticException is a runtime exception; and btw javac agrees with us: X.java:10: variable obj might already have been assigned obj= new Object(); ^ 1 error Closing as invalid Added InitializationTest#test195 OK, but can it happen? After the assignment, we issue a branch instruction to the end of the try/catch; in theory any instruction could cause an unchecked exception to be fired, and possibly an ArithmeticException; though you'd be extremely unlucky. <g> The language spec is too much defensive here, but this is what it takes to ensure no possible evil code is tampering with 'final' rules. Reopen to assign (In reply to comment #2) > Closing as invalid Verified for 3.5M4 Hi, before opening a new bug report, I was wondering if the same applies to the following case, where a *checked* exception is thrown: final MessageDigest digest; try { digest = MessageDigest.getInstance("SHA-256"); } catch (final NoSuchAlgorithmException e) { digest = null; } Here the error is given at "digest = null", but I can't think of any way in which it may have already been assigned. |