On Tue, 30 Jun 2026 18:56:16 GMT, Serguei Spitsyn <[email protected]> wrote:

>> JVMTI ForceEarlyReturnVoid can be used to return early from a constructor or 
>> class initializer. Early return from a constructor with strictly-initialized 
>> instance fields is problematic, as is early return from a class initializer 
>> when there are strictly-initialized static fields. The proposal for the 
>> initial integration is to keep it simple and just disallow 
>> ForceEarlyReturnVoid to return early from a value class constructor.
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> src/hotspot/share/prims/jvmti.xml line 3401:
> 
>> 3399:           The implementation is unable to force the current frame to 
>> return
>> 3400:           (e.g. current frame is executing a native method or the 
>> current frame is the
>> 3401:           constructor for a value class)
> 
> It is nice that the value class initializers are not impacted, so there is no 
> need to return `OPAQUE_FRAME` for value class initializer frames.

The more general restriction should probably be that ForceEarlyReturnVoid 
should fail for constructors if the class has strictly-initialized instance 
fields, and fail for class initializers if the class has strictly-initialized 
static fields. We can look at that later.

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

PR Review Comment: 
https://git.openjdk.org/valhalla/pull/2604#discussion_r3501289383

Reply via email to