"""error: module testng reads package test from both test and testng"""

mandy chung mandy.chung at oracle.com
Tue Aug 22 19:38:33 UTC 2017


Hi Martin,

"error: module testng reads package test from both test and testng" 
indicates that a split package is detected.   Does your testng.jar 
contain classes of package "test"?   I downloaded testng from maven 
which does not have the package "test".

The testng.jar version I had bundled with jcommander classes and hence 
the error message reports com.beust.jcommander.* packages from 
jcommander and testng module.  It was an old version before testng was 
mavenized.   If I run jtreg with the testng and jcommander downloaded 
from maven, the test passes.

You can run java -p JTwork/modules --validate-modules to check if any 
split packages or other conflict.

Jon, Jan,
   I think the javac error message could be improved to make it clear 
that the package is split in multiple module.   In addition, the test 
only contains explicit modules.   It's strange that the javac reports 
that "the unnamed module reads package xxx from ....".  I will create a 
JBS issue on improving the error message.

Mandy

On 8/21/17 4:06 PM, mandy chung wrote:
> I can reproduce it and javac outputs the following errors.  javac 
> compiles successfully if jcommander.jar is removed.   Will look into it.
>
> error: the unnamed module reads package com.beust.jcommander from both 
> jcommander and testng
> error: the unnamed module reads package 
> com.beust.jcommander.validators from both jcommander and testng
> error: the unnamed module reads package com.beust.jcommander.internal 
> from both jcommander and testng
> error: the unnamed module reads package 
> com.beust.jcommander.defaultprovider from both jcommander and testng
> error: the unnamed module reads package 
> com.beust.jcommander.converters from both jcommander and testng
> error: module jcommander reads package com.beust.jcommander from both 
> testng and jcommander
> error: module jcommander reads package com.beust.jcommander.validators 
> from both testng and jcommander
> error: module jcommander reads package com.beust.jcommander.internal 
> from both testng and jcommander
> error: module jcommander reads package 
> com.beust.jcommander.defaultprovider from both testng and jcommander
> error: module jcommander reads package com.beust.jcommander.converters 
> from both testng and jcommander
> error: module testng reads package com.beust.jcommander from both 
> jcommander and testng
> error: module testng reads package com.beust.jcommander.validators 
> from both jcommander and testng
> error: module testng reads package com.beust.jcommander.internal from 
> both jcommander and testng
> error: module testng reads package 
> com.beust.jcommander.defaultprovider from both jcommander and testng
> error: module testng reads package com.beust.jcommander.converters 
> from both jcommander and testng
> /scratch/mchung/ws/jdk10/jdk10-dev/jdk/test/java/lang/ModuleTests/addXXX/test/module-info.java:23: 
> error: module test reads package com.beust.jcommander from both testng 
> and jcommander
> module test {
>
> Mandy
>
> On 8/21/17 2:14 PM, Martin Buchholz wrote:
>> I just upgraded to 4.2-b08, although without any effect on this 
>> problem.  jcommander.jar is from jtreg's lib directory
>>
>> code-tools/jtreg/make/Defs.gmk says:
>> """
>> # TestNG requires jcommander, which may or may not be bundled with 
>> TESTNG_JAR.
>> # If it is not, set JCOMMANDER_JAR to an appropriate version
>> """
>>
>>  $ ls -l ./JTwork/modules
>> total 1620
>> -rw-r--r-- 1 martin martin   63504 Aug 21 12:27 jcommander.jar
>> -rw-r--r-- 1 martin martin 1589287 Aug 21 12:27 testng.jar
>>
>>  $ /home/martin/jtreg-binaries/current/bin/jtreg -noreport -v:fail 
>> -compilejdk:/home/martin/ws/jdk10/build/linux-x86_64-normal-server-release/images/jdk 
>> -testjdk:/home/martin/ws/jdk10/build/linux-x86_64-normal-server-release/images/jdk 
>> java/lang/ModuleTests/addXXX
>> --------------------------------------------------
>> TEST: java/lang/ModuleTests/addXXX/Driver.java
>> TEST JDK: 
>> /home/martin/ws/jdk10/build/linux-x86_64-normal-server-release/images/jdk
>>
>> ACTION: build -- Failed. Compilation failed: Compilation failed
>> REASON: User specified action: run build test/* m1/* m2/* m3/* m4/*
>> TIME:   0.943 seconds
>> messages:
>> command: build test/* m1/* m2/* m3/* m4/*
>> reason: User specified action: run build test/* m1/* m2/* m3/* m4/*
>> Test directory:
>>   compile: test/module-info, test/test.C, test/test.Service, 
>> test/test.Main, m1/module-info, m1/p1.C, m2/module-info, m2/p2.C, 
>> m2/p2.internal.C, m3/module-info, m3/p3.C, m4/module-info, m4/p4.C
>> elapsed time (seconds): 0.943
>>
>> ACTION: compile -- Failed. Compilation failed: Compilation failed
>> REASON: .class file out of date or does not exist
>> TIME:   0.938 seconds
>> messages:
>> command: compile 
>> /home/martin/ws/jdk10/jdk/test/java/lang/ModuleTests/addXXX/test/module-info.java 
>> /home/martin/ws/jdk10/jdk/test/java/lang/ModuleTests/addXXX/test/test/C.java 
>> /home/martin/ws/jdk10/jdk/test/java/lang/ModuleTests/addXXX/test/test/Service.java 
>> /home/martin/ws/jdk10/jdk/test/java/lang/ModuleTests/addXXX/test/test/Main.java 
>> /home/martin/ws/jdk10/jdk/test/java/lang/ModuleTests/addXXX/m1/module-info.java 
>> /home/martin/ws/jdk10/jdk/test/java/lang/ModuleTests/addXXX/m1/p1/C.java 
>> /home/martin/ws/jdk10/jdk/test/java/lang/ModuleTests/addXXX/m2/module-info.java 
>> /home/martin/ws/jdk10/jdk/test/java/lang/ModuleTests/addXXX/m2/p2/C.java 
>> /home/martin/ws/jdk10/jdk/test/java/lang/ModuleTests/addXXX/m2/p2/internal/C.java 
>> /home/martin/ws/jdk10/jdk/test/java/lang/ModuleTests/addXXX/m3/module-info.java 
>> /home/martin/ws/jdk10/jdk/test/java/lang/ModuleTests/addXXX/m3/p3/C.java 
>> /home/martin/ws/jdk10/jdk/test/java/lang/ModuleTests/addXXX/m4/module-info.java 
>> /home/martin/ws/jdk10/jdk/test/java/lang/ModuleTests/addXXX/m4/p4/C.java
>> reason: .class file out of date or does not exist
>> Mode: othervm
>> elapsed time (seconds): 0.938
>> configuration:
>> javac compilation environment
>>   add modules: testng jcommander
>>   module path: /home/martin/ws/jdk10/jdk/test/JTwork/modules
>>
>> rerun:
>> DISPLAY=localhost:10.0 \
>> HOME=/home/martin \
>> LANG=en_US.UTF-8 \
>> PATH=/bin:/usr/bin \
>> /home/martin/ws/jdk10/build/linux-x86_64-normal-server-release/images/jdk/bin/javac 
>> \
>> -J-Dtest.src=/home/martin/ws/jdk10/jdk/test/java/lang/ModuleTests/addXXX 
>> \
>> -J-Dtest.src.path=/home/martin/ws/jdk10/jdk/test/java/lang/ModuleTests/addXXX 
>> \
>> -J-Dtest.classes=/home/martin/ws/jdk10/jdk/test/JTwork/classes/java/lang/ModuleTests/addXXX/Driver.d 
>> \
>> -J-Dtest.class.path=/home/martin/ws/jdk10/jdk/test/JTwork/classes/java/lang/ModuleTests/addXXX/Driver.d 
>> \
>>         -J-Dtest.vm.opts= \
>>         -J-Dtest.tool.vm.opts= \
>>         -J-Dtest.compiler.opts= \
>>         -J-Dtest.java.opts= \
>> -J-Dtest.jdk=/home/martin/ws/jdk10/build/linux-x86_64-normal-server-release/images/jdk 
>> \
>> -J-Dcompile.jdk=/home/martin/ws/jdk10/build/linux-x86_64-normal-server-release/images/jdk 
>> \
>>         -J-Dtest.timeout.factor=1.0 \
>> @/home/martin/ws/jdk10/jdk/test/JTwork/java/lang/ModuleTests/addXXX/Driver.d/compile.0.jta 
>>
>> STDOUT:
>> STDERR:
>> error: module testng reads package test from both test and testng
>> 1 error
>>
>> TEST RESULT: Failed. Compilation failed: Compilation failed
>> --------------------------------------------------
>> Test results: failed: 1
>>
>> On Mon, Aug 21, 2017 at 12:12 PM, mandy chung <mandy.chung at oracle.com 
>> <mailto:mandy.chung at oracle.com>> wrote:
>>
>>     The test itself is a module that depends on testng.  So testng.jar
>>     is added as an automatic module.  This test passes on my setup.
>>
>>     I am puzzling how jcommander.jar is added to the module path. Can
>>     you send the .jtr file and list what's in JTwork/modules directory?
>>
>>     Mandy
>>
>>
>>     On 8/17/17 6:22 PM, Martin Buchholz wrote:
>>
>>         When I run the jtreg test
>>         java/lang/ModuleTests/addXXX
>>         I fail with
>>
>>         direct:
>>         error: module testng reads package test from both test and 
>> testng
>>
>>         In the javac command line I see:
>>           --add-modules testng,jcommander
>>         but ... testng and jcommander aren't modules; they're just
>>         garden variety
>>         jar files.
>>
>>         Running jtreg 4.2-b07.
>>
>>
>>
>



More information about the jigsaw-dev mailing list