Why does only small amount of Java libraries contain module-info.class inside?

Viewed 65

Why does only small amount of Java libraries contain module-info.class inside? I searched through my local Maven repository and from >400 jars only three had module-info.class inside (asm-7.2.jar, asm-6.2.jar and plexus-java-1.0.5.jar). Does that mean that Java modularity is not being accepted?

2 Answers

First, the number is a little bit higher see here https://github.com/sormuras/modules apart from that there are two/three aspects of using modules.

  • First the library authors must go that way (which is quite often harder than you think; much more separation/reflection etc.). Also, their used libraries must support JDK9+
  • A larger number of libraries on the other hand have not yet used modules nor working correctly on higher JDK versions (JDK9+) (which is a point for library authors as well or a circular dependency).
  • Finally the acceptance of modules on the user's side.

For some projects, it does not make sense to use modules (yes it has some advantages but no one likes to see that) for example in a spring boot project if you finally package everything into a single jar file because module-info.java works only a single jar file level. This is true for so many micro-services etc.

Apart from that, the acceptance of JDK9+ (minimum JDK11) is relatively small in comparison to JDK8 and less than that (unfortunately). Many companies/projects etc. are working on EE containers (old versions of Java) etc. and using libraries.. you see the circle.

And many projects don't like to cut the line from older versions meaning before JDK8 which is thing is very important. The issue is also JDK11 (currently LTS) will be replaced with JDK 17 (Sept. 2021) ... and so the hurdle becomes higher and higher...

Because the developers of those libraries used Java 9 or above.

module-info.class is the compiled version of module-info.java, which is a module descriptor. Modules were introduced in Java 9 to add an higher level of organisation above packages.

Related