[crac] RFR: 8364538: [CRaC] Test CRaCIgnoreRestoreIfUnavailable

Timofei Pushkin tpushkin at openjdk.org
Fri Aug 1 14:29:13 UTC 2025


On Fri, 1 Aug 2025 14:11:53 GMT, Timofei Pushkin <tpushkin at openjdk.org> wrote:

> Adds tests for `CRaCIgnoreRestoreIfUnavailable`.
> 
> The case for incompatible CPU features is not tested, although I believe it should work. Such test would be more complex (to the best of my knowledge, emulation is needed to be able to reduce the set of available features between checkpoint and restore) so it deserves a separate task. It would be something like what `test/jdk/jdk/crac/CPUFeatures/CPUFeatures.sh` does (have never run it, not sure if it works).

test/jdk/jdk/crac/ignoreRestore/RestoreIfPossibleTest.java line 65:

> 63: 
> 64:         final var out = builder.startRestoreWithArgs(null, List.of(Main.class.getName(), "false")).outputAnalyzer();
> 65:         out.stdoutShouldNotContain(WARMUP_MSG).stdoutShouldContain(MAIN_MSG);

Currently `MAIN_MSG` will actually be printed twice: once from newly launched main (because we provided new arguments on restore) and once from the original main.

Such behavior is inconvenient, especially when `-jar <jar-path>` is used (because new args feature does not support this yet and fails). It will be fixed once we add something like `-XX:+CRaCExecuteNewMain` required to execute new args:
- By default `CRaCExecuteNewMain` is false and restore fails if new args are provided (unless `-XX:+CRaCIgnoreRestoreIfUnavailable` is provided, then they should be ignored for restore but used if restore fails for another reason)
- With `-XX:+CRaCExecuteNewMain` new args are mandatory

With `-XX:+CRaCIgnoreRestoreIfUnavailable -XX:+CRaCExecuteNewMain` the behavior will be as it is now with just `-XX:+CRaCIgnoreRestoreIfUnavailable`.

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

PR Review Comment: https://git.openjdk.org/crac/pull/255#discussion_r2248123783


More information about the crac-dev mailing list