What is the use of C option in jshell

白昼怎懂夜的黑 提交于 2019-12-03 16:12:52

You can use this option to make use of javac command line arguments for example consider this piece of code:

String str = (String)"Hello"

Starting jshell normally and using the same would result as:


While at the same time you can enable compiler errors on warning(-Werror) and make use of the -Xlint key cast while compiling to warn you of the explicit cast used in the above code using -

jshell -C-Xlint:cast -C-Werror

and the same statement would result into warnings and error from Jshell compiler as:-


Though IMO, this certainly is documented far less in terms of what all flags shall/shall not be used while using the JShell -C command line option.

To pass options to the javac compiler that jshell is going to run to compile the statements in your REPL. One simple example (to see which classes are loaded), jshell -C-verbose. See also Standard Options for javac and Extra Options for javac for additional options you might specify.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!