<Swing Dev> RFR: 8272756: Remove unnecessary explicit initialization of volatile variables in java.desktop

Сергей Цыпанов github.com+10835776+stsypanov at openjdk.java.net
Mon Aug 23 06:38:27 UTC 2021


On Fri, 20 Aug 2021 21:26:41 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:

>> This is a continuation of
>> 
>> - https://bugs.openjdk.java.net/browse/JDK-6736490
>> - https://bugs.openjdk.java.net/browse/JDK-8035284
>> - https://bugs.openjdk.java.net/browse/JDK-8145680
>> - https://bugs.openjdk.java.net/browse/JDK-8251548
>> 
>> As mentioned in JDK-6736490:
>> 
>> _An explicit initialization of a volatile class instance variable, such as private volatile Object = null; or private volatile int scale = 0; is unnecessary since the Java spec automatically initializes objects to null and primitive type short, int, long, float and double to 0 and boolean to false. Explicit initialization of volatile variable to a value the same as the default implicit initialized value results in an unnecessary store and membar operation._
>
> src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFIFD.java line 64:
> 
>> 62:         Set<Integer> tags = essentialTags;
>> 63:         if (tags == null) {
>> 64:             essentialTags = Set.of(
> 
> What is the purpose of the local tags here?

Looks like there's no purpose, `tags` is not used after assignment

-------------

PR: https://git.openjdk.java.net/jdk/pull/5197


More information about the swing-dev mailing list