JDK9 and Gradle modular quickstart

Malachi de Ælfweald malachid at gmail.com
Thu Aug 25 15:00:44 UTC 2016

Hi David,

Thank you for sharing this.

A couple thoughts -

   - you might consider posting it in a repo as opposed to a zip so we can
   follow changes (bitbucket, kenai, whatever)
   - adding an .hgignore
   - reading the note at the top of your build.gradle, this comment caught
   my attention "*Note that the test packages cannot overlap with your
   module packages.*" I think that one is really important as it would
   indicate that there might be difficulties doing Android Flavors moving
   - on your build.gradle, you have '4.+' - it is no longer recommended to
   use the + and the IDEs will throw warnings about it (also JUnit 5 is
   - instead of having a single build.gradle with 3 different compile
   tasks; why did you not make it 3 separate modules (each with their own
   compile task)?

When I ran `./gradlew build` it failed because it could not find

test.org.dave.PersonTest > canConstructAPersonWithAName FAILED
    java.lang.NoClassDefFoundError at PersonTest.java:11
        Caused by: java.lang.ClassNotFoundException at PersonTest.java:11

Per your README, I tried setting export _JAVA_OPTIONS="--add-exports

and re-running the build; which resulted in:

Unrecognized option: --add-exports
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

Looking at my previous _JAVA_OPTIONS, I tried export

and re-running the build; which resulted in:

Error occurred during initialization of VM
java.lang.RuntimeException: Unknown module: dave
    at jdk.internal.module.ModuleBootstrap.fail(java.base at 9-ea
    at jdk.internal.module.ModuleBootstrap.addExtraExports(java.base at 9-ea
    at jdk.internal.module.ModuleBootstrap.boot(java.base at 9-ea
    at java.lang.System.initPhase2(java.base at 9-ea/System.java:1925)

Any thoughts?

Malachi de Ælfweald

On Thu, Aug 25, 2016 at 6:19 AM, David Hill <David.Hill at oracle.com> wrote:

> Hi,
>    I mentioned I was working on a modular compilation with Gradle 3 and
> JDK9. I have something to share now :-)
> This adapted quickstart comprises a "module" of two classes, a test class,
> and a "shim" test class. (The shim is an adapter used for 'white box' style
> tests).
>    http://cr.openjdk.java.net/~ddhill/module-quickstart.zip
> The first half of the build.gradle is a README that explains a lot of my
> design constraints, and choices.
> Gradle is really good at making the simple cases ... simple. Clearly they
> have a bit more to go to handle modules natively, but as my quickstart
> shows, it can be done now without too much extra effort.
> I would be interested in any comments or suggestions on how I have solved
> this task. I plan on folding what I have found into the OpenJFX build.
> Dave
> --
> David Hill<David.Hill at Oracle.com>
> 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