Skip to content

Latest commit

 

History

History
47 lines (32 loc) · 2.4 KB

jdks.md

File metadata and controls

47 lines (32 loc) · 2.4 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 to setup a few --add-opens commands. In particular, you will need:

-Djdk.attach.allowAttachSelf=true --add-opens java.base/java.util=ALL-UNNAMED --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 JDK 21, it looks like thanks to JEP 451 the attachment of agents gives 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 need. You will need a JDK on your machine to run it with java -jar evomaster.jar. Since version 3.2.0, there is no longer need to setup any --add-opens when using a JDK 17+, as those are now directly set in the jar's manifest.