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 201406 - Automatically added final modifiers
Summary: Automatically added final modifiers
Status: REOPENED
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 7.0.1
Hardware: PC Linux
: P3 normal with 6 votes (vote)
Assignee: Jan Lahoda
URL: http://twelve-programmers.blogspot.co...
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-29 16:52 UTC by gualtiero65
Modified: 2017-04-19 14:52 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description gualtiero65 2011-08-29 16:52:55 UTC
Hi,

it would be nice to have NB to automatically add (as Hint and/or as formatting opion) final modifier to private fields, method parameters and local variables.

This is a feature I used in Eclipse. See the URL for better explanation.

Thanks,

Gualtiero
Comment 1 markiewb 2012-12-28 22:33:48 UTC

*** This bug has been marked as a duplicate of bug 125566 ***
Comment 2 runiter 2016-02-17 15:01:31 UTC
Although netbean now hints that a field can be declared as final, this is not sufficient as the original poster had requested final to be added everywhere including "local variables" and "method parameters" (as is the case in eclipse).

Also hinting alone is not sufficient. It'd be much nicer if netbean could automatically add final wherever possible (add it as an option to onSave actions instead of hint). This is also the case in eclipse.

For these reasons I'm re-opening this issue.
Comment 3 jason3421 2017-04-19 14:52:48 UTC
IntelliJ also allows this: https://intellij-support.jetbrains.com/hc/en-us/community/posts/206185619-Auto-add-the-final-modifier-to-newly-declared-variables-values

Here is an idea for an additional feature that will help Netbeans stand even higher above Eclipse/IntelliJ. Allow the user (me!) to set a font color for non-final variables and optionally hide the final keyword all together (i.e. it's not displayed in the IDE!). E.g. say 'orange' (for me) represents all non-final variables, that's my chosen visual representation for non-final variables, done :) The 'final' attribute can then be cleanly added to the popup that already shows the variable type (cursor on variable, ctrl + space to see that popup). Thanks for reading!