Skip to content

Commit 8a676ad

Browse files
cpovirkGoogle Java Core Libraries
authored andcommitted
Make the build work under more JDK versions.
(Guava is already _usable_ under plenty of verions. This change affects only people who build it themselves.) And run CI under JDK17. Maybe this will make CI painfully slow, but we'll see what happens. If we want to drop something, we should consider whether to revert 17 or to drop 11 instead (so as to maintain coverage at the endpoints of \[8, 17\]). ## Notes on some of the versions ### JDK9 I expected Error Prone to work, but I saw `invalid flag: -Xep:NullArgumentForNonNullParameter:OFF`, even though that flag is [already](https://github.com/google/guava/blob/166d8c0d8733d40914fb24f368cb587a92bddfe0/pom.xml#L515) part of [the same `<arg>`](google/error-prone#1086 (comment)), which works fine for other JDK versions. So I disabled Error Prone for that version. Then I had a Javadoc problem with the `--no-module-directories` configuration from cl/413934851 (the fix for #5457). After reading [JDK-8215582](https://bugs.openjdk.org/browse/JDK-8215582) more carefully, I get the impression that that flag might not have been added until 11: "addressed in JDK 11, along with an option to revert to the old layout in case of need." So I disabled it for 9-10. Then I ran into a problem similar to bazelbuild/bazel#6173 / [JDK-8184940](https://bugs.openjdk.java.net/browse/JDK-8184940). I'm not sure exactly what tool produced a file with a month of 0, but it happened only when building `guava-tests`. At that point, I gave up, though I left the 2 above workarounds in place. ### JDK10 This fails with some kind of problem finding a Guice dependency inside Maven. I didn't investigate. ### JDK15 and JDK16 These fail with [the `TreeMap` bug](https://bugs.openjdk.org/browse/JDK-8259622) that [our collection testers had detected](#5801 (comment)) but we never got around to reporting. Thankfully, it got reported and [fixed](openjdk/jdk@2c8e337) for JDK17. We could consider suppressing the tests under that version. ### JDK18, JDK19, and JDK20-early-access These fail with [`SecurityManager` trouble](#5801 (comment)). ## Notes on the other actual changes ### `maven-javadoc-plugin` I set up `maven-javadoc-plugin` to use `-source ${java.specification.version}`. Otherwise, it would [take the version from `maven-compiler-plugin`](#5801 (comment)). That's typically fine: Guava's source code targets Java 8, so `-source 8` "ought" to work. But it doesn't actually work because we also pass Javadoc the _JDK_ sources (so that `{@inheritdoc}` works better), which naturally can target whichever version of the JDK we're building with. ### Error Prone While Error Prone is mostly usable [on JDK11+](https://errorprone.info/docs/installation), some of its checks have [problems under some versions](google/error-prone#3540), at least when they're reporting warnings. This stems from its use of part of the Checker Framework, which [doesn't support JDKs in the gap between 11 and 17](https://github.com/typetools/checker-framework/blob/c2d16b3409000ac2e2ca95b8b81ae11e42195308/framework/src/main/java/org/checkerframework/framework/source/SourceChecker.java#L553-L554). And specifically, it looks like the Checker Framework is [trying to look up `BindingPatternTree` under any JDK12+](https://github.com/typetools/checker-framework/blob/c2d16b3409000ac2e2ca95b8b81ae11e42195308/javacutil/src/main/java/org/checkerframework/javacutil/TreeUtils.java#L131-L144). But `BindingPatternTree` (besides not being present at all [until JDK14](openjdk/jdk@229e0d1#diff-3db4b0ce4411c851bcf75d92ef4dadc7351debcf0f9b2c2623dc513923b45867R41)) didn't declare that method [until JDK16](openjdk/jdk@18bc95b#diff-3db4b0ce4411c851bcf75d92ef4dadc7351debcf0f9b2c2623dc513923b45867R39). Anyway, the problem we saw was [a `NoSuchMethodException` during the `AbstractReferenceEquality` call to `NullnessAnalysis.getNullness`](https://oss-fuzz-build-logs.storage.googleapis.com/log-a9d04aa2-8b5a-47ca-8066-7e6b38548064.txt), which uses Checker Framework dataflow. To address that, I disabled Error Prone for the versions under which I'd expect the `BindingPatternTree` code to be a problem. (I also disabled it for JDK10: As noted above, Error Prone [supports JDK11+](https://errorprone.info/docs/installation). And as noted further above, Maven doesn't get far enough with JDK10 to even start running Error Prone.) Fixes #5801 RELNOTES=n/a PiperOrigin-RevId: 488902996
1 parent c5d7b86 commit 8a676ad

3 files changed

Lines changed: 27 additions & 13 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
name: "${{ matrix.root-pom }} on JDK ${{ matrix.java }}"
2020
strategy:
2121
matrix:
22-
java: [ 8, 11 ]
22+
java: [ 8, 11, 17 ]
2323
root-pom: [ 'pom.xml', 'android/pom.xml' ]
2424
runs-on: ubuntu-latest
2525
env:

android/pom.xml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@
113113
<plugin>
114114
<artifactId>maven-javadoc-plugin</artifactId>
115115
<version>${maven-javadoc-plugin.version}</version>
116+
<configuration>
117+
<source>${java.specification.version}</source>
118+
</configuration>
116119
</plugin>
117120
</plugins>
118121
<pluginManagement>
@@ -408,17 +411,17 @@
408411
</profile>
409412
<profile>
410413
<!--
411-
Passes JDK 9-12-specific `no-module-directories` flag to Javadoc tool,
414+
Passes JDK 11-12-specific `no-module-directories` flag to Javadoc tool,
412415
which is required to make symbol search work correctly in the generated
413416
pages.
414417
415-
This flag does not exist on 8 and 13+ (https://bugs.openjdk.java.net/browse/JDK-8215582).
418+
This flag does not exist on 9-10 and 13+ (https://bugs.openjdk.java.net/browse/JDK-8215582).
416419
417420
Consider removing it once our release and test scripts are migrated to a recent JDK (17+).
418421
-->
419-
<id>javadocs-jdk9-12</id>
422+
<id>javadocs-jdk11-12</id>
420423
<activation>
421-
<jdk>[9,13)</jdk>
424+
<jdk>[11,13)</jdk>
422425
</activation>
423426
<properties>
424427
<maven-javadoc-plugin.additionalJOptions>--no-module-directories</maven-javadoc-plugin.additionalJOptions>
@@ -485,9 +488,13 @@
485488
</build>
486489
</profile>
487490
<profile>
488-
<id>new-enough-for-error-prone</id>
491+
<id>run-error-prone</id>
489492
<activation>
490-
<jdk>[9,)</jdk>
493+
<!--
494+
Error Prone requires 11+: https://errorprone.info/docs/installation
495+
We skip 12-15 because of https://github.com/google/error-prone/issues/3540.
496+
-->
497+
<jdk>[11,12),[16,)</jdk>
491498
</activation>
492499
<build>
493500
<plugins>

pom.xml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@
114114
<plugin>
115115
<artifactId>maven-javadoc-plugin</artifactId>
116116
<version>${maven-javadoc-plugin.version}</version>
117+
<configuration>
118+
<source>${java.specification.version}</source>
119+
</configuration>
117120
</plugin>
118121
</plugins>
119122
<pluginManagement>
@@ -415,17 +418,17 @@
415418
</profile>
416419
<profile>
417420
<!--
418-
Passes JDK 9-12-specific `no-module-directories` flag to Javadoc tool,
421+
Passes JDK 11-12-specific `no-module-directories` flag to Javadoc tool,
419422
which is required to make symbol search work correctly in the generated
420423
pages.
421424
422-
This flag does not exist on 8 and 13+ (https://bugs.openjdk.java.net/browse/JDK-8215582).
425+
This flag does not exist on 9-10 and 13+ (https://bugs.openjdk.java.net/browse/JDK-8215582).
423426
424427
Consider removing it once our release and test scripts are migrated to a recent JDK (17+).
425428
-->
426-
<id>javadocs-jdk9-12</id>
429+
<id>javadocs-jdk11-12</id>
427430
<activation>
428-
<jdk>[9,13)</jdk>
431+
<jdk>[11,13)</jdk>
429432
</activation>
430433
<properties>
431434
<maven-javadoc-plugin.additionalJOptions>--no-module-directories</maven-javadoc-plugin.additionalJOptions>
@@ -492,9 +495,13 @@
492495
</build>
493496
</profile>
494497
<profile>
495-
<id>new-enough-for-error-prone</id>
498+
<id>run-error-prone</id>
496499
<activation>
497-
<jdk>[9,)</jdk>
500+
<!--
501+
Error Prone requires 11+: https://errorprone.info/docs/installation
502+
We skip 12-15 because of https://github.com/google/error-prone/issues/3540.
503+
-->
504+
<jdk>[11,12),[16,)</jdk>
498505
</activation>
499506
<build>
500507
<plugins>

0 commit comments

Comments
 (0)