On Thu, 6 Aug 2026 19:56:59 GMT, Matias Saavedra Silva <[email protected]> 
wrote:

> [JDK-8376522](https://bugs.openjdk.org/browse/JDK-8376522) indicates that the 
> thisUninit should be applied even when uninitializedThis is on the stack. 
> Previous implementations failed to do this, so this patch properly enforces 
> this spec change. 
> 
> Now that both the stack and locals must be considered when applying 
> flagThisUninit, the origin of the flag needs to  be preserved, so the 
> StackMapReader now tracks if the flag originated from locals or the stack. 
> Since the stack is cleared between frames, only an uninitializedThis from 
> locals is preserved. 
> 
> In addition to VM changes, the ClassFile API had to be updated as it only 
> considered stack frame locals. The test case offered by @liach in the JBS 
> issue has been adapted to a JASM test to verify the change. Verified with 
> tier 1-5 tests.
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

I recommend the implementation to add a separate tracking flag for 
`uninitializedThis` on stack, because each stack map frame clears the previous 
stack.

You can rollback the jdk/internal/classfile changes: They are fixed in 
https://github.com/openjdk/jdk/pull/32224

src/hotspot/share/classfile/stackMapTable.cpp line 356:

> 354:     u2 stack_size = 1;
> 355:     u1 flags = _prev_frame->flags();
> 356:     stack[0] = parse_verification_type(&flags, CHECK_VERIFY_(_verifier, 
> nullptr));

Thsi is not correct - all stack map frames clear all previous stacks. So if a 
previous frame has `flagThisUninit` due to an `uninitializedThis` on the stack 
only, this logic is wrong if the new stack has no `uninitializedThis`

test/hotspot/jtreg/runtime/valhalla/inlinetypes/verifier/UninitThisOnStack.jasm 
line 66:

> 64:         stack_map this;
> 65:     invokespecial Method java/lang/Object."<init>":"()V";
> 66:     return;

Should we add a branching after super call to verify the `flagThisUninit` 
status is correctly removed too?

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

Changes requested by liach (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/32242#pullrequestreview-4877912632
PR Comment: https://git.openjdk.org/jdk/pull/32242#issuecomment-5210107381
PR Review Comment: https://git.openjdk.org/jdk/pull/32242#discussion_r3731611035
PR Review Comment: https://git.openjdk.org/jdk/pull/32242#discussion_r3732494716

Reply via email to