Java 9 + maven + junit: does test code need module-info.java of its own and where to put it?

The module system does not distinguish between production code and test code, so if you choose to modularize test code, the prod.module and the test.module cannot share the same package com.acme.project, as described in the specs: Non-interference — The Java compiler, virtual machine, and run-time system must ensure that modules that contain packages of the … Read more

How to use 3rd party library in Java9 module?

You can use your library as an automatic module. An automatic module is a module that doesn’t have a module descriptor (i.e. module-info.class). But what name do you need to specify to refer to an automatic module? The name of the automatic module is derived from the JAR name (unless this JAR contains an Automatic-Module-Name … Read more

Scanning classpath/modulepath in runtime in Java 9

The following code achieves module path scanning in Java 9+ (Jigsaw / JPMS). It finds all classes on the callstack, then for each class reference, calls classRef.getModule().getLayer().getConfiguration().modules(), which returns a a List<ResolvedModule>, rather than just a List<Module>. (ResolvedModule gives you access to the module resources, whereas Module does not.) Given a ResolvedModule reference for each … Read more

List the modules resolved during the application startup

Module Resolution The module resolution is a two-step process. The first step recursively enumerates the ‘requires’ directives of a set of root modules. If all the enumerated modules are observable, then the second step computes their readability graph. The readability graph embodies how modules depend on each other, which in turn controls access across module … Read more

JDK9: An illegal reflective access operation has occurred. org.python.core.PySystemState

The ideal way to resolve this would be to reporting this to the maintainers of org.python.core.PySystemState and asking them to fix such reflective access going forward. If the default mode permits illegal reflective access, however, then it’s essential to make that known so that people aren’t surprised when this is no longer the default mode … Read more

Package conflicts with automatic modules in Java 9

Am I using the new module system correctly? Yes. What you are seeing is intended behavior, and this is because JPMS modules do not allow split packages. In case you are not familiar with the term “split packages” it essentially means two members of the same package coming from two different modules. For example: com.foo.A … Read more