On Wed, 20 May 2026 19:12:06 GMT, Chen Liang <[email protected]> wrote:

>> src/java.base/share/classes/jdk/internal/reflect/MethodHandleAccessorFactory.java
>>  line 123:
>> 
>>> 121:      * @throws UnsupportedOperationException if the constructor is not 
>>> from
>>> 122:      *         a superclass, if the instantiated class is a value 
>>> class, or if
>>> 123:      *         any superclass between the declaring class of the 
>>> constructor and
>> 
>> The "any superclass" rule should apply to value classes too.
>> 
>> (Here's how I described it in the serialization spec: "Then, in 
>> superclass-to-subclass order, starting with the first superclass that 
>> implements Serializable: if the class is a value class, or if it declares an 
>> instance field with the ACC_STRICT_INIT field modifier (see [JVMS 
>> 4.5](https://cr.openjdk.org/~dlsmith/jep401/jep401-20260518/specs/strict-fields-jvms.html#jvms-4.5)),
>>  an InvalidClassException is thrown.")
>
> Do you mean to reject any superclass that is an abstract value class here?

Yes. Any value class, abstract or not, with fields or not, must have its 
instances initialized using a real constructor.

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

PR Review Comment: 
https://git.openjdk.org/valhalla/pull/2350#discussion_r3277088701

Reply via email to