On Tue, 2 Jun 2026 17:26:43 GMT, Chen Liang <[email protected]> wrote:
>> src/java.base/share/classes/java/io/ObjectStreamClass.java line 1433:
>>
>>> 1431: */
>>> 1432: @SuppressWarnings("unchecked")
>>> 1433: private static MethodHandle getDeserializingValueCons(Class<?>
>>> clazz,
>>
>> `@DeserializeConstructor` was created for constructors or static factory
>> methods. Was there a usage for static methods at one point or maybe there
>> are plans to use it at some point? Asking because I see the usage on
>> constructors in the wrapper classes but not anywhere else. The tests, e.g.
>> ValueSerializationTest, also use it on the constructor.
>
> Yes, they were initially used on `valueOf` static methods. Turns out such
> uses introduced a performance regression for serialization benchmarks, and
> the annotations are moved onto the constructors instead.
So is the support for static methods a left-over? I'm wondering if
`getDeserializingValueCons` can be simplified and the
`DeserializeConstructor`'s doc updated. It's just just a question on
unused/untested code.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/31123#discussion_r3346622797