On Tue, 30 Jun 2026 19:09:39 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). > > test/hotspot/jtreg/serviceability/jvmti/ForceEarlyReturn/ForceEarlyReturnValueClass.java > line 55: > >> 53: while (!TestCase.stop) {} >> 54: TestCase.finished = true; >> 55: } > > Nit: We may need one more test case for a helper method invoked from a value > object constructor. My understanding is that such methods can not initialize > the value object fields. The instance fields of a value class are strictly-initialized fields so have to be initialized before super or leaking "this" by invoking an instance method. It would be feasible to have the test exercise ForceEarlyReturn to return early from something that the constructor invokes after super. I add something as that would at least test the function with a value class constructor on the stack and not the top frame. ------------- PR Review Comment: https://git.openjdk.org/valhalla/pull/2604#discussion_r3503838697
