r/java • • Mar 19 '19

Java 12 Released !!!

https://www.oracle.com/technetwork/java/javase/downloads/jdk12-downloads-5295953.html
235 Upvotes

98 comments sorted by

View all comments

Show parent comments

15

u/MasterLJ Mar 19 '19

Modules just seem like unnecessary hassle if you already partition your dependencies well, but I'm probably missing some useful use cases. I'm a solo developer, fwiw.

17

u/[deleted] Mar 19 '19

[removed] — view removed comment

12

u/cogman10 Mar 19 '19

Not only that, you get startup time bonuses as well since there aren't as many internal classes to load. For example, your server probably doesn't need to bring in the swing modules.

4

u/pron98 Mar 19 '19

... and the new default CDS archive (in JDK 12) improves startup times further.

10

u/ObscureCulturalMeme Mar 19 '19 edited Mar 19 '19

Modules seem to be all the rage for enterprise container "app servers" and the like, but for the rest of us, modules are solving a problem that we simply don't have.

Unfortunately, a lot of third party libraries are still problematic to use in 9+, and the JVM unconditionally spits out warnings about them anyhow. So our users complain to us about problems (but not really) in code that we don't control.

4

u/capitol_ Mar 19 '19

It's often very easy to add a Automatic-Module-Name entry to the manifest file, and I have only had one maintainer that have been negative to it when I have opened bug in projects.

2

u/FoodComputer Mar 19 '19

Is this why I see warnings like "found module-info.java. shading will break its strong encapsulation." when using the Maven Shade Plugin?

2

u/MMPride Mar 20 '19

Illegal reflective access warnings are going to be a fun one to fix for unmaintained dependencies when the warnings turn to errors then turn to removals.

3

u/dpash Mar 19 '19

Modules are particularly useful for libraries. It means they can expose their interfaces and public API and completely hide their implementation and private classes without someone using a non-public API. And now your non-public API has hundreds and thousands of users and it's de facto a public API that you can't change.

Don't think people won't use a non-public API they find in your jar? Look at how many people used sun.misc.Unsafe despite compiler warnings telling them to keep out of anything in the sun package.

1

u/sievebrain Mar 20 '19

Well not really. Users will just put your JAR on the classpath, or use reflection. They aren't going to not use internal APIs just because they're labelled as such and the compiler tries to make life hard.

1

u/dpash Mar 20 '19

Eventually the ability to avoid modules is going away.