-
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. |
I can't think of any problems with you depending on |
@cpovirk I've been reworking this PR over the past 48 hours, and it is apparent to me that there are multiple approaches we could take with regard to JPMS compilation steps: (1) Modify JPMS-enabled libs only. Additional compiler executions could be added to JPMS-enabled modules (non-Android
(2) Modify defaults and then non-JPMS libs. More targets are JPMS-enabled in this PR than not (the odd ones out are Android Guava,
Any advice one way or the other? After investigating 2, I'm inclined to stick with 1, with extensive inline comments justifying why compiler flags are put where they are. Current draft of these changes is here, although it is undergoing cleanup now and will trim down. Case 1 and 2 are both on the order of hundreds of lines, less than 500 for sure. We're talking about, like, 350 vs. 250 or somewhere in there in terms of lines added, mostly of POM XML: The original PR weighs in much heavier: So I think we are well on our way to a trim, potentially mergeable change. cc / @cowwoc in case you want to weigh in |
Update: You can try the latest JPMS-enabled Guava here, in the JPMS attic repository. Add it to your Gradle or Maven build according to the directions, and then use the JPMS version of Guava with: <dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</groupId>
<version>33.4.0-jre-jpms</version>
</dependency> dependencies {
implementation("com.google.guava:guava:33.4.0-jre-jpms")
} To force overrides transitively in Gradle: configurations.all {
resolutionStrategy.eachDependency {
if (it.requested.group == "com.google.guava") {
useVersion("33.4.0-jre-jpms")
because("jpms support")
}
}
} Several projects are passing integration tests, including Caffeine, GSON, Checkstyle, and others. I am using it already in downstream projects via Gradle with no issues. |
This changeset adds full support for modular Java builds in Guava, and in libraries which depend on Guava. The Guava JAR for JRE now structures as a Multi-Release JAR, with a module definition situated in `META-INF/versions/9/`. Guava remains compatible with JDK 8. - feat: add `module-info.java` to `guava` module - chore: update `guava` to build MRJAR - chore: adjust dev version → `1.0-HEAD-[jre|android]-SNAPSHOT` - chore: upgrade maven compiler plugin → `3.12.1` Fixes and closes google#2970 Relates-To: elide-dev/jpms#1 Signed-off-by: Sam Gammon <[email protected]> Signed-off-by: Sam Gammon <[email protected]>
I don't want to act like I would have foreseen this, but now that you say it, I find it very believable that (1) would turn out simpler. I skimmed the draft PR, and nothing in it immediately offended my delicate sensibilities, so that also seems like a good sign. I'm all ears if you or others end up with reasons to prefer (2) in the future, but (1) sounds fine to me. |
Cool :) once it is cleaned up and my mess of commits are squashed, I will update the attached PR (#7094) and push it again to the JPMS attic for testing. |
This changeset adds full support for modular Java builds in Guava, and in libraries which depend on Guava. The Guava JAR for JRE now structures as a Multi-Release JAR, with a module definition situated in `META-INF/versions/9/`. Guava remains compatible with JDK 8. - feat: add `module-info.java` to `guava` module - chore: update `guava` to build MRJAR - chore: adjust dev version → `1.0-HEAD-[jre|android]-SNAPSHOT` - chore: upgrade maven compiler plugin → `3.12.1` Fixes and closes google#2970 Relates-To: elide-dev/jpms#1 Signed-off-by: Sam Gammon <[email protected]> Signed-off-by: Sam Gammon <[email protected]>
This changeset adds full support for modular Java builds in Guava, and in libraries which depend on Guava. The Guava JAR for JRE now structures as a Multi-Release JAR, with a module definition situated in `META-INF/versions/9/`. Guava remains compatible with JDK 8. - feat: add `module-info.java` to `guava` module - chore: update `guava` to build MRJAR - chore: adjust dev version → `1.0-HEAD-[jre|android]-SNAPSHOT` - chore: upgrade maven compiler plugin → `3.12.1` Fixes and closes google#2970 Relates-To: elide-dev/jpms#1 Signed-off-by: Sam Gammon <[email protected]> Signed-off-by: Sam Gammon <[email protected]>
This changeset adds full support for modular Java builds in Guava, and in libraries which depend on Guava. The Guava JAR for JRE now structures as a Multi-Release JAR, with a module definition situated in `META-INF/versions/9/`. Guava remains compatible with JDK 8. - feat: add `module-info.java` to `guava` module - feat(jpms): add `module-info.java` to `failureaccess` - feat(jpms): add `module-info.java` to `testlib` - fix: necessary fixes to get testsuite running on modular java - chore: update `guava` to build MRJAR - chore: adjust dev version → `1.0-HEAD-[jre|android]-SNAPSHOT` - chore: upgrade maven compiler plugin → `3.12.1` Fixes and closes google#2970 Relates-To: elide-dev/jpms#1 Signed-off-by: Sam Gammon <[email protected]>
This changeset adds full support for modular Java builds in Guava, and in libraries which depend on Guava. The Guava JAR for JRE now structures as a Multi-Release JAR, with a module definition situated in `META-INF/versions/9/`. Guava remains compatible with JDK 8. - feat: add `module-info.java` to `guava` module - feat(jpms): add `module-info.java` to `failureaccess` - feat(jpms): add `module-info.java` to `testlib` - fix: necessary fixes to get testsuite running on modular java - chore: update `guava` to build MRJAR - chore: adjust dev version → `1.0-HEAD-[jre|android]-SNAPSHOT` - chore: upgrade maven compiler plugin → `3.12.1` Fixes and closes google#2970 Relates-To: elide-dev/jpms#1 Signed-off-by: Sam Gammon <[email protected]>
This changeset adds full support for modular Java builds in Guava, and in libraries which depend on Guava. The Guava JAR for JRE now structures as a Multi-Release JAR, with a module definition situated in `META-INF/versions/9/`. Guava remains compatible with JDK 8. - feat: add `module-info.java` to `guava` module - feat(jpms): add `module-info.java` to `failureaccess` - feat(jpms): add `module-info.java` to `testlib` - fix: necessary fixes to get testsuite running on modular java - chore: update `guava` to build MRJAR - chore: adjust dev version → `1.0-HEAD-[jre|android]-SNAPSHOT` - chore: upgrade maven compiler plugin → `3.12.1` Fixes and closes google#2970 Relates-To: elide-dev/jpms#1 Signed-off-by: Sam Gammon <[email protected]>
This changeset adds full support for modular Java builds in Guava, and in libraries which depend on Guava. The Guava JAR for JRE now structures as a Multi-Release JAR, with a module definition situated in `META-INF/versions/9/`. Guava remains compatible with JDK 8. - feat: add `module-info.java` to `guava` module - feat(jpms): add `module-info.java` to `failureaccess` - feat(jpms): add `module-info.java` to `testlib` - fix: necessary fixes to get testsuite running on modular java - chore: update `guava` to build MRJAR - chore: adjust dev version → `1.0-HEAD-[jre|android]-SNAPSHOT` - chore: upgrade maven compiler plugin → `3.12.1` Fixes and closes google#2970 Relates-To: elide-dev/jpms#1 Signed-off-by: Sam Gammon <[email protected]>
This is the first piece of #7094, which is progress toward [modularization](#2970): javac (rightly or wrongly) wants a version number that starts with a number. We saw this previously [with Error Prone](google/error-prone#4311 (comment)) and [with JSpecify](jspecify/jspecify@0d39a0e). Relates-To: elide-dev/jpms#1 Signed-off-by: Sam Gammon <[email protected]> RELNOTES=n/a PiperOrigin-RevId: 725320956
This is the first piece of #7094, which is progress toward [modularization](#2970): javac (rightly or wrongly) wants a version number that starts with a number. We saw this previously [with Error Prone](google/error-prone#4311 (comment)) and [with JSpecify](jspecify/jspecify@0d39a0e). Relates-To: elide-dev/jpms#1 Signed-off-by: Sam Gammon <[email protected]> RELNOTES=n/a PiperOrigin-RevId: 725320956
This is the first piece of #7094, which is progress toward [modularization](#2970): javac (rightly or wrongly) wants a version number that starts with a number. We saw this previously [with Error Prone](google/error-prone#4311 (comment)) and [with JSpecify](jspecify/jspecify@0d39a0e). Relates-To: elide-dev/jpms#1 Signed-off-by: Sam Gammon <[email protected]> RELNOTES=n/a PiperOrigin-RevId: 725625326
This changeset adds full support for modular Java builds in Guava, and in libraries which depend on Guava. The Guava JAR for JRE now structures as a Multi-Release JAR, with a module definition situated in `META-INF/versions/9/`. Guava remains compatible with JDK 8. - feat: add `module-info.java` to `guava` module - feat(jpms): add `module-info.java` to `failureaccess` - feat(jpms): add `module-info.java` to `testlib` - fix: necessary fixes to get testsuite running on modular java - chore: update `guava` to build MRJAR - chore: adjust dev version → `1.0-HEAD-[jre|android]-SNAPSHOT` - chore: upgrade maven compiler plugin → `3.12.1` Fixes and closes google#2970 Relates-To: elide-dev/jpms#1 Signed-off-by: Sam Gammon <[email protected]>
This is the next piece of #7094, which is progress toward [modularization](#2970). I've modified this CL somewhat from the original version so that I can deploy a new version of `failureaccess` without needing to make any updates to `guava-parent` first. `failureaccess` does still use `guava-parent` (and I've bumped it to use the newest released version) for its configuration for Sonatype, Javadoc, etc. But I've inlined all the configuration that I need for the modularization. I did note a few differences from the original version: - This version includes `LICENSE` under `META-INF`, both in the main jar and in the sources jars. - This version uses a different configuration for Javadoc, I assume because my recent changes there didn't make it into 33.4.0. I also notice that _neither_ version contains `module-info.java` in its source jar. We could presumably fix that in the future if anyone is interested. (And while this isn't strictly related, I do notice that we could consider also releasing a modularized version of `listenablefuture` someday.) I have tested with: ``` $ JAVA_HOME=$HOME/.m2/jdks/jdk-17.0.13+11 ./mvnw clean install -Psonatype-oss-release -Dmaven.test.redirectTestOutputToFile=true -Dsurefire.printSummary=false -Drelease -f futures/failureaccess ``` (Some of those flags aren't necessary, but I found it easiest to copy what our release script does for "normal" releases.) I would use `deploy` instead of `install` for the real thing. Relates-To: elide-dev/jpms#1 Signed-off-by: Sam Gammon <[email protected]> RELNOTES=Changed the `failureaccess` jar to be a modular jar. PiperOrigin-RevId: 725708714
This is the next piece of #7094, which is progress toward [modularization](#2970). I've modified this CL somewhat from the original version so that I can deploy a new version of `failureaccess` without needing to make any updates to `guava-parent` first. `failureaccess` does still use `guava-parent` (and I've bumped it to use the newest released version) for its configuration for Sonatype, Javadoc, etc. But I've inlined all the configuration that I need for the modularization. I did note a few differences from the original version: - This version includes `LICENSE` under `META-INF`, both in the main jar and in the sources jars. - This version uses a different configuration for Javadoc, I assume because my recent changes there didn't make it into 33.4.0. I also notice that _neither_ version contains `module-info.java` in its source jar. We could presumably fix that in the future if anyone is interested. (And while this isn't strictly related, I do notice that we could consider also releasing a modularized version of `listenablefuture` someday.) I have tested with: ``` $ JAVA_HOME=$HOME/.m2/jdks/jdk-17.0.13+11 ./mvnw clean install -Psonatype-oss-release -Dmaven.test.redirectTestOutputToFile=true -Dsurefire.printSummary=false -Drelease -f futures/failureaccess ``` (Some of those flags aren't necessary, but I found it easiest to copy what our release script does for "normal" releases.) I would use `deploy` instead of `install` for the real thing. Relates-To: elide-dev/jpms#1 Signed-off-by: Sam Gammon <[email protected]> RELNOTES=Changed the `failureaccess` jar to be a modular jar. PiperOrigin-RevId: 726100871
This changeset adds full support for modular Java builds in Guava and in libraries which depend on Guava. The Guava JAR for JRE now structures as a Multi-Release JAR, with a module definition situated in `META-INF/versions/9/`. Guava remains compatible with JDK 8. - Fixes #2970 - Fixes #7094 Relates-To: elide-dev/jpms#1 Signed-off-by: Sam Gammon <[email protected]> RELNOTES=Changed the Guava jar (and guava-testlib jar) to be a modular jar. PiperOrigin-RevId: 725281837
This is the next piece of #7094, which is progress toward [modularization](#2970). (Also bump `maven-bundle-plugin`.) Relates-To: elide-dev/jpms#1 Signed-off-by: Sam Gammon <[email protected]> RELNOTES=n/a PiperOrigin-RevId: 725727215
In pre-[modularization](#2970) cl/725625326, I had pledged not to bikeshed over this. But it turns out that the number matters to some part of our JDiff pipeline, which has been broken since that CL. (Then I broke it _even more_ by introducing usages of `java.io.Serial` (cl/726154745), which I've since rolled back externally (cl/726521329).) We still really should [finish setting up japicmp](google/error-prone#4311 (comment)) to replace JDiff, but again, I just want to unbreak publishing documentation for releases and snapshots. (I will still view this as a _small_ bit of evidence that biggest version number is best version number for snapshot purposes :)) RELNOTES=n/a PiperOrigin-RevId: 726570524
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: