Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8187591

-Werror turns incubator module warning to an error

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 22
    • 9
    • tools
    • None
    • b25

    Description

      $ cat Test.java
      import jdk.incubator.http.*;

      class Test {
         int m() {
            int i = 1/0;
            return i;
         }
      }

      $ javac --add-modules jdk.incubator.httpclient -Xlint -Werror Test.java
      warning: using incubating module(s): jdk.incubator.httpclient
      error: warnings found and -Werror specified
      1 error
      1 warning

      javac stops when it detects the incubator warning and does not show any other warnings e.g. -Xlint is set.

      It's common to turn on -Werror to ensure a warning-free compilation. When the application depends on an incubating API, I think -Werror should not turn it into an error since the application depends on it.

      Incubating module warning is not suppressible. We should revisit the interaction of the incubator module warning and -Werror.

      The current workaround is to use an internal --should-stop option.

      $ javac --add-modules jdk.incubator.httpclient -Xlint -Werror --should-stop:ifError=PARSE Test.java
      warning: using incubating module(s): jdk.incubator.httpclient
      error: warnings found and -Werror specified
      /tmp/TestIncub.java:5: warning: [divzero] division by zero
            int i = 1/0;
                      ^
      1 error
      2 warnings

      Attachments

        Issue Links

          Activity

            People

              asotona Adam Sotona
              mchung Mandy Chung
              Votes:
              0 Vote for this issue
              Watchers:
              11 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: