javac, modular builds mixed with some gradle.

David Hill David.Hill at
Tue Aug 23 22:57:01 UTC 2016

On 8/23/16, 6:37 PM, Jonathan Gibbons wrote:
> David,
> Are you being affected by javac's long-standing policy of implicit compilation?
This is why I ask the list :-)
No, I was not aware of this behavior, but will play with it now.

Regardless of how I get there - I am pretty sure I need two "modules", one "real" one, and a test module - one that contains everything including the shim adapters.

thanks Jon.

> If references other classes, and those classes either only exist on the module source path, or are newer on the module source path, then they will be compiled into the output directory as well.
> You can disable this behavior with javac's -implicit option:
>    -implicit:{none,class}     Specify whether or not to generate class files for implicitly referenced files
> -- Jon
> On 08/23/2016 01:57 PM, David Hill wrote:
>> I am trying to understand module compilation using a trivial set of classes. These comprise a "module" of two classes, a test class, and a "shim" test class. (The shim is an adapter used for 'white box' style tests).
>> On top of this, I am trying this with Gradle 3.
>> So far, I have made some interesting progress. For the "simple" case, Gradle 3 seems to be handling the required tasks nicely. A 'simple' module and set of public api test classes works without much effort.  Certainly Gradle has a few more fixes to go, for example its insistence on stuffing
>>     -sourcepath /some/empty/directory
>> in some compilations, which collides with my addition of --module-source-path
>> Mostly however, I have just be able to tack on additional JDK 9 arguments.
>> I am currently trying to understand how I can best compile my shim classes. In my current build, I perform a non-modular build of the module classes, and then the shim classes, and then combine the sum of them together and call it a module :-) This is a stopgap until we can rework to create a proper modular build.
>> The item that currently puzzles me is an invocation of javac (b132) with a list of a single file to be compiled that ends up compiling everything within the module-source-path. I would have expected that only the listed files would be compiled. Below is the extracted compile line (with -sourcepath removed).
>> Any thoughts or suggestions are welcome.
>> Anyone else interested in my Gradle module quickstart demo let me know off list and I will point you to a copy when I get past this hump.
>> /Users/ddhill/shared/jdk9/osx-x64/jdk-9.jdk/Contents/Home//bin/javac -verbose \
>> -d \
>> /Users/ddhill/shared/gradle/module-quickstart/modules/dave/build/classes/shims \
>> -g \
>> -release \
>> 9 \
>> --module-path /Users/ddhill/shared/gradle/module-quickstart/modules/dave/build/classes/main/dave \
>> --add-modules dave \
>> --module-source-path '/Users/ddhill/shared/gradle/module-quickstart/modules/*/src/{main,test}/{java,module-info}' \
>> -classpath \
>> /Users/ddhill/shared/gradle/module-quickstart/modules/dave/build/classes/test:/Users/ddhill/shared/gradle/module-quickstart/modules/dave/build/resources/test:/Users/ddhill/shared/gradle/module-quickstart/modules/dave/build/classes/main:/Users/ddhill/shared/gradle/module-quickstart/modules/dave/build/resources/main:/Users/ddhill/.gradle/caches/modules-2/files-2.1/junit/junit/4.12/2973d150c0dc1fefe998f834810d68f278ea58ec/junit-4.12.jar:/Users/ddhill/.gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-core/1.3/42a25dc3219429f0e5d060061f71acb49bf010a0/hamcrest-core-1.3.jar \
>> /Users/ddhill/shared/gradle/module-quickstart/modules/dave/src/test/java/org/dave/ \
>> -XDuseUnsharedTable=true
>> and yet the result is more classes than the ListShim that was listed:
>> [ddhill module-quickstart]$ find /Users/ddhill/shared/gradle/module-quickstart/modules/dave/build/classes/shims
>> /Users/ddhill/shared/gradle/module-quickstart/modules/dave/build/classes/shims
>> /Users/ddhill/shared/gradle/module-quickstart/modules/dave/build/classes/shims/dave
>> /Users/ddhill/shared/gradle/module-quickstart/modules/dave/build/classes/shims/dave/module-info.class
>> /Users/ddhill/shared/gradle/module-quickstart/modules/dave/build/classes/shims/dave/org
>> /Users/ddhill/shared/gradle/module-quickstart/modules/dave/build/classes/shims/dave/org/dave
>> /Users/ddhill/shared/gradle/module-quickstart/modules/dave/build/classes/shims/dave/org/dave/List.class
>> /Users/ddhill/shared/gradle/module-quickstart/modules/dave/build/classes/shims/dave/org/dave/ListShim.class
>> /Users/ddhill/shared/gradle/module-quickstart/modules/dave/build/classes/shims/dave/org/dave/Person.class

David Hill<David.Hill at>
Java Embedded Development

"A man's feet should be planted in his country, but his eyes should survey the world."
-- George Santayana (1863 - 1952)

More information about the jigsaw-dev mailing list