Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Run tests under Java 17 #5801

Closed
cpovirk opened this issue Dec 1, 2021 · 10 comments
Closed

Run tests under Java 17 #5801

cpovirk opened this issue Dec 1, 2021 · 10 comments
Assignees
Labels
P2 platform=java17 type=other Miscellaneous activities not covered by other type= labels

Comments

@cpovirk
Copy link
Member

cpovirk commented Dec 1, 2021

We would want to detect anything that breaks with more recent versions than what we currently test with (Java 11).

To do so, I'm told that we'll have to omit the --no-module-directories option that we're likely adding in #5800, just as we'll have to have found a way to omit it under Java 8.

I think that's fine, as I think we're using it only to work around a JDK11(?) bug that was fixed in JDK13(?): https://bugs.openjdk.java.net/browse/JDK-8215582

After that, I see issues because we pass the JDK sources to our Javadoc generation (so that @inheritDoc works for JDK classes). We've seen this before, though we just omitted files to work around it. (Maybe we'd want to rewrite the files, or maybe we can really pass -source 17 or whatever nowadays??) For purposes of filing this bug, I'm just skipping that by passing -Dmaven.javadoc.skip=true.

There's also a TreeMap bug that I've been meaning to report for a long time. (As of Java 15, that was the only test failure.)

My notes from Java 15 (internal bug 182929722) also describe some compilation errors, which I still see (as expected) under Java 17:

  [ERROR] /usr/local/google/home/cpovirk/clients/guava-black/guava/guava-tests/benchmark/com/google/common/util/concurrent/FuturesGetCheckedBenchmark.java:[37,25] package java.security.acl does not exist

Just pick another exception type to test with.

  [ERROR] /usr/local/google/home/cpovirk/clients/guava-black/guava/guava-tests/test/com/google/common/reflect/TypeTokenTest.java:[421,11] types java.lang.CharSequence and java.util.List<E> are incompatible;
  [ERROR]   class java.lang.Object&java.util.List<java.lang.String>&java.lang.CharSequence inherits abstract and default for isEmpty() from types java.lang.CharSequence and java.util.List
  [ERROR] /usr/local/google/home/cpovirk/clients/guava-black/guava/guava-tests/test/com/google/common/reflect/TypeTokenTest.java:[435,11] types java.lang.CharSequence and java.util.List<E> are incompatible;
  [ERROR]   class java.lang.Object&java.util.List<java.lang.String>&java.lang.CharSequence inherits abstract and default for isEmpty() from types java.lang.CharSequence and java.util.List

...because both define isEmpty(). Just pick another type.

@netdpb netdpb added P3 type=other Miscellaneous activities not covered by other type= labels platform=java17 labels Dec 1, 2021
@dmitry-timofeev
Copy link

we'll have to omit the --no-module-directories option

Do I understand correctly that this issue is only to run tests on 17, but not to migrate our release scripts to 17?

If we move all release scripts to 17, then we can just keep the present configuration (i.e., without 9–12 specific no-module-directories option). That will mean that Javadoc will be generated fine on 8 and 13+ (with working search on 13+), whilst on 9–12 it will just have silently broken search functionality (but, if we release Javadoc JARs to Maven Central and upload Javadocs to guava.dev with 17, that mustn't affect anyone).


We would want to detect anything that breaks with more recent versions

I've noticed that some projects run their tests with early-access OpenJDK builds (in non-blocking mode); and some report the failures to OpenJDK.

Do you think it'd be valuable for Guava?

@cpovirk
Copy link
Member Author

cpovirk commented Dec 2, 2021

Do I understand correctly that this issue is only to run tests on 17, but not to migrate our release scripts to 17?

That's my initial thinking. But you raise an interesting option that I don't think we'd considered.

We currently run the release script on our own machines and with whatever the Google default JDK is. That, particularly the second half, is not necessarily a great idea (see also internal bug 165936854), so it could be nice to hardcode a JDK that we change only deliberately.

The place to do that would be (Google-internal) devtools/javalibraries/release/release.sh. It would need to pull a Java 17 from somewhere (I can point you at a Java Platform Team copy) and point JAVA_HOME at that. (Or there's probably some better way that we should be doing all this.)

That would also mean fixing the tests -- for this project and for the other project that use that script, or else we could make the choice of JDK conditional on the project.


I think I've seen the early-access approach in Error Prone. It sounds like a good idea, too, though I want to say we're all pulling from a common Google quota, so there is some cost.

(I have been meaning to report the TreeMap thing forever :( One of these years....)

@dmitry-timofeev
Copy link

One more bit of work to support 17: fix Javadoc generation there 🙃

Turns out it won’t work on 17 just yet, because, apparently, javadoc tool switched a warning on using incompatible language features in source files to an error. As we pass source 8, but also take JDK sources from the JDK at JAVA_HOME (which naturally uses newer language features), it fails:

Error on 17
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:3.1.0:javadoc (default-cli) on project guava: An error has occurred in Javadoc report generation: 
[ERROR] Exit code: 1 - /usr/local/google/home/dmitrytimofeev/third_party_projects/guava/guava/target/jdk-sources/java.base/java/lang/reflect/Proxy.java:710: warning: as of release 10, 'var' is a restricted type name and cannot be used for type declarations or as the element type of an array
[ERROR]             var types = new HashSet<Class<?>>();
[ERROR]                 ^                   ^
Warning on the same thing in the currently used 11
[WARNING] /usr/local/google/home/dmitrytimofeev/third_party_projects/guava/android/guava/target/jdk-sources/java.base/java/lang/reflect/Proxy.java:710: warning: as of release 10, 'var' is a restricted local variable type and cannot be used for type declarations or as the element type of an array
[WARNING] var types = new HashSet<Class<?>>();
[WARNING] ^

@cpovirk
Copy link
Member Author

cpovirk commented Dec 3, 2021

Oh, right, this is the same general problem as we're working around with

<!-- Exclude module-info files (since we're using -source 8 to avoid other modules problems) and FileDescriptor (which uses a language feature not available in Java 8). -->
. There were already some problems that were errors, but now there are even more.

The comment there says that "we're using -source 8 to avoid other modules problems." I don't remember what the problems are, though. My guess would be that we need to keep doing that, at least under JDK11, though who knows if it would work under JDK17?

There must be some kind of conditional setup that would make it all work, but it's fine with me to fall back to ignoring JDK17.

@cpovirk
Copy link
Member Author

cpovirk commented Mar 22, 2022

(progress in 7e04a00)

@cpovirk
Copy link
Member Author

cpovirk commented Mar 22, 2022

Possible other trouble:

testNewHashMapWithExpectedSize_wontGrow(com.google.common.collect.MapsTest): Unable to make field transient java.util.HashMap$Node[] java.util.HashMap.table accessible: module java.base does not "opens java.util" to unnamed module @4297a8a1
testNewLinkedHashMapWithExpectedSize_wontGrow(com.google.common.collect.MapsTest): Unable to make field transient java.util.HashMap$Node[] java.util.HashMap.table accessible: module java.base does not "opens java.util" to unnamed module @4297a8a1
testNoProviders(com.google.common.hash.MacHashFunctionTest): class com.google.common.hash.MacHashFunctionTest (in unnamed module @0x4297a8a1) cannot access class sun.security.jca.Providers (in module java.base) because module java.base does not export sun.security.jca to unnamed module @0x4297a8a1
testInterruptIsSlow(com.google.common.util.concurrent.InterruptibleTaskTest): Unable to make protected final java.lang.Thread java.util.concurrent.locks.AbstractOwnableSynchronizer.getExclusiveOwnerThread() accessible: module java.base does not "opens java.util.concurrent.locks" to unnamed module @4297a8a1
testMockingEasyMock(com.google.common.util.concurrent.RateLimiterTest)

Some of that might be stuff we're willing to use --add-opens for (or whatever the flag is; I haven't gotten the hang of them all yet).

copybara-service bot pushed a commit that referenced this issue Mar 22, 2022
We make the same changes to `pom.xml` in the Android branch, even though they have no effect there. That's just to minimize differences between the two branches.

More progress toward #5801 (maybe enough to close it?)

RELNOTES=n/a
PiperOrigin-RevId: 436528838
copybara-service bot pushed a commit that referenced this issue Mar 22, 2022
We make the same changes to `pom.xml` in the Android branch, even though they have no effect there. That's just to minimize differences between the two branches.

More progress toward #5801 (maybe enough to close it?)

RELNOTES=n/a
PiperOrigin-RevId: 436528838
copybara-service bot pushed a commit that referenced this issue Mar 22, 2022
We make the same changes to `pom.xml` in the Android branch, even though they have no effect there. That's just to minimize differences between the two branches.

More progress toward #5801 (maybe enough to close it?)

RELNOTES=n/a
PiperOrigin-RevId: 436544563
copybara-service bot pushed a commit that referenced this issue Aug 23, 2022
Under modern JDKs, it will fail.

This lets us remove one of our `--add-opens` lines. (I haven't looked into [the others](#5801 (comment)).)

Example failure:

```
java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Thread java.util.concurrent.locks.AbstractOwnableSynchronizer.getExclusiveOwnerThread() accessible: module java.base does not "opens java.util.concurrent.locks" to unnamed module @5ba184fc; did you mean --add-opens=java.base/java.util.concurrent.locks=ALL-UNNAMED
	at java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:348)
	at java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:280)
	at java.lang.reflect.Method.checkCanSetAccessible(Method.java:198)
	at java.lang.reflect.Method.setAccessible(Method.java:192)
	at com.google.common.util.concurrent.InterruptibleTaskTest.testInterruptIsSlow(InterruptibleTaskTest.java:160)
```

Relevant to #5801

RELNOTES=n/a
PiperOrigin-RevId: 469500716
copybara-service bot pushed a commit that referenced this issue Aug 23, 2022
Under modern JDKs, it will fail.

This lets us remove one of our `--add-opens` lines. (I haven't looked into [the others](#5801 (comment)).)

Example failure:

```
java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Thread java.util.concurrent.locks.AbstractOwnableSynchronizer.getExclusiveOwnerThread() accessible: module java.base does not "opens java.util.concurrent.locks" to unnamed module @5ba184fc; did you mean --add-opens=java.base/java.util.concurrent.locks=ALL-UNNAMED
	at java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:348)
	at java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:280)
	at java.lang.reflect.Method.checkCanSetAccessible(Method.java:198)
	at java.lang.reflect.Method.setAccessible(Method.java:192)
	at com.google.common.util.concurrent.InterruptibleTaskTest.testInterruptIsSlow(InterruptibleTaskTest.java:160)
```

Relevant to #5801

RELNOTES=n/a
PiperOrigin-RevId: 469515689
@cpovirk
Copy link
Member Author

cpovirk commented Oct 27, 2022

Another thing for us to look at (possibly not for JDK 17 but for a later version?) is https://openjdk.org/jeps/411. I saw failures when testing with jdk-20-ea+16. I was able to get around them by adding -Djava.security.manager=allow to...

guava/pom.xml

Line 241 in b337be6

<argLine>-Xmx1536M -Duser.language=hi -Duser.country=IN ${test.add.opens}</argLine>

...but that broke JDK8 builds with an error whose message I couldn't see until I ran Maven with -X -e and then directly ran the shell script that it printed out:

Error occurred during initialization of VM
java.lang.InternalError: Could not create SecurityManager: allow

copybara-service bot pushed a commit that referenced this issue Oct 27, 2022
…nd make builds work with newer JDKs.

This should fix the error reported in #6217 (comment). I'm not sure if the Error Prone update was necessary for that or if only the `pom.xml` changes were. Still, it seems inevitable that we'll be forced to upgrade Error Prone eventually, and it's rarely a bad idea to update a plugin.

This change is progress toward building and testing under Java 17 (#5801)...

...which we apparently regressed at when we enabled Error Prone (#2484).

I've set this change up in a way that lets builds continue to work under JDK8 (which is potentially useful for #3990 or for anyone building Guava manually with an old JDK), albeit with Error Prone disabled.

RELNOTES=n/a
PiperOrigin-RevId: 484299394
copybara-service bot pushed a commit that referenced this issue Nov 3, 2022
This has some effects on us as we develop Guava, but it doesn't affect end users.

Specifically:

- When we build Guava with JDK8, we now have to disable Error Prone. (Again, users can still use Guava with JDK8, including with Error Prone. The effect is limited to people who are developing Guava.)
- We can now successfully build Guava with Error Prone under more recent JDKs. That is, this change should fix the error reported in #6217 (comment). (I'm not sure if the Error Prone update was necessary for that or if only the other `pom.xml` changes were. Still, it seems inevitable that we'll be forced to upgrade Error Prone eventually, and it's rarely a bad idea to update a plugin.)

This change is progress toward building and testing under Java 17 (#5801)...

...which we apparently regressed at when we enabled Error Prone (#2484).

Oddly, it seems that part of our existing Error Prone setup is _required_ to continue building Guava under JDK8. (Such builds are potentially useful for #3990 or for anyone building Guava manually with an old JDK.) That's the case even though we're now disabling Error Prone for those builds.

Again, all these changes affect only people who are developing Guava, not end users.

RELNOTES=n/a
PiperOrigin-RevId: 484299394
copybara-service bot pushed a commit that referenced this issue Nov 3, 2022
This has some effects on us as we develop Guava, but it doesn't affect end users.

Specifically:

- When we build Guava with JDK8, we now have to disable Error Prone. (Again, users can still use Guava with JDK8, including with Error Prone. The effect is limited to people who are developing Guava.)
- We can now successfully build Guava with Error Prone under more recent JDKs. That is, this change should fix the error reported in #6217 (comment). (I'm not sure if the Error Prone update was necessary for that or if only the other `pom.xml` changes were. Still, it seems inevitable that we'll be forced to upgrade Error Prone eventually, and it's rarely a bad idea to update a plugin.)

This change is progress toward building and testing under Java 17 (#5801)...

...which we apparently regressed at when we enabled Error Prone (#2484).

Oddly, it seems that part of our existing Error Prone setup is _required_ to continue building Guava under JDK8. (Such builds are potentially useful for #3990 or for anyone building Guava manually with an old JDK.) That's the case even though we're now disabling Error Prone for those builds.

Again, all these changes affect only people who are developing Guava, not end users.

RELNOTES=n/a
PiperOrigin-RevId: 485770768
@cpovirk
Copy link
Member Author

cpovirk commented Nov 14, 2022

JDK17 appears to... pass all tests!? (It does still fail to build Javadoc.) I knew that @eamonnmcmanus had done a bunch of work, but I hadn't realized we were so close.

Probably what put us over the top was the EasyMock upgrade in #6229, which pulled in an EasyMock fix for new JDKs.

The errors I see with JDK20 are almost all Security-Manager-related.

  testUnloadableInStaticFieldIfClosed(com.google.common.base.FinalizableReferenceQueueClassLoaderUnloadingTest): The Security Manager is deprecated and will be removed in a future release
  testUnloadableWithSecurityManager(com.google.common.base.FinalizableReferenceQueueClassLoaderUnloadingTest): The Security Manager is deprecated and will be removed in a future release
  testExistsThrowsSecurityException(com.google.common.reflect.ClassPathTest): The Security Manager is deprecated and will be removed in a future release
  testAbstractFutureInitializationWithInnocuousThread_doesNotThrow(com.google.common.util.concurrent.AbstractFutureInnocuousThreadTest): The Security Manager is deprecated and will be removed in a future release
  testRenaming_noPermissions(com.google.common.util.concurrent.CallablesTest): The Security Manager is deprecated and will be removed in a future release
  testOnSuccessThrowsRuntimeException(com.google.common.util.concurrent.FutureCallbackTest): 
  testOnSuccessThrowsError(com.google.common.util.concurrent.FutureCallbackTest): 

It's interesting that JDK20 shows a problem in some tests that use Mockito. Though I know the JDK is locking down some internals that Mockito depends on to do certain things, I wouldn't have expected the problems to affect mocking of FutureCallback from within its package. But I haven't looked at the error closely enough to even say if Mockito is the cause, let alone to say specifically where the problem lies.

Somewhat related: Another thing we may look at is limiting our Error Prone usage to LTS JDKs, since some Error Prone checks use a repackaged Checker Framework, which doesn't support versions like JDK15 (as eamonnmcmanus recently reported).

@cpovirk
Copy link
Member Author

cpovirk commented Nov 14, 2022

It looks like JDK17 Javadoc can work fine with <source>17</source>. The trick is how to set that for JDK17 without also setting it for other JDK versions (especially older ones): Worst case, we could use profiles. But maybe we can do something with java.specification.version or another property.

(maven-javadoc-plugin says that it defaults to maven.compiler.source, which seems to mean "whatever <source> is set for maven-compiler-plugin." I had thought that it might mean that maven.compiler.source was a property that was read by both plugins, but it sounds like it's "written" by maven-compiler-plugin and read only by other plugins, like maven-javadoc-plugin.)

@cpovirk
Copy link
Member Author

cpovirk commented Nov 14, 2022

RE: Mockito: It looks specific to the InnocuousThread tests:

testOnSuccessThrowsRuntimeException(com.google.common.util.concurrent.FutureCallbackTest)  Time elapsed: 0.005 sec  <<< ERROR!
org.mockito.exceptions.base.MockitoException: 
ClassCastException occurred while creating the mockito mock :
  class to mock : 'com.google.common.util.concurrent.FutureCallback', loaded by classloader : 'jdk.internal.loader.ClassLoaders$AppClassLoader@5ffd2b27'
  created class : 'org.mockito.codegen.FutureCallback$MockitoMock$WO17i1nt', loaded by classloader : 'com.google.common.util.concurrent.AbstractFutureInnocuousThreadTest$1@2b6c724a'
  proxy instance class : 'org.mockito.codegen.FutureCallback$MockitoMock$WO17i1nt', loaded by classloader : 'com.google.common.util.concurrent.AbstractFutureInnocuousThreadTest$1@2b6c724a'
  instance creation by : ObjenesisInstantiator

You might experience classloading issues, please ask the mockito mailing-list.

	at com.google.common.util.concurrent.FutureCallbackTest.testOnSuccessThrowsRuntimeException(FutureCallbackTest.java:105)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
	at java.base/java.lang.reflect.Method.invoke(Method.java:578)
	at junit.framework.TestCase.runTest(TestCase.java:177)
	at junit.framework.TestCase.runBare(TestCase.java:142)
	at junit.framework.TestResult$1.protect(TestResult.java:122)
	at junit.framework.TestResult.runProtected(TestResult.java:142)
	at junit.framework.TestResult.run(TestResult.java:125)
	at junit.framework.TestCase.run(TestCase.java:130)
	at junit.framework.TestSuite.runTest(TestSuite.java:241)
	at junit.framework.TestSuite.run(TestSuite.java:236)
	at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:90)
	at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:35)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:115)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:97)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
	at java.base/java.lang.reflect.Method.invoke(Method.java:578)
	at org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.invoke(ProviderFactory.java:103)
	at jdk.proxy1/jdk.proxy1.$Proxy0.invoke(Unknown Source)
	at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:150)
	at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:91)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:69)
Caused by: java.lang.ClassCastException: Cannot cast org.mockito.codegen.FutureCallback$MockitoMock$WO17i1nt to com.google.common.util.concurrent.FutureCallback
	at java.base/java.lang.Class.cast(Class.java:3983)
	at org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.ensureMockIsAssignableToMockedType(SubclassByteBuddyMockMaker.java:95)
	at org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.createMock(SubclassByteBuddyMockMaker.java:52)
	at org.mockito.internal.creation.bytebuddy.ByteBuddyMockMaker.createMock(ByteBuddyMockMaker.java:42)
	at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:99)
	at org.mockito.internal.MockitoCore.mock(MockitoCore.java:88)
	at org.mockito.Mockito.mock(Mockito.java:1998)
	at org.mockito.Mockito.mock(Mockito.java:1913)
	... 22 more

The simplest thing is probably just to not use Mockito there, since we don't really need it. That will also make our tests runnable under GWT, which is nice. I'll take a stab at it.

copybara-service bot pushed a commit that referenced this issue Nov 15, 2022
This addresses [a class-loader mismatch under JDK20](#5801 (comment)). As a bonus, it makes the test work under GWT.

PiperOrigin-RevId: 488442758
@cpovirk cpovirk added P2 and removed P3 labels Nov 15, 2022
@cpovirk cpovirk self-assigned this Nov 15, 2022
copybara-service bot pushed a commit that referenced this issue Nov 15, 2022
This addresses [a class-loader mismatch under JDK20](#5801 (comment)). As a bonus, it makes the test work under GWT.

PiperOrigin-RevId: 488665105
copybara-service bot pushed a commit that referenced this issue Nov 15, 2022
(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, 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.

Fixes #5801

RELNOTES=n/a
PiperOrigin-RevId: 488700624
copybara-service bot pushed a commit that referenced this issue Nov 15, 2022
(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: 488700624
copybara-service bot pushed a commit that referenced this issue Nov 15, 2022
(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: 488700624
copybara-service bot pushed a commit that referenced this issue Nov 16, 2022
(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: 488700624
copybara-service bot pushed a commit that referenced this issue Nov 16, 2022
(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: 488700624
copybara-service bot pushed a commit that referenced this issue Jun 15, 2023
Also, update documentation to reflect that we test under:
- [Windows](#2686)
- [Java 17](#5801)

RELNOTES=n/a
PiperOrigin-RevId: 539045930
copybara-service bot pushed a commit that referenced this issue Jun 15, 2023
Also, update documentation to reflect that we test under:
- [Windows](#2686)
- [Java 17](#5801)

RELNOTES=n/a
PiperOrigin-RevId: 540650887
cpovirk added a commit that referenced this issue Jun 16, 2023
@google google deleted a comment from SteveBombardier Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 platform=java17 type=other Miscellaneous activities not covered by other type= labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants