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

No way to add back lint categories after "none"

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 24, 25
    • tools
    • None
    • openjdk version "24" 2025-03-18
      OpenJDK Runtime Environment (build 24+36-3646)
      OpenJDK 64-Bit Server VM (build 24+36-3646, mixed mode, sharing)

    • generic
    • generic

      If "foo" is any non-mandatory lint category (for example, "serial") then a javac flag like "-Xlint:none,foo" is being handled incorrectly by the compiler.

      Whereas "-Xlint:all,-foo" means "Enable all categories, then remove foo", the flag "-Xlint:none,foo" should mean "Disable all categories, then add foo".

      However, the actual effect of "-Xlint:none,foo" is the same as "-Xlint:none", that is, "Disable all categories, period."

      Reproducer:

          $ cat NoSUID.java
          class NoSUID implements java.io.Serializable { }
          $ javac -Xlint:all NoSUID.java
          NoSUID.java:1: warning: [serial] serializable class NoSUID has no definition of serialVersionUID
          class NoSUID implements java.io.Serializable { }
          ^
          1 warning
          $ javac -Xlint:all,-serial NoSUID.java
          $ javac -Xlint:none NoSUID.java
          $ javac -Xlint:none,serial NoSUID.java # MISSING WARNING HERE
          $ javac -Xlint:serial NoSUID.java
          NoSUID.java:1: warning: [serial] serializable class NoSUID has no definition of serialVersionUID
          class NoSUID implements java.io.Serializable { }
          ^
          1 warning
          $ javac -version
          javac 24

            acobbs Archie Cobbs
            acobbs Archie Cobbs
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: