Skip to content

Commit

Permalink
Merge pull request #65 from nickbutcher/patch-1
Browse files Browse the repository at this point in the history
Fix typo in gradle-toolchains
  • Loading branch information
JakeWharton authored Mar 26, 2024
2 parents acc906e + 326ad2b commit 35cd5fd
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ If your build already has a minimum JDK requirement then why force installation

I want to stress that toolchains are unequivocally not a good idea _for compilation_. They still have utility elsewhere, however.

Retrofit has runtime behavior that changes based on the JVM version on which it's running. (This is because until Java 16 it took various different hacks to support invoking default methods through a [`Proxy`](https://docs.oracle.com/en%2Fjava%2Fjavase%2F22%2Fdocs%2Fapi%2F%2F/java.base/java/lang/reflect/Proxy.html).) That code needs tested on different JVM versions. As a result, we [compile with the latest Java, but test through the lowest-supported Java](/build-on-latest-java-test-through-lowest-java/) using toolchains on the `Test` task. No need to worry about the user having weird old JDKs for Java 14 because it's now installed on-demand when the full test suite is run.
Retrofit has runtime behavior that changes based on the JVM version on which it's running. (This is because until Java 16 it took various different hacks to support invoking default methods through a [`Proxy`](https://docs.oracle.com/en%2Fjava%2Fjavase%2F22%2Fdocs%2Fapi%2F%2F/java.base/java/lang/reflect/Proxy.html).) That code needs to be tested on different JVM versions. As a result, we [compile with the latest Java, but test through the lowest-supported Java](/build-on-latest-java-test-through-lowest-java/) using toolchains on the `Test` task. No need to worry about the user having weird old JDKs for Java 14 because it's now installed on-demand when the full test suite is run.

Some tools that dip into JDK internals regularly break on newer versions of the compiler because they rely on unstable APIs. I'm thinking about things like [Google Java Format](https://github.com/google/google-java-format) or [Error-Prone](https://errorprone.info/). No need to hold the rest of your project from enjoying the latest JDK, if those tools are run via a `JavaExec` task you can use a toolchain to keep them on an older JDK until a newer version is available.

Expand Down

0 comments on commit 35cd5fd

Please sign in to comment.