changeset 49716:0b4d0779f772 switch

A little cleanup of the switch branch; adding provisional source-level checks for the new switch-related features.
author jlahoda
date Tue, 10 Apr 2018 16:25:35 +0200
parents f7a8524a7e9b
children 07e680a35423
files src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java test/langtools/tools/javac/switchexpr/ExpressionSwitch-old.out test/langtools/tools/javac/switchexpr/ExpressionSwitch.java test/langtools/tools/javac/switchexpr/ExpressionSwitchBreaks1.java test/langtools/tools/javac/switchexpr/MultipleLabels.java test/langtools/tools/javac/switchextra/MultipleLabelsExpression-old.out test/langtools/tools/javac/switchextra/MultipleLabelsExpression.java test/langtools/tools/javac/switchextra/MultipleLabelsStatement-old.out test/langtools/tools/javac/switchextra/MultipleLabelsStatement.java test/langtools/tools/javac/switchextra/SwitchExtra-old.out test/langtools/tools/javac/switchextra/SwitchExtra.java test/langtools/tools/javac/switchnull/SwitchNull-old.out test/langtools/tools/javac/switchnull/SwitchNull.java test/langtools/tools/javac/switchnull/SwitchNull.out test/langtools/tools/javac/tree/SourceTreeScannerTest.java
diffstat 20 files changed, 233 insertions(+), 123 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java	Fri Apr 06 18:13:21 2018 -0400
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java	Tue Apr 10 16:25:35 2018 +0200
@@ -181,7 +181,11 @@
         DIAMOND_WITH_ANONYMOUS_CLASS_CREATION(JDK9, Fragments.FeatureDiamondAndAnonClass, DiagKind.NORMAL),
         UNDERSCORE_IDENTIFIER(MIN, JDK8),
         PRIVATE_INTERFACE_METHODS(JDK9, Fragments.FeaturePrivateIntfMethods, DiagKind.PLURAL),
-        LOCAL_VARIABLE_TYPE_INFERENCE(JDK10);
+        LOCAL_VARIABLE_TYPE_INFERENCE(JDK10),
+        SWITCH_MULTIPLE_CASE_LABELS(JDK10, Fragments.FeatureMultipleCaseLabels, DiagKind.PLURAL),
+        SWITCH_EXPRESSION(JDK10, Fragments.FeatureSwitchExpressions, DiagKind.PLURAL),
+        SWITCH_CASE_NULL(JDK10, Fragments.FeatureCaseNull, DiagKind.NORMAL),
+        SWITCH_EXTRA_TYPES(JDK10, Fragments.FeatureSwitchExtraTypes, DiagKind.NORMAL);
 
         enum DiagKind {
             NORMAL,
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Fri Apr 06 18:13:21 2018 -0400
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Tue Apr 10 16:25:35 2018 +0200
@@ -27,8 +27,6 @@
 
 import java.util.*;
 import java.util.function.BiConsumer;
-import java.util.function.BiFunction;
-import java.util.function.Function;
 
 import javax.lang.model.element.ElementKind;
 import javax.tools.JavaFileObject;
@@ -158,6 +156,8 @@
 
         Source source = Source.instance(context);
         allowStringsInSwitch = Feature.STRINGS_IN_SWITCH.allowedInSource(source);
+        allowExtraTypesInSwitch = Feature.SWITCH_EXTRA_TYPES.allowedInSource(source);
+        allowNullCase = Feature.SWITCH_EXTRA_TYPES.allowedInSource(source);
         allowPoly = Feature.POLY.allowedInSource(source);
         allowTypeAnnos = Feature.TYPE_ANNOTATIONS.allowedInSource(source);
         allowLambda = Feature.LAMBDA.allowedInSource(source);
@@ -207,6 +207,16 @@
     boolean allowStringsInSwitch;
 
     /**
+     * Switch: allow extra types in switch?
+     */
+    boolean allowExtraTypesInSwitch;
+
+    /**
+     * Switch: allow case null in switch?
+     */
+    boolean allowNullCase;
+
+    /**
      * Switch: name of source level; used for error reporting.
      */
     String sourceName;
@@ -1459,8 +1469,12 @@
                 log.error(DiagnosticFlag.SOURCE_LEVEL, selector.pos(), Feature.STRINGS_IN_SWITCH.error(sourceName));
             }
             Type unboxedSelType = types.unboxedTypeOrType(seltype);
-            if (!enumSwitch && !stringSwitch && !unboxedSelType.isPrimitive()) {
-                log.error(selector.pos(), Errors.SwitchInvalidType(seltype));
+            if (!enumSwitch && !stringSwitch) {
+                if (!unboxedSelType.isPrimitive()) {
+                    log.error(selector.pos(), Errors.SwitchInvalidType(seltype));
+                } else if (!types.isSubtype(unboxedSelType, syms.intType) && !allowExtraTypesInSwitch) {
+                    log.error(DiagnosticFlag.SOURCE_LEVEL, selector.pos(), Feature.SWITCH_EXTRA_TYPES.error(sourceName));
+                }
             }
 
             // Attribute all cases and
@@ -1472,6 +1486,11 @@
                 JCExpression pat = c.pat;
                 if (pat != null) {
                     if (TreeInfo.isNull(pat)) {
+                        if (!allowNullCase) {
+                            log.error(DiagnosticFlag.SOURCE_LEVEL,
+                                      selector.pos(),
+                                      Feature.SWITCH_CASE_NULL.error(sourceName));
+                        }
                         //case null:
                         //TODO: check -source
                         if (seltype.isPrimitive()) {
@@ -1850,7 +1869,7 @@
         if (env.info.breakResult != null) {
             if (tree.value == null) {
                 tree.target = findJumpTarget(tree.pos(), tree.getTag(), null, env);
-                if (tree.target.hasTag(SWITCH_EXPRESSIOM)) {
+                if (tree.target.hasTag(SWITCH_EXPRESSION)) {
                     log.error(tree.pos(), Errors.BreakMissingValue);
                 }
             } else {
@@ -1880,7 +1899,7 @@
                 if (attribute) {
                     attribTree(tree.value, env, env.info.breakResult);
                     Env<AttrContext> env1 = env;
-                    while (env1 != null && env1.tree.getTag() != SWITCH_EXPRESSIOM) {
+                    while (env1 != null && env1.tree.getTag() != SWITCH_EXPRESSION) {
                         env1 = env1.next;
                     }
                     Assert.checkNonNull(env1);
@@ -1978,7 +1997,7 @@
                     case SWITCH:
                         if (label == null && tag == BREAK) return Pair.of(env1.tree, null);
                         break;
-                    case SWITCH_EXPRESSIOM:
+                    case SWITCH_EXPRESSION:
                         if (tag == BREAK) {
                             if (label == null) {
                                 return Pair.of(env1.tree, null);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java	Fri Apr 06 18:13:21 2018 -0400
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java	Tue Apr 10 16:25:35 2018 +0200
@@ -56,6 +56,7 @@
 import static com.sun.tools.javac.code.Kinds.Kind.*;
 import static com.sun.tools.javac.code.Symbol.OperatorSymbol.AccessCode.DEREF;
 import static com.sun.tools.javac.jvm.ByteCodes.*;
+import com.sun.tools.javac.tree.JCTree.JCBreak;
 import com.sun.tools.javac.tree.JCTree.JCCase.CaseKind;
 import com.sun.tools.javac.tree.JCTree.JCExpression;
 import static com.sun.tools.javac.tree.JCTree.JCOperatorExpression.OperandPos.LEFT;
@@ -3828,22 +3829,16 @@
                 public void visitClassDef(JCClassDecl tree) {}
                 @Override
                 public void visitMethodDef(JCMethodDecl tree) {}
-                @SuppressWarnings("unchecked")
-                public <T extends JCTree> List<T> translate(List<T> trees) {
-                    if (trees == null) return null;
-                    ListBuffer<T> result = new ListBuffer<>();
-                    for (List<T> l = trees; l.nonEmpty(); l = l.tail) {
-                        if (l.head.hasTag(BREAK) && ((JCBreak) l.head).target == switchExpr) {
-                            JCBreak tree = (JCBreak) l.head;
-                            tree.target = switchStatement;
-                            result.append((T) make.Exec(make.Assign(make.Ident(dollar_switchexpr), translate(tree.value)).setType(dollar_switchexpr.type)));
-                            result.append((T) tree);
-                            tree.value = null;
-                        } else {
-                            result.append(translate(l.head));
-                        }
+                @Override
+                public void visitBreak(JCBreak tree) {
+                    if (tree.target == switchExpr) {
+                        tree.target = switchStatement;
+                        result = make.Block(0, List.of(make.Exec(make.Assign(make.Ident(dollar_switchexpr), translate(tree.value)).setType(dollar_switchexpr.type)),
+                                                       tree));
+                        tree.value = null;
+                    } else {
+                        result = tree;
                     }
-                    return result.toList();
                 }
             }.translate(c.stats));
             return make.Case(c.pat, statements.toList(), CaseKind.STATEMENTS);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Fri Apr 06 18:13:21 2018 -0400
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Tue Apr 10 16:25:35 2018 +0200
@@ -1355,6 +1355,7 @@
             }
             break;
         case SWITCH:
+            checkSourceLevel(Feature.SWITCH_EXPRESSION);
             int switchPos = token.pos;
             nextToken();
             JCExpression selector = parExpression();
@@ -1396,6 +1397,7 @@
             while (true) {
                 pat = term(EXPR | NOLAMBDA);
                 if (token.kind != COMMA) break;
+                checkSourceLevel(Feature.SWITCH_MULTIPLE_CASE_LABELS);
                 nextToken();
                 caseExprs.append(toP(F.at(casePos).Case(pat, List.nil(), CaseKind.STATEMENTS)));
             };
@@ -2803,6 +2805,7 @@
                 pat = parseExpression();
                 if (token.kind != COMMA) break;
                 nextToken();
+                checkSourceLevel(Feature.SWITCH_MULTIPLE_CASE_LABELS);
                 c = F.at(pos).Case(pat, List.nil(), CaseKind.STATEMENTS);
                 storeEnd(c, S.prevToken().endPos);
                 cases.append(c);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Fri Apr 06 18:13:21 2018 -0400
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Tue Apr 10 16:25:35 2018 +0200
@@ -2744,6 +2744,18 @@
 compiler.misc.feature.private.intf.methods=\
     private interface methods
 
+compiler.misc.feature.multiple.case.labels=\
+    multiple case labels
+
+compiler.misc.feature.switch.expressions=\
+    switch expressions
+
+compiler.misc.feature.switch.extra.types=\
+    switch over boolean, long, float and double
+
+compiler.misc.feature.case.null=\
+    case null
+
 compiler.warn.underscore.as.identifier=\
     as of release 9, ''_'' is a keyword, and may not be used as an identifier
 
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java	Fri Apr 06 18:13:21 2018 -0400
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java	Tue Apr 10 16:25:35 2018 +0200
@@ -155,17 +155,13 @@
          */
         SWITCH,
 
-        /** Case parts in switch statements, of type Case.
+        /** Case parts in switch statements/expressions, of type Case.
          */
         CASE,
 
         /** Switch expression statements, of type Switch.
          */
-        SWITCH_EXPRESSIOM,
-
-        /** Case expression parts in switch expressions, of type Case.
-         */
-        CASE_EXPRESSIOM,
+        SWITCH_EXPRESSION,
 
         /** Synchronized statements, of type Synchonized.
          */
@@ -1310,7 +1306,7 @@
         }
         @Override
         public Tag getTag() {
-            return SWITCH_EXPRESSIOM;
+            return SWITCH_EXPRESSION;
         }
     }
 
@@ -1544,7 +1540,7 @@
         @Override
         public void accept(Visitor v) { v.visitBreak(this); }
         public boolean isValueBreak() {
-            return target != null && target.hasTag(SWITCH_EXPRESSIOM);
+            return target != null && target.hasTag(SWITCH_EXPRESSION);
         }
 
         @DefinedBy(Api.COMPILER_TREE)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitch-old.out	Tue Apr 10 16:25:35 2018 +0200
@@ -0,0 +1,2 @@
+ExpressionSwitch.java:48:16: compiler.err.feature.not.supported.in.source.plural: (compiler.misc.feature.switch.expressions), 9, 10
+1 error
--- a/test/langtools/tools/javac/switchexpr/ExpressionSwitch.java	Fri Apr 06 18:13:21 2018 -0400
+++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitch.java	Tue Apr 10 16:25:35 2018 +0200
@@ -23,6 +23,7 @@
 
 /**
  * @test
+ * @compile/fail/ref=ExpressionSwitch-old.out -source 9 -Xlint:-options -XDrawDiagnostics ExpressionSwitch.java
  * @compile ExpressionSwitch.java
  * @run main ExpressionSwitch
  */
@@ -81,4 +82,8 @@
     enum T {
         A, B, C, D;
     }
+    void t() {
+        Runnable r = () -> {};
+        r.run();
+    }
 }
--- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchBreaks1.java	Fri Apr 06 18:13:21 2018 -0400
+++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchBreaks1.java	Tue Apr 10 16:25:35 2018 +0200
@@ -56,7 +56,7 @@
             case 0:
                 return switch (j) {
                     case 0:
-                        break "0-0";
+                        if (true) break "0-0";
                     case 1:
                         break "0-1";
                     default:
--- a/test/langtools/tools/javac/switchexpr/MultipleLabels.java	Fri Apr 06 18:13:21 2018 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/**
- * @test
- * @compile MultipleLabels.java
- * @run main MultipleLabels
- */
-
-import java.util.Objects;
-import java.util.function.Function;
-
-public class MultipleLabels {
-    public static void main(String... args) {
-        new MultipleLabels().run();
-    }
-
-    private void run() {
-        runTest(this::statement1);
-    }
-
-    private void runTest(Function<T, String> print) {
-        check(null, print, "NULL-A");
-        check(T.A,  print, "NULL-A");
-        check(T.B,  print, "B-C");
-        check(T.C,  print, "B-C");
-        check(T.D,  print, "D");
-        check(T.E,  print, "other");
-    }
-
-    private String statement1(T t) {
-        String res;
-
-        switch (t) {
-            case null, A: res = "NULL-A"; break;
-            case B, C: res = "B-C"; break;
-            case D: res = "D"; break;
-            default: res = "other"; break;
-        }
-
-        return res;
-    }
-
-    private String expression1(T t) {
-        return switch (t) {
-            case null, A -> "NULL-A";
-            case B, C: break "B-C";
-            case D -> "D";
-            default -> "other";
-        };
-    }
-
-    private void check(T t, Function<T, String> print, String expected) {
-        String result = print.apply(t);
-        if (!Objects.equals(result, expected)) {
-            throw new AssertionError("Unexpected result: " + result);
-        }
-    }
-
-    enum T {
-        A, B, C, D, E;
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/switchextra/MultipleLabelsExpression-old.out	Tue Apr 10 16:25:35 2018 +0200
@@ -0,0 +1,3 @@
+MultipleLabelsExpression.java:53:16: compiler.err.feature.not.supported.in.source.plural: (compiler.misc.feature.switch.expressions), 9, 10
+MultipleLabelsExpression.java:54:22: compiler.err.feature.not.supported.in.source.plural: (compiler.misc.feature.multiple.case.labels), 9, 10
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/switchextra/MultipleLabelsExpression.java	Tue Apr 10 16:25:35 2018 +0200
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @compile/fail/ref=MultipleLabelsExpression-old.out -source 9 -Xlint:-options -XDrawDiagnostics MultipleLabelsExpression.java
+ * @compile MultipleLabelsExpression.java
+ * @run main MultipleLabelsExpression
+ */
+
+import java.util.Objects;
+import java.util.function.Function;
+
+public class MultipleLabelsExpression {
+    public static void main(String... args) {
+        new MultipleLabelsExpression().run();
+    }
+
+    private void run() {
+        runTest(this::expression1);
+    }
+
+    private void runTest(Function<T, String> print) {
+        check(null, print, "NULL-A");
+        check(T.A,  print, "NULL-A");
+        check(T.B,  print, "B-C");
+        check(T.C,  print, "B-C");
+        check(T.D,  print, "D");
+        check(T.E,  print, "other");
+    }
+
+    private String expression1(T t) {
+        return switch (t) {
+            case null, A -> "NULL-A";
+            case B, C: break "B-C";
+            case D -> "D";
+            default -> "other";
+        };
+    }
+
+    private void check(T t, Function<T, String> print, String expected) {
+        String result = print.apply(t);
+        if (!Objects.equals(result, expected)) {
+            throw new AssertionError("Unexpected result: " + result);
+        }
+    }
+
+    enum T {
+        A, B, C, D, E;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/switchextra/MultipleLabelsStatement-old.out	Tue Apr 10 16:25:35 2018 +0200
@@ -0,0 +1,2 @@
+MultipleLabelsStatement.java:56:24: compiler.err.feature.not.supported.in.source.plural: (compiler.misc.feature.multiple.case.labels), 9, 10
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/switchextra/MultipleLabelsStatement.java	Tue Apr 10 16:25:35 2018 +0200
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @compile/fail/ref=MultipleLabelsStatement-old.out -source 9 -Xlint:-options -XDrawDiagnostics MultipleLabelsStatement.java
+ * @compile MultipleLabelsStatement.java
+ * @run main MultipleLabelsStatement
+ */
+
+import java.util.Objects;
+import java.util.function.Function;
+
+public class MultipleLabelsStatement {
+    public static void main(String... args) {
+        new MultipleLabelsStatement().run();
+    }
+
+    private void run() {
+        runTest(this::statement1);
+    }
+
+    private void runTest(Function<T, String> print) {
+        check(null, print, "NULL-A");
+        check(T.A,  print, "NULL-A");
+        check(T.B,  print, "B-C");
+        check(T.C,  print, "B-C");
+        check(T.D,  print, "D");
+        check(T.E,  print, "other");
+    }
+
+    private String statement1(T t) {
+        String res;
+
+        switch (t) {
+            case null, A: res = "NULL-A"; break;
+            case B, C: res = "B-C"; break;
+            case D: res = "D"; break;
+            default: res = "other"; break;
+        }
+
+        return res;
+    }
+
+    private void check(T t, Function<T, String> print, String expected) {
+        String result = print.apply(t);
+        if (!Objects.equals(result, expected)) {
+            throw new AssertionError("Unexpected result: " + result);
+        }
+    }
+
+    enum T {
+        A, B, C, D, E;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/switchextra/SwitchExtra-old.out	Tue Apr 10 16:25:35 2018 +0200
@@ -0,0 +1,3 @@
+SwitchExtra.java:186:16: compiler.err.feature.not.supported.in.source.plural: (compiler.misc.feature.switch.expressions), 9, 10
+SwitchExtra.java:91:16: compiler.err.feature.not.supported.in.source: (compiler.misc.feature.switch.extra.types), 9, 10
+2 errors
--- a/test/langtools/tools/javac/switchextra/SwitchExtra.java	Fri Apr 06 18:13:21 2018 -0400
+++ b/test/langtools/tools/javac/switchextra/SwitchExtra.java	Tue Apr 10 16:25:35 2018 +0200
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @compile/fail/ref=SwitchExtra-old.out -source 9 -Xlint:-options -XDrawDiagnostics -XDshould-stop.at=FLOW SwitchExtra.java
  * @compile SwitchExtra.java
  * @run main SwitchExtra
  */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/switchnull/SwitchNull-old.out	Tue Apr 10 16:25:35 2018 +0200
@@ -0,0 +1,2 @@
+SwitchNull.java:32:16: compiler.err.feature.not.supported.in.source: (compiler.misc.feature.case.null), 9, 10
+1 error
--- a/test/langtools/tools/javac/switchnull/SwitchNull.java	Fri Apr 06 18:13:21 2018 -0400
+++ b/test/langtools/tools/javac/switchnull/SwitchNull.java	Tue Apr 10 16:25:35 2018 +0200
@@ -1,8 +1,9 @@
 /**
  * @test
+ * @compile/fail/ref=SwitchNull-old.out -source 9 -Xlint:-options -XDrawDiagnostics SwitchNull.java
+ * @compile/fail/ref=SwitchNull.out -XDdisableIndySwitch=true -XDrawDiagnostics SwitchNull.java
  * @compile SwitchNull.java
  * @run main SwitchNull
- * @compile/fail/ref=SwitchNull.out -XDdisableIndySwitch=true -XDrawDiagnostics SwitchNull.java
  */
 
 public class SwitchNull {
--- a/test/langtools/tools/javac/switchnull/SwitchNull.out	Fri Apr 06 18:13:21 2018 -0400
+++ b/test/langtools/tools/javac/switchnull/SwitchNull.out	Tue Apr 10 16:25:35 2018 +0200
@@ -1,7 +1,7 @@
-SwitchNull.java:31:9: compiler.err.no.legacy.desugaring
-SwitchNull.java:39:9: compiler.err.no.legacy.desugaring
-SwitchNull.java:47:9: compiler.err.no.legacy.desugaring
-SwitchNull.java:55:9: compiler.err.no.legacy.desugaring
-SwitchNull.java:63:9: compiler.err.no.legacy.desugaring
-SwitchNull.java:71:9: compiler.err.no.legacy.desugaring
+SwitchNull.java:32:9: compiler.err.no.legacy.desugaring
+SwitchNull.java:40:9: compiler.err.no.legacy.desugaring
+SwitchNull.java:48:9: compiler.err.no.legacy.desugaring
+SwitchNull.java:56:9: compiler.err.no.legacy.desugaring
+SwitchNull.java:64:9: compiler.err.no.legacy.desugaring
+SwitchNull.java:72:9: compiler.err.no.legacy.desugaring
 6 errors
--- a/test/langtools/tools/javac/tree/SourceTreeScannerTest.java	Fri Apr 06 18:13:21 2018 -0400
+++ b/test/langtools/tools/javac/tree/SourceTreeScannerTest.java	Tue Apr 10 16:25:35 2018 +0200
@@ -47,7 +47,6 @@
 import java.io.*;
 import java.lang.reflect.*;
 import java.util.*;
-
 import javax.tools.*;
 
 import com.sun.source.tree.Tree;