modulepath and classpath mixture

Robert Scholte rfscholte at apache.org
Tue Feb 23 20:48:50 UTC 2016


On Tue, 23 Feb 2016 01:52:50 +0100, Jonathan Gibbons  
<jonathan.gibbons at oracle.com> wrote:

>
>
> On 02/22/2016 12:44 PM, Robert Scholte wrote:
>> Hi,
>>
>> first of all I'd like to say that I'm very pleased with the new -mp  
>> options, these matches better with the way Apache Maven would like to  
>> work with jars and class-folders.
>>
>> Here's my use case: I noticed that if I add a module-info to  
>> src/main/java and put all compile-scoped dependencies to the module  
>> path, all compiles fines.
>> I assume that developers are less interested in adding a  
>> module-info.java file to src/test/java, so that's what I'm doing right  
>> now too.
>> Now it seems that I *must* add compile + test scoped to the *classpath*  
>> to be able to compile the test classes.
>> My first approach was to leave the compile-scoped dependencies on the  
>> modulepath and all test-scoped dependencies on the classpath, so the  
>> modules keeps their inner related structure, but it seems that the  
>> classpath classes cannot access the modulepath classes.
>>
>> I'm looking for the confirmation that putting all dependencies on the  
>> classpath is indeed the right approach in this case.
>>
>> thanks,
>> Robert
>
> Robert,
>
> We definitely need some more detailed notes on setting up javac  
> compilations (note to self!) but one thing to note is that by default,  
> the unnamed module (i.e. code on the classpath) only has observability  
> of the modules in the system image. To make modules on the module path  
> observable, you need to use the -addmods option.
>
> -- Jon

Hi Jonathan,

this would indeed explain what I'm facing right now. However, adding  
-addmods gives me the following exception:
Caused by: java.lang.IllegalArgumentException: -addmods requires an  
argument
         at  
com.sun.tools.javac.main.Arguments.error(jdk.compiler at 9-ea/Arguments.java:708)

Is -addmods followed by the same entries as -modulepath or by the  
modulenames. I really hope it is not the latter, because that would mean  
that I first need to discover and read all module-info files.

thanks,
Robert


More information about the jigsaw-dev mailing list