This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 125566

Summary: format source and make fields final
Product: java Reporter: fommil <fommil>
Component: HintsAssignee: Jan Lahoda <jlahoda>
Status: RESOLVED FIXED    
Severity: blocker CC: gualtiero65, jbecicka, jlahoda, jpokorsky, markiewb
Priority: P3    
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:

Description fommil 2008-01-18 14:36:52 UTC
In Eclipse, the formatter/code cleanup functionality is capable of discovering when it is possible to make a field final (e.g. the field is private and never 
reassigned).

As final fields are fantastic for visibility in concurrency and anonymous inner classes, it would be productive if NetBeans did a similar code cleanup.
Comment 1 fommil 2008-03-20 21:53:27 UTC
Has this anyone been assigned to anyone? I think it's a fairly major oversight of NetBeans not to have this support... it's in Eclipse and almost everybody I 
know uses it and would miss it dearly if they came over to NetBeans.
Comment 2 David Strupl 2012-07-02 16:08:49 UTC
Jan, do we have "add final" hint? Can it be applied as part of inspect and transform? If so this ENH might be closed as implemented (???).
Comment 3 Jan Lahoda 2012-07-03 07:41:14 UTC
I don't think we have such a hint, but it surely can be added.
Comment 4 markiewb 2012-12-28 22:33:48 UTC
*** Bug 201406 has been marked as a duplicate of this bug. ***
Comment 5 markiewb 2013-01-12 13:53:39 UTC
@Jan: I guess there is no change to get this feature in 7.3?! Will you please set the target version to PLAN or NEXT?
Comment 6 markiewb 2013-01-12 14:52:36 UTC
(In reply to comment #5)
> @Jan: I guess there is no change to get this feature in 7.3?! Will you please
> set the target version to PLAN or NEXT?

Typo: @Jan: I guess there is no chance to get this feature in 7.3?! Will you please set the target version to PLAN or NEXT?
Comment 7 Jan Lahoda 2013-01-14 17:23:18 UTC
(In reply to comment #6)
> (In reply to comment #5)
> > @Jan: I guess there is no change to get this feature in 7.3?! Will you please
> > set the target version to PLAN or NEXT?
> 
> Typo: @Jan: I guess there is no chance to get this feature in 7.3?! Will you

Correct - 7.3 is feature frozen for a long time, and is "code frozen" since last week, so unfortunately no chance to add any stuff unless it is a stopper.

Trunk is not open for feature integrations yet, but I created a private branch that I intend to merge into trunk once it will be open for features, and tried to implement a "field can be made final" hint there:
http://hg.netbeans.org/jet-main/rev/a8007ad79e19

> please set the target version to PLAN or NEXT?
Comment 8 Quality Engineering 2013-01-29 03:28:49 UTC
Integrated into 'main-golden', will be available in build *201301290001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/a8007ad79e19
User: Jan Lahoda <jlahoda@netbeans.org>
Log: #125566: hint "field can be final".
Comment 9 Jan Lahoda 2013-01-31 12:28:39 UTC
In daily builds now.
Comment 10 nezda 2013-10-08 05:07:50 UTC
I see (in 7.4 RC2) this is implemented for fields (controlled by Preferences > Editor > Hints > (Language: Java) # Threading # Field Can Be Final which is awesome.

I think this feature would be even more useful if it could also make method parameters and local variables final (its implemented this way in Eclipse).  This expanded functionality was specifically requested in duplicate https://netbeans.org/bugzilla/show_bug.cgi?id=201406 .