Skip to content

Latest commit

 

History

History
47 lines (32 loc) · 2.27 KB

jdks.md

File metadata and controls

47 lines (32 loc) · 2.27 KB

Dealing With JDKs Above Version 8

Driver/Controller Class

Java 9 broke backward compatibility in an awful way. And each new JDK version seems breaking even more stuff :-(. One painful change was that self-attachment of Java-Agents (needed for bytecode instrumentation) is now forbidden by default. When for example starting the driver with a JDK 9+ (e.g., JDK 11), you need to add the VM option -Djdk.attach.allowAttachSelf=true, otherwise the process will crash.
For example, in IntelliJ IDEA:

Note: there is a hacky workaround for this "feature" (i.e., as done in ByteBuddy), but it is not implemented. There is no much point in implementing such feature, as JDK 17 broke more stuff as well, and we would still need to set some JVM parameters. To use JDK 17, besides passing -Djdk.attach.allowAttachSelf=true, you will also need:

--add-opens java.base/java.util.regex=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED

isn't it lovely?

An option to solve this issue is to set those options in an environment variable called JDK_JAVA_OPTIONS (which was introduced in JDK 9). However, this would apply to all JVM programs running on your machine. So, use it with care. A further alternative is to set them up globally in your IDE per project, but of course that is IDE dependent. For example, for IntelliJ there are plugins such as JVM Default Options that might help. But we have not tried them.

Regarding the incoming JDK 21, it looks like thanks to JEP 451 the attachment of agents will give a warning, as it will be deactivated by default in future releases. When that will happen, there will be yet again another JVM option that will need to be set.

evomaster.jar

The recommended way to use EvoMaster is via its installer, e.g., .msi for Windows. However, you can still use its jar file directly, if you really want. Unfortunately, though, if you use JDK 17 or above, you have to deal with --add-opens shenanigans.

To see how to set it up, look at the usage of --add-opens in makeExecutable.sh script.