8 ms·
Java 9: The State of the Module System
- mateuszf 11y agoDoesn't solve the versioning problem. That's a little disappointing.
- dj-wonk 11y agoAccording to the article: "A module’s declaration does not include a version string, nor constraints upon the version strings of the modules upon which it depends. This is intentional: It is not a goal of the module system to solve the version-selection problem, which is best left to build tools and container applications." I'm surprised by this as well. I was somewhat expecting Java 9 to tackle the dependency version problem.
- MrBuddyCasino 11y agoI'm glad they didn't. Its not essential to solve the problems the module system is designed to solve, making adoption easier. A mechanism to resolve, download and cache artifacts is still needed anyway, at least I didn't see anything in that regard.
- lighthawk 11y ago> I'm glad they didn't. Its not essential to solve the problems the module system is designed to solve, making adoption easier. A mechanism to resolve, download and cache artifacts is still needed anyway, at least I didn't see anything in that regard. 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.
- needusername 11y agoMy reading is it's hard enough as is because of backwards compatibility. They seem to be under massive pressure to deliver something for JDK 9 and can't push the deadline much longer. 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.
- dj-wonk 11y agoIt would seem that one of the JSR 376's key goals is to provide a saner way to manage dependencies than the Java classpath. See also: http://wiki.osgi.org/w/images/thumb/e/e2/Classpath.jpg/500px-Classpath.jpg http://wiki.osgi.org/w/images/thumb/e/e2/Classpath.jpg/500px...
- needusername 11y agoThey say that but I don't know anybody who actually uses classpath (java -cp). Most people use a custom class loader, container and module system. In addition Oracle cops out of versioning. So I'm not sure who they are targeting.
- acveilleux 11y agoThe folks you work with seem to be more diligent than a lot of enterprise java folks I know. Explicit classpath is useful in deeply silo'd enterprise environment to get around multiple dependencies on incompatible versions of the same 3rd party jars. Often introduced while under the guns and then kept because maintenance dollars go elsewhere.
- HiYaBarbie 11y ago> Most people use a custom class loader, container and module system. Huh? That sounds like a lot of work reinventing the wheel. Could you give me some details on how that's arranged?
- needusername 11y ago
- norswap 11y agoIt is indeed a bit underwhelming, especially if you consider for how long it has been in the pipeline.
- iso8859-1 11y agoIf you're talking about the inability to have multiple versions of the class, it is addressed, using layers: http://openjdk.java.net/projects/jigsaw/spec/sotms/#layers http://openjdk.java.net/projects/jigsaw/spec/sotms/#layers
- hitlin37 11y agois this the same module thing that's coming up in c++17( or later, it it doesn't make on time.)
- pjmlp 11y agoNo. 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.
- dj-wonk 11y agoSee also: JEP 261: Module System http://openjdk.java.net/jeps/261 http://openjdk.java.net/jeps/261 Java Platform Module System (JSR 376) http://openjdk.java.net/projects/jigsaw/spec/ http://openjdk.java.net/projects/jigsaw/spec/
- wiradikusuma 11y agoOr, you know, you can use OSGi (http://www.osgi.org/Main/HomePage http://www.osgi.org/Main/HomePage)
- desdiv 11y agoOne motivation for the module system is faster JVM boot time. OSGi doesn't help with that at all.
- needusername 11y agoExcept they don't mention at all how a module system should lead to faster boot times. Sure you could come up with faster lookup for classes by picking the right JAR but OSGi and JBoss Modules already do this today. 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=PLX8CzqL3ArzUo2dtMurvpUTAaujPMeuuU&index=6 https://www.youtube.com/watch?v=d4B8sc7ltZk&list=PLX8CzqL3Ar...
- syjer 11y ago>Except they don't mention at all how a module system should lead to faster boot times. 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.
- chrisseaton 11y agoThe JVM already only loads classes on demand so if you don't use Corba it doesn't have any impact on you (maybe minuscule extra seek time reading the JAR).
- syjer 11y agoClear, but the single rt.jar will be replaced with a more convenient representation, so, as you said, the seek time will be reduced.
- wener 11y agoWill java drop the bc in the future ? (e.g. 1.4 1.5 1.6) With the time by, java have a heavier bc problem.
- codingvelocity 11y agoI believe older java versions are already incompatible with newer jvms. I couldn't find it explicitly stated but i'd be surprised if 1.4 code worked 100% correct on a 1.7 jvm. My experience so far is that the list of incompatibilities (http://www.oracle.com/technetwork/java/javase/compatibility-417013.html#jdk7 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
- wener 11y agoI think so, the implementation is hard to control than jvms.As long as jvm can run older(e.g. 1.4) version bytecodes, jvms is compatibility, but what if jvm drop that, then support real type generic like C#, etc, that's would be wonderful.
- krzyk 11y agoWhat is "bc"?
- 11y ago
- jonnw 11y agoi really like how simple it is to declare the module metadata and how easy it is to read it
- smithkl42 11y agoI've used C# for a long time, but have barely touched Java. How does this differ from the idea of "Assemblies" in the .NET world?
- pjmlp 11y agoThis is like .NET modules. 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.
- iso8859-1 11y agoSee http://www.25hoursaday.com/CsharpVsJava.html#assemblies http://www.25hoursaday.com/CsharpVsJava.html#assemblies (and the rest of that page) and http://stackoverflow.com/q/90578/309483 http://stackoverflow.com/q/90578/309483
- pjmlp 11y agoYet another feature that Android devs won't get. 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.
- uxcn 11y agoIs there an actual JSR for reified generics? I was under the impression that would generally break VM compatibility. 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.
- pjmlp 11y ago> Is there an actual JSR for reified generics? I was under the impression that would generally break VM compatibility. 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/jlssessions-2015-2633029.html 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.
- uxcn 11y agoInteresting, thanks for the links. Honestly, I tend to avoid writing Java in favor of native languages at this point largely because of latency requirements. I still wonder where code sharing outweighs the type cast overhead for most JVMs though. > It doesn't have any official support from the Android team. Go on Android definitely seems to be in its infancy.
- pc2g4d 11y agoFeels clunky doing require/export at the package level. Why not allow exporting of individual classes, for example?
- skrebbel 11y agoThe cool thing is that compared to many languages/platforms, Java already has an excellent module system. Just look at the horrible hacks you have to go through in C++, Ruby or Python to manage multiple projects written in different versions of the language or with different versions of dependencies are just ridiculous, especially if you're developing on multiple platforms. Oh, you want to deploy it too? Have fun. 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.
- aabbccdd 11y agoAre there any horrible hacks needed for Ruby to cope with dependencies? Is this something new or you're just ranting?
- skrebbel 11y agoMy experience with this is a bit dated so maybe they fixed it since, but here goes: Gems are installed globally on your system. You need something like RVM to work around this, but oops, RVM doesn't work on Windows and one of your devs uses that. There's a 3-year old tutorial about how you can get it to work with cygwin, but that doesn't work well with your favourite Ruby IDE, and the list goes on. You want to deploy to a server so you try to use bundler, but bundler hard-copies a dependency called somelib-mingw-x86 into the Gemfile.lock and your linux server chokes on that. In general, the idea that bundler makes a different dependency graph depending on the OS of the dev that happens to run "bundler install" is completely beyond my understanding. 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.