Skip to content

gradlew fails under java-17 #235

Open
@joshuaulrich

Description

@joshuaulrich

The documentation says java-11 is required. It would be helpful if gradlew checked the java version to make sure java-11 is being used. Java-17 is first on the path on my system, so gradlew failed:

$ ./gradlew help
Starting a Gradle Daemon (subsequent builds will be faster)
> Task :buildSrc:compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':buildSrc:compileJava'.
> java.lang.IllegalAccessError: class org.gradle.internal.compiler.java.ClassNameCollector (in unnamed module
@0x6d3c3f0e) cannot access class com.sun.tools.javac.code.Symbol$TypeSymbol (in module jdk.compiler) because
module jdk.compiler does not export com.sun.tools.javac.code to unnamed module @0x6d3c3f0e 

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.8.3/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 5s

$ java --version
openjdk 17.0.7 2023-04-18
OpenJDK Runtime Environment (build 17.0.7+7-Ubuntu-0ubuntu122.04.2)
OpenJDK 64-Bit Server VM (build 17.0.7+7-Ubuntu-0ubuntu122.04.2, mixed mode, sharing)

A google search suggests java-17 ignores compileJava.options.compilerArgs += '--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED' in java/build.gradle.

As expected, it works if I use JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64/ ./gradlew help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions