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

Figure out when to require Java 11 for new Guava versions #6614

Open
cpovirk opened this issue Jun 30, 2023 · 7 comments
Open

Figure out when to require Java 11 for new Guava versions #6614

cpovirk opened this issue Jun 30, 2023 · 7 comments
Labels
P3 no SLO package=general type=other Miscellaneous activities not covered by other type= labels

Comments

@cpovirk
Copy link
Member

cpovirk commented Jun 30, 2023

Probably not soon :) I just had another note I wanted to make about this, so now seems like the time to start collecting those notes.

@cpovirk cpovirk added type=other Miscellaneous activities not covered by other type= labels package=general P3 no SLO labels Jun 30, 2023
@cpovirk
Copy link
Member Author

cpovirk commented Jul 5, 2023

I think I failed to actually mention the new "note I wanted to make about this," which was:

cpovirk added a commit to google/truth that referenced this issue Jul 24, 2023
Notes:

- The GWT bump requires changing the browser setting from "FF38" to "FF."
- I skipped the `jsinterop-annotations` bump to 2.1.0 because it's built
  with `-target 11`, while we still support 8.
  (Closes #1147)
  (I've noted this in google/guava#6614)
- The command I used is:
  ```
  mvn org.codehaus.mojo:versions-maven-plugin:2.16.0:{update-properties,use-latest-releases} -DgenerateBackupPoms=false -Dexcludes=com.google.guava:guava
  ```
  That tried to update protobuf to a release candidate. I had thought
  that perhaps this was the result of [a protobuf change from "-rc1" to
  "-rc-1"](protocolbuffers/protobuf#6522), but
  I'm wondering if it's actually just that `versions-maven-plugin` (in
  contrast to Dependabot) counts release candidates [as
  releases](https://www.mojohaus.org/versions/versions-maven-plugin/use-latest-releases-mojo.html)?
  I'd have to investigate further and perhaps [use
  `rulesUri`](https://stackoverflow.com/a/46935363/28465). But since we
  normally rely on Dependabot (and I was using `versions-maven-plugin`
  here only "to make things easier"... :)), I'm not going to worry about
  it now.
cpovirk added a commit to google/truth that referenced this issue Jul 24, 2023
Notes:

- The GWT bump requires changing the browser setting from "FF38" to "FF."
- I skipped the `jsinterop-annotations` bump to 2.1.0 because it's built
  with `-target 11`, while we still support 8.
  (Closes #1147)
  (I've noted this in google/guava#6614)
- The command I used is:
  ```
  mvn org.codehaus.mojo:versions-maven-plugin:2.16.0:{update-properties,use-latest-releases} -DgenerateBackupPoms=false -Dexcludes=com.google.guava:guava
  ```
  That tried to update protobuf to a release candidate. I had thought
  that perhaps this was the result of [a protobuf change from "-rc1" to
  "-rc-1"](protocolbuffers/protobuf#6522), but
  I'm wondering if it's actually just that `versions-maven-plugin` (in
  contrast to Dependabot) counts release candidates [as
  releases](https://www.mojohaus.org/versions/versions-maven-plugin/use-latest-releases-mojo.html)?
  I'd have to investigate further and perhaps [use
  `rulesUri`](https://stackoverflow.com/a/46935363/28465). But since we
  normally rely on Dependabot (and I was using `versions-maven-plugin`
  here only "to make things easier"... :)), I'm not going to worry about
  it now.
  ...
  Also, it looks like protobuf 4 might remove the `hasPresence()` method
  that we'd migrated to back in cl/508716698. If so, there's a good
  chance that the protobuf team will fix things for us :) If not, I'm
  assuming that this will relate to
  ["Editions."](https://protobuf.dev/editions/overview/)
cpovirk added a commit to google/truth that referenced this issue Jul 24, 2023
Notes:

- The GWT bump requires changing the browser setting from "FF38" to "FF."
- I skipped the `jsinterop-annotations` bump to 2.1.0 because it's built
  with `-target 11`, while we still support 8.
  (Closes #1147)
  (I've noted this in google/guava#6614)
- The command I used is:
  ```
  mvn org.codehaus.mojo:versions-maven-plugin:2.16.0:{update-properties,use-latest-releases} -DgenerateBackupPoms=false -Dexcludes=com.google.guava:guava
  ```
  That tried to update protobuf to a release candidate. I had thought
  that perhaps this was the result of [a protobuf change from "-rc1" to
  "-rc-1"](protocolbuffers/protobuf#6522), but
  I'm wondering if it's actually just that `versions-maven-plugin` (in
  contrast to Dependabot) counts release candidates [as
  releases](https://www.mojohaus.org/versions/versions-maven-plugin/use-latest-releases-mojo.html)?
  I'd have to investigate further and perhaps [use
  `rulesUri`](https://stackoverflow.com/a/46935363/28465). But since we
  normally rely on Dependabot (and I was using `versions-maven-plugin`
  here only "to make things easier"... :)), I'm not going to worry about
  it now.
  ...
  Also, it looks like protobuf 4 might remove the `hasPresence()` method
  that we'd migrated to back in cl/508716698. If so, there's a good
  chance that the protobuf team will fix things for us :) If not, I'm
  assuming that this will relate to
  ["Editions."](https://protobuf.dev/editions/overview/)

Fixes #1149
Fixes #1148
Fixes #1146
Fixes #1145
@cpovirk
Copy link
Member Author

cpovirk commented Jul 24, 2023

It turns out that the latest release of jsinterop-annotations is built to require Java 11. That said:

  • We somehow don't declare a dep on that library, even though we use things from that package in guava-gwt. Are we relying on users to provide it themselves? (This is another case in which it would be nice for our external GWT tests to be as thorough as our internal ones: b/169936479.) Ah, might the GWT plugin provide it automatically? Are the effects any different on J2CL than on GWT? (Perhaps J2CL users are even more likely to provide the dependency themselves?)
  • I don't know how much the annotations artifact changes over time. I guess @JsNonNull was new in 2.0 or so, but I haven't looked at what changes in 2.1.0. Maybe we can get away with not updating for a while.
  • Even if we eventually need to require Java 11 for this reason, we might be able to require it only for guava-gwt.
  • Maybe things actually kinda sorta work if only annotations are built for Java 11, given how Java is usually tolerant of missing annotations?
  • Oh, and this is all just in sources seen only by the GWT and J2CL compilers. Maybe we should just increase the -target for our GWT build? Unfortunately, I think that might affect both client (JavaScript) and server (bytecode), which would mean that users do need to upgrade. Hmm, I thought guava-gwt contained actual compiled classes (not just sources to be compiled by the GWT/J2CL compiler later), but maybe that is only for GWT-RPC, which we don't support anymore. If we do still need to provide server sources, perhaps it's possible to compile them with a different -target than the others.
  • Or I guess we don't even need to change our -target: We just need to use a compiler that would recognize the newer bytecode (assuming that everything works OK for users at runtime). That's more like Require Java 11+ to *build* Guava but continue to support Java 8 at runtime #6549. I'll note this there.

copybara-service bot pushed a commit to google/truth that referenced this issue Jul 24, 2023
Notes:

- The GWT bump requires changing the browser setting from "FF38" to "FF."
- I skipped the `jsinterop-annotations` bump to 2.1.0 because it's built
  with `-target 11`, while we still support 8.
  (Closes #1147)
  (I've noted this in google/guava#6614)
- The command I used is:
  ```
  mvn org.codehaus.mojo:versions-maven-plugin:2.16.0:{update-properties,use-latest-releases} -DgenerateBackupPoms=false -Dexcludes=com.google.guava:guava
  ```
  That tried to update protobuf to a release candidate. I had thought
  that perhaps this was the result of [a protobuf change from "-rc1" to
  "-rc-1"](protocolbuffers/protobuf#6522), but
  I'm wondering if it's actually just that `versions-maven-plugin` (in
  contrast to Dependabot) counts release candidates [as
  releases](https://www.mojohaus.org/versions/versions-maven-plugin/use-latest-releases-mojo.html)?
  I'd have to investigate further and perhaps [use
  `rulesUri`](https://stackoverflow.com/a/46935363/28465). But since we
  normally rely on Dependabot (and I was using `versions-maven-plugin`
  here only "to make things easier"... :)), I'm not going to worry about
  it now.
  ...
  Also, it looks like protobuf 4 might remove the `hasPresence()` method
  that we'd migrated to back in cl/508716698. If so, there's a good
  chance that the protobuf team will fix things for us :) If not, I'm
  assuming that this will relate to
  ["Editions."](https://protobuf.dev/editions/overview/)

Fixes #1149
Fixes #1148
Fixes #1146
Fixes #1145

Fixes #1150

RELNOTES=n/a
PiperOrigin-RevId: 550553262
copybara-service bot pushed a commit to google/truth that referenced this issue Jul 24, 2023
Notes:

- The GWT bump requires changing the browser setting from "FF38" to "FF."
- I skipped the `jsinterop-annotations` bump to 2.1.0 because it's built
  with `-target 11`, while we still support 8.
  (Closes #1147)
  (I've noted this in google/guava#6614)
- The command I used is:
  ```
  mvn org.codehaus.mojo:versions-maven-plugin:2.16.0:{update-properties,use-latest-releases} -DgenerateBackupPoms=false -Dexcludes=com.google.guava:guava
  ```
  That tried to update protobuf to a release candidate. I had thought
  that perhaps this was the result of [a protobuf change from "-rc1" to
  "-rc-1"](protocolbuffers/protobuf#6522), but
  I'm wondering if it's actually just that `versions-maven-plugin` (in
  contrast to Dependabot) counts release candidates [as
  releases](https://www.mojohaus.org/versions/versions-maven-plugin/use-latest-releases-mojo.html)?
  I'd have to investigate further and perhaps [use
  `rulesUri`](https://stackoverflow.com/a/46935363/28465). But since we
  normally rely on Dependabot (and I was using `versions-maven-plugin`
  here only "to make things easier"... :)), I'm not going to worry about
  it now.
  ...
  Also, it looks like protobuf 4 might remove the `hasPresence()` method
  that we'd migrated to back in cl/508716698. If so, there's a good
  chance that the protobuf team will fix things for us :) If not, I'm
  assuming that this will relate to
  ["Editions."](https://protobuf.dev/editions/overview/)

Fixes #1149
Fixes #1148
Fixes #1146
Fixes #1145

Fixes #1150

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

cpovirk commented Oct 9, 2023

Java 11 brought nestmates, which would let us make fields like this one private without any performance hit from the need for bridge methods. That hit is likely to be unnoticeable for most methods, small even for CharMatcher, and avoidable by assigning the result of the CharMatcher accessor call to a field (rather than calling the accessor over and over). Still, it would be nice for a single innocent-looking keyword not to have the potential to affect performance. And making things private is nice. (It's even required for similar constructs in Kotlin.)

Admittedly, making nested classes' members private is less important when the class that the API is part of is final, since that makes clear that any package-private methods aren't being called more widely through a subtype. And there are additional arguments for omitting private: One is that private doesn't further restrict visibility, so we'd rather write leave it out for brevity. Another (somewhat contradictory) argument is that the lack of private hints that the API is being used from the nested class's enclosing class (though of course Java would permit the call even with private, just with the possible performance hit discussed above).

Anyway, the point here is that we'd pick up this improvement (and others, like better string concatenation) if we didn't have to target Java 8. (Hmm, I guess we could theoretically provide a multi-release jar with the exact same classes built for both versions, just with different -source -target flags! This would even provide yet another partial defense against problems like that from #3990. But that would double the size of Guava (and possibly upset tools that get confused by mrjars) for very little upside.)

(I was tempted to add that we could consider targeting a newer version of Java for guava-android, since newer bytecode gets converted to Android bytecode that supports even old versions of Android. But of course we say that guava-android is usable under a JVM, too, so that wouldn't work.)

@cpovirk
Copy link
Member Author

cpovirk commented Nov 18, 2024

Other potentially nice things for the future:

  • @Deprecated(forRemoval = true)
  • the ability to drop a boatload of code in Throwables (including references to ThreadDeath, which is (speaking of which!) deprecated for removal), in ChecksumhashFunction, in Hashing, and perhaps elsewhere
  • we hope someday nullness markers
  • var and maybe other nice little things
  • [edit: Runtime.version, mostly for use in our tests, though we primarily check isJava8(), so any checks based on Java 8 would just go away entirely :)]

(As always, we'd want to keep in mind that we also still target Android, including fairly old versions, so we might not want to make at least some changes until we can make them there, too.)

@cpovirk
Copy link
Member Author

cpovirk commented Dec 17, 2024

Java 11 brought nestmates, which would let us make fields like this one private without any performance hit from the need for bridge methods.... And making things private is nice. (It's even required for similar constructs in Kotlin.)

I learned yesterday that nestmates also enable runtime access through MethodHandles.Lookup, which would be helpful for the forthcoming usage of VarHandle in AbstractFuture (and, I suspect, would let us simplify its existing usage of AtomicReferenceFieldUpdater) in #7555. We have an easy workaround, but it would have been nice to not have had to fiddle around with the code and then retrace my steps after I forgot my earlier partial understanding and so had to build up a fuller understanding later.

@cpovirk
Copy link
Member Author

cpovirk commented Dec 20, 2024

More notes:

Historically, one reason that we've maintained support for Java 8 is the Google Cloud Client Libraries. The documentation for those libraries currently says:

Java 8 will continue to be supported by Cloud Client Libraries for Java until at least September 2026.

I'm not sure how much we've pushed on the idea that those libraries could stick with an older version of Guava if Guava were to drop support for Java 8 before Cloud did. I would expect that approach to work well in practice for Cloud users, but I could imagine that some users would have reservations about running with a newer version of Guava than the one that Cloud recommends, and that may be enough to stop the idea.

Anyway, the reason that I'm thinking about this yet again is that the majority of my week is going to reworking our nullness annotations to work better with Java 8 (e.g., #7566). That's turned what should have been a straightforward update of https://github.com/google/guava/tree/jspecify-preview into a Project.

@cpovirk
Copy link
Member Author

cpovirk commented Dec 26, 2024

Whenever we do do this, Cloud (and others) may want us to bump our major version. It's left a bit up in the air in https://opensource.google/documentation/policies/library-breaking-change. Additionally, that policy refers to "vendor support," which can mean a lot of things in the context of Java (and something else in the context of Cloud). It's something for us to look into.

@cpovirk cpovirk changed the title Figure out when to drop Java 8 support Figure out when to require Java 11 for new Guava versions Dec 30, 2024
copybara-service bot pushed a commit that referenced this issue Jan 13, 2025
…possible.

(One other note: I had some more fun with [Java 8 support](#6614) in `LittleEndianByteArray`.)

RELNOTES=Changed various classes to stop using `sun.misc.Unsafe` under Java 9+.
PiperOrigin-RevId: 714943678
copybara-service bot pushed a commit that referenced this issue Jan 14, 2025
…possible.

(One other note: I had some more fun with [Java 8 support](#6614) in `LittleEndianByteArray`.)

RELNOTES=Changed various classes to stop using `sun.misc.Unsafe` under Java 9+.
PiperOrigin-RevId: 715182856
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 no SLO package=general type=other Miscellaneous activities not covered by other type= labels
Projects
None yet
Development

No branches or pull requests

1 participant