7

I would like my build to break if any compiler warnings occur, so I enabled -Werror. At some point later on I decided to use Java 9 HttpClient which is an incubating module. Unfortunately, I now get the following compiler warning:

using incubating module(s): jdk.incubator.httpclient

Is there a way to use incubating modules alongside -Werror without breaking the build? Ideally, I'd like to suppress this warning showing up altogether.

I am using Maven to build my project, so ideally answers should provide an example of how to get incubation modules to compile as part of a Maven project.

Krzysztof Krasoń
  • 26,515
  • 16
  • 89
  • 115
Gili
  • 86,244
  • 97
  • 390
  • 689
  • During the JDK build incubator modules *must be packaged into jmod files* with the `--do-not-resolve-by-default` option of the jmod tool, so that they are not in the default set of root modules for the unnamed module. This makes them, in effect, "opt-in". The `--warn-if-resolved=incubator` option must be also passed to the jmod tool, so that a warning is issued at compile time, link time, and run time if the incubator module is resolved. This warning can be suppressed at compile time, but not at other times. – Naman Dec 29 '17 at 05:21
  • @nullpointer I don't think I am using `jmod`. I am compiling my project through maven, so I think only `javac` is getting invoked. – Gili Dec 29 '17 at 05:23
  • @nullpointer I still don't fully get it. Are you saying that I have to package my project using the `jmod` tool to suppress this warnings? Are you able to share an example Maven project that does this? (I'll add the Maven tag now) – Gili Dec 29 '17 at 05:27
  • 5
    This is a known issue: https://bugs.openjdk.java.net/browse/JDK-8187591 – Alan Bateman Dec 29 '17 at 07:54
  • 1
    @AlanBateman Would the `-Xlint:-module` not help here temporarily? (Though I agree the cons then might be that the module related warnings would all be disabled). Just a thought since I was unable to find `--should-stop:ifError=PARSE` in the docs. – Naman Dec 29 '17 at 08:17
  • @AlanBateman The workaround mentioned in JDK-8187591 does not work in JDK 19. `javac` returns `invalid flag: --should-stop:ifError=PARSE`. – Gili Nov 16 '22 at 16:54

0 Answers0