Skip to content

Conversation

@theresa-m
Copy link
Contributor

@theresa-m theresa-m commented Dec 3, 2025

  • support fields set through the ConstantValue attribute
  • exclude 8th bit representing null restricted static field from type calculations
  • verbose messages for IllegalStateException
  • save unset strict field flags for final fields

This fixes more tests in test/hotspot/jtreg/runtime/valhalla/inlinetypes/verifier/StrictStaticFieldsTest.java. The final tests require the implementation of notifyStrictStaticAccess.

Related: #21884

@theresa-m theresa-m requested a review from dsouzai as a code owner December 3, 2025 21:30
@theresa-m theresa-m added comp:vm project:valhalla Used to track Project Valhalla related work labels Dec 3, 2025
@theresa-m theresa-m requested a review from hangshao0 December 3, 2025 21:30
buildGenericSpecialStackFrame(REGISTER_ARGS, 0);
updateVMStruct(REGISTER_ARGS);
void *resolveResult = resolveStaticFieldRef(_currentThread, NULL, ramConstantPool, index, J9_RESOLVE_FLAG_RUNTIME_RESOLVE | J9_RESOLVE_FLAG_CHECK_CLINIT, NULL);
void *resolveResult = resolveStaticFieldRef(_currentThread, NULL, ramConstantPool, index, J9_RESOLVE_FLAG_RUNTIME_RESOLVE | J9_RESOLVE_FLAG_CHECK_CLINIT, NULL
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When resolveResult is -1 (the <clinit> case where the class is in larval state ), ramStaticFieldRef is set to _currentThread->floatTemp1, the modification to classAndFlags at line 7706 won't be saved to the class/class constant pool.

I think putstatic has the same issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

putstatic on a strict field will not go through the clinit case, the check at line 918 should always be true. For getstatic when resolveResult is -1 the code will attempt to resolve the field again.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

putstatic on a strict field will not go through the clinit case

Is it correct to change the behaviour of <clinit> for putstatic ?

For getstatic when resolveResult is -1 the code will attempt to resolve the field again.

The code in getstatic is:

if ((void*)-1 != resolveResult) {
      goto retry;
}

So when resolveResult is not -1, it will attempt to resolve again.
It can be resolved by another call of getstatic or putstatic though. But J9StaticFieldRefStrictInitRead is not recorded for this call.


#if defined(J9VM_OPT_VALHALLA_STRICT_FIELDS)
if (J9ClassInitNotInitialized == (ramConstantPool->ramClass->initializeStatus & J9ClassInitStatusMask)) {
if (J9_STATIC_FIELD_STRICT_INIT_IS_UNSET(classAndFlags)) {
Copy link
Contributor

@hangshao0 hangshao0 Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the the <clinit> case, the classAndFlags here and in the else if below is also from ramStaticFieldRef (which is _currentThread->floatTemp1), not from the class/class constant pool.

- support fields set through the ConstantValue attribute
- exclude 8th bit representing null restricted static field from type calculations
- verbose messages for IllegalStateException
- save unset strict field flags for final fields

Signed-off-by: Theresa Mammarella <Theresa.T.Mammarella@ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:vm project:valhalla Used to track Project Valhalla related work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants