Way to bypass "uniquely visible" check for named vs. unnamed module conflict?

Stephan Herrmann stephan.herrmann at berlin.de
Tue Dec 18 19:04:05 UTC 2018


Hi,

This has been discussed on StackOverflow in threads like https://stackoverflow.com/q/51094274/4611488

The question can be simplified like this:
//---
import javax.xml.transform.Transformer;

public class Test {
     Transformer transformer;
}
//---

Which of the following compiler invocations should accept / reject the program:

$ javac Test.java
$ javac -classpath xml-apis-1.4.01.jar Test.java
$ javac -classpath xml-apis-1.4.01.jar --limit-modules=java.base,java.xml Test.java
$ javac -classpath xml-apis-1.4.01.jar --limit-modules=java.base Test.java

 From my understanding, only the first and the last invocations should succeed.
In both other cases the code in Test.java (associated to the unnamed module)
can access package javax.xml.transform both from module java.xml and from
the unnamed module containing xml-apis-1.4.01.jar.
(I say "the unnamed module" but I don't seen any impact if an implementation
would choose to support several unnamed modules).

Also ecj has some issues in this area, but I want to be sure my corrections
go in the right direction.

Is javac applying some tricks like deciding that the content of xml-apis-1.4.01.jar
is not observable if that would create a conflict with a JDK module?

best,
Stephan


More information about the jigsaw-dev mailing list