Win a copy of The Java Performance Companion this week in the Performance forum!
    Bookmark Topic Watch Topic
  • New Topic

Final modifier applied to local variables - Java performance tuning

 
Kevin Hermann
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi,

A few developers in my company have encountered websites that claim that using the final modifier on local variables creates a slight performance boost for a Java application.  We are using WebSphere Portal 6.1 and WAS 7.0 and we use JSR 168/286 Portlets, EJB 3.0, Web Services, and Java 6. It's just that if the final modifier on local variables was truly a performance tuning tip I'm sure it would be general Java knowledge and would have been covered in the official SCJP book (Kathy & Bert). Using a final modifier should only be applied to a variable if a client with access to that variable has an opportunity to change the object it is referring to and this behavior is not desired.

Yesterday I posted this thread on the JSP forum and it appears to have been moved. This morning I was looking for this thread to see if anyone else had provided replies.

If anyone with expertise in this area can comment so I can share this finding with my peers it will be greatly appreciated.

Cheers!
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
When a thread is moved on the Ranch, it just goes from one forum to some other, more you just click on it in the original forum, and you're automatically taken to the new location in the new forum. It's in "Java in General" now, and this link should take you there:

http://www.coderanch.com/t/506424/java/java/Final-modifier-Java-performance-tuning

I'll close this for you, as it's just a duplicate.
 
    Bookmark Topic Watch Topic
  • New Topic