And they will keep doing that. However, Java modules now enable you to strongly encapsulate internal implementation details of modules in your application, while only sharing APIs. This is a pretty big deal if you're developing (moderately) large applications in a team-setting. In fact, this is one of the main reasons the JDK is now modularized.
Also, Maven/Gradle etc. don't have a role beyond build-time. Java modules carry their meta-data to run-time, where you can now rely on module resolution to tease out any dependency problems. What's more, a new tool called jlink allows you to leverage this explicit dependency information to create custom runtime images. These images contain only the modules your application needs (incl. modules from the JDK).
So all in all having modules as part of the platform will be a big step forward. It will take time, for sure.
This is a pretty big deal if you're developing (moderately) large applications in a team-setting.
There were tools like OSGi since the early 2000's that also solved that problem (and unlike Java 9, solved version conflicts also!) but we know very well that that was not compelling enough for most Java shops to switch over to it... More modern options also exist, like the Ceylon language, which a much nicer module system than Java 9! So, when you say it's a big deal, I think I have to disagree... even though I would like the Java community to value modularity more, the evidence so far is that it doesn't.
There were tools like OSGi since the early 2000's that also solved that problem (and unlike Java 9, solved version conflicts also!)
Sorta agree, but OSGi's modularity model is both weaker (run-time only, based on classloaders) and more dynamic/complex, which in aggregate lead to low adoption. Also, I've worked with multiple versions in OSGi and I would like that part of my life back. It's not nearly as easy/desirable to have multiple versions of dependencies as people think. Last, did you know Jigsaw does allow loading of multiple versions of the same module through ModuleLayer?
More modern options also exist, like the Ceylon language, which a much nicer module system than Java 9!
Which is even more of a non-starter than OSGi for Java shops. I do think the 'default' effect of having a module system will be stronger than what previous efforts could reach in terms of adoption.
In what way do you mean that isolation by visibility (i.e. classloaders) is weaker than isolation by accessibility? Security? Seems like an orthogonal issue to me. I'm not sure what benefit you think the accessibility based model brings. The visibility model however has plenty of benefits.
And I wholeheartedly disagree that solving the multiple conflicting versions problems isn't significant. Bear in mind the JPMS model can't even cope with overlapping private packages from different modules out of the box (lol).
I'm also not sure what you mean by saying OSGi's modularity is runtime only. The standard tools allow you to e.g. resolve and validate set of bundles according to a set of requirements at build time, and you can only build against exported packages, with the imports needed for runtime automatically generated from this.
This ties into another difference, JPMS dependencies are at module granularity, whereas OSGi dependencies are at package granularity. (The former model is actually deprecated in OSGi because experience tells us it leads to terribly messy consequences.)
What strength does JPMS offer here that OSGi doesn't?
The main difference I see at build time is that OSGi recognises that sometimes you want to build against an API not an implementation. Also with semver in OSGi we are able to build against the lowest version we wish to support and run against the highest. JPMS's decision to strive for "fidelity across phases" makes no sense at all imo.
I think it's important for all the people complaining about the complexity of OSGi to realise that JPMS has already become way more complex than it set out to be in trying to solve the same problems... (The ModuleLayer being an example of this by my understanding).
In what way do you mean that isolation by visibility (i.e. classloaders) is weaker than isolation by accessibility?
I was thinking of the fact that JPMS enforces encapsulation at compile-time as well (addressing the tools argument below). Also, pass a Class instance from a bundle to another bundle and you've broken encapsulation. Can't trick around JPMS with reflection unless you explicitly allow it. And security is a nice added bonus, orthogonal or not.
And I wholeheartedly disagree that solving the multiple conflicting versions problems isn't significant.
I didn't say solving the problem is insignificant. Rather, the 'solution' offered by OSGi isn't all rainbows and ponies like some people imagine it to be. It's an incredibly tough problem to solve given the current evolution of the Java platform.
The standard [OSGi] tools allow you to e.g. resolve and validate set of bundles according to a set of requirements at build time.
Sure, if by standard tools you mean non-standard (ie. outside of the Java language/spec) tools. Yes, Bnd(Tools) is indispensable when doing OSGi. But that effectively ties you to Eclipse, which is sub-optimal. JPMS is supported out of the gate by Netbeans, IntelliJ and Eclipse, without being at the mercy of third-party plugin vendors.
What strength does JPMS offer here that OSGi doesn't?
That it doesn't require anyone to do stuff that's not part of Java lang/spec, that it will just work with mainstream tooling. And yes, some of this might boil down to a VHS vs. Betamax like situation. It happens.
The main difference I see at build time is that OSGi recognises that sometimes you want to build against an API not an implementation.
As you can do with services in JPMS (or, alternatively, if you like that better, with a DI framework and open modules/packages).
JPMS's decision to strive for "fidelity across phases" makes no sense at all imo.
I don't understand this given the above (and the compile-time only dependencies feature, if you must).
I'm in no way saying OSGi is bad. Obviously they've thought things through and it has proven itself in many ways. Heck, I've got years of OSGi development under the belt (even using it in my current project), so I definitely see its value.
All in all, moving the Java ecosystem to OSGi just isn't going to happen. JPMS does have a fighting chance. So yes, I'm rooting for it, and doing everything I can to make it better and spread knowledge about it.
did you know Jigsaw does allow loading of multiple versions of the same module through ModuleLayer?
Yes, I even tried to use layers to fix version problems automatically several months ago by automatically figuring out how to split the modules into layers, but that turned out to be much harder than I anticipated.
0
u/[deleted] Sep 22 '17
[deleted]