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
Build with --release 8, or require builds to use JDK 8 #3990
Comments
Later, assuming that the implementation of GoogleCloudPlatform/cloud-opensource-java#1605 goes in, we should consider switching to the Linkage Checker Enforcer Rule. |
Ah, but the Linkage Checker will check only against the JDK that you're using to build. So we're back to needing to require builds to use JDK 8. And all the Linkage Checker would be doing then is looking at dependencies (of which we have effectively none). |
|
As I just noted on the protobuf thread, it sounds like the best option is to require builds to be done with JDK 8. (It might also be OK to build with a newer JDK but with an older bootclasspath, but I'm not sure how well supported that is, since bootclasspath is on the way out. I gather that we're internally doing something along those lines with Bazel, but I don't know how easy it is to do the equivalent externally or with Maven.) We could consider requiring JDK 8 only for release builds. That would make life easier for an average developer who wants to contribute to Guava (and might not have JDK 8 lying around). On the other hand, it might make it more confusing to reproduce actual problems. Maybe we'd want to support some kind of Hmm, and we have Travis building with various versions.... I wonder how long it will be until openjdk8 is no longer available there. |
(Certainly we at least want it to be possible to build and test with another JDK, since we want to verify that Guava works with new Java versions.) |
Hmm, internally we're not going to be able to keep building with JDK 8 after our switchover. (And as established above, we can't just use Such a check, of course, would catch only the methods that we specifically program it to look for. If we get things right internally, that should also make it possible to build with JDK 11 externally. And building with JDK 11 is good for at least one more reason: Just as we currently use We'll see if it's still straightforward to refer to |
Hmm, and this is not the same thing, but when testing my fix for
It works fine if I set JAVA_HOME, but it's unfortunate that that's necessary. I will see if 3.2.0 works better. |
(3.2.0 has the same problem.) |
…rns in Java 9+. Doing so produces a jar that doesn't work under Java 8. This CL addresses the currently existing problematic calls (by calling the methods on the supertype Buffer instead), but we should also add safeguards. The normal solution to this general problem is to use --release, but doing so here is complicated. For more information, see #3990 RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=327654073
Ah, since we run our build and tests under JDK 11 with Travis, I guess we have evidence that that works, at least currently :) |
…rns in Java 9+. Doing so produces a jar that doesn't work under Java 8. This CL addresses the currently existing problematic calls (by calling the methods on the supertype Buffer instead), but we should also add safeguards. The normal solution to this general problem is to use --release, but doing so here is complicated. For more information, see #3990 RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=327654073
406a4ea did enough that I'm no longer alarmed about this. Still, we'll want to do more before too long. |
Some work on |
We already have cases of the conditional use I described above. Specifically, we use APIs from higher than Java 6 in guava-android -- again, only conditionally, but guava/android/guava/src/com/google/common/util/concurrent/FuturesGetChecked.java Line 117 in c8d0536
|
|
We can also consider using That said, that is an option only for the JRE, not for Android. That said, we less urgently need |
…m tests. This doesn't fix a practical problem today. What it does do is unblock us from adding checking (which will run in our internal builds) that will detect the main problems described in #3990. RELNOTES=n/a PiperOrigin-RevId: 395740030
(Building with JDK8 requires our newly adopted Error Prone setup to stick with an old version of Error Prone.) [edit: And eamonnmcmanus mentions #5653 as a problem with using older-than-necessary versions of the JDK in general.] |
Issue #6167 is related to Error Prone setup. |
…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
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
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
…hecker) for Maven builds. We already have it on for our builds inside Google, but Maven checking provides an additional line of defense against #3990. Because this CL enables checking for our _tests_, too (which is hard not to do, as discussed in the existing `pom.xml` comment about NullArgumentForNonNullParameter), I had to edit a couple benchmarks to avoid using what are _in a limited sense_ "Java 9+ APIs." They wouldn't be practical problems, though. RELNOTES=n/a PiperOrigin-RevId: 511801224
…hecker) for Maven builds. We already have it on for our builds inside Google, but Maven checking provides an additional line of defense against #3990. Because this CL enables checking for our _tests_, too (which is hard not to do, as discussed in the existing `pom.xml` comment about NullArgumentForNonNullParameter), I had to edit a couple benchmarks to avoid using what are _in a limited sense_ "Java 9+ APIs." They wouldn't be practical problems, though. RELNOTES=n/a PiperOrigin-RevId: 511830560
I am not quite ready to declare absolute victory after #6334, but that helps. I note that we don't run Error Prone (and thus Java8ApiChecker) under Java versions below 11 (#6230, #6243), but that's OK:
Other things that could help:
|
I mentioned this in #5457 (comment) earlier today, but: Error Prone just set up testing based on Maven toolchains. As discussed above, that would be useful for us here. |
This is the first use of a Java 9 API in Guava, but we use the API only when it's available, so we maintain compatibility with Java 8. Use of Java 9 APIs is relevant to #6549 and #3990 (and also mojohaus/animal-sniffer#67). I didn't make the same change for `guava-android`, which [will add `java.util.zip.CRC32C` in API Level 34](https://developer.android.com/reference/java/util/zip/CRC32C). I don't know if Android is providing similar performance improvements, so it might not even matter. But even if I wanted to do it, I can't with my current approach, which relies on `MethodHandle`—unless I want to make even the usage of `MethodHandle` conditional on a reflective check :) RELNOTES=`hash`: Enhanced `crc32c()` to use Java's hardware-accelerated implementation where available. PiperOrigin-RevId: 539722059
This is the first use of a Java 9 API in Guava, but we use the API only when it's available, so we maintain compatibility with Java 8. Use of Java 9 APIs is relevant to #6549 and #3990 (and also mojohaus/animal-sniffer#67). I didn't make the same change for `guava-android`, which [will add `java.util.zip.CRC32C` in API Level 34](https://developer.android.com/reference/java/util/zip/CRC32C). I don't know if Android is providing similar performance improvements, so it might not even matter. But even if I wanted to do it, I can't with my current approach, which relies on `MethodHandle`—unless I want to make even the usage of `MethodHandle` conditional on a reflective check :) RELNOTES=`hash`: Enhanced `crc32c()` to use Java's hardware-accelerated implementation where available. PiperOrigin-RevId: 539722059
This is the first use of a Java 9 API in Guava, but we use the API only when it's available, so we maintain compatibility with Java 8. Use of Java 9 APIs is relevant to #6549 and #3990 (and also mojohaus/animal-sniffer#67). I didn't make the same change for `guava-android`, which [will add `java.util.zip.CRC32C` in API Level 34](https://developer.android.com/reference/java/util/zip/CRC32C). I don't know if Android is providing similar performance improvements, so it might not even matter. But even if I wanted to do it, I can't with my current approach, which relies on `MethodHandle`—unless I want to make even the usage of `MethodHandle` conditional on a reflective check :) RELNOTES=`hash`: Enhanced `crc32c()` to use Java's hardware-accelerated implementation where available. PiperOrigin-RevId: 539722059
This is the first use of a Java 9 API in Guava, but we use the API only when it's available, so we maintain compatibility with Java 8. Use of Java 9 APIs is relevant to #6549 and #3990 (and also mojohaus/animal-sniffer#67). I didn't make the same change for `guava-android`, which [will add `java.util.zip.CRC32C` in API Level 34](https://developer.android.com/reference/java/util/zip/CRC32C). I don't know if Android is providing similar performance improvements, so it might not even matter. But even if I wanted to do it, I can't with my current approach, which relies on `MethodHandle`—unless I want to make even the usage of `MethodHandle` conditional on a reflective check :) RELNOTES=`hash`: Enhanced `crc32c()` to use Java's hardware-accelerated implementation where available. PiperOrigin-RevId: 539983316
There are many downsides to the "be very very sure" approach, but one that's only recently occurred to me is this: Other people may build their own copies of Guava for internal use (to fulfill security requirements, to apply patches, to insert debugging printlns...). It would be nice if they didn't encounter any unpleasant surprises when they switch from a prebuilt Guava to a version that they build locally—and potentially build with a different version of javac. (not that we are currently relying on our builds to be built with JDK 8, but the JDK developers have the right to make another |
Coming here from google/auto#1596 Fwiw, that "animal sniffer doesn't detect everything" issue has been known for almost a decade (and the underlying issue for much more: there's a reason why javac warns when using |
The bizarre thing about the |
Sorry, I was a bit distracted by my Animal Sniffer grouchiness yesterday, and I didn't really speak much to your point, nor think things through a whole lot in general. If I had any point yesterday, it would be: The combination of Animal Sniffer and an additional build with Java 8 has worked pretty well for us, except for the For our projects that don't even use Animal Sniffer yet, I definitely would want to pursue the toolchain-based approach (rather than Animal Sniffer) if we were to decide to pursue anything at all. Our current approach in Guava (and Truth and maybe others) is Doing It Wrong (though we're likely to be OK in practice, given that we've thrown yet more testing thrown into the mix). Your comment also reminds me that, while I found that we could add |
We're also hearing that Android desugaring is more reliable when libraries are compiled against |
(Ideally we'd have a test that runs D8/R8 over |
I discovered in protocolbuffers/protobuf#7827 (comment) that Animal Sniffer does not fail the build for dangerous covariant return types. This means that, if we build a Guava release with JDK 11 (which we probably will, if we haven't already!), it will contain references that don't work under JDK 8. We do in fact have such references.
Luckily, I do not see any additional such problems in the Android branch. (Presumably our internal Android tests have detected any possible problems so far.)
We should set this up before our next release or else be VERY VERY sure to use JDK 8 to build it.
The text was updated successfully, but these errors were encountered: