Not yet again !
Remi Forax
forax at univ-mlv.fr
Sat Oct 21 08:04:39 UTC 2023
Hello,
in https://bugs.openjdk.org/browse/JDK-8317766,
the atomicity of a null restricted value class is set using a marker interface named LooselyConsistentValue.
Last year, we stop to use interfaces IdentityObject and ValueObject to specify value/identity-ness.
LooselyConsistentValue exhibits exactly the same bad behaviors as those interfaces.
A marker interface can not only be used to specify a property by implementing it, it can also be used as a type, worst it will appear as a type because of type inference.
As examples: Long and Double now have LooselyConsistentValue as a common super type and one can creates arrays of LooselyConsistentValue just to mess with the poor brain of everybody else trying to figure out exactly what it means.
I understand the relunctance to introduce a new keyword to avoid people to use that keyword because it may be faster at the expanse of the safety of the code.
But in reality, it's not a problem. A lot of people never heard about strictfp before it was retired. Being a keyword does not make it automatically popular.
A contrario, using a keyword extensively inside the JDK will make it popular. In my opinion, it's more important to ONLY use the keyword non-atomic (or whatever its name) on Long and Double inside the JDK than to use a marker interface instead a keyword.
Note: that an annotation is always a better as a "marker interface" than an interface, but I think we should stick to our mantra that an annotation should not change the behavior.
regards,
Rémi
More information about the valhalla-spec-observers
mailing list