On Tue, 31 Mar 2026 14:19:48 GMT, ExE Boss <[email protected]> wrote:
>> On the review for [JDK-8380955](https://bugs.openjdk.org/browse/JDK-8380955)
>> (#30443), `Linker` and `FunctionDescriptor` do not need to be value based
>> class because they would not be treated as "value".
>> `Linker` is defined as providing a way to look up the canonical layouts
>> associated with the data types used by the ABI. `FunctionDescriptor`
>> represents the signature of a foreign function. They are not "value".
>>
>> Actually they and their child (final) classes do not have `@ValueBased`,
>> thus `javac` and `-XX:DiagnoseSyncOnValueBasedClasses` cannot identify if
>> they are used in anti-pattern of value based class. Thus this change does
>> not change behavior, just documentation updates.
>>
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> src/java.base/share/classes/java/lang/foreign/FunctionDescriptor.java line 45:
>
>> 43: *
>> 44: * @implSpec
>> 45: * Implementing classes are immutable, thread-safe.
>
> Suggestion:
>
> * Implementing classes are immutable, thread-safe and
> * <a
> href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">value-based</a>.
If we go for annotation we should not also mention value-based in the doc
(uniformly with what we've done in other places)
> src/java.base/share/classes/java/lang/foreign/FunctionDescriptor.java line 50:
>
>> 48: * @since 22
>> 49: */
>> 50: public sealed interface FunctionDescriptor permits
>> FunctionDescriptorImpl {
>
> Suggestion:
>
> @ValueBased
> public sealed interface FunctionDescriptor permits FunctionDescriptorImpl {
This I agree with. If a layout is value based -- well a function descriptor is
an aggregate of layouts, so that also seem value based? I know comparing
descriptors with `==` feels odd, but at the end of the day, that's the
semantics you get from value objects (and works compatibly with current
`FunctionDescriptor::equals`).
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/30481#discussion_r3233500303
PR Review Comment: https://git.openjdk.org/jdk/pull/30481#discussion_r3233509580