Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Use Gradle toolchains to avoid signature parsing errors #248

Open
tbroyer opened this issue Jul 11, 2024 · 0 comments
Open

Use Gradle toolchains to avoid signature parsing errors #248

tbroyer opened this issue Jul 11, 2024 · 0 comments

Comments

@tbroyer
Copy link

tbroyer commented Jul 11, 2024

Gradle can run with a JDK that's different from the one that's used to compile, and that means it could run with a lower version of the JDK, lower even than the configured java.targetCompatibility, and that causes signature parsing errors.

For example, running Gradle with JDK 11 while using a JDK 21 toolchain and targetCompatibility will cause this error:

> Task :example:forbiddenApisMain FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':example:forbiddenApisMain'.
> Parsing signatures failed: Method not found while parsing signature: java.text.NumberFormat#getCompactNumberInstance()

I would add that Forbidden APIs, particularly as it creates a task for each source set, should read that source set's JavaCompile task's own targetCompatibility rather than the project-wide java.targetCompatibility.

The Forbidden APIs task should itself use a toolchain/JavaLauncher with the Worker API to make sure (or at least make it possible for) the Forbidden APIs checker runs in a JDK compatible with the target compatibility.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Development

No branches or pull requests

1 participant