Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 520934

Summary: Save actions don't add final to try-with-resources
Product: [Eclipse Project] JDT Reporter: Jens Reimann <jreimann>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: stephan.herrmann
Version: 4.8   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard: stalebug

Description Jens Reimann CLA 2017-08-14 04:40:50 EDT
Having a piece of code like this:

----
try ( Foo bar = new Foo (); )  {
  foo.doStuff ();
}
----

And the settings: Java Editor -> Save actions

Code Style - Variable Declarations:
[X] Use final where possible
  [X] Private Fields [X] Parameter [X] Local variables

I would expect the code the cleaned up as:

----
try ( final Foo bar = new Foo (); )  {
      ^---^
  foo.doStuff ();
}
----

But the "final" keyword doesn't get added in the case of a try-with-resources expression.

Eclipse:

Version: Oxygen Release (4.7.0)
Build id: 20170620-1800
Comment 1 Eclipse Genie CLA 2019-10-13 14:13:42 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.