[PATCH] remove redundant initialization of volatile fields with default values

Сергей Цыпанов sergei.tsypanov at yandex.ru
Thu Aug 13 11:04:23 UTC 2020


previously I've sent an email regarding removal of redundant assignments if default values to volatile fields, see

There was a concern whether it's completely safe to remove those assignments from JMM point of view, see

Recently I've found a thread in concurrency-interest mailing list where Aleksey Shiplive tried to find a constraint
agians such removal: http://cs.oswego.edu/pipermail/concurrency-interest/2015-December/014767.html

It appears that there are no constraitns and Doug Lea mentions in
that "there is never any reason to explicitly initialize fields to 0/0.0/false/null"

Also there we similar code changes in java.base before:

- https://bugs.openjdk.java.net/browse/JDK-6736490
- https://bugs.openjdk.java.net/browse/JDK-8035284
- https://bugs.openjdk.java.net/browse/JDK-8145680

So I think now we can accept the patch as the changes appear to be safe.

Best regards,
Sergey Tsypanov
-------------- next part --------------
A non-text attachment was scrubbed...
Name: volatile.patch
Type: text/x-diff
Size: 6253 bytes
Desc: not available
URL: <https://mail.openjdk.java.net/pipermail/security-dev/attachments/20200813/5e2ef98e/volatile.patch>

More information about the security-dev mailing list