While working through the TDD with Spring Boot↗ series, I kept seeing this red message in the console even when the tests passed.
OpenJDK 64-Bit Server VM warning
OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
At first glance, it might look like an error. It's a
warning
, and it doesn't affect the functionality being tested. If seeing red text every time bothers you, this extra installment is for you.
You can also jump straight to the fix.
changes the situation. Tools such as Mockito and JaCoCo, a test coverage tool, participate in the execution process.
As part of that process, they append entries to Java's bootstrap class path.
From the JVM's point of view, it goes something like this.
‘The current environment doesn't match the notes I prepared in the CDS archive.
Someone appended something.
I can't use those notes, so I'll read the classes myself.’
The JVM issues a warning about the restriction on sharing. It's effectively saying that
You can safely ignore this warning.
If the red text bothers you, configure the JVM to disable CDS.
It will then skip sharing in the first place, so the warning goes away.
Change the Gradle configuration to apply the setting across the project so the rest of your team also stops seeing the warning.
Add this configuration to the test task in build.gradle.