RFR: 8337102: JITTester: Fix breaks in static initialization blocks

Evgeny Nikitin enikitin at openjdk.org
Sat Jul 27 17:34:05 UTC 2024


Static initialisation blocks (SIBs) should not have `break`s in their code, as well as their descendants. Currently, StaticConstructorDefinitionFactory allows them, causing non-compilable constructions like this:


class Test_0 {
    static {
        if (true) {
            break; // <- compilation error here
        }
    }
}


It seems like previously an attempt have been made to resolve this by disabling SIBs whatsoever.

Currently, out of 100 generated tests we have 2-3 compilation errors.
Allowing SIBs raises this to 80 out of 100 tests failing due to erroneous 'break' blocks.
Disabling breaks in StaticConstructorDefinition gives us SIBs, and returns failure rate to the same 2-3%.
Disabling breaks in StaticConstructorDefinition doesn't prevent breaks from happening, as loop factories (`ForFactory`, `WhileFactory`, etc.) explicitly allow for breaks in their descendant trees.

Testing: 
1. 200-300 generations in various setups to get the numbers mentioned above;
2. I checked manually that breaks do not disappear from code,
3. ... and appear in loops' (for, while, do-while) descendants.

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

Commit messages:
 - 8337102: JITTester: Fix breaks in static initialization blocks

Changes: https://git.openjdk.org/jdk/pull/20310/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=20310&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8337102
  Stats: 3 lines in 2 files changed: 0 ins; 0 del; 3 mod
  Patch: https://git.openjdk.org/jdk/pull/20310.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/20310/head:pull/20310

PR: https://git.openjdk.org/jdk/pull/20310


More information about the hotspot-compiler-dev mailing list