JDK-8351362 : [lworld] Post-process @Strict annotation for testing
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: test
  • Affected Version: repo-valhalla
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2025-03-06
  • Updated: 2025-08-29
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
repo-valhallaUnresolved
Related Reports
Blocks :  
Description
We need test infrastructure for Valhalla HotSpot tests that does the following:

- Introduce a `@Strict` annotation (within the test space, *not* the same thing as `jdk.internal.vm.annotation.Strict`, which we can eventually garbage-collect)

- Pre-process classes to spot uses of `@Strict` applied to a field

- Where identified, rewrite that field's flags to set ACC_STRICT (0x0800)

- Inspect the <init> methods of these classes, and if strict fields are left uninitialized before the javac-generated 'super()' call, move the 'super()' call to the end, immediately before 'return'

- Regenerate the StackMapTable of each <init> method, as needed, to indicate larval stack frames where the field has been set

- Adjust the class file version number, if necessary

With these changes, update all tests that use `jdk.internal.vm.annotation.Strict` today so that they:

- Use the test annotation instead
- Invoke the class pre-processor as part of the compilation step

The class files used to run these tests should be mostly identical to the ones that are generated today, just produced with different tooling.
Comments
Goal: Remove the use of jdk.internal..vm.annotation.Strict and consistently use a fabricated test-local strict instead.
29-08-2025

A pull request was submitted for review. Branch: lworld URL: https://git.openjdk.org/valhalla/pull/1395 Date: 2025-03-12 14:15:31 +0000
12-03-2025

Some possible complications to watch for in tests: - Some tests generate sources and compile them with the javac API, that compilation step will need to include the rewrite - Some tests may be sensitive to precise class file bits, might need tweaking
07-03-2025

This tool, including the annotation, is intended as a test support feature for now. We'll need to revisit whether we're comfortable leaving clients of `@NullRestricted` outside of tests to generate their own class files that use ACC_STRICT. TBD.
06-03-2025

The constructor rewrite feature is open-ended, it needs to be good enough to support most of the tests, but doesn't have to be perfect. It's an experiment. Potential complications that it might just give up on: - Classes with captures/enclosing instances - Constructors with 'return' statements - Super calls with arguments - Constructors with 'this' dependencies If we can handle 99% of the tests, we can tweak the remaining 1%. (Workaround: explicitly set your strict fields in the constructor before an explicit 'super()' call.)
06-03-2025

Note that the relevant tests are coming from this PR, plus some followup work: https://github.com/openjdk/valhalla/pull/1389
06-03-2025