On Tue, 24 Mar 2026 14:44:06 GMT, Chen Liang <[email protected]> wrote:

>> According to [Javadoc of 
>> `jdk.incubator.vector.Vector`](https://docs.oracle.com/en/java/javase/26/docs/api/jdk.incubator.vector/jdk/incubator/vector/Vector.html),
>>  vector classes are declared as value based class. However all vector 
>> classes (e.g. `IntVector256`) do not have `@jdk.internal.ValueBased`, so 
>> `DiagnoseSyncOnValueBasedClasses` does not affect if vector object are used 
>> as a monitor.
>> 
>> This PR fixes all of final classes of vector, but most of files were 
>> generated by `gen-src.sh`. Essense of this PR is a chenge for 
>> `X-VectorBits.java.template`.
>> After this change, we can see following logs if 
>> `-XX:DiagnoseSyncOnValueBasedClasses` is set and vector class is used as 
>> monitor object.
>> 
>> 
>> $ java --add-modules jdk.incubator.vector 
>> -XX:DiagnoseSyncOnValueBasedClasses=2  ValueBaseLock
>> WARNING: Using incubator modules: jdk.incubator.vector
>> [0.453s][info][valuebasedclasses] Synchronizing on object 0x00000000823b1258 
>> of klass jdk.incubator.vector.IntVector256
>> [0.453s][info][valuebasedclasses]       at 
>> ValueBaseLock.run(ValueBaseLock.java:9)
>> [0.453s][info][valuebasedclasses]       - locked <0x00000000823b1258> (a 
>> jdk.incubator.vector.IntVector256)
>> [0.453s][info][valuebasedclasses]       at 
>> java.lang.Thread.runWith(java.base@27-internal/Thread.java:1540)
>> [0.453s][info][valuebasedclasses]       at 
>> java.lang.Thread.run(java.base@27-internal/Thread.java:1527)
>
> Re-`@ValueBased`:
> 
> 1. We need such an excerpt in every immediately annotated classes:
> 
>  * <p>This is a <a 
> href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">value-based</a>
>  * class; programmers should treat instances that are
>  * {@linkplain #equals(Object) equal} as interchangeable and should not
>  * use instances for synchronization, or unpredictable behavior may
>  * occur. For example, in a future release, synchronization may fail.
> 
> 
> 2. `VectorMask` and `VectorShuffle` should be marked so too.

@liach Thanks for your review!
I filed [JDK-8380955](https://bugs.openjdk.org/browse/JDK-8380955) ( #30443 ) 
for FFM, and [JDK-8380956](https://bugs.openjdk.org/browse/JDK-8380956) ( 
#30444 ) for HexFormat. I hope they could have the review.

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

PR Comment: https://git.openjdk.org/jdk/pull/30392#issuecomment-4132279585

Reply via email to