-
Notifications
You must be signed in to change notification settings - Fork 11k
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
Add module-info.java #2970
Comments
Guava has an (BTW, I think I might have misunderstood something, because |
Our current thinking is that we'll look into this next quarter. We have seen some problems from |
It is possible to only compile A maven example: |
Right, thanks. We've seen problems even when the main |
@cpovirk could you tell me more about this problem? |
I wasn't personally involved in fixing the problems, but the basic idea seems to be that people scan the whole classpath (using something like |
It's worth mentioning that if we add |
@orionll Am I right to think/remember that in the JPMS, open packages are packages whose internal classes can be inspected with reflection? |
@jbduncat Yes, exactly. And also private members of public classes. |
@orionll Cool, thanks for confirming things for me. :) I personally wonder how important it would be for Guava's packages to be open when used on the module path. I struggle to imagine that reflectively calling Guava's internals is a common thing to do, especially considering Guava's (IMO) pretty durn good API. 🤔 |
Are there any reasons for it not being open? Even if it's uncommon it might still be done by some people. |
@HoldYourWaffle I think the main reason is it prevents people from using reflection to depend on internals which may change or disappear in future releases of Guava without warning. |
...which by my understanding makes things easier for everyone in the long-run. |
The only reason I can currently think of to have Guava's packages open in the |
All Guava packages should be closed because as @jbduncan said the dependence on class internals is a bad practice. If someone really wants to access the internals, they can use |
Good point I forgot about |
It does mean that |
As much as I love Guava and appreciate Google's efforts, it is somehow embarrassing that a company like Google is not able to adopt Java modules within one year. Either Google does not use Guava internally or they keep using JDK 8 and won't adopt Jigsaw. |
@hannes-transentials I think it's most likely that Google have not migrated to JDK 11 and adopted modules yet simply because their internal codebase is so mind-bogglingly humongous. ;) I say this because I remember reading somewhere (or I inferred) that they use Guava or an superset internally, and I also remember they announced a few years ago that they'd finally migrated to JDK 8 after a lot of effort. So I'm sure that they'll announce support for JDK 11 or a later LTS version (and, by extension, modules) when they fully migrate away from Java 8 and when they feel that most of us non-Googlers have moved away from Java 8 too. (I know that my company hasn't done so yet simply because Java 9 was such a freaking big, backwards-incompatible change!) |
It's worth mentioning that adding |
So I either do without modularized applications or stay away from Guava (and many other popular applications)? I somehow hoped that there was some middle ground. |
Well... you can use Guava as a module in a vanilla-Java modular application. But since Guava only includes an Furthermore, frameworks built on top of Java that have their own programming models, like Spring, may have not fully migrated to be Java-11-compatible yet, so if you use such frameworks a lot, you may have to wait a bit longer. That being said, if you do use a framework such a Spring, please check for yourself if Java 11 and modules work with it, since my knowledge of Spring and other frameworks is limited. :) |
Well you can create multi-release jars, where the ¹ As long as no fancy custom class loaders eagerly load everything they find in a jar without reading the manifest entries. |
@hannes-transentials You could make use of something like https://github.com/moditect/moditect to adapt guava and add a module-info.java/.class at your applications side of things as a transitionary work around. If module-info.java was to be added to guava, hopefully it'd be done so as a modular jar so we don't break java 8< versions. |
(And this time, include a `@since` tag :)) We'd originally added this in cl/723988216 but then withdrew it in cl/728267849 so that we could release a [module-system-friendly](#2970) version of Guava as a _patch_ release, rather than as a _minor_ release. RELNOTES=`net`: Added `image/avif` to `MediaType`. PiperOrigin-RevId: 728268046
(And this time, include a `@since` tag :)) We'd originally added this in cl/723988216 but then withdrew it in cl/728267849 so that we could release a [module-system-friendly](#2970) version of Guava as a _patch_ release, rather than as a _minor_ release. RELNOTES=`net`: Added `image/avif` to `MediaType`. PiperOrigin-RevId: 738775856
@bowbahdoe I kind of want to actually make them. I'll look for a low-min jacket provider 😆 Also, I just wanted to extend a thank you to @cpovirk, @bowbahdoe, @cowwoc, @ben-manes, @jbduncan, and many others in this thread who were extremely helpful and patient. This PR was easy to write because of all the research that was done ahead of time. I'm so glad Guava will support modules now. Yay! We did it guys |
Folks, the new release seems to have a serious regression in that it doubles the size of the Guava jar file, from approximately 3MB to 6MB. |
Yes, sorry, that was a misconfiguration, which obviously I should have tested before publishing the release :( It's mentioned in the current release notes, and I have to have a fixed version published today. [edit: Now see #7743 Sorry for not filing such an issue.] |
@norrisjeremy This is probably my fault. I encountered this issue with the JAR and OSGi plugin during the JPMS PR, but thought I had solved it. In any case, extra classes in the versioned JAR root won't preclude anything from working. The JVM will prefer those classes but otherwise they should be identical. The next release should fix the issue. @cpovirk sorry about this. I promise I tested as much as I feasibly could locally. I did try to build the module descriptor without sources, but at the time sources were required for other complex reasons (iirc). |
I believe that the testlib's module-info should also require junit, e.g.
|
The PR looked pretty clearly like the result of solving a dozen similar issues, so I think an extra-large jar with some For JUnit 4:
|
…e module deps in `testlib`, too. See #2970 (comment) RELNOTES=Modified the `guava` module's dependency on `failureaccess` to be `transitive`. Also, modified the `guava-testlib` module to make its dependency on `guava` transitive, to remove its dependency on `failureaccess`, and to add a dependency (`transitive`) on `junit`. PiperOrigin-RevId: 741266808
Check my proposed changes here: #7748 History shows that a number of you folks know more about all this than we do :) |
@cpovirk I am only concerned about https://github.com/google/guava/pull/7748/files#diff-6eabd8d281c8a36ef65bc60a72f3e4af026d190937553b6b5ac0b9ddb2a6d190R20 By adding |
I agree, maybe it is better to relocate |
@sgammon thanks for your effort |
Thanks for having a look. " |
@cpovirk Backwards-compatibility aside, the right way to go would be to rename the package and then export it. Worse-case scenario, you could deprecate the old classes, redirect calls to the new package under the hood, and add Javadoc steering users to the new package. |
Hmm, where is this package anyway? :) The closest I got to finding it was https://github.com/google/guava/blob/master/guava/src/com/google/common/util/concurrent/Internal.java but this is a class, not a package. |
Nevermind, found it: https://github.com/google/guava/tree/master/futures/failureaccess/src/com/google/common/util/concurrent/internal And then I found this README.md at the top-level directory:
Oops... Are we in trouble? |
The package has been around, publicly accessible, and endorsed by us for usage a few years at this point, so I think that's as good as "exported." (That includes being listed in the OSGi As for the multiple releases: The main goal has been to neither add nor remove APIs. I think that 1.0.1 was to add the OSGi information, 1.0.2 was to add an Automatic-Module-Name, and 1.0.3 was to set up a proper module. It would have been idea to do that all in 1.0, but I think that the multiple releases have been only a marginal contributor to the occasional annoyances that people see with |
Bazel is already automatically pulling 1.0.3, since that's a transitive dependency of recent Guava releases. This just brings our explicit specification in line with that. (It's possible that it would make sense for us to stop listing the `failureaccess` dependency entirely: We're always going to be getting it as part of Guava. But maybe that would prevent us from exporting it from the `guava` target that we define? I don't feel like figuring that out right at this moment.) (followup to [our modularization efforts](google/guava#2970)) RELNOTES=n/a PiperOrigin-RevId: 741501993
Bazel is already automatically pulling 1.0.3, since that's a transitive dependency of recent Guava releases. This just brings our explicit specification in line with that. (It's possible that it would make sense for us to stop listing the `failureaccess` dependency entirely: We're always going to be getting it as part of Guava. But maybe that would prevent us from exporting it from the `guava` target that we define? I don't feel like figuring that out right at this moment.) (followup to [our modularization efforts](google/guava#2970)) RELNOTES=n/a PiperOrigin-RevId: 741553352
…ev.java/learn/modules/implied-readability/), and improve module deps in `testlib`, too. See #2970 (comment) RELNOTES=Modified the `guava` module's dependency on `failureaccess` to be `transitive`. Also, modified the `guava-testlib` module to make its dependency on `guava` transitive, to remove its dependency on `failureaccess`, and to add a dependency (`transitive`) on `junit`. PiperOrigin-RevId: 741266808
…ev.java/learn/modules/implied-readability/), and improve module deps in `testlib`, too. See #2970 (comment) RELNOTES=Modified the `guava` module's dependency on `failureaccess` to be `transitive`. Also, modified the `guava-testlib` module to make its dependency on `guava` transitive, to remove its dependency on `failureaccess`, and to add a dependency (`transitive`) on `junit`. PiperOrigin-RevId: 742835889
I released 33.4.7 with the fixes of #7748, including |
So that projects depend on this can be published to a public artifact repository.
Note that this is not breaking backward compatibility. All codes except this file can be still compiled in Java 6.
The text was updated successfully, but these errors were encountered: