java throws InvalidModuleDescriptorException when module exports patched package

Viewed 1640

java 10.0.2+13 throws a java.lang.module.InvalidModuleDescriptorException when a module-info.class in a directory in the module path exports a package that isn't under the same directory.

That is sensible behavior in many circumstances, but, in my case, I have the package under another directory which is patched into the module in question using --patch-module.

Example:

Module m is defined in file classes/m/module-info.class.

m exports package p.

module-info.class is the only child of directory classes/m.

Directory classes/patch contains p/Main.class.

Simplified command line:

java --module-path classes/m --patch-module m=classes/patch --module m/p.Main

The above will throw a java.lang.module.InvalidModuleDescriptorException that says that "Package p not found in module".

Is there any way to get java to not throw an InvalidModuleDescriptorException, without having to copy the class files from classes/m & classes/patch into the same directory, or into the same jar file?

0 Answers
Related