I try to add:

compileJava {
//disable compilation in a separate daemon process...should be faster?
options.fork = false
options.compilerArgs << '-Xshare:on'

but I get

Cause: error: invalid flag: -Xshare:on

I CAN add


to gradle.properties to get the daemon to use CDS (I believe, anyway).

Is there a way to get Gradle/java 11 to use CDS throughout?

By throughout, I mean not just for the daemon but for the compiler as well?

I have also tried:

compileJava.options.forkOptions.jvmArgs << '-Xshare:on'

But that doesn't get me anywhere either (and I guess would be slower due to the fork overhead...destroying any speed advantage that CDS might provide?)

  • You might also try the gradle forums for that question. – tkruse Apr 16 at 3:25
  • Isn't CDS auto-enabled according to the docs? docs.oracle.com/en/java/javase/11/vm/… – tkruse Apr 16 at 3:29
  • @tkruse: true, it seems but the archive is only generated if you use the installer. hmmm. The link you gave explictly says to NOT use -Xshare:on in production. Thanks for enlightening me! – Bob Brown Apr 16 at 3:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.