On 07.11.2017 21:43, Alan Bateman wrote:
On 07/11/2017 18:56, Stephan Herrmann wrote:
I recently noticed that compilers start to ignore -classpath as soon
as module-info (.java or .class) is found during the compile.
(Incidentally, javac and Eclipse compiler agree in this).

Using a trivial test class this works:
$ javac -classpath junit4.jar -d bin/ src/pkg/TestJUnit4.java

This doesn't (cannot resolve any types from junit4.jar):
$ javac -classpath junit4.jar -d bin/ src/pkg/TestJUnit4.java 
src/module-info.java
The module you are compiling doesn't read the unnamed module. You can't write 
"requires $CLASSPATH" for example.

If you add `--add-reads <module>=ALL-UNNAMED` to the command line then it 
should compile.

-Alan

Thanks, Alan, that would work.

But that is not what I meant when referring to JEP 261.

In JEP 261 I see (under "Single-module mode"):
"It is possible to put arbitrary classes and JAR files on the class path in 
this mode,
 but that is not recommended since it amounts to treating those classes and JAR 
files as
 part of the module being compiled."

Doesn't this say, my above command line treats junit4.jar as part of the 
current module,
*not* as an unnamed module?

Is everything referenced via -classpath definitely treated as an unnamed module?
Independent of single-/multi-module modes?

Stephan

Reply via email to