Running Robocode on Java 9 prints this message:
WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by net.sf.robocode.io.URLJarCollector (file:/C:/robocode/libs/robocode.core-1.9.3..jar) to field sun.net.www.protocol.jar.JarFileFactory.fileCache WARNING: Please consider reporting this to the maintainers of net.sf.robocode.io.URLJarCollector WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release
All of these messages can be silenced by passing these command-line arguments:
java --add-opens java.base/sun.net.www.protocol.jar=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.desktop/sun.awt=ALL-UNNAMED
I believe this fixes #386.
Fixed. The installer of Robocode will add the "--add-opens" options for Java 9, which does not work with Java 8.
Alternatively, you can use
-XX:+IgnoreUnrecognizedVMOptions
, which has existed since Java 6, which will cause the JVM to ignore unknown flags. So (note the quotes aroundadd-opens
):This will allow users to upgrade to Java 9 without having to reinstall Robocode.
Tested on both Java 8 and 9 on Robocode 1.9.3.0 Alpha on Windows 10.
Thanks for the tip. That is a nice feature. I was not aware of this feature. :-)
I will change it, so the -XX:+IgnoreUnrecognizedVMOptions is used.
It might be deprecated in the future though:
https://bugs.openjdk.java.net/browse/JDK-6788376
The new fix works for me.
Oops. I made a typo in the last suggestion, which got into the release and breaks it, and I didn't notice because I didn't test it nearly enough.
Instead of:
Use (with the equal sign):
Apologies for that mistake, and it should work after correcting it.
No harm done. I have replaced the string in all the .bat, .sh, .command files, where I added the --add-opens lines.