[crac] RFR: Provide arguments for restore [v4]
Anton Kozlov
akozlov at openjdk.java.net
Sat Mar 5 09:39:32 UTC 2022
On Sat, 5 Mar 2022 09:17:26 GMT, Anton Kozlov <akozlov at openjdk.org> wrote:
>> This change adds an ability to receive a new set of command-line arguments in the restored Java instance. The supplied demo code shows a faster replacement for `javac`.
>
> Anton Kozlov has updated the pull request incrementally with two additional commits since the last revision:
>
> - Better error handling in hotspot
> - Call the main of provided class
I think I found a better approach to achieve the same. I didn't like the first argument was going to be ignored most of the time (considering use-cases like in the demo). So instead, we can require arguments provided for restore need to be an actual Class, which main method will be called, and the arguments. So `java -XX:CRaCRestore Main arg1" will restore the instance and execute Main.main(arg1) in that instance.
Comparing with the previous approach, it's like a program did
checkpointRestore();
mainClass, arguments = getAndParseNewArguments()
invoke(mainClass, "main", arguments)
Now the target Main class may handle new arguments right away, or store them to be used for later, like it was done in versions up to v3[1].
The demo is extended for Compile to be the Class, so examples above are still valid. Start-up time is roughly the same (actually a bit better, but it should be a noise).
[1] https://mail.openjdk.java.net/pipermail/crac-dev/2022-March/000132.html
-------------
PR: https://git.openjdk.java.net/crac/pull/16
More information about the crac-dev
mailing list