Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 384922 - [quick fix] Assign parameter to field creates non-final field
Summary: [quick fix] Assign parameter to field creates non-final field
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.8   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 389246 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-07-12 07:34 EDT by Rüdiger Herrmann CLA
Modified: 2012-09-11 09:49 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rüdiger Herrmann CLA 2012-07-12 07:34:19 EDT
The 'Assign parameter to field' quick assist for constructors does not declare the created field as final any more. Prior to version 3.8 the field was made final.

Given this code
  class Foo {
    Foo( Object param ) {
    }
  }

Invoking the quick assist on 'param' would result in this code:
  class Foo {
    private *final* Object param;
    Foo( Object param ) {
      this.param = param;
    }
  }
  
Since 3.8, a non-final field 'param' is created:
  private Object param;

This requires to manually correct the quick assist code in almost all cases. Is this a bug or was this change made intentionally?
Comment 1 Deepak Azad CLA 2012-07-12 21:00:47 EDT
(In reply to comment #0)
> This requires to manually correct the quick assist code in almost all cases. Is
> this a bug or was this change made intentionally?

This is intentional, see bug 130922. If you like your fields to be final you can use the "Add final modifier to private fields" Save Action or Clean up. 

You can also use "Change modifiers to final where possible" quick assist on a selection.
Comment 2 Markus Keller CLA 2012-09-11 09:49:55 EDT
*** Bug 389246 has been marked as a duplicate of this bug. ***