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

Behavior change when both -Xlint:options and -Xlint:-options flags are given

XMLWordPrintable

    • 25
    • generic
    • generic

      With a recent EA build of Java 25 (it worked at least in ea+15) there is a regression in the warning behaviour of javac.

      In Lucene's build we do some patching of modules to get rid of preview limitations and to allow compiling agains API stubs of a specific vector incubator version. Therefore we cannot pass "-release" flag and have to fallback to "source/target".

      We know that this emits some warnings, so we added "-Xlint:-options" and "-Werror". But with Java 25 ea+27 and (also Java 26 ea+2) it still fails build because the warning is treated as error. The only workaround we can apply is to disable fail on warnings in Java 25 or later.

      This happened quite often in the past that the "options" warnings cannot be suppressed with Xlint. It was always fixed, but there should be a check in the build that all "options" warnings can be suppressed in javac compiler.

      To reproduce execute javac with source and target, but no release:

      $ javac -source 21 -target 21 -Xlint:-options -Werror SomeJavaFile.java
      warning: [options] location of system modules is not set in conjunction with -source 21
        not setting the location of system modules may lead to class files that cannot run on JDK 21
          --release 21 is recommended instead of -source 21 -target 21 because it sets the location of system modules automatically
      error: warnings found and -Werror specified
      1 error
      1 warning

      As this warning is in "option" category it should be supressed and not fail build when "-Werror" is enabled.

      This is aregression and should be fixed before Java 25 is released.

            acobbs Archie Cobbs
            uschindler Uwe Schindler
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: