Issue with Java module system and Vert.x CodeGen

162 views
Skip to first unread message

JEREMY FLORTE

unread,
Jul 28, 2020, 4:31:51 AM7/28/20
to vert.x
Hi,

I'm working on a Vert.X project with latest release (3.9.2) and using a JDK 11 (open 11.0.7). I made some attempts to build a lighter Docker image (using Jlink to build a custom JRE).

It works until I try to use code generator and service-proxy. So I tried with a clean sample project that comes from Vert.X "how to": https://github.com/vertx-howtos/service-proxy-howto

Moving to JDK 8 to 11 OK. But once I add a module-info.java file like this (minimal version here, jlink may require some other dependencies later on but it's enough to get the bug):

module service.proxy.howto {

   requires vertx.codegen;
   requires vertx.service.proxy;
 
   requires vertx.core;
   requires vertx.web.client;
}

And after I added the maven compiler plugin:

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-compiler-plugin</artifactId>
   <version>3.8.1</version>
   <configuration>
     <source>${maven.compiler.source}</source>
     <target>${maven.compiler.target}</target>
     <annotationProcessorPaths>
      <annotationProcessorPath>
        <groupId>io.vertx</groupId>
          <artifactId>vertx-codegen</artifactId>
           <version>${vertx.version}</version>
           <classifier>processor</classifier>
        </annotationProcessorPath>
        <annotationProcessorPath>
           <groupId>io.vertx</groupId>
           <artifactId>vertx-service-proxy</artifactId>
           <version>${vertx.version}</version>
           <classifier>processor</classifier>
        </annotationProcessorPath>
     </annotationProcessorPaths>
  </configuration>
</plugin>

Then, I cannot compile my project because of a NPE. Using Maven -X option, I see:

Caused by: java.lang.NullPointerException
    at com.sun.tools.javac.code.Symbol.packge (Symbol.java:497)
    at com.sun.tools.javac.model.JavacElements.getPackageOf (JavacElements.java:439)
    at io.vertx.codegen.CodeGen.lambda$new$0 (CodeGen.java:60)

I've tried with 3.9.0, 3.9.1 and 3.9.2, same issue. With 5th milestone from Vert.X 4, this is the CodeGenProcessor class that throws a NPE.

I previously made some attemps too with the moditect plugin (that allows to kinf od "modularize" non "modularized" jar) but last versions of Vert.X does not work (last working version is 3.8.0, 3.8.1 updated to Netty 4.1.36.Final and it just crash: https://github.com/moditect/moditect/issues/57).

More generally, I'd like to know what is the "official" way of doing with Vert.X to produce lighter Docker images with JDK 11+ ?
Base images are awfully big and even a 20 MB application jar may results in a 280 MB Docker image (><).

I managed to have something better by using modules (more something like 80 MB) but then the code generator issue I mentioned earlier happened.
I also gave a try to native builds but again, get blocked by several issues (like this one: https://github.com/oracle/graal/issues/1902).

From now on, I think I'm going to give a try by providing an automatic module (it's a bit weird but if it works....)

If someone has a better idea or already encountered the same issues, I'm all ears.

Regards,

Jérémy Florte

Julien Viet

unread,
Jul 28, 2020, 8:28:30 AM7/28/20
to vert.x
Hi Jeremy,

can you shared a reproducer project so we can test it for JDK 11 and fix the bug with such module ?

it sounds like a codegen issue potentially and it would be good to fix it.

Julien

--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/04e0811f-bb5e-45ee-874c-98c570960b51n%40googlegroups.com.

Jérémy Florte

unread,
Jul 28, 2020, 8:45:10 AM7/28/20
to ve...@googlegroups.com
Hi,

Of course ^^
I attached it with this email. It's the same project as provided in Vert.X howto, but with JDK 11 and a module-info.java file.

A simple command to reproduce: mvn clean compile -X

Regards,

Jérémy

PS: 'had to change address ^^

service-proxy-howto-bis.tar.xz

Julien Viet

unread,
Jul 29, 2020, 6:21:20 AM7/29/20
to vert.x
I used the project you provided and it is a bug of the Java compiler.

While we cannot really fix it (what the code generator do seems legit), the consequences of this NPE are not dramatic and we can handle the NPE instead.

I implemented this work around in https://github.com/vert-x3/vertx-codegen/issues/306

Do you mind having a try with this?

thanks

Julien

Jérémy Florte

unread,
Jul 29, 2020, 8:38:58 AM7/29/20
to ve...@googlegroups.com
Hi,

I made a try with sources from 3.9.3-SNAPSHOT and it's now OK.
Thanks for your quick response !

Regards,

Jérémy

Reply all
Reply to author
Forward
0 new messages