Java 9: The State of the Module System
openjdk.java.net
openjdk.java.net
Let alone the IDE support. I think it's truly amazing that I can make a project with 3 different JVM languages and get instant IDE autocompletion and warnings when calling methods between those languages. The source -> .class -> .jar thing has turned out to be a remarkably visionary design (or just a very lucky hit). For comparison, C# still compiles and "tools" that much slower because .class files are missing in the pipeline.
It's a testament to some of the true goodness of Java, despite its unpopularity in hipper circles, that they don't think a Maven-managed folder full of JARs is good enough.
Of course, this is really a JVM thing and you'll also get it if you use a different JVM language so you can actually get the best of both worlds.
I assume that it's a bit better if all your devs (and your servers) are on the exact same OS, but compared to say NodeJS or Java, the Ruby experience is pretty messy. With Node or Java, I just say "these are my dependencies", some package manager downloads them all into a subdirectory, and then I run the app. Done. The only global dependency is the VM itself, which is typically backward compatible so no problem there, just use the latest one. C# has it just as awesome except that some libraries were written by boneheaded Windows-only people (hardcoded backslashes in pathnames, Windows Registry dependencies, stuff like that), so in practice it isn't as cool.
All that said, maven repositories and the groupId:artifactId:version:type:classifier organization of modules are really genius. As you say, this genius shines in IDE's where, as just one example, you get nice binary/source .jar distributions automatically downloaded to your local repo. Having an IDE's debugger be able to seamlessly and accurately step through 1st party java sources and 3rd party source .jar sources is always so impressive to me.
Gradle (and Ivy before it) help paper over the pain and expose the good parts of the maven ecosystem. I have some gripes with Gradle, but after seeing it in action (and now that IDE's can grok its project configs) I'm so happy to be ditching maven/plugins and hand-written pom's for the most part.
Java needs a holistic dependency management/dependency injection/artifact repository/publishing workflow rethink where well-defined concepts like semver are enforced in the version numbering scheme, making it easier to express "safe" legal version ranges in transitive dependencies.
By the time Java 10 gets out, they can see how libraries that make use of modules, reified generics, value types, GPGPU integration, JIT plugins are out of reach.
Worse even, having library devs writing two versions of their libraries.
Google's fork of Java is leading to a Python 2 - 3 scenario.
I have a hard time believing Google will stop supporting Java on Android, especially considering how widely they support it for other various platforms. I do know Go support for Android was recently released though.
Not yet. But it might happen, it depends how value types get implemented.
Check "New Bytecodes, New Objects", "Adventures on the Road to Valhalla":
http://www.oracle.com/technetwork/java/javase/community/jlss...
> I have a hard time believing Google will stop supporting Java on Android
Of course they won't stop supporting it. After all they stated at Google IO 2014, that only Java matters and they could not see why anyone would want to use something else.
But they also don't show any interest to reduce the gap with the official Java.
Even the actual version lacks many of the Java 7 libraries.
> I do know Go support for Android was recently released though.
It doesn't have any official support from the Android team.
> It doesn't have any official support from the Android team.
Go on Android definitely seems to be in its infancy.
https://source.android.com/devices/tech/dalvik/index.html#AO...
And apparently Oracle is finally joining the third party JVMs by adding AOT support to the reference JDK, but it might only come after Java 10.
This together with the upcoming value types and JNI replacement, might eventually close the gap with the alternatives.
Not being a Java zealot, as a polyglot developer I use a bit of everything, just spreading the word.
They have a protoype that does AOT compilation [1] but that's only a prototype and the gains are meager.
[1] https://www.youtube.com/watch?v=d4B8sc7ltZk&list=PLX8CzqL3Ar...
They will switch from the basic jar (zip) format to a more optimized one. Additionally, with a modularized jre, it will load less modules (who use corba?). I'm quite sure there are additional reasons, but it's the 2 that I remember.
You could also perhaps be looking at a situation in the future where the JRE can selectively exclude things at install time, which would be nice.
Straight from the article:
> A modular JAR file is like an ordinary JAR file in all possible ways, except that it also includes a module-info.class file in its root directory.
> A modular JAR file can be used as a module, in which case its module-info.class file is taken to contain the module’s declaration. It can, alternatively, be placed on the ordinary class path, in which case its module-info.class file is ignored
So no.
"For the purpose of modularizing the Java SE Platform’s reference implementation, the JDK, we will introduce a new artifact format that goes beyond JAR files to accommodate native code, configuration files, and other kinds of data that do not fit naturally, if at all, into JAR files. This format leverages another advantage of expressing module declarations in source files and compiling them into class files, namely that class files are independent of any particular artifact format. Whether this new format, provisionally named “JMOD,” should be standardized is an open question."
Edit: from http://mreinhold.org/blog/jigsaw-modular-images
"The internal files rt.jar, tools.jar, and dt.jar have been removed. The content of these files is now stored in a more efficient format in implementation-private files in the lib directory."
That just talks about the JDK. There is no promise that normal applications can use this format.
In the end, not a solution, but a very nice environment and development choice if you are greenfield and in the target audience.
I'm surprised by this as well. I was somewhat expecting Java 9 to tackle the dependency version problem.
But, had they included versioning support, they could have also built upon that later to support module distribution to finally not have to worry about maven, ivy, etc.
The main difficulty about versioning though are snapshot (development) versions that don't have a defined version number. In maven, typically these are just "*-SNAPSHOT" which may not be unique enough if two projects wanted to depend on two different snapshots of the same module.
If memory serves me correctly I remember Mark Reinhold saying to do it "right" they would have to run a linear equation solver like Eclipse/P2.
See also: http://wiki.osgi.org/w/images/thumb/e/e2/Classpath.jpg/500px...
Huh? That sounds like a lot of work reinventing the wheel. Could you give me some details on how that's arranged?
Every Java EE server (even Tomcat) sets up its own class loaders. So does Jenkins/Hudson, Maven, all RCP platforms, even applets. It's really rare to find applications where all the code is in the class path.
JEP 261: Module System http://openjdk.java.net/jeps/261
Java Platform Module System (JSR 376) http://openjdk.java.net/projects/jigsaw/spec/
It will allow a group of jars to be exposed as a single entity, with internal APIs that can be exposed across jars, but not accessible outside the module.
C++ modules are more like packages.
Java modules, which happen to exist in other languages like .NET, Delphi and Ada, are akin to having a set of dynamic libraries exposed as a single library. With the ability of having symbols that are only visible to the dynamic libraries that are part of the same module.
My experience so far is that the list of incompatibilities (http://www.oracle.com/technetwork/java/javase/compatibility-...) between versions makes it nearly impossible to just drop code between versions. It will run, but often implementation details have changed causing significant bugs. Your mileage may vary