On Fri, 8 May 2026 17:11:07 GMT, Serguei Spitsyn <[email protected]> wrote:
>> Is the behavior special when the frame's method is declared by a _value
>> class_, or when the requested local is a _value object_? (E.g., what happens
>> when I'm looking at the (value class) `Number` constructor and `this` is a
>> (value object) `BigInteger`?)
>
> @dansmithcode
> I'm not sure I fully understand the question. The requested local is a value
> `this` object. The API behavior is special in a case when two conditions are
> `true`: (1) the frame belongs to a value object constructor (so the cltor's
> class is a value class) and (2) the requested local is the `THIS` object from
> the slot 0. It is per our previous discussion on the `project-jep401` slack
> channel: We do not want mutable JNI reference to a value object to escape
> while it is under construction, so we return a JNI reference to a snapshot of
> the 'THIS' object.
An abstract value class can have identity and value subclasses.
abstract value class Number { ... }
value class Integer extends Number { ... }
class BigInteger extends Number { ... }
I'm asking what happens when you try to get `this` from a constructor of
`Number`: do you check whether `this` is a value object (an Integer, not a
BigInteger), or do you apply the special-case logic to _all_ values of `this`,
whether they are Integers or BigIntegers?
-------------
PR Review Comment:
https://git.openjdk.org/valhalla/pull/2412#discussion_r3210437895