What is the exact meaning / purpose of the J and R flags in jshell?

后端 未结 2 1338
南笙
南笙 2021-01-05 08:19

From the help information:

-J              Pass  directly to the runtime system.
                      Use one -J for each runtime fl         


        
2条回答
  •  既然无缘
    2021-01-05 08:42

    I still find the scope of explaining the usage of the flags used in both the attributes for the question to be answered completely, hence putting that in words here.

    -J flag is used to provide a runtime argument to the JShell which is similar to the way one provides while performing via an IDE under Run -> Configuration to specify arguments as -Dkey=value.

    The usage of the attribute is documented and quite similar to ones illustrated for the flag -C just that the -J flags are instead the java command line options. For example, using the -XX:+PrintCommandLineFlags would detail out the runtime flags used by the current JVM.

    So, the default values of command line flags used by your JShell instance(without setting any additional flag) could be as:-

    But let's say you don't want to make use of the CompactStrings of Java9 in your JShell execution you can tell the JVM using the -J flag and -XX:-CompactStrings attribute to do so, as -

    jshell -R-XX:+PrintCommandLineFlags -R-XX:-CompactStrings
    

    would list out the following output:

    ➜ Similar java command line options/flags, when attached with and used to start JShell on a remote JVM, are linked to -R attribute of the JShell during remote execution.

    jshell -R-XX:+PrintCommandLineFlags -R-XX:-CompactStrings
    

    Anatoly's answer has got some good amount of research attached to it and I would suggest that to be read to understand about control and execution engine of the JShell for local Vs remote execution.

提交回复
热议问题