bootstrapClasspath doesn't add to the classpath, but replaces it

(Rivas) #1

According to the docs for JavaExec, the method bootstrapClasspath " Adds the given values to the end of the bootstrap classpath for the process."

That would mean using the jvm option -Xbootclasspath/a, however what happens is that the option -Xbootclasspath is used instad, so the bootstrap classpath is replaced. A simple way to test it:

task javatest(type: JavaExec) {
bootstrapClasspath files(“foo”)
main = “”

Then run gradle as: ./gradlew javatest --info

And you’ll see the command being invoked is

Command: /usr/bin/java -Xbootclasspath:/tmp/gradle_tests/foo -Dfile.encoding=UTF-8 -Duser.language=en -Duser.variant

And the failure

java/lang/NoClassDefFoundError: java/lang/Object

While if we run

java -Xbootclasspath/a:/tmp/gradle_tests/foo -Dfile.encoding=UTF-8 -Duser.language=en -Duser.variant

Then the failure is the expected

Error: Could not find or load main class

Three is a very similar question/report in the old forum: JavaExec bootstrapClasspath docs and behaviour don’t match, but hasn’t received any attention.

Is there any way to workaround this?