0

Does anyone have suggestions regarding getting rid of "final" modifiers on method- as well as constructor-parameters (without having to do it manually)? I've come to the conclusion that I don't want these modifiers anymore, as it clutters the method signatures (as a consequence I also have to get rid of JSR 305 @Nonnull annotations and provide an annotation on the package level).

Johannes
  • 2,021
  • 2
  • 23
  • 40

2 Answers2

1

Using final in method signatures is a good practise.

If you still want to remove them, Go to Eclipse Window < Preferences < Java < Editor < Save actions.

If Additional Actions is checked, Click Configure < Code Style

Uncheck "use modifier final where possible".

Note : This will help you to get rid of new occurrences of final, but will not remove existing ones.

See here for useful info.

Hope this helps.

Ric
  • 1,074
  • 1
  • 7
  • 12
0

Maybe I can convince you to keep the final modifiers, as it helps the compiler to optimize your code. Otherwise just use your favourite generic text editor and replace in all files: "(final " with "" and ", final " with ", " (depending on whether you have a space or not)

Philip Helger
  • 1,814
  • 18
  • 28
  • 1
    Do you have evidence that there's optimization for *parameters* being final? – Jon Skeet May 17 '13 at 09:08
  • Yes, I have spaces and I your expression shouldn't have any side-effects (as I'm also using the final modifier on almost all instances, classes...). – Johannes May 17 '13 at 09:14
  • @phloc I read on various pages that the resulting byte code is exactly the same, no matter if parameters are final or not. This means that there are no optimizations done by the compiler. – Sky May 17 '13 at 10:07