Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jdt-dev] Cannot use '--add-modules' for internal JDK module

Consider this class:

------------------------------------------------------------

import sun.nio.cs.ext.ExtendedCharsets;

public class NonModular2 {
  ExtendedCharsets extendedCharsets;
}

------------------------------------------------------------

The class is from module jdk.charsets, which is not a JDK root module.
So something like simply the following of course does not work:

------------------------------------------------------------

$ javac NonModular2.java

NonModular2.java:1: error: package sun.nio.cs.ext is not visible
import sun.nio.cs.ext.ExtendedCharsets;
^
(package sun.nio.cs.ext is declared in module jdk.charsets, which is not in
the module graph)

------------------------------------------------------------

This is not enough either:

------------------------------------------------------------

$ javac --add-modules jdk.charsets NonModular2.java

NonModular2.java:1: error: package sun.nio.cs.ext is not visible
import sun.nio.cs.ext.ExtendedCharsets;
                 ^
  (package sun.nio.cs.ext is declared in module jdk.charsets, which does not export it)

------------------------------------------------------------

But like this it works nicely with javac - so far, so normal and to be
expected:

------------------------------------------------------------

$ javac --add-modules jdk.charsets --add-exports jdk.charsets/sun.nio.cs.ext=ALL-UNNAMED NonModular2.java

------------------------------------------------------------

Now I tried to do the same with ECJ:

------------------------------------------------------------

$ java -jar ecj-3.29.0.jar --add-modules jdk.charsets --add-exports jdk.charsets/sun.nio.cs.ext=ALL-UNNAMED -9 NonModular2.java

invalid module name: jdk.charsets

------------------------------------------------------------

Because I am not a regular user of Java modules and just trying to
compare how Javac, ECJ and AJC behave in comparison, I would like to
know if this is some kind of incomplete implementation or maybe a bug,
of if the fact that it is working with Javac is some vendor-specific,
non-standard thing. I was expecting this to work in ECJ, but obviously
it does not. But instead of filing a bug right away, first I would like
to have opinions from the experts around here.

Kind regards
-- 
Alexander Kriegisch
https://scrum-master.de



Back to the top