I am experimenting with CRaC on Azul JVM. I have built a checkpoint of my program with
$JAVA_CMD -XX:CRaCCheckpointTo=cr -jar target/cractest-0.1.0-standalone.jar
And I can restore it successfully with
$JAVA_CMD -XX:CRaCRestoreFrom=cr
It works all right. In the next step, I want to pass arguments to the program on restore, so the program can pick it up, ideally just like the following:
$JAVA_CMD -XX:CRaCRestoreFrom=cr -- arg1 arg2 arg3
And normally I would access arg1 arg2 arg3
in the String[] args
parameter of main
, but since we are resuming a checkpoint, we don't have access to that array anymore.
How could I still access the parameters on checkpoint restore? Is it available in some context object during runtime?
In theory, you can build this functionallity by adding a Resource into your program, that will read arguments from a file and call some java code. And then, prior restore, write the parameters to the file.
It all looks general enough to be implemented in the JDK. So since https://github.com/openjdk/crac/pull/16, you can pass a class name and arguments to run on restore. Please check the supplied JavaCompilerCRaC.java.
Ability to run some java code is inteded to do some post-restore actions. For example, setting some parameters, etc. The command line looks like:
CRaC allows to set properties on restore by
But you can implement it yourself:
So the limit is what you can express with java code.
Feedback on this functionallity would be appreciated.