changeset 51534:c2746556c7c9 switch

Assorted cleanups to the switch branch.
author jlahoda
date Fri, 29 Jun 2018 13:42:14 +0200
parents 1361c9377df0
children 27247bfeaf89
files make/CompileJavaModules.gmk src/jdk.compiler/share/classes/com/sun/source/tree/CaseTree.java src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ArgumentAttr.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Target.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 src/jdk.compiler/share/classes/com/sun/tools/javac/tree/Pretty.java src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java test/langtools/tools/javac/diags/examples/BreakAmbiguousTarget.java test/langtools/tools/javac/diags/examples/BreakComplexValueNoSwitchExpression.java test/langtools/tools/javac/diags/examples/BreakExprNotImmediate.java test/langtools/tools/javac/diags/examples/BreakMissingValue.java test/langtools/tools/javac/diags/examples/BreakOutsideSwitchExpression.java test/langtools/tools/javac/diags/examples/ContinueOutsideSwitchExpression.java test/langtools/tools/javac/diags/examples/MultipleCaseLabels.java test/langtools/tools/javac/diags/examples/NotExhaustive.java test/langtools/tools/javac/diags/examples/ReturnOutsideSwitchExpression.java test/langtools/tools/javac/diags/examples/SwitchCaseUnexpectedStatement.java test/langtools/tools/javac/diags/examples/SwitchExpressionTargetCantBeVoid.java test/langtools/tools/javac/diags/examples/SwitchExpressions.java test/langtools/tools/javac/diags/examples/SwitchMixingCaseTypes.java test/langtools/tools/javac/diags/examples/SwitchNullNotAllowed.java test/langtools/tools/javac/expswitch/ExpSwitchNestingTest.java test/langtools/tools/javac/failover/CheckAttributedTree.java test/langtools/tools/javac/lambda/BadSwitchExpressionLambda.java test/langtools/tools/javac/lambda/BadSwitchExpressionLambda.out test/langtools/tools/javac/modules/JavaBaseTest.java test/langtools/tools/javac/parser/JavacParserTest.java test/langtools/tools/javac/switchexpr/BooleanNumericNonNumeric.java test/langtools/tools/javac/switchexpr/BooleanNumericNonNumeric.out test/langtools/tools/javac/switchexpr/ExpressionSwitch-old.out test/langtools/tools/javac/switchexpr/ExpressionSwitch.java test/langtools/tools/javac/switchexpr/ExpressionSwitchBreaks2.java test/langtools/tools/javac/switchexpr/ExpressionSwitchBreaks2.out test/langtools/tools/javac/switchexpr/ParserRecovery.java test/langtools/tools/javac/switchexpr/ParserRecovery.out 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/SwitchNoExtraTypes.java test/langtools/tools/javac/switchextra/SwitchStatementArrow.java test/langtools/tools/javac/switchextra/SwitchStatementBroken.java test/langtools/tools/javac/switchextra/SwitchStatementBroken.out test/langtools/tools/javac/switchextra/SwitchStatementBroken2.java test/langtools/tools/javac/switchextra/SwitchStatementBroken2.out test/langtools/tools/javac/switchnull/SwitchNullDisabled.java
diffstat 54 files changed, 814 insertions(+), 287 deletions(-) [+]
line wrap: on
line diff
--- a/make/CompileJavaModules.gmk	Thu Jun 28 22:13:55 2018 +0200
+++ b/make/CompileJavaModules.gmk	Fri Jun 29 13:42:14 2018 +0200
@@ -38,8 +38,6 @@
 ################################################################################
 # Module specific build settings
 
-################################################################################
-
 java.base_ADD_JAVAC_FLAGS += -Xdoclint:all/protected,-reference '-Xdoclint/package:java.*,javax.*' -XDstringConcat=inline
 java.base_COPY += .icu .dat .spp content-types.properties hijrah-config-islamic-umalqura.properties
 java.base_CLEAN += intrinsic.properties
--- a/src/jdk.compiler/share/classes/com/sun/source/tree/CaseTree.java	Thu Jun 28 22:13:55 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/source/tree/CaseTree.java	Fri Jun 29 13:42:14 2018 +0200
@@ -75,9 +75,10 @@
     List<? extends StatementTree> getStatements();
 
     /**
-     * If this is a case in switch expression in for
-     * {@linkplain CaseKind#ARROW}, the right-hand-side of
-     * the case, null otherwise.
+     * For case with kind {@linkplain CaseKind#ARROW},
+     * return the statement or expression after the arrow.
+     * Returns {@code null} for case with kind
+     * {@linkplain CaseKind#STATEMENT}.
      * 
      * @return case value or null
      * @since TBD
@@ -100,8 +101,7 @@
      * The syntatic form of this case:
      * <ul>
      *     <li>STATEMENT: {@code case <expression>: <statements>}</li>
-     *     <li>VALUE: {@code case <expression> -> <expression>}</li>
-     *     <li>THROW: {@code case <expression> -> throw ...}</li>
+     *     <li>ARROW: {@code case <expression> -> <expression>/<statement>}</li>
      * </ul>
      * @since TBD
      */
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java	Thu Jun 28 22:13:55 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java	Fri Jun 29 13:42:14 2018 +0200
@@ -186,7 +186,6 @@
     public final Type assertionErrorType;
     public final Type incompatibleClassChangeErrorType;
     public final Type cloneNotSupportedExceptionType;
-    public final Type nullPointerExceptionType;
     public final Type annotationType;
     public final TypeSymbol enumSym;
     public final Type listType;
@@ -210,8 +209,6 @@
     public final Type trustMeType;
     public final Type lambdaMetafactory;
     public final Type stringConcatFactory;
-    public final Type switchBootstraps;
-    public final Type constantBootstraps;
     public final Type repeatableType;
     public final Type documentedType;
     public final Type elementTypeType;
@@ -532,7 +529,6 @@
         assertionErrorType = enterClass("java.lang.AssertionError");
         incompatibleClassChangeErrorType = enterClass("java.lang.IncompatibleClassChangeError");
         cloneNotSupportedExceptionType = enterClass("java.lang.CloneNotSupportedException");
-        nullPointerExceptionType = enterClass("java.lang.NullPointerException");
         annotationType = enterClass("java.lang.annotation.Annotation");
         classLoaderType = enterClass("java.lang.ClassLoader");
         enumSym = enterClass(java_base, names.java_lang_Enum);
@@ -570,8 +566,6 @@
         nativeHeaderType = enterClass("java.lang.annotation.Native");
         lambdaMetafactory = enterClass("java.lang.invoke.LambdaMetafactory");
         stringConcatFactory = enterClass("java.lang.invoke.StringConcatFactory");
-        switchBootstraps = enterClass("java.lang.runtime.SwitchBootstraps");
-        constantBootstraps = enterClass("java.lang.invoke.ConstantBootstraps");
         functionalInterfaceType = enterClass("java.lang.FunctionalInterface");
 
         synthesizeEmptyInterfaceIfMissing(autoCloseableType);
@@ -580,7 +574,6 @@
         synthesizeEmptyInterfaceIfMissing(lambdaMetafactory);
         synthesizeEmptyInterfaceIfMissing(serializedLambdaType);
         synthesizeEmptyInterfaceIfMissing(stringConcatFactory);
-        synthesizeEmptyInterfaceIfMissing(switchBootstraps);
         synthesizeBoxTypeIfMissing(doubleType);
         synthesizeBoxTypeIfMissing(floatType);
         synthesizeBoxTypeIfMissing(voidType);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ArgumentAttr.java	Thu Jun 28 22:13:55 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ArgumentAttr.java	Fri Jun 29 13:42:14 2018 +0200
@@ -25,7 +25,6 @@
 
 package com.sun.tools.javac.comp;
 
-import com.sun.source.tree.LambdaExpressionTree.BodyKind;
 import com.sun.tools.javac.code.Flags;
 import com.sun.tools.javac.code.Symbol;
 import com.sun.tools.javac.code.Symtab;
@@ -39,10 +38,12 @@
 import com.sun.tools.javac.comp.DeferredAttr.DeferredType;
 import com.sun.tools.javac.comp.DeferredAttr.DeferredTypeCompleter;
 import com.sun.tools.javac.comp.DeferredAttr.LambdaReturnScanner;
+import com.sun.tools.javac.comp.DeferredAttr.SwitchExpressionScanner;
 import com.sun.tools.javac.comp.Infer.PartiallyInferredMethodType;
 import com.sun.tools.javac.comp.Resolve.MethodResolutionPhase;
 import com.sun.tools.javac.resources.CompilerProperties.Fragments;
 import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.tree.JCTree.JCBreak;
 import com.sun.tools.javac.tree.JCTree.JCConditional;
 import com.sun.tools.javac.tree.JCTree.JCExpression;
 import com.sun.tools.javac.tree.JCTree.JCLambda;
@@ -52,6 +53,7 @@
 import com.sun.tools.javac.tree.JCTree.JCNewClass;
 import com.sun.tools.javac.tree.JCTree.JCParens;
 import com.sun.tools.javac.tree.JCTree.JCReturn;
+import com.sun.tools.javac.tree.JCTree.JCSwitchExpression;
 import com.sun.tools.javac.tree.TreeCopier;
 import com.sun.tools.javac.tree.TreeInfo;
 import com.sun.tools.javac.util.Assert;
@@ -75,10 +77,6 @@
 import static com.sun.tools.javac.code.TypeTag.FORALL;
 import static com.sun.tools.javac.code.TypeTag.METHOD;
 import static com.sun.tools.javac.code.TypeTag.VOID;
-import com.sun.tools.javac.comp.DeferredAttr.SwitchExpressionScanner;
-import com.sun.tools.javac.tree.JCTree.JCBreak;
-import com.sun.tools.javac.tree.JCTree.JCCase;
-import com.sun.tools.javac.tree.JCTree.JCSwitchExpression;
 
 /**
  * This class performs attribution of method/constructor arguments when target-typing is enabled
@@ -485,9 +483,8 @@
             if (speculativeTree.isStandalone()) {
                 return localInfo.check(speculativeTree, speculativeTree.type);
             } else if (resultInfo.pt.hasTag(VOID)) {
-                //this means we are returning a poly conditional from void-compatible lambda expression
-                //XXX: fix error:
-                resultInfo.checkContext.report(tree, attr.diags.fragment(Fragments.ConditionalTargetCantBeVoid));
+                //this means we are returning a poly switch expression from void-compatible lambda expression
+                resultInfo.checkContext.report(tree, attr.diags.fragment(Fragments.SwitchExpressionTargetCantBeVoid));
                 return attr.types.createErrorType(resultInfo.pt);
             } else {
                 //poly
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Jun 28 22:13:55 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Fri Jun 29 13:42:14 2018 +0200
@@ -73,6 +73,10 @@
 import static com.sun.tools.javac.code.Kinds.Kind.*;
 import static com.sun.tools.javac.code.TypeTag.*;
 import static com.sun.tools.javac.code.TypeTag.WILDCARD;
+import com.sun.tools.javac.tree.JCTree.JCBreak;
+import com.sun.tools.javac.tree.JCTree.JCClassDecl;
+import com.sun.tools.javac.tree.JCTree.JCLambda;
+import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
 import static com.sun.tools.javac.tree.JCTree.Tag.*;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag;
 import com.sun.tools.javac.util.JCDiagnostic.Error;
@@ -1401,14 +1405,12 @@
     }
 
     public void visitSwitchExpression(JCSwitchExpression tree) {
-        tree.polyKind = (pt().hasTag(NONE) && pt() != Type.recoveryType && pt() != Infer.anyPoly
-                /*TODO: || isBooleanOrNumeric(env, tree)*/) ?
+        tree.polyKind = (pt().hasTag(NONE) && pt() != Type.recoveryType && pt() != Infer.anyPoly) ?
                 PolyKind.STANDALONE : PolyKind.POLY;
 
         if (tree.polyKind == PolyKind.POLY && resultInfo.pt.hasTag(VOID)) {
             //this means we are returning a poly conditional from void-compatible lambda expression
-            //TODO: fix error (&test):
-            resultInfo.checkContext.report(tree, diags.fragment(Fragments.ConditionalTargetCantBeVoid));
+            resultInfo.checkContext.report(tree, diags.fragment(Fragments.SwitchExpressionTargetCantBeVoid));
             result = tree.type = types.createErrorType(resultInfo.pt);
             return;
         }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java	Thu Jun 28 22:13:55 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java	Fri Jun 29 13:42:14 2018 +0200
@@ -601,12 +601,6 @@
             ListBuffer<PendingExit> prevPendingExits = pendingExits;
             pendingExits = new ListBuffer<>();
             scan(tree.selector);
-            Set<Object> constants = null;
-            if (types.unboxedTypeOrType(tree.selector.type).tsym == syms.booleanType.tsym) {
-                constants = new HashSet<>();
-                constants.add(0);
-                constants.add(1);
-            }
             boolean hasDefault = false;
             for (List<JCCase> l = tree.cases; l.nonEmpty(); l = l.tail) {
                 alive = true;
@@ -616,9 +610,6 @@
                 else {
                     for (JCExpression pat : c.pats) {
                         scan(pat);
-                        if (constants != null) {
-                            constants.remove(pat.type.constValue());
-                        }
                     }
                 }
                 scanStats(c.stats);
@@ -631,7 +622,7 @@
                                 l.tail.head.pos(),
                                 Warnings.PossibleFallThroughIntoCase);
             }
-            if ((constants == null || !constants.isEmpty()) && !hasDefault) {
+            if (!hasDefault) {
                 alive = true;
             }
             alive |= resolveBreaks(tree, prevPendingExits);
@@ -649,11 +640,6 @@
                     constants.add(s.name);
                 }
             }
-            if (types.unboxedTypeOrType(tree.selector.type).tsym == syms.booleanType.tsym) {
-                constants = new HashSet<>();
-                constants.add(0);
-                constants.add(1);
-            }
             boolean hasDefault = false;
             boolean prevAlive = alive;
             for (List<JCCase> l = tree.cases; l.nonEmpty(); l = l.tail) {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java	Thu Jun 28 22:13:55 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java	Fri Jun 29 13:42:14 2018 +0200
@@ -59,7 +59,9 @@
 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;
 import com.sun.tools.javac.tree.JCTree.JCExpression;
+import com.sun.tools.javac.tree.JCTree.JCExpressionStatement;
 import static com.sun.tools.javac.tree.JCTree.JCOperatorExpression.OperandPos.LEFT;
 import static com.sun.tools.javac.tree.JCTree.Tag.*;
 
@@ -3365,7 +3367,10 @@
                 default: //multiple labels, expand:
                     List<JCExpression> patterns = c.pats;
                     while (patterns.tail.nonEmpty()) {
-                        cases.append(make.Case(CaseKind.STATEMENT, List.of(patterns.head), List.nil(), null));
+                        cases.append(make_at(c.pos()).Case(CaseKind.STATEMENT,
+                                                           List.of(patterns.head),
+                                                           List.nil(),
+                                                           null));
                         patterns = patterns.tail;
                     }
                     c.pats = patterns;
@@ -3376,7 +3381,7 @@
         
         for (JCCase c : cases) {
             if (c.caseKind == CaseKind.ARROW && c.completesNormally) {
-                JCBreak b = make.Break(null);
+                JCBreak b = make_at(c.pos()).Break(null);
                 b.target = tree;
                 c.stats = c.stats.append(b);
             }
@@ -3391,7 +3396,6 @@
             types.isSameType(tree.selector.type, syms.stringType);
         Type target = enumSwitch ? tree.selector.type :
             (stringSwitch? syms.stringType : syms.intType);
-
         tree.selector = translate(tree.selector, target);
         tree.cases = translateCases(tree.cases);
         if (enumSwitch) {
@@ -3611,10 +3615,6 @@
         }
     }
 
-    private boolean hasNullCase(JCSwitch tree) {
-        return tree.cases.stream().flatMap(c -> c.pats.stream()).anyMatch(TreeInfo::isNull);
-    }
-
     @Override
     public void visitSwitchExpression(JCSwitchExpression tree) {
         VarSymbol dollar_switchexpr = new VarSymbol(Flags.FINAL|Flags.SYNTHETIC,
@@ -3626,17 +3626,25 @@
 
         stmtList.append(make.at(tree.pos()).VarDef(dollar_switchexpr, null).setType(dollar_switchexpr.type));
         JCSwitch switchStatement = make.Switch(tree.selector, null);
-        switchStatement.cases = tree.cases.stream().map(c -> convertCase(dollar_switchexpr, switchStatement, tree, c)).collect(List.collector());
+        switchStatement.cases =
+                tree.cases.stream()
+                          .map(c -> convertCase(dollar_switchexpr, switchStatement, tree, c))
+                          .collect(List.collector());
         if (tree.cases.stream().noneMatch(c -> c.pats.isEmpty())) {
-            JCThrow thr = make.Throw(makeNewClass(syms.incompatibleClassChangeErrorType, List.nil()));
-            switchStatement.cases = switchStatement.cases.append(make.Case(CaseKind.STATEMENT, List.nil(), List.of(thr), null));
+            JCThrow thr = make.Throw(makeNewClass(syms.incompatibleClassChangeErrorType,
+                                                  List.nil()));
+            JCCase c = make.Case(CaseKind.STATEMENT, List.nil(), List.of(thr), null);
+            switchStatement.cases = switchStatement.cases.append(c);
         }
+
         stmtList.append(translate(switchStatement));
 
-        result = make.LetExpr(stmtList.toList(), make.Ident(dollar_switchexpr)).setType(dollar_switchexpr.type);
+        result = make.LetExpr(stmtList.toList(), make.Ident(dollar_switchexpr))
+                     .setType(dollar_switchexpr.type);
     }
         //where:
-        private JCCase convertCase(VarSymbol dollar_switchexpr, JCSwitch switchStatement, JCSwitchExpression switchExpr, JCCase c) {
+        private JCCase convertCase(VarSymbol dollar_switchexpr, JCSwitch switchStatement,
+                                   JCSwitchExpression switchExpr, JCCase c) {
             make.at(c.pos());
             ListBuffer<JCStatement> statements = new ListBuffer<>();
             statements.addAll(new TreeTranslator() {
@@ -3650,7 +3658,11 @@
                 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)),
+                        JCExpressionStatement assignment =
+                                make.Exec(make.Assign(make.Ident(dollar_switchexpr),
+                                                      translate(tree.value))
+                                              .setType(dollar_switchexpr.type));
+                        result = make.Block(0, List.of(assignment,
                                                        tree));
                         tree.value = null;
                     } else {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Thu Jun 28 22:13:55 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Fri Jun 29 13:42:14 2018 +0200
@@ -423,7 +423,7 @@
                     for (Object staticArg : dynSym.staticArgs) {
                         pool.put(staticArg);
                     }
-                    poolbuf.appendByte(dynSym.type.hasTag(METHOD) ? CONSTANT_InvokeDynamic : CONSTANT_Dynamic);
+                    poolbuf.appendByte(CONSTANT_InvokeDynamic);
                     poolbuf.appendChar(val.index);
                     poolbuf.appendChar(pool.put(nameType(dynSym)));
                 }
@@ -495,7 +495,7 @@
                 poolbuf.appendByte(CONSTANT_Package);
                 poolbuf.appendChar(pool.put(names.fromUtf(externalize(m.fullname))));
             } else {
-                Assert.error("writePool " + value + "/" + value.getClass());
+                Assert.error("writePool " + value);
             }
             i++;
         }
@@ -1171,7 +1171,7 @@
             databuf.appendChar(uniqueArgs.length);
             //write static args array
             for (Object o : uniqueArgs) {
-                databuf.appendChar(pool.get(pool.makePoolValue(o)));
+                databuf.appendChar(pool.get(o));
             }
         }
         endAttr(alenIdx);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java	Thu Jun 28 22:13:55 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java	Fri Jun 29 13:42:14 2018 +0200
@@ -334,9 +334,6 @@
      *  Mark beginning of gap in catch all range for finalizer.
      */
     void genFinalizer(Env<GenContext> env) {
-        if (env == null || env.info == null) {
-            System.err.println("XXX");
-        }
         if (code.isAlive() && env.info.finalize != null)
             env.info.finalize.gen();
     }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Target.java	Thu Jun 28 22:13:55 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Target.java	Fri Jun 29 13:42:14 2018 +0200
@@ -159,12 +159,6 @@
         return compareTo(JDK1_9) >= 0;
     }
 
-    /** Does the target JDK contain SwitchBootstraps class?
-     */
-    public boolean hasSwichBootstraps() {
-        return compareTo(JDK1_10) >= 0;
-    }
-
     /** Value of platform release used to access multi-release jar files
      */
     public String multiReleaseValue() {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Thu Jun 28 22:13:55 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Fri Jun 29 13:42:14 2018 +0200
@@ -60,6 +60,7 @@
 import static com.sun.tools.javac.resources.CompilerProperties.Fragments.ImplicitAndExplicitNotAllowed;
 import static com.sun.tools.javac.resources.CompilerProperties.Fragments.VarAndExplicitNotAllowed;
 import static com.sun.tools.javac.resources.CompilerProperties.Fragments.VarAndImplicitNotAllowed;
+import com.sun.tools.javac.tree.JCTree.JCStatement;
 
 /** The parser maps a token sequence into an abstract syntax
  *  tree. It operates by recursive descent, with code derived
@@ -1418,6 +1419,7 @@
                 } else {
                     JCExpression value = parseExpression();
                     stats = List.of(to(F.at(value).Break(value)));
+                    body = value;
                     kind = CaseKind.ARROW;
                     accept(SEMI);
                 }
@@ -2817,7 +2819,11 @@
             if (token.kind == ARROW) {
                 accept(ARROW);
                 caseKind = CaseKind.ARROW;
-                stats = List.of(parseStatementAsBlock());
+                JCStatement statement = parseStatementAsBlock();
+                if (!statement.hasTag(EXEC) && !statement.hasTag(BLOCK) && !statement.hasTag(Tag.THROW)) {
+                    log.error(statement.pos(), Errors.SwitchCaseUnexpectedStatement);
+                }
+                stats = List.of(statement);
                 body = stats.head;
             } else {
                 accept(COLON);
@@ -2840,7 +2846,11 @@
             } else {
                 accept(ARROW);
                 caseKind = CaseKind.ARROW;
-                stats = List.of(parseStatementAsBlock());
+                JCStatement statement = parseStatementAsBlock();
+                if (!statement.hasTag(EXEC) && !statement.hasTag(BLOCK) && !statement.hasTag(Tag.THROW)) {
+                    log.error(statement.pos(), Errors.SwitchCaseUnexpectedStatement);
+                }
+                stats = List.of(statement);
                 body = stats.head;
             }
             c = F.at(pos).Case(caseKind, List.nil(), stats, body);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Thu Jun 28 22:13:55 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Fri Jun 29 13:42:14 2018 +0200
@@ -836,6 +836,9 @@
 compiler.misc.conditional.target.cant.be.void=\
     target-type for conditional expression cannot be void
 
+compiler.misc.switch.expression.target.cant.be.void=\
+    target-type for switch expression cannot be void
+
 # 0: message segment
 compiler.misc.incompatible.ret.type.in.lambda=\
     bad return type in lambda expression\n\
@@ -3314,12 +3317,8 @@
 compiler.err.switch.null.not.allowed=\
     null label in case is not allowed
 
-compiler.err.no.legacy.desugaring=\
-    cannot desugar this statement with -XDdisableIndySwitch set
-
-# 0: type
-compiler.err.switch.invalid.type=\
-    the switch selector must be either String, enum, a primitive type or a boxed primitive type, found: {0}
+compiler.err.switch.case.unexpected.statement=\
+    unexpected statement in case, expected is an expression, a block or a throw statement
 
 compiler.err.switch.mixing.case.types=\
     different case kinds used in the switch
@@ -3442,4 +3441,3 @@
 
 compiler.err.preview.without.source.or.release=\
     --enable-preview must be used with either -source or --release
-
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java	Thu Jun 28 22:13:55 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java	Fri Jun 29 13:42:14 2018 +0200
@@ -127,10 +127,6 @@
          */
         BLOCK,
 
-        /** Block expressions, of type BlockExpression.
-         */
-        BLOCK_EXPRESSION,
-
         /** Do-while loops, of type DoLoop.
          */
         DOLOOP,
@@ -1538,7 +1534,7 @@
      * A break from a loop or switch.
      */
     public static class JCBreak extends JCStatement implements BreakTree {
-        public JCExpression value; //TODO: should be expr?
+        public JCExpression value;
         public JCTree target;
         protected JCBreak(JCExpression value, JCTree target) {
             this.value = value;
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/Pretty.java	Thu Jun 28 22:13:55 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/Pretty.java	Fri Jun 29 13:42:14 2018 +0200
@@ -27,6 +27,7 @@
 
 import java.io.*;
 
+import com.sun.source.tree.CaseTree.CaseKind;
 import com.sun.source.tree.MemberReferenceTree.ReferenceMode;
 import com.sun.source.tree.ModuleTree.ModuleKind;
 import com.sun.tools.javac.code.*;
@@ -841,17 +842,22 @@
                 print("case ");
                 printExprs(tree.pats);
             }
-            print(": "); //XXX
-            println();
-            indent();
-            printStats(tree.stats);
-            undent();
-            align();
+            if (tree.caseKind == CaseKind.STATEMENT) {
+                print(":");
+                println();
+                indent();
+                printStats(tree.stats);
+                undent();
+                align();
+            } else {
+                print(" -> ");
+                printStat(tree.stats.head);
+            }
         } catch (IOException e) {
             throw new UncheckedIOException(e);
         }
     }
-
+ 
     public void visitSwitchExpression(JCSwitchExpression tree) {
         try {
             print("switch ");
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java	Thu Jun 28 22:13:55 2018 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java	Fri Jun 29 13:42:14 2018 +0200
@@ -205,18 +205,6 @@
     public final Name makeConcat;
     public final Name makeConcatWithConstants;
 
-    // switch
-    public final Name stringSwitch;
-    public final Name enumSwitch;
-    public final Name booleanSwitch;
-    public final Name intSwitch;
-    public final Name longSwitch;
-    public final Name floatSwitch;
-    public final Name doubleSwitch;
-    public final Name getStaticFinal;
-    public final Name TRUE;
-    public final Name FALSE;
-
     public final Name.Table table;
 
     public Names(Context context) {
@@ -380,18 +368,6 @@
         // string concat
         makeConcat = fromString("makeConcat");
         makeConcatWithConstants = fromString("makeConcatWithConstants");
-
-        //switch desugaring:
-        stringSwitch = fromString("stringSwitch");
-        enumSwitch = fromString("enumSwitch");
-        booleanSwitch = fromString("booleanSwitch");
-        intSwitch = fromString("intSwitch");
-        longSwitch = fromString("longSwitch");
-        floatSwitch = fromString("floatSwitch");
-        doubleSwitch = fromString("doubleSwitch");
-        getStaticFinal = fromString("getStaticFinal");
-        TRUE = fromString("TRUE");
-        FALSE = fromString("FALSE");
     }
 
     protected Name.Table createTable(Options options) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/diags/examples/BreakAmbiguousTarget.java	Fri Jun 29 13:42:14 2018 +0200
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+// key: compiler.warn.break.ambiguous.target
+
+class BreakAmbiguousTarget {
+    void m(int i, int j) {
+        j: print(switch (i) {
+            default: break j;
+        });
+    }
+    void print(int i) { }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/diags/examples/BreakComplexValueNoSwitchExpression.java	Fri Jun 29 13:42:14 2018 +0200
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+
+// key: compiler.err.break.complex.value.no.switch.expression
+
+class BreakComplexValueNoSwitchExpressions {
+    void t() {
+        while (true) {
+            break 1 + 1;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/diags/examples/BreakExprNotImmediate.java	Fri Jun 29 13:42:14 2018 +0200
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+// key: compiler.err.break.expr.not.immediate
+
+class BreakExprNotImmediate {
+    int t(int i) {
+        return switch (i) {
+            default:
+                while (true) {
+                    break 1 + 1;
+                }
+        };
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/diags/examples/BreakMissingValue.java	Fri Jun 29 13:42:14 2018 +0200
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+
+// key: compiler.err.break.missing.value
+
+class BreakMissingValue {
+    int t(int i) {
+        return switch (i) {
+            default: break;
+        };
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/diags/examples/BreakOutsideSwitchExpression.java	Fri Jun 29 13:42:14 2018 +0200
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+// key: compiler.err.break.outside.switch.expression
+
+class BreakOutsideSwitchExpression {
+    int t(int i) {
+        OUT: while (true) {
+            return switch (i) {
+                default: break OUT;
+            };
+        }
+        return -1;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/diags/examples/ContinueOutsideSwitchExpression.java	Fri Jun 29 13:42:14 2018 +0200
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+// key: compiler.err.continue.outside.switch.expression
+
+class ContinueOutsideSwitchExpression {
+    int t(int i) {
+        OUT: while (true) {
+            return switch (i) {
+                default: continue OUT;
+            };
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/diags/examples/MultipleCaseLabels.java	Fri Jun 29 13:42:14 2018 +0200
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+// key: compiler.misc.feature.multiple.case.labels
+// key: compiler.warn.source.no.bootclasspath
+// options: -source 11
+
+class MultipleCaseLabels {
+    void m(int i) {
+        switch (i) {
+            case 0, 1, 2: break;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/diags/examples/NotExhaustive.java	Fri Jun 29 13:42:14 2018 +0200
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+
+// key: compiler.err.not.exhaustive
+
+class NotExhaustive {
+    int t(int i) {
+        return switch (i) {
+            case 0 -> -1;
+        };
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/diags/examples/ReturnOutsideSwitchExpression.java	Fri Jun 29 13:42:14 2018 +0200
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+
+// key: compiler.err.return.outside.switch.expression
+
+class ReturnOutsideSwitchExpression {
+    int t(int i) {
+        return switch (i) {
+            default: return -1;
+        };
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/diags/examples/SwitchCaseUnexpectedStatement.java	Fri Jun 29 13:42:14 2018 +0200
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+
+// key: compiler.err.switch.case.unexpected.statement
+
+class ReturnOutsideSwitchExpression {
+    void t(int i) {
+        switch (i) {
+            case 0 -> if (true);
+        };
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/diags/examples/SwitchExpressionTargetCantBeVoid.java	Fri Jun 29 13:42:14 2018 +0200
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+
+// key: compiler.err.prob.found.req
+// key: compiler.misc.incompatible.ret.type.in.lambda
+// key: compiler.misc.switch.expression.target.cant.be.void
+
+class SwitchExpressionTargetCantBeVoid {
+
+    interface SAM {
+        void m();
+    }
+
+    void test(int cond, Object o1, Object o2, Object o3) {
+        SAM s = ()-> switch (cond) { case 0 -> o1; case 1 -> o2; default -> o3; };
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/diags/examples/SwitchExpressions.java	Fri Jun 29 13:42:14 2018 +0200
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+// key: compiler.misc.feature.switch.expressions
+// key: compiler.warn.source.no.bootclasspath
+// options: -source 11
+
+class SwitchExpressions {
+    int m(int i) {
+        return switch (i) {
+            default -> -1;
+        };
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/diags/examples/SwitchMixingCaseTypes.java	Fri Jun 29 13:42:14 2018 +0200
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+// key: compiler.err.switch.mixing.case.types
+
+class SwitchMixingCaseTypes {
+
+    void test(int i) {
+        switch (i) {
+            case 0: break;
+            case 1 -> System.out.println();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/diags/examples/SwitchNullNotAllowed.java	Fri Jun 29 13:42:14 2018 +0200
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+// key: compiler.err.switch.null.not.allowed
+
+class SwitchNullNotAllowed {
+
+    void test(Integer i) {
+        switch (i) {
+            case null: break;
+            case 0: break;
+        }
+    }
+}
--- a/test/langtools/tools/javac/expswitch/ExpSwitchNestingTest.java	Thu Jun 28 22:13:55 2018 +0200
+++ b/test/langtools/tools/javac/expswitch/ExpSwitchNestingTest.java	Fri Jun 29 13:42:14 2018 +0200
@@ -1,3 +1,26 @@
+/*
+ * 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.
+ */
+
 import java.io.IOException;
 import java.util.List;
 
--- a/test/langtools/tools/javac/failover/CheckAttributedTree.java	Thu Jun 28 22:13:55 2018 +0200
+++ b/test/langtools/tools/javac/failover/CheckAttributedTree.java	Fri Jun 29 13:42:14 2018 +0200
@@ -95,6 +95,7 @@
 import com.sun.tools.javac.code.Type;
 import com.sun.tools.javac.tree.EndPosTable;
 import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.tree.JCTree.JCBreak;
 import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
 import com.sun.tools.javac.tree.JCTree.JCImport;
 import com.sun.tools.javac.tree.TreeInfo;
@@ -445,6 +446,12 @@
             public void visitTopLevel(JCCompilationUnit tree) {
                 scan(tree.defs);
             }
+            
+            @Override
+            public void visitBreak(JCBreak tree) {
+                if (tree.isValueBreak())
+                    super.visitBreak(tree);
+            }
 
             JavaFileObject sourcefile;
             EndPosTable endPosTable;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/lambda/BadSwitchExpressionLambda.java	Fri Jun 29 13:42:14 2018 +0200
@@ -0,0 +1,19 @@
+/*
+ * @test /nodynamiccopyright/
+ * @summary Adding switch expressions
+ * @compile/fail/ref=BadSwitchExpressionLambda.out -XDrawDiagnostics BadSwitchExpressionLambda.java
+ */
+
+class BadSwitchExpressionLambda {
+
+    interface SAM {
+        void invoke();
+    }
+
+    public static void m() {}
+
+    void test(int i) {
+        SAM sam1 = () -> m(); //ok
+        SAM sam2 = () -> switch (i) { case 0 -> m(); default -> m(); }; //not ok
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/lambda/BadSwitchExpressionLambda.out	Fri Jun 29 13:42:14 2018 +0200
@@ -0,0 +1,2 @@
+BadSwitchExpressionLambda.java:17:26: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.switch.expression.target.cant.be.void))
+1 error
--- a/test/langtools/tools/javac/modules/JavaBaseTest.java	Thu Jun 28 22:13:55 2018 +0200
+++ b/test/langtools/tools/javac/modules/JavaBaseTest.java	Fri Jun 29 13:42:14 2018 +0200
@@ -39,7 +39,6 @@
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
-import java.util.Arrays;
 import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
 import java.util.List;
@@ -58,7 +57,6 @@
 
 import toolbox.JavacTask;
 import toolbox.Task;
-import toolbox.Task.Expect;
 import toolbox.ToolBox;
 
 public class JavaBaseTest {
@@ -74,12 +72,6 @@
         List.of("static", "transitive")
     );
 
-    final List<String> targets = List.of("9", "10", "current");
-    
-    {
-        JDKPlatformProvider.
-    }
-
     enum Mode { SOURCE, CLASS };
 
     ToolBox tb = new ToolBox();
--- a/test/langtools/tools/javac/parser/JavacParserTest.java	Thu Jun 28 22:13:55 2018 +0200
+++ b/test/langtools/tools/javac/parser/JavacParserTest.java	Fri Jun 29 13:42:14 2018 +0200
@@ -58,6 +58,7 @@
 import com.sun.tools.javac.main.Main;
 import com.sun.tools.javac.main.Main.Result;
 import com.sun.tools.javac.tree.JCTree;
+
 import java.io.IOException;
 import java.io.StringWriter;
 import java.lang.annotation.ElementType;
@@ -71,6 +72,7 @@
 import java.util.LinkedList;
 import java.util.List;
 import java.util.regex.Pattern;
+
 import javax.lang.model.type.TypeKind;
 import javax.tools.Diagnostic;
 import javax.tools.DiagnosticCollector;
@@ -81,6 +83,9 @@
 import javax.tools.SimpleJavaFileObject;
 import javax.tools.ToolProvider;
 
+import com.sun.source.tree.CaseTree;
+import com.sun.source.util.TreePathScanner;
+
 public class JavacParserTest extends TestCase {
     static final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
     static final JavaFileManager fm = tool.getStandardFileManager(null, null, null);
@@ -1037,6 +1042,134 @@
         assertEquals("the error message is not correct, actual: " + actualErrors, expectedErrors, actualErrors);
     }
 
+    @Test
+    void testCaseBodyStatements() throws IOException {
+        String code = "class C {" +
+                      "    void t(int i) {" +
+                      "        switch (i) {" +
+                      "            case 0 -> i++;" +
+                      "            case 1 -> { i++; }" +
+                      "            case 2 -> throw new RuntimeException();" +
+                      "            case 3 -> if (true) ;" +
+                      "            default -> i++;" +
+                      "        }" +
+                      "        switch (i) {" +
+                      "            case 0: i++; break;" +
+                      "            case 1: { i++; break;}" +
+                      "            case 2: throw new RuntimeException();" +
+                      "            case 3: if (true) ; break;" +
+                      "            default: i++; break;" +
+                      "        }" +
+                      "        int j = switch (i) {" +
+                      "            case 0 -> i + 1;" +
+                      "            case 1 -> { break i + 1; }" +
+                      "            default -> throw new RuntimeException();" +
+                      "        };" +
+                      "        int k = switch (i) {" +
+                      "            case 0: break i + 1;" +
+                      "            case 1: { break i + 1; }" +
+                      "            default: throw new RuntimeException();" +
+                      "        };" +
+                      "    }" +
+                      "}";
+        String expectedErrors = "Test.java:1:178: compiler.err.switch.case.unexpected.statement\n";
+        StringWriter out = new StringWriter();
+        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(out, fm, null,
+                Arrays.asList("-XDrawDiagnostics"), null, Arrays.asList(new MyFileObject(code)));
+
+        CompilationUnitTree cut = ct.parse().iterator().next();
+        Trees trees = Trees.instance(ct);
+        List<String> spans = new ArrayList<>();
+
+        new TreePathScanner<Void, Void>() {
+            @Override
+            public Void visitCase(CaseTree tree, Void v) {
+                if (tree.getBody() != null) {
+                    int start = (int) trees.getSourcePositions().getStartPosition(cut, tree.getBody());
+                    int end = (int) trees.getSourcePositions().getEndPosition(cut, tree.getBody());
+                    spans.add(code.substring(start, end));
+                } else {
+                    spans.add("<null>");
+                }
+                return super.visitCase(tree, v);
+            }
+        }.scan(cut, null);
+
+        List<String> expectedSpans = List.of(
+                "i++;", "{ i++; }", "throw new RuntimeException();", "if (true) ;", "i++;",
+                "<null>", "<null>", "<null>", "<null>", "<null>",
+                "i + 1"/*TODO semicolon?*/, "{ break i + 1; }", "throw new RuntimeException();",
+                "<null>", "<null>", "<null>");
+        assertEquals("the error spans are not correct; actual:" + spans, expectedSpans, spans);
+        String toString = cut.toString();
+        String expectedToString =
+                "\n" +
+                "class C {\n" +
+                "    \n" +
+                "    void t(int i) {\n" +
+                "        switch (i) {\n" +
+                "        case 0 -> i++;\n" +
+                "        case 1 -> {\n" +
+                "            i++;\n" +
+                "        }\n" +
+                "        case 2 -> throw new RuntimeException();\n" +
+                "        case 3 -> if (true) ;\n" +
+                "        default -> i++;\n" +
+                "        }\n" +
+                "        switch (i) {\n" +
+                "        case 0:\n" +
+                "            i++;\n" +
+                "            break;\n" +
+                "        \n" +
+                "        case 1:\n" +
+                "            {\n" +
+                "                i++;\n" +
+                "                break;\n" +
+                "            }\n" +
+                "        \n" +
+                "        case 2:\n" +
+                "            throw new RuntimeException();\n" +
+                "        \n" +
+                "        case 3:\n" +
+                "            if (true) ;\n" +
+                "            break;\n" +
+                "        \n" +
+                "        default:\n" +
+                "            i++;\n" +
+                "            break;\n" +
+                "        \n" +
+                "        }\n" +
+                "        int j = switch (i) {\n" +
+                "        case 0 -> break i + 1;\n" +
+                "        case 1 -> {\n" +
+                "            break i + 1;\n" +
+                "        }\n" +
+                "        default -> throw new RuntimeException();\n" +
+                "        };\n" +
+                "        int k = switch (i) {\n" +
+                "        case 0:\n" +
+                "            break i + 1;\n" +
+                "        \n" +
+                "        case 1:\n" +
+                "            {\n" +
+                "                break i + 1;\n" +
+                "            }\n" +
+                "        \n" +
+                "        default:\n" +
+                "            throw new RuntimeException();\n" +
+                "        \n" +
+                "        };\n" +
+                "    }\n" +
+                "}";
+        System.err.println("toString:");
+        System.err.println(toString);
+        System.err.println("expectedToString:");
+        System.err.println(expectedToString);
+        assertEquals("the error spans are not correct; actual:" + toString, expectedToString, toString);
+        String actualErrors = normalize(out.toString());
+        assertEquals("the error message is not correct, actual: " + actualErrors, expectedErrors, actualErrors);
+    }
+
     void run(String[] args) throws Exception {
         int passed = 0, failed = 0;
         final Pattern p = (args != null && args.length > 0)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/switchexpr/BooleanNumericNonNumeric.java	Fri Jun 29 13:42:14 2018 +0200
@@ -0,0 +1,24 @@
+/**
+ * @test /nodynamiccopyright/
+ * @compile/fail/ref=BooleanNumericNonNumeric.out -XDrawDiagnostics BooleanNumericNonNumeric.java
+ */
+
+public class BooleanNumericNonNumeric {
+
+    private void test(boolean b, int i) {
+        int r1 = 1 + (b ? switch (i) { //boolean, error
+            default -> true;
+        } : false);
+        int r2 = 1 + (b ? switch (i) { //int, ok
+            default -> 0;
+        } : 1);
+        (b ? switch (i) { //int, error
+            default -> 0;
+        } : 1).toString();
+        (b ? switch (i) { //"object", ok
+            case 0 -> true;
+            default -> 0;
+        } : 1).toString();
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/switchexpr/BooleanNumericNonNumeric.out	Fri Jun 29 13:42:14 2018 +0200
@@ -0,0 +1,3 @@
+BooleanNumericNonNumeric.java:9:20: compiler.err.operator.cant.be.applied.1: +, int, boolean
+BooleanNumericNonNumeric.java:17:15: compiler.err.cant.deref: int
+2 errors
--- a/test/langtools/tools/javac/switchexpr/ExpressionSwitch-old.out	Thu Jun 28 22:13:55 2018 +0200
+++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitch-old.out	Fri Jun 29 13:42:14 2018 +0200
@@ -1,2 +1,2 @@
-ExpressionSwitch.java:46:16: compiler.err.feature.not.supported.in.source.plural: (compiler.misc.feature.switch.expressions), 9, 10
+ExpressionSwitch.java:23: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	Thu Jun 28 22:13:55 2018 +0200
+++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitch.java	Fri Jun 29 13:42:14 2018 +0200
@@ -1,28 +1,5 @@
-/*
- * Copyright (c) 2017, 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
+ * @test /nodynamiccopyright/
  * @compile/fail/ref=ExpressionSwitch-old.out -source 9 -Xlint:-options -XDrawDiagnostics ExpressionSwitch.java
  * @compile ExpressionSwitch.java
  * @run main ExpressionSwitch
--- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchBreaks2.java	Thu Jun 28 22:13:55 2018 +0200
+++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchBreaks2.java	Fri Jun 29 13:42:14 2018 +0200
@@ -1,28 +1,5 @@
-/*
- * Copyright (c) 2017, 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
+ * @test /nodynamiccopyright/
  * @compile/fail/ref=ExpressionSwitchBreaks2.out -XDrawDiagnostics ExpressionSwitchBreaks2.java
  */
 
--- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchBreaks2.out	Thu Jun 28 22:13:55 2018 +0200
+++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchBreaks2.out	Fri Jun 29 13:42:14 2018 +0200
@@ -1,14 +1,14 @@
-ExpressionSwitchBreaks2.java:38:25: compiler.err.break.missing.value
-ExpressionSwitchBreaks2.java:40:25: compiler.err.break.outside.switch.expression
-ExpressionSwitchBreaks2.java:44:37: compiler.warn.break.ambiguous.target: x
-ExpressionSwitchBreaks2.java:48:29: compiler.err.return.outside.switch.expression
-ExpressionSwitchBreaks2.java:49:29: compiler.err.continue.outside.switch.expression
-ExpressionSwitchBreaks2.java:50:29: compiler.err.continue.outside.switch.expression
-ExpressionSwitchBreaks2.java:51:29: compiler.err.undef.label: UNKNOWN
-ExpressionSwitchBreaks2.java:55:37: compiler.err.break.expr.not.immediate
-ExpressionSwitchBreaks2.java:61:17: compiler.err.break.complex.value.no.switch.expression
-ExpressionSwitchBreaks2.java:61:29: compiler.err.cant.resolve.location: kindname.variable, undef, , , (compiler.misc.location: kindname.class, ExpressionSwitchBreaks2, null)
-ExpressionSwitchBreaks2.java:65:22: compiler.warn.break.ambiguous.target: j
-ExpressionSwitchBreaks2.java:68:22: compiler.err.break.outside.switch.expression
+ExpressionSwitchBreaks2.java:15:25: compiler.err.break.missing.value
+ExpressionSwitchBreaks2.java:17:25: compiler.err.break.outside.switch.expression
+ExpressionSwitchBreaks2.java:21:37: compiler.warn.break.ambiguous.target: x
+ExpressionSwitchBreaks2.java:25:29: compiler.err.return.outside.switch.expression
+ExpressionSwitchBreaks2.java:26:29: compiler.err.continue.outside.switch.expression
+ExpressionSwitchBreaks2.java:27:29: compiler.err.continue.outside.switch.expression
+ExpressionSwitchBreaks2.java:28:29: compiler.err.undef.label: UNKNOWN
+ExpressionSwitchBreaks2.java:32:37: compiler.err.break.expr.not.immediate
+ExpressionSwitchBreaks2.java:38:17: compiler.err.break.complex.value.no.switch.expression
+ExpressionSwitchBreaks2.java:38:29: compiler.err.cant.resolve.location: kindname.variable, undef, , , (compiler.misc.location: kindname.class, ExpressionSwitchBreaks2, null)
+ExpressionSwitchBreaks2.java:42:22: compiler.warn.break.ambiguous.target: j
+ExpressionSwitchBreaks2.java:45:22: compiler.err.break.outside.switch.expression
 10 errors
 2 warnings
--- a/test/langtools/tools/javac/switchexpr/ParserRecovery.java	Thu Jun 28 22:13:55 2018 +0200
+++ b/test/langtools/tools/javac/switchexpr/ParserRecovery.java	Fri Jun 29 13:42:14 2018 +0200
@@ -1,29 +1,6 @@
-/*
- * 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=ParserRecovery.out -XDdev -XDrawDiagnostics ParserRecovery.java
+ * @test /nodynamiccopyright/
+ * @compile/fail/ref=ParserRecovery.out -XDrawDiagnostics ParserRecovery.java
  */
 
 public class ParserRecovery {
--- a/test/langtools/tools/javac/switchexpr/ParserRecovery.out	Thu Jun 28 22:13:55 2018 +0200
+++ b/test/langtools/tools/javac/switchexpr/ParserRecovery.out	Fri Jun 29 13:42:14 2018 +0200
@@ -1,3 +1,3 @@
-ParserRecovery.java:31:39: compiler.err.expected: :
-ParserRecovery.java:34:31: compiler.err.expected: :
+ParserRecovery.java:8:39: compiler.err.expected: :
+ParserRecovery.java:11:31: compiler.err.expected: :
 2 errors
--- a/test/langtools/tools/javac/switchextra/MultipleLabelsExpression-old.out	Thu Jun 28 22:13:55 2018 +0200
+++ b/test/langtools/tools/javac/switchextra/MultipleLabelsExpression-old.out	Fri Jun 29 13:42:14 2018 +0200
@@ -1,3 +1,3 @@
-MultipleLabelsExpression.java:52:16: compiler.err.feature.not.supported.in.source.plural: (compiler.misc.feature.switch.expressions), 9, 10
-MultipleLabelsExpression.java:54:19: compiler.err.feature.not.supported.in.source.plural: (compiler.misc.feature.multiple.case.labels), 9, 10
+MultipleLabelsExpression.java:29:16: compiler.err.feature.not.supported.in.source.plural: (compiler.misc.feature.switch.expressions), 9, 10
+MultipleLabelsExpression.java:31:19: compiler.err.feature.not.supported.in.source.plural: (compiler.misc.feature.multiple.case.labels), 9, 10
 2 errors
--- a/test/langtools/tools/javac/switchextra/MultipleLabelsExpression.java	Thu Jun 28 22:13:55 2018 +0200
+++ b/test/langtools/tools/javac/switchextra/MultipleLabelsExpression.java	Fri Jun 29 13:42:14 2018 +0200
@@ -1,28 +1,5 @@
-/*
- * 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
+ * @test /nodynamiccopyright/
  * @compile/fail/ref=MultipleLabelsExpression-old.out -source 9 -Xlint:-options -XDrawDiagnostics MultipleLabelsExpression.java
  * @compile MultipleLabelsExpression.java
  * @run main MultipleLabelsExpression
--- a/test/langtools/tools/javac/switchextra/MultipleLabelsStatement-old.out	Thu Jun 28 22:13:55 2018 +0200
+++ b/test/langtools/tools/javac/switchextra/MultipleLabelsStatement-old.out	Fri Jun 29 13:42:14 2018 +0200
@@ -1,2 +1,2 @@
-MultipleLabelsStatement.java:56:21: compiler.err.feature.not.supported.in.source.plural: (compiler.misc.feature.multiple.case.labels), 9, 10
+MultipleLabelsStatement.java:33:21: compiler.err.feature.not.supported.in.source.plural: (compiler.misc.feature.multiple.case.labels), 9, 10
 1 error
--- a/test/langtools/tools/javac/switchextra/MultipleLabelsStatement.java	Thu Jun 28 22:13:55 2018 +0200
+++ b/test/langtools/tools/javac/switchextra/MultipleLabelsStatement.java	Fri Jun 29 13:42:14 2018 +0200
@@ -1,28 +1,5 @@
-/*
- * 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
+ * @test /nodynamiccopyright/
  * @compile/fail/ref=MultipleLabelsStatement-old.out -source 9 -Xlint:-options -XDrawDiagnostics MultipleLabelsStatement.java
  * @compile MultipleLabelsStatement.java
  * @run main MultipleLabelsStatement
--- a/test/langtools/tools/javac/switchextra/SwitchNoExtraTypes.java	Thu Jun 28 22:13:55 2018 +0200
+++ b/test/langtools/tools/javac/switchextra/SwitchNoExtraTypes.java	Fri Jun 29 13:42:14 2018 +0200
@@ -1,5 +1,5 @@
 /**
- * @test
+ * @test /nodynamiccopyright/
  * @compile/fail/ref=SwitchNoExtraTypes.out -XDrawDiagnostics SwitchNoExtraTypes.java
  */
 
--- a/test/langtools/tools/javac/switchextra/SwitchStatementArrow.java	Thu Jun 28 22:13:55 2018 +0200
+++ b/test/langtools/tools/javac/switchextra/SwitchStatementArrow.java	Fri Jun 29 13:42:14 2018 +0200
@@ -26,7 +26,6 @@
  * @compile SwitchStatementArrow.java
  * @run main SwitchStatementArrow
  */
-// * @compile/fail/ref=MultipleLabelsStatement-old.out -source 9 -Xlint:-options -XDrawDiagnostics MultipleLabelsStatement.java
 
 import java.util.Objects;
 import java.util.function.Function;
--- a/test/langtools/tools/javac/switchextra/SwitchStatementBroken.java	Thu Jun 28 22:13:55 2018 +0200
+++ b/test/langtools/tools/javac/switchextra/SwitchStatementBroken.java	Fri Jun 29 13:42:14 2018 +0200
@@ -1,31 +1,7 @@
-/*
- * 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
+ * @test /nodynamiccopyright/
  * @compile/fail/ref=SwitchStatementBroken.out -XDrawDiagnostics SwitchStatementBroken.java
  */
-// * @compile/fail/ref=MultipleLabelsStatement-old.out -source 9 -Xlint:-options -XDrawDiagnostics MultipleLabelsStatement.java
 
 public class SwitchStatementBroken {
 
--- a/test/langtools/tools/javac/switchextra/SwitchStatementBroken.out	Thu Jun 28 22:13:55 2018 +0200
+++ b/test/langtools/tools/javac/switchextra/SwitchStatementBroken.out	Fri Jun 29 13:42:14 2018 +0200
@@ -1,2 +1,2 @@
-SwitchStatementBroken.java:37:13: compiler.err.switch.mixing.case.types
+SwitchStatementBroken.java:13:13: compiler.err.switch.mixing.case.types
 1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/switchextra/SwitchStatementBroken2.java	Fri Jun 29 13:42:14 2018 +0200
@@ -0,0 +1,24 @@
+/** /nodynamiccopyright/
+ * @test
+ * @compile/fail/ref=SwitchStatementBroken2.out -XDrawDiagnostics SwitchStatementBroken2.java
+ */
+
+public class SwitchStatementBroken2 {
+
+    private void statementArrowNotArbitraryStatements(int i, int j) {
+        String res;
+
+        switch (i) {
+            case 0 -> res = "NULL-A";
+            case 1 -> { res = "NULL-A"; }
+            case 2 -> throw new IllegalStateException();
+            case 3 -> if  (j < 0) res = "A"; else res = "B";
+            case 4 -> while (j-- > 0) res += "I";
+            case 5 -> switch (j) {
+                case 0: res = "0"; break;
+            }
+            default -> if  (j < 0) res = "A"; else res = "B";
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/switchextra/SwitchStatementBroken2.out	Fri Jun 29 13:42:14 2018 +0200
@@ -0,0 +1,5 @@
+SwitchStatementBroken2.java:15:23: compiler.err.switch.case.unexpected.statement
+SwitchStatementBroken2.java:16:23: compiler.err.switch.case.unexpected.statement
+SwitchStatementBroken2.java:17:23: compiler.err.switch.case.unexpected.statement
+SwitchStatementBroken2.java:20:24: compiler.err.switch.case.unexpected.statement
+4 errors
--- a/test/langtools/tools/javac/switchnull/SwitchNullDisabled.java	Thu Jun 28 22:13:55 2018 +0200
+++ b/test/langtools/tools/javac/switchnull/SwitchNullDisabled.java	Fri Jun 29 13:42:14 2018 +0200
@@ -1,5 +1,5 @@
 /**
- * @test
+ * @test /nodynamiccopyright/
  * @compile/fail/ref=SwitchNullDisabled.out -XDrawDiagnostics SwitchNullDisabled.java
  */