Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd module-info.java #2970
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. |
So Guava is still not natively JPMS compatible in May 2020? |
No. And it isn't hard to add support without breaking pre-Java9 support. As @overheadhunter mentioned, all they need to do is add The easiest way to provide Java9 support is to release a separate artifact for it but if they don't want to maintain multiple artifacts then the multi-release JAR approach would work as well (it's just harder to build). |
hrchu commentedOct 18, 2017
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.