RFR: 8145680: Remove unnecessary explicit initialization of volatile variables in java.base

Alan Bateman Alan.Bateman at oracle.com
Mon Dec 21 12:01:09 UTC 2015



On 19/12/2015 13:07, Claes Redestad wrote:
> Hi,
>
> initializing volatile fields to their default value has a well-known 
> performance penalty, and removing these should typically be safe. This 
> patch addresses java.base.
>
> There are however some corner cases that we need to check for, see 
> examples and discussion in 
> http://cs.oswego.edu/pipermail/concurrency-interest/2015-December/014767.html
>
> When meticulously going through and checking each usage for odd 
> pattern like this I accidentally did a bit of extra cleanup, mostly 
> addressing a number of cases where the volatile field was being read 
> twice. Sorry!
>
> Bug: https://bugs.openjdk.java.net/browse/JDK-8145680
>
> Webrev: http://cr.openjdk.java.net/~redestad/8145680/webrev.01/
I skimmed through the webrev and it looks okay. A few classes are 
arguably less-readable now due to the double negatives (!invalid).

I see the changes to URI have been split out to a separate issue because 
it does other clean-ups. In this case it might be better to keep 
defineString and it return the String rather than calling toString and 
needing to explain the side effect in several places.

-Alan.



More information about the core-libs-dev mailing list