Re: RFR: 8272756: Remove unnecessary explicit initialization of volatile variables in java.desktop

2021-08-23 Thread Alexey Ivanov
On Mon, 23 Aug 2021 17:57:52 GMT, Sergey Bylokhov  wrote:

>> Maybe it's kind of a protection from a race. Yet it's possible either way: 
>> another thread could see `essentialTags == null` before this one initialises 
>> the field.
>
> I think we can drop it completely.

Agree.

-

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


Re: RFR: 8272756: Remove unnecessary explicit initialization of volatile variables in java.desktop

2021-08-23 Thread Sergey Bylokhov
On Mon, 23 Aug 2021 13:08:02 GMT, Alexey Ivanov  wrote:

>> Looks like there's no purpose, `tags` is not used after assignment
>
> Maybe it's kind of a protection from a race. Yet it's possible either way: 
> another thread could see `essentialTags == null` before this one initialises 
> the field.

I think we can drop it completely.

-

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


Re: RFR: 8272756: Remove unnecessary explicit initialization of volatile variables in java.desktop

2021-08-23 Thread Alexey Ivanov
On Mon, 23 Aug 2021 06:35:34 GMT, Сергей Цыпанов 
 wrote:

>> src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFIFD.java 
>> line 64:
>> 
>>> 62: Set 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

Maybe it's kind of a protection from a race. Yet it's possible either way: 
another thread could see `essentialTags == null` before this one initialises 
the field.

-

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


Re: RFR: 8272756: Remove unnecessary explicit initialization of volatile variables in java.desktop

2021-08-23 Thread Сергей Цыпанов
On Fri, 20 Aug 2021 21:26:41 GMT, Sergey Bylokhov  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 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


Re: RFR: 8272756: Remove unnecessary explicit initialization of volatile variables in java.desktop

2021-08-20 Thread Sergey Bylokhov
On Fri, 20 Aug 2021 09:41:15 GMT, Сергей Цыпанов 
 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 tags = essentialTags;
> 63: if (tags == null) {
> 64: essentialTags = Set.of(

What is the purpose of the local tags here?

-

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


RFR: 8272756: Remove unnecessary explicit initialization of volatile variables in java.desktop

2021-08-20 Thread Сергей Цыпанов
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._

-

Commit messages:
 - 8272756: Remove unnecessary explicit initialization of volatile fields in 
java.desktop

Changes: https://git.openjdk.java.net/jdk/pull/5197/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk=5197=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8272756
  Stats: 50 lines in 25 files changed: 0 ins; 0 del; 50 mod
  Patch: https://git.openjdk.java.net/jdk/pull/5197.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/5197/head:pull/5197

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