How to avoid "Sharing is only supported for boot loader classes because bootstrap classpath has been appended" warning during debug with Java 11?
This warning can occur when using a Java command line agent, such as the DataDog APM agent, in conjunction with Java 11. Here are a few possible solutions:
- Disable the DataDog APM agent: If you are using the DataDog APM agent, try disabling it and see if the warning goes away. You can do this by removing the
-javaagent:/dd-java-agent.jar
argument from your Java command. - Disable Async Stack Traces in IntelliJ IDEA: If you are using IntelliJ IDEA, go to Settings > Build, Execution, Deployment > Debugger > Async Stack Traces and uncheck the Instrumenting agent (requires debugger restart) checkbox.
- Use a different JDK version: Some users have reported that the warning can be avoided by using a different JDK version, such as Java 8 or Java 10.
- Set at least one breakpoint before debugging: If you are not setting any breakpoints before starting a debug session, try setting at least one breakpoint and see if the warning goes away.
- Change the debug configuration: In IntelliJ IDEA, go to Run > Edit Configurations and select the configuration you are using for debugging. In the VM options field, add the following argument:
-Xshare:off
- Use gradle to turn sharing off: If you are using gradle, you can turn sharing off by adding the following lines to your
build.gradle
file:
tasks.test { //kotlin jvmArgs = listOf("-Xshare:off") //groovy jvmArgs "-Xshare:off'"; }
Note: The -Xshare:off
argument may increase the launch time of your application.