<Swing Dev> JDK 9 RFR of JDK-8039860: Fix fallthrough lint warnings in swing

Joe Darcy joe.darcy at oracle.com
Thu Apr 10 02:33:30 UTC 2014


Hello,

Please review the changes below to address

     JDK-8039860: Fix fallthrough lint warnings in swing
     http://cr.openjdk.java.net/~darcy/8039860.0/

In many cases, there is already a comment stating that the fallthrough 
is intended. However, please examine in particular the changes in 
javax.swing.text.html.parser.{ContentModelState.java, Parser.java} to 
verify the existing fallthroughs are appropriate.

Thanks,

-Joe

--- 
old/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java 
2014-04-09 19:26:14.000000000 -0700
+++ 
new/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java 
2014-04-09 19:26:14.000000000 -0700
@@ -1683,6 +1683,7 @@
       * adjustments that windows/metal do.  This is because gtk doesn't
       * provide margins/insets for checkbox/radiobuttons.
       */
+    @SuppressWarnings("fallthrough")
      private static class GnomeLayoutStyle extends DefaultLayoutStyle {
          private static GnomeLayoutStyle INSTANCE = new GnomeLayoutStyle();

--- 
old/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java 
2014-04-09 19:26:15.000000000 -0700
+++ 
new/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java 
2014-04-09 19:26:14.000000000 -0700
@@ -2409,6 +2409,7 @@

      // Windows LayoutStyle.  From:
      // 
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwue/html/ch14e.asp
+    @SuppressWarnings("fallthrough")
      private class WindowsLayoutStyle extends DefaultLayoutStyle {
          @Override
          public int getPreferredGap(JComponent component1,
--- 
old/src/share/classes/com/sun/java/swing/plaf/windows/WindowsTableHeaderUI.java 
2014-04-09 19:26:15.000000000 -0700
+++ 
new/src/share/classes/com/sun/java/swing/plaf/windows/WindowsTableHeaderUI.java 
2014-04-09 19:26:15.000000000 -0700
@@ -182,7 +182,6 @@
                  if (sortOrder != null) {
                       switch(sortOrder) {
                       case ASCENDING:
-                         /* falls through */
                       case DESCENDING:
                           switch (state) {
                           case NORMAL:
@@ -197,6 +196,7 @@
                           default:
                               /* do nothing */
                           }
+                         break;
                       default :
                           /* do nothing */
                       }
--- old/src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java 
2014-04-09 19:26:16.000000000 -0700
+++ new/src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java 
2014-04-09 19:26:15.000000000 -0700
@@ -2338,6 +2338,7 @@

      // From the JLF Design Guidelines:
      // http://www.oracle.com/technetwork/java/jlf-135985.html
+    @SuppressWarnings("fallthrough")
      private static class MetalLayoutStyle extends DefaultLayoutStyle {
          private static MetalLayoutStyle INSTANCE = new MetalLayoutStyle();

@@ -2474,4 +2475,4 @@
              return 0;
          }
      }
-}
\ No newline at end of file
+}
--- old/src/share/classes/javax/swing/text/JTextComponent.java 
2014-04-09 19:26:16.000000000 -0700
+++ new/src/share/classes/javax/swing/text/JTextComponent.java 
2014-04-09 19:26:16.000000000 -0700
@@ -4473,6 +4473,7 @@
      // composed(uncommitted) text is done here after all input
      // method listeners get called for stealing the events.
      //
+    @SuppressWarnings("fallthrough")
      protected void processInputMethodEvent(InputMethodEvent e) {
          // let listeners handle the events
          super.processInputMethodEvent(e);
--- old/src/share/classes/javax/swing/text/html/StyleSheet.java 
2014-04-09 19:26:17.000000000 -0700
+++ new/src/share/classes/javax/swing/text/html/StyleSheet.java 
2014-04-09 19:26:17.000000000 -0700
@@ -2324,6 +2324,7 @@
           * @param itemNum number to format
           * @param type    type of ordered list
           */
+        @SuppressWarnings("fallthrough")
          String formatItemNum(int itemNum, char type) {
              String numStyle = "1";

--- 
old/src/share/classes/javax/swing/text/html/parser/ContentModelState.java 2014-04-09 
19:26:19.000000000 -0700
+++ 
new/src/share/classes/javax/swing/text/html/parser/ContentModelState.java 2014-04-09 
19:26:17.000000000 -0700
@@ -92,12 +92,14 @@
       * tokens required in the input stream.
       * @return true if the model can terminate without further input
       */
+    @SuppressWarnings("fallthrough")
      public boolean terminate() {
          switch (model.type) {
            case '+':
              if ((value == 0) && !(model).empty()) {
                  return false;
              }
+            // Fall through okay?
            case '*':
            case '?':
              return (next == null) || next.terminate();
--- old/src/share/classes/javax/swing/text/html/parser/Parser.java 
2014-04-09 19:26:20.000000000 -0700
+++ new/src/share/classes/javax/swing/text/html/parser/Parser.java 
2014-04-09 19:26:20.000000000 -0700
@@ -852,6 +852,7 @@
              if (lower) {
                  ch = 'a' + (ch - 'A');
              }
+            break;

            case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
            case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
@@ -876,6 +877,7 @@
                  if (lower) {
                      ch = 'a' + (ch - 'A');
                  }
+                break;

                case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
                case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
@@ -1214,6 +1216,7 @@
      /**
       * Parse attribute value. [33] 331:1
       */
+    @SuppressWarnings("fallthrough")
      String parseAttributeValue(boolean lower) throws IOException {
          int delim = -1;

@@ -1258,6 +1261,7 @@
                case '\t':
                    if (delim < 0)
                        c = ' ';
+                  // Fall through ?
                case ' ':
                  ch = readCh();
                  if (delim < 0) {
@@ -1559,6 +1563,7 @@
      /**
       * Parse a start or end tag.
       */
+    @SuppressWarnings("fallthrough")
      void parseTag() throws IOException {
          Element elem;
          boolean net = false;
@@ -1602,6 +1607,7 @@
                          continue;
                        case '>':
                          ch = readCh();
+                        // Fall through okay?
                        case -1:
                          return;
                        default:
@@ -1626,6 +1632,7 @@
                      switch(ch) {
                        case '>':
                          ch = readCh();
+                        // Fall through okay?
                        case -1:
                          error("invalid.markup");
                          return;
@@ -1657,6 +1664,7 @@
              switch (ch = readCh()) {
                case '>':
                  ch = readCh();
+                // Fall through okay?
                case '<':
                  // empty end tag. either </> or </<
                  if (recent == null) {
@@ -1675,6 +1683,7 @@
                  switch (ch) {
                    case '>':
                      ch = readCh();
+                    // Fall through okay?
                    case '<':
                      break;

@@ -1875,6 +1884,7 @@
          switch (ch) {
            case '/':
              net = true;
+            // Fall through okay?
            case '>':
              ch = readCh();
              if (ch == '>' && net) {
--- old/src/share/classes/javax/swing/text/rtf/RTFGenerator.java 
2014-04-09 19:26:21.000000000 -0700
+++ new/src/share/classes/javax/swing/text/rtf/RTFGenerator.java 
2014-04-09 19:26:21.000000000 -0700
@@ -868,6 +868,7 @@
      afterKeyword = false;
  }

+ at SuppressWarnings("fallthrough")
  public void writeCharacter(char ch)
      throws IOException
  {
--- old/src/share/classes/javax/swing/text/rtf/RTFParser.java 2014-04-09 
19:26:22.000000000 -0700
+++ new/src/share/classes/javax/swing/text/rtf/RTFParser.java 2014-04-09 
19:26:22.000000000 -0700
@@ -148,6 +148,7 @@
        handleText(s);
    }

+  @SuppressWarnings("fallthrough")
    public void write(char ch)
      throws IOException
    {




More information about the swing-dev mailing list