Re: effects of "final" in parameters
- From: Thomas Hawtin <usenet@xxxxxxxxxxxxxxxxx>
- Date: Tue, 28 Feb 2006 15:06:10 +0000
Chris Uppal wrote:
Final /fields/ are different, as are final methods -- and it's the latter that
are sometimes touted as an optimisation (which I doubt, but have never tried to
measure).
Years ago making a method used in an inner loop final could improve performance significantly. I found it useful for one get method once, and then removed the field. However, this century JVMs will inline methods anyway and it makes no difference.
Final fields may have some impact on performance from Java 1.5. They need not be reread, even when dealing with synchronised blocks and reading volatiles. I haven't tested to see whether that actually makes any difference. If you have a field that could be made final, it should be made final regardless of performance concerns.
Tom Hawtin
--
Unemployed English Java programmer
http://jroller.com/page/tackline/
.
- References:
- effects of "final" in parameters
- From: tom fredriksen
- Re: effects of "final" in parameters
- From: Chris Uppal
- effects of "final" in parameters
- Prev by Date: Re: How do java programmers cope with java missing c++ const?
- Next by Date: Re: Are javac -target and -source arguments broken in JDK 1.5 ?
- Previous by thread: Re: effects of "final" in parameters
- Next by thread: Re: effects of "final" in parameters
- Index(es):