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

Java 9 and Jigsaw compatibility #2571

Closed
jbduncan opened this issue Sep 21, 2016 · 17 comments
Closed

Java 9 and Jigsaw compatibility #2571

jbduncan opened this issue Sep 21, 2016 · 17 comments
Assignees

Comments

@jbduncan
Copy link
Contributor

jbduncan commented Sep 21, 2016

I wasn't able to find an issue for this, so apologies if this has been raised already.

Has Guava been tested with any of the early-access Java 9 and/or Jigsaw releases yet?

If not, this seems to be a pretty important medium-to-long-term thing to look into, as Guava currently uses sun.misc.Unsafe in a number of places, which by my understanding would prevent Guava from being used in Jigsaw-enabled versions of Java, including Java 9.

@kevinb9n
Copy link
Contributor

Guava's usage of Unsafe always has a fallback if any problem occurs.

On Wed, Sep 21, 2016 at 12:36 PM, Jonathan Bluett-Duncan <
[email protected]> wrote:

I wasn't able to find an issue for this, so apologies if this has been
raised already.

Has Guava been tested with any of the early-access Java 9 and/or Jigsaw
releases yet?

If not, this seems to be a pretty important medium-to-long-term thing to
look into, as Guava currently uses sun.misc.Unsafe in a number of places,
which by my understanding would prevent Guava from being used in
Jigsaw-enabled versions of Java, including Java 9


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#2571, or mute the thread
https://github.com/notifications/unsubscribe-auth/AA5Cl6sN5NjLotWT34upHBri7CQqC54Aks5qsYcpgaJpZM4KDMZj
.

Kevin Bourrillion | Java Librarian | Google, Inc. | [email protected]

@jbduncan
Copy link
Contributor Author

jbduncan commented Sep 21, 2016

Yes, that's true actually!

However, I think the fallbacks work on the assumption that sun.misc.Unsafe is a class which exists and which can be made accessible by reflection, which I believe has been "fixed" in Jigsaw by either removing sun.misc.Unsafe completely or moving it to a jdk-internal module which can only be accessed with a command-line argument. If I'm mistaken on this, then I'd be more than happy to be proved so. :)

But despite all this, I still think it's important to test Guava against Java 9 and Jigsaw if it's not been done so already, in case there are other crucial areas where backwards-compatibility has been broken and would otherwise prevent open source Guava's uptake by Java 9 users in the future.

@kevinb9n
Copy link
Contributor

Ah, I see.

We'll be receptive to specific fix requests, but probably won't be able to put much thought into this ourselves until we get to the point of testing migrating ourselves to Java 9. (Bear in mind we finally successfully moved to Java 8 last week! But Java 9 should definitely be a quicker project.)

@jbduncan
Copy link
Contributor Author

Ah yes, I learned about your successful migration to Java 8 the other day. Congratulations!

Going back to the subject of Java 9 though, you may very well be right about it being quicker to migrate to than Java 8.

On one hand, it'll help that with the release of MRJARs, one can have build artifacts that continue to use internal APIs like com.sun.* on Java 8 but use officially supported replacements on Java 9+. But on the other hand, if there are places in Guava where com.sun.* is vital and Oracle have not provided sufficient replacement APIs, then Guava may end up being stuck on Java 8, which concerns me.

I'm also concerned by how OpenJDK 9 has, at the time of writing of me writing this, gone past the Feature Complete milestone, which may make improving the replacement APIs difficult if needed.

What are your thoughts on this @kevinb9n?

Also, whereas I don't feel qualified enough to thoroughly test Guava against Java 9 & Jigsaw and to talk to Oracle in your stead (as I'm not familiar with all of Guava's intricacies), I am more than happy to run Guava against Java 9 and reply back to this issue if I discover anything. Would you be happy if I did this @kevinb9n?

@octylFractal
Copy link

According to jdeps -jdkinternals, Guava only relies on sun.misc.Unsafe, which has been mostly replaced by variable handles in Java 9. There might be some other things that are different but not explicitly depended on. I'm going to try making a fork of Guava that uses Java 9 as it's JDK requirement and run my small projects on that for testing.

@jbduncan
Copy link
Contributor Author

jbduncan commented Sep 24, 2016

I just ran jdeps -jdkinternals using jigsaw-jdk-9-ea+136_windows-x64_bin on my copy of Guava, and it seems that sun.security.jca.{ProviderList, Providers} and sun.misc.FpUtils are used in test code as well. But I'm not so concerned about that, because the tests which use those APIs are more-or-less one off cases, and it looks like they can be changed, disabled or removed if needed.

I also did a half-thorough search of the Guava non-test codebase, and it seems that @kevinb9n was actually right, and I was wrong!

Although using sun.misc.Unsafe on a JVM which doesn't have that class would cause exceptions/errors to be thrown by the Guava classes that use it, it seems the exceptions do get caught eventually, higher up all the potential call chains, by other Guava classes, and that viable alternatives would be used whenever they happen.

So it seems this issue is actually not as urgent as I first thought it was! 😝

@octylFractal
Copy link

I also just ran through master and replaced all the usages of Unsafe with VarHandle. The code looks much cleaner, and it was a quick & easy transition. So handling this when Java 9 is released probably shouldn't be too much of a hassle.

The main pain I encountered while doing this was that the tools used in the maven build can't handle Java 9 yet, so I can't actually make a build of it immediately.

@jbduncan
Copy link
Contributor Author

jbduncan commented Sep 24, 2016

@kenzierocks Thanks for looking into that.

So I suppose this would only be urgent then if Guava starts having users who try to compile the Guava sources or tests with JDK 9+ and they find that certain sun.* classes which Guava depends on have been removed. But we won't really know until Maven supports Java 9.

I also don't know enough to know exactly which classes have been planned for removal/module encapsulation in JDK 9 and which are just deprecated (jdeps doesn't seem to give me the whole picture here), so more research would be needed.

@jbduncan
Copy link
Contributor Author

The transition might be made even easier by the lexicographical Arrays::compare methods, which could potentially be used to implement or replace UnsignedBytes.lexicographicalComparator.

@chrisseaton
Copy link

I found this use of an internal JDK field which doesn't work on Java 9.

b5b4b40#commitcomment-20536128

There's a fallback, but it just does nothing. Is that a problem? What goes wrong if we use the fallback?

chrisseaton referenced this issue Jan 19, 2017
ClassLoader that loaded FinalizableReferenceQueue from being
garbage-collected subsequently. This is Guava issue
http://code.google.com/p/guava-libraries/issues/detail?id=92
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=28624233
@cpovirk
Copy link
Member

cpovirk commented Jan 19, 2017

@eamonnmcmanus might know what we'd need to do.

@eamonnmcmanus
Copy link
Member

@cpovirk can you log a separate issue for that and assign it to me?

@cpovirk
Copy link
Member

cpovirk commented Jan 23, 2017

Filed #2723

cpovirk added a commit that referenced this issue Jun 8, 2017
cpovirk added a commit that referenced this issue Jun 8, 2017
FpUtils is going away in Java 9.
We'd use Math under Java 7, too, but it's not present until Java 8.

(part of #2571)

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=158434703
cpovirk added a commit that referenced this issue Jun 9, 2017
(part of #2571)

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=158475485
cpovirk added a commit that referenced this issue Jun 9, 2017
(part of #2571)

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=158545119
cpovirk added a commit that referenced this issue Jun 12, 2017
(I got confused when I added an argLine in the parent pom (as part of Java 9 testing) and found it had no effect, apparently because it's overwritten in the child.)

(part of #2571)

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=158738701
cpovirk added a commit that referenced this issue Jun 12, 2017
Apparently 2.8.40 is out, but currently we're internally upgrading to 2.7.19, so that seems like the safest thing to target. (But I'm sure we'll get to 2.8.40 or later eventually, so maybe I'm wasting time bothering with 2.7.19....)

(part of #2571)

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=158745717
cpovirk added a commit that referenced this issue Jun 12, 2017
(part of #2571)

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=158747678
cpovirk added a commit that referenced this issue Jun 16, 2017
Under previous JDKs, we continue to output "java.util.Map.java.util.Map.Entry," just as those JDKs do.

(part of #2571)

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=159237707
@cowwoc
Copy link

cowwoc commented Aug 22, 2017

Filed #2920

@eamonnmcmanus eamonnmcmanus removed their assignment Oct 4, 2017
@eamonnmcmanus
Copy link
Member

(I'm already assigned on #2723 and I don't think I'm otherwise involved here.)

@jbduncan
Copy link
Contributor Author

jbduncan commented Oct 4, 2017

(SGTM, @eamonnmcmanus. Many thanks in advance!)

@cpovirk
Copy link
Member

cpovirk commented Oct 4, 2017

@netdpb did a bunch of work here after I stopped, and it's been released in 23.1.

Remaining:

I don't believe there's anything to do with Unsafe yet, as it's remaining exposed in Java 9.

Let's track remaining work with the separate bugs. Please open more if you encounter more problems.

@cpovirk cpovirk closed this as completed Oct 4, 2017
cpovirk added a commit that referenced this issue Oct 20, 2017
(followup to CL 158434703 to make the Android tests runnable under Java 9)

(part of #2571)

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=172804202
netdpb pushed a commit that referenced this issue Dec 3, 2020
…and deprecate JAVA_EXT_DIRS.

value()'s return type has been @nullable since 4232450, but I had forgotten the details about why, despite past CLs to update the test for specific missing keys.

I assume that we'll never actually *remove* JAVA_EXT_DIRS.

(Just slightly relevant to #2571)

RELNOTES=`base`: Deprecated `StandardSystemProperty.JAVA_EXT_DIRS`. We do not plan to remove the API, but in recent versions of Java, that property always has a value of `null`.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=345251412
netdpb pushed a commit that referenced this issue Dec 3, 2020
…and deprecate JAVA_EXT_DIRS.

value()'s return type has been @nullable since 4232450, but I had forgotten the details about why, despite past CLs to update the test for specific missing keys.

I assume that we'll never actually *remove* JAVA_EXT_DIRS.

(Just slightly relevant to #2571)

RELNOTES=`base`: Deprecated `StandardSystemProperty.JAVA_EXT_DIRS`. We do not plan to remove the API, but in recent versions of Java, that property always has a value of `null`.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=345251412
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants