--- old/src/jdk.compiler/share/classes/com/sun/source/tree/BreakTree.java 2018-08-01 08:08:58.103826316 +0200
+++ new/src/jdk.compiler/share/classes/com/sun/source/tree/BreakTree.java 2018-08-01 08:08:57.811826329 +0200
@@ -54,14 +54,14 @@
/**
* Returns the expression for this {@code break} statement.
- *
- * @apiNote
- * This method is modeling value breaks, which are part of
- * a preview feature and may be removed if the preview feature
- * is removed.
- *
+ *
* @return the expression
* @since 12
+ *
+ * @deprecated This method is modeling value breaks, which are part of
+ * a preview feature and may be removed if the preview feature
+ * is removed.
+ *
*/
@Deprecated(forRemoval=true, since="12")
ExpressionTree getValue();
--- old/src/jdk.compiler/share/classes/com/sun/source/tree/CaseTree.java 2018-08-01 08:08:58.767826285 +0200
+++ new/src/jdk.compiler/share/classes/com/sun/source/tree/CaseTree.java 2018-08-01 08:08:58.471826299 +0200
@@ -57,14 +57,13 @@
/**
* Returns the labels for this case.
* For default case, returns an empty list.
- *
- * @apiNote
- * This method is modeling a case with multiple labels,
- * which is part of a preview feature and may be removed
- * if the preview feature is removed.
- *
+ *
* @return labels for this case
* @since 12
+ *
+ * @deprecated This method is modeling a case with multiple labels,
+ * which is part of a preview feature and may be removed
+ * if the preview feature is removed.
*/
@Deprecated(forRemoval=true, since="12")
List extends ExpressionTree> getExpressions();
@@ -81,17 +80,16 @@
/**
* For case with kind {@linkplain CaseKind#RULE},
- * return the statement or expression after the arrow.
+ * returns the statement or expression after the arrow.
* Returns {@code null} for case with kind
* {@linkplain CaseKind#STATEMENT}.
- *
- * @apiNote
- * This method is modeling a rule case,
- * which is part of a preview feature and may be removed
- * if the preview feature is removed.
- *
+ *
* @return case value or null
* @since 12
+ *
+ * @deprecated This method is modeling a rule case,
+ * which is part of a preview feature and may be removed
+ * if the preview feature is removed.
*/
@Deprecated(forRemoval=true, since="12")
public default Tree getBody() {
@@ -100,14 +98,13 @@
/**
* Returns the kind of this case.
- *
- * @apiNote
- * This method is used to model a rule case,
- * which is part of a preview feature and may be removed
- * if the preview feature is removed.
- *
+ *
* @return the kind of this case
* @since 12
+ *
+ * @deprecated This method is used to model a rule case,
+ * which is part of a preview feature and may be removed
+ * if the preview feature is removed.
*/
@Deprecated(forRemoval=true, since="12")
public default CaseKind getCaseKind() {
@@ -121,12 +118,11 @@
*
RULE: {@code case -> /}
*
*
- * @apiNote
- * This enum is used to model a rule case,
+ * @since 12
+ *
+ * @deprecated This enum is used to model a rule case,
* which is part of a preview feature and may be removed
* if the preview feature is removed.
- *
- * @since 12
*/
@Deprecated(forRemoval=true, since="12")
public enum CaseKind {
--- old/src/jdk.compiler/share/classes/com/sun/source/tree/SwitchExpressionTree.java 2018-08-01 08:08:59.431826254 +0200
+++ new/src/jdk.compiler/share/classes/com/sun/source/tree/SwitchExpressionTree.java 2018-08-01 08:08:59.135826268 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -39,14 +39,11 @@
*
* @jls section 15.29
*
- * @apiNote
- * This method is modeling switch expressions,
+ * @since 12
+ *
+ * @deprecated This method is modeling switch expressions,
* which are part of a preview feature and may be removed
* if the preview feature is removed.
- *
- * @author Peter von der Ahé
- * @author Jonathan Gibbons
- * @since 12
*/
@Deprecated(forRemoval=true, since="12")
public interface SwitchExpressionTree extends ExpressionTree {
--- old/src/jdk.compiler/share/classes/com/sun/source/tree/Tree.java 2018-08-01 08:09:00.107826222 +0200
+++ new/src/jdk.compiler/share/classes/com/sun/source/tree/Tree.java 2018-08-01 08:08:59.811826236 +0200
@@ -241,13 +241,13 @@
/**
* Used for instances of {@link SwitchExpressionTree}.
- *
- * @apiNote
+ *
+ * @since 12
+ *
+ * @deprecated
* This enum constant is modeling switch expressions,
* which are part of a preview feature and may be removed
* if the preview feature is removed.
- *
- * @since 12
*/
@Deprecated(forRemoval=true, since="12")
@SuppressWarnings("removal")
--- old/src/jdk.compiler/share/classes/com/sun/source/tree/TreeVisitor.java 2018-08-01 08:09:00.779826191 +0200
+++ new/src/jdk.compiler/share/classes/com/sun/source/tree/TreeVisitor.java 2018-08-01 08:09:00.483826205 +0200
@@ -355,16 +355,16 @@
/**
* Visits a SwitchExpressionTree node.
- *
- * @apiNote
- * This method is modeling switch expressions,
- * which are part of a preview feature and may be removed
- * if the preview feature is removed.
- *
+ *
* @param node the node being visited
* @param p a parameter value
* @return a result value
* @since 12
+ *
+ * @deprecated
+ * This method is modeling switch expressions,
+ * which are part of a preview feature and may be removed
+ * if the preview feature is removed.
*/
@Deprecated(forRemoval=true, since="12")
@SuppressWarnings("removal")
--- old/src/jdk.compiler/share/classes/com/sun/source/util/SimpleTreeVisitor.java 2018-08-01 08:09:01.443826160 +0200
+++ new/src/jdk.compiler/share/classes/com/sun/source/util/SimpleTreeVisitor.java 2018-08-01 08:09:01.147826174 +0200
@@ -269,6 +269,11 @@
* @param node {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
+ *
+ * @deprecated
+ * This method is modeling switch expressions,
+ * which are part of a preview feature and may be removed
+ * if the preview feature is removed.
*/
@Override
@Deprecated(forRemoval=true, since="12")
--- old/src/jdk.compiler/share/classes/com/sun/source/util/TreeScanner.java 2018-08-01 08:09:02.111826129 +0200
+++ new/src/jdk.compiler/share/classes/com/sun/source/util/TreeScanner.java 2018-08-01 08:09:01.819826143 +0200
@@ -340,6 +340,11 @@
* @param node {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of scanning
+ *
+ * @deprecated
+ * This method is modeling switch expressions,
+ * which are part of a preview feature and may be removed
+ * if the preview feature is removed.
*/
@Override
@Deprecated(forRemoval=true, since="12")
--- old/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ArgumentAttr.java 2018-08-01 08:09:02.787826097 +0200
+++ new/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ArgumentAttr.java 2018-08-01 08:09:02.495826111 +0200
@@ -480,9 +480,7 @@
@Override
Type overloadCheck(ResultInfo resultInfo, DeferredAttrContext deferredAttrContext) {
ResultInfo localInfo = resultInfo.dup(attr.conditionalContext(resultInfo.checkContext));
- if (speculativeTree.isStandalone()) {
- return localInfo.check(speculativeTree, speculativeTree.type);
- } else if (resultInfo.pt.hasTag(VOID)) {
+ if (resultInfo.pt.hasTag(VOID)) {
//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);
--- old/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java 2018-08-01 08:09:03.455826066 +0200
+++ new/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java 2018-08-01 08:09:03.163826080 +0200
@@ -27,6 +27,7 @@
import java.util.*;
import java.util.function.BiConsumer;
+import java.util.stream.Collectors;
import javax.lang.model.element.ElementKind;
import javax.tools.JavaFileObject;
@@ -707,12 +708,6 @@
return attribTree(tree, env, new ResultInfo(KindSelector.VAL, !pt.hasTag(ERROR) ? pt : Type.noType));
}
- /** Derived visitor method: attribute an expression tree.
- */
- public Type attribExpr(JCTree tree, Env env, ResultInfo resultInfo) {
- return attribTree(tree, env, resultInfo);
- }
-
/** Derived visitor method: attribute an expression tree with
* no constraints on the computed type.
*/
@@ -1424,6 +1419,7 @@
unknownExprInfo :
resultInfo.dup(switchExpressionContext(resultInfo.checkContext));
+ ListBuffer caseTypePositions = new ListBuffer<>();
ListBuffer caseTypes = new ListBuffer<>();
handleSwitch(tree, tree.selector, tree.cases, (c, caseEnv) -> {
@@ -1432,18 +1428,24 @@
new TreeScanner() {
@Override
public void visitBreak(JCBreak brk) {
- if (brk.target == tree)
+ if (brk.target == tree) {
+ caseTypePositions.append(brk.value != null ? brk.value.pos() : brk.pos());
caseTypes.append(brk.value != null ? brk.value.type : syms.errType);
+ }
super.visitBreak(brk);
}
@Override public void visitClassDef(JCClassDecl tree) {}
@Override public void visitLambda(JCLambda tree) {}
- @Override public void visitMethodDef(JCMethodDecl tree) {}
}.scan(c.stats);
});
- Type owntype = (tree.polyKind == PolyKind.STANDALONE) ? condType(tree, caseTypes.toList()) : pt();
+ if (tree.cases.isEmpty()) {
+ log.error(tree.pos(),
+ Errors.SwitchExpressionEmpty);
+ }
+
+ Type owntype = (tree.polyKind == PolyKind.STANDALONE) ? condType(caseTypePositions.toList(), caseTypes.toList()) : pt();
result = tree.type = check(tree, owntype, KindSelector.VAL, resultInfo);
}
@@ -1689,7 +1691,9 @@
Type truetype = attribTree(tree.truepart, env, condInfo);
Type falsetype = attribTree(tree.falsepart, env, condInfo);
- Type owntype = (tree.polyKind == PolyKind.STANDALONE) ? condType(tree, List.of(truetype, falsetype)) : pt();
+ Type owntype = (tree.polyKind == PolyKind.STANDALONE) ?
+ condType(List.of(tree.truepart.pos(), tree.falsepart.pos()),
+ List.of(truetype, falsetype)) : pt();
if (condtype.constValue() != null &&
truetype.constValue() != null &&
falsetype.constValue() != null &&
@@ -1770,8 +1774,7 @@
* @param thentype The type of the expression's then-part.
* @param elsetype The type of the expression's else-part.
*/
- Type condType(DiagnosticPosition pos,
- List condTypes) {
+ Type condType(List positions, List condTypes) {
if (condTypes.isEmpty()) {
return syms.objectType; //TODO: how to handle?
}
@@ -1821,13 +1824,11 @@
return type.baseType();
}
- if (condTypes.stream().anyMatch(t -> t.hasTag(VOID))) {
- //XXX:
- log.error(pos,
- Errors.NeitherConditionalSubtype(condTypes.head,
- condTypes.tail.head));
- return condTypes.head.baseType();
- }
+ Iterator posIt = positions.iterator();
+
+ condTypes = condTypes.stream()
+ .map(t -> chk.checkNonVoid(posIt.next(), t))
+ .collect(List.collector());
// both are known to be reference types. The result is
// lub(thentype,elsetype). This cannot fail, as it will
--- old/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java 2018-08-01 08:09:04.175826033 +0200
+++ new/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java 2018-08-01 08:09:03.883826046 +0200
@@ -31,7 +31,6 @@
import java.util.HashSet;
import java.util.Set;
-import com.sun.source.tree.CaseTree.CaseKind;
import com.sun.source.tree.LambdaExpressionTree.BodyKind;
import com.sun.tools.javac.code.*;
import com.sun.tools.javac.code.Scope.WriteableScope;
--- old/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java 2018-08-01 08:09:04.863826001 +0200
+++ new/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java 2018-08-01 08:09:04.563826015 +0200
@@ -72,7 +72,6 @@
import javax.lang.model.element.ElementKind;
import javax.lang.model.type.TypeKind;
-import com.sun.source.tree.CaseTree.CaseKind;
import com.sun.tools.javac.code.Type.IntersectionClassType;
import com.sun.tools.javac.code.Types.FunctionDescriptorLookupError;
import com.sun.tools.javac.main.Option;
--- old/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java 2018-08-01 08:09:05.567825968 +0200
+++ new/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java 2018-08-01 08:09:05.263825982 +0200
@@ -271,6 +271,13 @@
}
super.visitApply(tree);
}
+
+ @Override
+ public void visitBreak(JCBreak tree) {
+ if (tree.isValueBreak())
+ scan(tree.value);
+ }
+
}
/**
@@ -373,12 +380,6 @@
super.visitApply(tree);
}
- @Override
- public void visitBreak(JCBreak tree) {
- if (tree.isValueBreak())
- scan(tree.value);
- }
-
}
ClassSymbol ownerToCopyFreeVarsFrom(ClassSymbol c) {
@@ -3378,7 +3379,7 @@
break;
}
}
-
+
for (JCCase c : cases) {
if (c.caseKind == JCCase.RULE && c.completesNormally) {
JCBreak b = make_at(c.pos()).Break(null);
--- old/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java 2018-08-01 08:09:06.307825933 +0200
+++ new/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java 2018-08-01 08:09:06.011825947 +0200
@@ -31,7 +31,6 @@
import com.sun.source.tree.CaseTree.CaseKind;
import com.sun.source.tree.MemberReferenceTree.ReferenceMode;
import com.sun.source.tree.ModuleTree.ModuleKind;
-import com.sun.source.tree.Tree;
import com.sun.tools.javac.code.*;
import com.sun.tools.javac.code.Source.Feature;
@@ -60,7 +59,6 @@
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
--- old/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties 2018-08-01 08:09:07.003825901 +0200
+++ new/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties 2018-08-01 08:09:06.707825915 +0200
@@ -201,7 +201,7 @@
# 0: name
compiler.err.break.ambiguous.target=\
- {0} is both a valid expression and a valid label
+ {0} is ambiguously both a valid expression and a valid label
compiler.err.break.expr.not.immediate=\
expression break not immediately enclosed by a switch expression
@@ -209,6 +209,9 @@
compiler.err.break.complex.value.no.switch.expression=\
value break outside of switch expression
+compiler.err.switch.expression.empty=\
+ switch expression does not have any case clauses
+
# 0: name
compiler.err.call.must.be.first.stmt.in.ctor=\
call to {0} must be first statement in constructor
@@ -821,12 +824,6 @@
compiler.err.native.meth.cant.have.body=\
native methods cannot have a body
-# 0: type, 1: type
-compiler.err.neither.conditional.subtype=\
- incompatible types for ?: neither is a subtype of the other\n\
- second operand: {0}\n\
- third operand : {1}
-
# 0: message segment
compiler.misc.incompatible.type.in.conditional=\
--- old/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java 2018-08-01 08:09:07.703825868 +0200
+++ new/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java 2018-08-01 08:09:07.403825882 +0200
@@ -1270,17 +1270,17 @@
@Override @DefinedBy(Api.COMPILER_TREE)
public Kind getKind() { return Kind.CASE; }
- @Override @Deprecated @DefinedBy(Api.COMPILER_TREE)
+ @Override @DefinedBy(Api.COMPILER_TREE)
public JCExpression getExpression() { return pats.head; }
@Override @DefinedBy(Api.COMPILER_TREE)
@SuppressWarnings("removal")
public List getExpressions() { return pats; }
- @DefinedBy(Api.COMPILER_TREE)
+ @Override @DefinedBy(Api.COMPILER_TREE)
public List getStatements() { return stats; }
- @DefinedBy(Api.COMPILER_TREE)
+ @Override @DefinedBy(Api.COMPILER_TREE)
@SuppressWarnings("removal")
public JCTree getBody() { return body; }
- @Override
+ @Override @DefinedBy(Api.COMPILER_TREE)
@SuppressWarnings("removal")
public CaseKind getCaseKind() {
return caseKind;
--- old/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/Pretty.java 2018-08-01 08:09:08.403825836 +0200
+++ new/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/Pretty.java 2018-08-01 08:09:08.103825850 +0200
@@ -857,7 +857,7 @@
throw new UncheckedIOException(e);
}
}
-
+
public void visitSwitchExpression(JCSwitchExpression tree) {
try {
print("switch ");
--- old/test/langtools/tools/javac/ConditionalWithVoid.java 2018-08-01 08:09:09.083825804 +0200
+++ new/test/langtools/tools/javac/ConditionalWithVoid.java 2018-08-01 08:09:08.791825818 +0200
@@ -4,13 +4,17 @@
* @summary The compiler was allowing void types in its parsing of conditional expressions.
* @author tball
*
- * @compile/fail/ref=ConditionalWithVoid.out -XDrawDiagnostics ConditionalWithVoid.java
+ * @compile/fail/ref=ConditionalWithVoid.out --enable-preview -source 12 -XDrawDiagnostics ConditionalWithVoid.java
*/
public class ConditionalWithVoid {
- public void test(Object o) {
+ public void test(Object o, String s) {
// Should fail to compile since Object.wait() has a void return type. Poly case.
System.out.println(o instanceof String ? o.hashCode() : o.wait());
// Should fail to compile since Object.wait() has a void return type. Standalone case.
(o instanceof String ? o.hashCode() : o.wait()).toString();
+ // Should fail to compile since Object.wait() has a void return type. Poly case.
+ System.out.println(switch (s) {case "" -> o.hashCode(); default -> o.wait();});
+ // Should fail to compile since Object.wait() has a void return type. Standalone case.
+ (switch (s) {case "" -> o.hashCode(); default -> o.wait();}).toString();
}
}
--- old/test/langtools/tools/javac/ConditionalWithVoid.out 2018-08-01 08:09:09.751825773 +0200
+++ new/test/langtools/tools/javac/ConditionalWithVoid.out 2018-08-01 08:09:09.451825787 +0200
@@ -1,3 +1,7 @@
ConditionalWithVoid.java:12:71: compiler.err.void.not.allowed.here
-ConditionalWithVoid.java:14:30: compiler.err.neither.conditional.subtype: java.lang.Integer, void
-2 errors
+ConditionalWithVoid.java:14:53: compiler.err.void.not.allowed.here
+ConditionalWithVoid.java:16:82: compiler.err.void.not.allowed.here
+ConditionalWithVoid.java:18:64: compiler.err.void.not.allowed.here
+- compiler.note.preview.filename: ConditionalWithVoid.java
+- compiler.note.preview.recompile
+4 errors
--- old/test/langtools/tools/javac/expswitch/ExpSwitchNestingTest.java 2018-08-01 08:09:10.415825742 +0200
+++ new/test/langtools/tools/javac/expswitch/ExpSwitchNestingTest.java 2018-08-01 08:09:10.127825755 +0200
@@ -38,6 +38,7 @@
private static final String LABEL = "label: #";
private static final String DEF_LABEL_VAR = "int label = 0; { # }";
private static final String FOR = "for (int i=0; i<10; i++) { # }";
+ private static final String FOR_EACH = "for (int i : new int[] {}) { # }";
private static final String WHILE = "while (cond) { # }";
private static final String DO = "do { # } while (cond);";
private static final String SSWITCH = "switch (x) { case 0: # };";
@@ -178,7 +179,7 @@
assertFail("compiler.err.undef.label", ESWITCH_S, CONTINUE_L);
assertFail("compiler.err.cont.outside.loop", ESWITCH_S, CONTINUE_N);
assertFail("compiler.err.return.outside.switch.expression", ESWITCH_S, RETURN_N);
- assertFail("compiler.err.return.outside.switch.expression", ESWITCH_S, RETURN_S);
+ assertFail("compiler.err.return.outside.switch.expression", ESWITCH_S, RETURN_S);
// Function-valued switch expression
assertOK(INT_FN_ESWITCH, BREAK_INT_FN);
assertFail("compiler.err.break.missing.value", INT_FN_ESWITCH, BREAK_N);
@@ -190,7 +191,7 @@
assertFail("compiler.err.undef.label", INT_FN_ESWITCH, CONTINUE_L);
assertFail("compiler.err.cont.outside.loop", INT_FN_ESWITCH, CONTINUE_N);
assertFail("compiler.err.return.outside.switch.expression", INT_FN_ESWITCH, RETURN_N);
- assertFail("compiler.err.return.outside.switch.expression", INT_FN_ESWITCH, RETURN_S);
+ assertFail("compiler.err.return.outside.switch.expression", INT_FN_ESWITCH, RETURN_S);
}
@@ -238,4 +239,12 @@
public void testFunReturningSwitchExp() {
assertOK(INT_FN_ESWITCH, BREAK_INT_FN);
}
+
+ public void testContinueLoops() {
+ assertOK(LABEL, FOR, CONTINUE_L);
+ assertOK(LABEL, FOR_EACH, CONTINUE_L);
+ assertOK(LABEL, WHILE, CONTINUE_L);
+ assertOK(LABEL, DO, CONTINUE_L);
+ assertFail("compiler.err.not.loop.label", LABEL, CONTINUE_L);
+ }
}
--- old/test/langtools/tools/javac/failover/CheckAttributedTree.java 2018-08-01 08:09:11.095825710 +0200
+++ new/test/langtools/tools/javac/failover/CheckAttributedTree.java 2018-08-01 08:09:10.799825724 +0200
@@ -446,7 +446,7 @@
public void visitTopLevel(JCCompilationUnit tree) {
scan(tree.defs);
}
-
+
@Override
public void visitBreak(JCBreak tree) {
if (tree.isValueBreak())
--- old/test/langtools/tools/javac/lambda/BadSwitchExpressionLambda.java 2018-08-01 08:09:11.767825679 +0200
+++ new/test/langtools/tools/javac/lambda/BadSwitchExpressionLambda.java 2018-08-01 08:09:11.467825693 +0200
@@ -12,9 +12,13 @@
}
public static void m() {}
+ public static void r(SAM sam) {}
void test(int i) {
SAM sam1 = () -> m(); //ok
SAM sam2 = () -> switch (i) { case 0 -> m(); default -> m(); }; //not ok
+ r(() -> m()); //ok
+ r(() -> switch (i) { case 0 -> m(); default -> m(); }); //not ok
+ return switch (i) { case 0 -> m(); default -> m(); }; //not ok
}
}
--- old/test/langtools/tools/javac/lambda/BadSwitchExpressionLambda.out 2018-08-01 08:09:12.431825648 +0200
+++ new/test/langtools/tools/javac/lambda/BadSwitchExpressionLambda.out 2018-08-01 08:09:12.135825662 +0200
@@ -1,4 +1,6 @@
-BadSwitchExpressionLambda.java:18:26: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.switch.expression.target.cant.be.void))
+BadSwitchExpressionLambda.java:19:26: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.switch.expression.target.cant.be.void))
+BadSwitchExpressionLambda.java:21:9: compiler.err.cant.apply.symbol: kindname.method, r, BadSwitchExpressionLambda.SAM, @11, kindname.class, BadSwitchExpressionLambda, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.switch.expression.target.cant.be.void)))
+BadSwitchExpressionLambda.java:22:16: compiler.err.prob.found.req: (compiler.misc.unexpected.ret.val)
- compiler.note.preview.filename: BadSwitchExpressionLambda.java
- compiler.note.preview.recompile
-1 error
+3 errors
--- old/test/langtools/tools/javac/switchexpr/BlockExpression.java 2018-08-01 08:09:13.103825617 +0200
+++ new/test/langtools/tools/javac/switchexpr/BlockExpression.java 2018-08-01 08:09:12.811825630 +0200
@@ -21,9 +21,10 @@
* questions.
*/
-/**
+/*
* @test
* @bug 8206986
+ * @summary Verify rule cases with expression statements and throw statements work.
* @compile --enable-preview -source 12 BlockExpression.java
* @run main/othervm --enable-preview BlockExpression
*/
--- old/test/langtools/tools/javac/switchexpr/BooleanNumericNonNumeric.java 2018-08-01 08:09:13.771825585 +0200
+++ new/test/langtools/tools/javac/switchexpr/BooleanNumericNonNumeric.java 2018-08-01 08:09:13.471825599 +0200
@@ -1,6 +1,7 @@
-/**
+/*
* @test /nodynamiccopyright/
* @bug 8206986
+ * @summary Verify the type of a conditional expression with nested switch expression is computed properly
* @compile/fail/ref=BooleanNumericNonNumeric.out -XDrawDiagnostics --enable-preview -source 12 BooleanNumericNonNumeric.java
*/
--- old/test/langtools/tools/javac/switchexpr/BooleanNumericNonNumeric.out 2018-08-01 08:09:14.427825555 +0200
+++ new/test/langtools/tools/javac/switchexpr/BooleanNumericNonNumeric.out 2018-08-01 08:09:14.139825568 +0200
@@ -1,5 +1,5 @@
-BooleanNumericNonNumeric.java:10:20: compiler.err.operator.cant.be.applied.1: +, int, boolean
-BooleanNumericNonNumeric.java:18:15: compiler.err.cant.deref: int
+BooleanNumericNonNumeric.java:11:20: compiler.err.operator.cant.be.applied.1: +, int, boolean
+BooleanNumericNonNumeric.java:19:15: compiler.err.cant.deref: int
- compiler.note.preview.filename: BooleanNumericNonNumeric.java
- compiler.note.preview.recompile
2 errors
--- old/test/langtools/tools/javac/switchexpr/ExhaustiveEnumSwitch.java 2018-08-01 08:09:15.087825524 +0200
+++ new/test/langtools/tools/javac/switchexpr/ExhaustiveEnumSwitch.java 2018-08-01 08:09:14.795825538 +0200
@@ -21,9 +21,10 @@
* questions.
*/
-/**
+/*
* @test
* @bug 8206986
+ * @summary Verify that an switch expression over enum can be exhaustive without default.
* @compile --enable-preview -source 12 ExhaustiveEnumSwitch.java
* @compile ExhaustiveEnumSwitchExtra.java
* @run main/othervm --enable-preview ExhaustiveEnumSwitch
--- old/test/langtools/tools/javac/switchexpr/ExpressionSwitch-old.out 2018-08-01 08:09:15.759825493 +0200
+++ new/test/langtools/tools/javac/switchexpr/ExpressionSwitch-old.out 2018-08-01 08:09:15.459825507 +0200
@@ -1,3 +1,3 @@
-ExpressionSwitch.java:24:16: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.switch.expressions)
-ExpressionSwitch.java:25:20: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.switch.rules)
+ExpressionSwitch.java:26:16: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.switch.expressions)
+ExpressionSwitch.java:27:20: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.switch.rules)
2 errors
--- old/test/langtools/tools/javac/switchexpr/ExpressionSwitch.java 2018-08-01 08:09:16.423825462 +0200
+++ new/test/langtools/tools/javac/switchexpr/ExpressionSwitch.java 2018-08-01 08:09:16.127825476 +0200
@@ -1,6 +1,7 @@
-/**
+/*
* @test /nodynamiccopyright/
* @bug 8206986
+ * @summary Check expression switch works.
* @compile/fail/ref=ExpressionSwitch-old.out -source 9 -Xlint:-options -XDrawDiagnostics ExpressionSwitch.java
* @compile --enable-preview -source 12 ExpressionSwitch.java
* @run main/othervm --enable-preview ExpressionSwitch
@@ -18,6 +19,7 @@
check(T.B, "B");
check(T.C, "other");
exhaustive1(T.C);
+ localClass(T.A);
}
private String print(T t) {
@@ -46,6 +48,24 @@
};
}
+ private void localClass(T t) {
+ String good = "good";
+ class L {
+ public String c() {
+ STOP: switch (t) {
+ default: break STOP;
+ }
+ return switch (t) {
+ default: break good;
+ };
+ }
+ }
+ String result = new L().c();
+ if (!Objects.equals(result, good)) {
+ throw new AssertionError("Unexpected result: " + result);
+ }
+ }
+
private void check(T t, String expected) {
String result = print(t);
if (!Objects.equals(result, expected)) {
--- old/test/langtools/tools/javac/switchexpr/ExpressionSwitchBreaks1.java 2018-08-01 08:09:17.083825431 +0200
+++ new/test/langtools/tools/javac/switchexpr/ExpressionSwitchBreaks1.java 2018-08-01 08:09:16.791825445 +0200
@@ -21,9 +21,10 @@
* questions.
*/
-/**
+/*
* @test
* @bug 8206986
+ * @summary Verify behavior of various kinds of breaks.
* @compile --enable-preview -source 12 ExpressionSwitchBreaks1.java
* @run main/othervm --enable-preview ExpressionSwitchBreaks1
*/
--- old/test/langtools/tools/javac/switchexpr/ExpressionSwitchBreaks2.java 2018-08-01 08:09:17.751825400 +0200
+++ new/test/langtools/tools/javac/switchexpr/ExpressionSwitchBreaks2.java 2018-08-01 08:09:17.451825414 +0200
@@ -1,6 +1,7 @@
-/**
+/*
* @test /nodynamiccopyright/
* @bug 8206986
+ * @summary Check behavior for invalid breaks.
* @compile/fail/ref=ExpressionSwitchBreaks2.out -XDrawDiagnostics --enable-preview -source 12 ExpressionSwitchBreaks2.java
*/
--- old/test/langtools/tools/javac/switchexpr/ExpressionSwitchBreaks2.out 2018-08-01 08:09:18.423825369 +0200
+++ new/test/langtools/tools/javac/switchexpr/ExpressionSwitchBreaks2.out 2018-08-01 08:09:18.123825383 +0200
@@ -1,15 +1,15 @@
-ExpressionSwitchBreaks2.java:16:25: compiler.err.break.missing.value
-ExpressionSwitchBreaks2.java:18:25: compiler.err.break.outside.switch.expression
-ExpressionSwitchBreaks2.java:22:37: compiler.err.break.ambiguous.target: x
-ExpressionSwitchBreaks2.java:26:29: compiler.err.return.outside.switch.expression
-ExpressionSwitchBreaks2.java:27:29: compiler.err.continue.outside.switch.expression
+ExpressionSwitchBreaks2.java:17:25: compiler.err.break.missing.value
+ExpressionSwitchBreaks2.java:19:25: compiler.err.break.outside.switch.expression
+ExpressionSwitchBreaks2.java:23:37: compiler.err.break.ambiguous.target: x
+ExpressionSwitchBreaks2.java:27:29: compiler.err.return.outside.switch.expression
ExpressionSwitchBreaks2.java:28:29: compiler.err.continue.outside.switch.expression
-ExpressionSwitchBreaks2.java:29:29: compiler.err.undef.label: UNKNOWN
-ExpressionSwitchBreaks2.java:33:37: compiler.err.break.expr.not.immediate
-ExpressionSwitchBreaks2.java:39:17: compiler.err.break.complex.value.no.switch.expression
-ExpressionSwitchBreaks2.java:39:29: compiler.err.cant.resolve.location: kindname.variable, undef, , , (compiler.misc.location: kindname.class, ExpressionSwitchBreaks2, null)
-ExpressionSwitchBreaks2.java:43:22: compiler.err.break.ambiguous.target: j
-ExpressionSwitchBreaks2.java:46:22: compiler.err.break.outside.switch.expression
+ExpressionSwitchBreaks2.java:29:29: compiler.err.continue.outside.switch.expression
+ExpressionSwitchBreaks2.java:30:29: compiler.err.undef.label: UNKNOWN
+ExpressionSwitchBreaks2.java:34:37: compiler.err.break.expr.not.immediate
+ExpressionSwitchBreaks2.java:40:17: compiler.err.break.complex.value.no.switch.expression
+ExpressionSwitchBreaks2.java:40:29: compiler.err.cant.resolve.location: kindname.variable, undef, , , (compiler.misc.location: kindname.class, ExpressionSwitchBreaks2, null)
+ExpressionSwitchBreaks2.java:44:22: compiler.err.break.ambiguous.target: j
+ExpressionSwitchBreaks2.java:47:22: compiler.err.break.outside.switch.expression
- compiler.note.preview.filename: ExpressionSwitchBreaks2.java
- compiler.note.preview.recompile
12 errors
--- old/test/langtools/tools/javac/switchexpr/ExpressionSwitchBugs.java 2018-08-01 08:09:19.083825338 +0200
+++ new/test/langtools/tools/javac/switchexpr/ExpressionSwitchBugs.java 2018-08-01 08:09:18.791825351 +0200
@@ -21,9 +21,10 @@
* questions.
*/
-/**
+/*
* @test
* @bug 8206986
+ * @summary Verify various corner cases with nested switch expressions.
* @compile --enable-preview -source 12 ExpressionSwitchBugs.java
* @run main/othervm --enable-preview ExpressionSwitchBugs
*/
--- old/test/langtools/tools/javac/switchexpr/ExpressionSwitchCodeFromJLS.java 2018-08-01 08:09:19.751825307 +0200
+++ new/test/langtools/tools/javac/switchexpr/ExpressionSwitchCodeFromJLS.java 2018-08-01 08:09:19.455825320 +0200
@@ -21,9 +21,10 @@
* questions.
*/
-/**
+/*
* @test
* @bug 8206986
+ * @summary Check switch expressions
* @compile --enable-preview -source 12 ExpressionSwitchCodeFromJLS.java
* @run main/othervm --enable-preview ExpressionSwitchCodeFromJLS
*/
--- old/test/langtools/tools/javac/switchexpr/ExpressionSwitchDA.java 2018-08-01 08:09:20.423825275 +0200
+++ new/test/langtools/tools/javac/switchexpr/ExpressionSwitchDA.java 2018-08-01 08:09:20.127825289 +0200
@@ -21,9 +21,10 @@
* questions.
*/
-/**
+/*
* @test
* @bug 8206986
+ * @summary Check definite (un)assignment for in switch expressions.
* @compile --enable-preview -source 12 ExpressionSwitchDA.java
* @run main/othervm --enable-preview ExpressionSwitchDA
*/
--- old/test/langtools/tools/javac/switchexpr/ExpressionSwitchFallThrough.java 2018-08-01 08:09:21.091825244 +0200
+++ new/test/langtools/tools/javac/switchexpr/ExpressionSwitchFallThrough.java 2018-08-01 08:09:20.803825258 +0200
@@ -21,9 +21,10 @@
* questions.
*/
-/**
+/*
* @test
* @bug 8206986
+ * @summary Check fall through in switch expressions.
* @compile --enable-preview -source 12 ExpressionSwitchFallThrough.java
* @run main/othervm --enable-preview ExpressionSwitchFallThrough
*/
--- old/test/langtools/tools/javac/switchexpr/ExpressionSwitchFallThrough1.java 2018-08-01 08:09:21.767825213 +0200
+++ new/test/langtools/tools/javac/switchexpr/ExpressionSwitchFallThrough1.java 2018-08-01 08:09:21.467825227 +0200
@@ -21,9 +21,10 @@
* questions.
*/
-/**
+/*
* @test
* @bug 8206986
+ * @summary Check fall through in switch expressions.
* @compile --enable-preview -source 12 ExpressionSwitchFallThrough1.java
* @run main/othervm --enable-preview ExpressionSwitchFallThrough1
*/
--- old/test/langtools/tools/javac/switchexpr/ExpressionSwitchInExpressionSwitch.java 2018-08-01 08:09:22.435825182 +0200
+++ new/test/langtools/tools/javac/switchexpr/ExpressionSwitchInExpressionSwitch.java 2018-08-01 08:09:22.143825195 +0200
@@ -23,8 +23,10 @@
* questions.
*/
-/**
+/*
* @test
+ * @bug 8206986
+ * @summary Check switch expressions embedded in switch expressions.
* @compile --enable-preview -source 12 ExpressionSwitchInExpressionSwitch.java
* @run main/othervm --enable-preview ExpressionSwitchInExpressionSwitch
*/
--- old/test/langtools/tools/javac/switchexpr/ExpressionSwitchInfer.java 2018-08-01 08:09:23.111825150 +0200
+++ new/test/langtools/tools/javac/switchexpr/ExpressionSwitchInfer.java 2018-08-01 08:09:22.811825164 +0200
@@ -1,12 +1,12 @@
-/**
+/*
* @test /nodynamiccopyright/
* @bug 8206986
+ * @summary Check types inferred for switch expressions.
* @compile/fail/ref=ExpressionSwitchInfer.out -XDrawDiagnostics --enable-preview -source 12 ExpressionSwitchInfer.java
*/
import java.util.ArrayList;
import java.util.List;
-import java.util.Objects;
public class ExpressionSwitchInfer {
--- old/test/langtools/tools/javac/switchexpr/ExpressionSwitchIntersectionTypes.java 2018-08-01 08:09:23.775825119 +0200
+++ new/test/langtools/tools/javac/switchexpr/ExpressionSwitchIntersectionTypes.java 2018-08-01 08:09:23.479825133 +0200
@@ -21,9 +21,10 @@
* questions.
*/
-/**
+/*
* @test
* @bug 8206986
+ * @summary Verify behavior when an intersection type is inferred for switch expression.
* @compile --enable-preview -source 12 ExpressionSwitchIntersectionTypes.java
* @run main/othervm --enable-preview ExpressionSwitchIntersectionTypes
*/
--- old/test/langtools/tools/javac/switchexpr/ExpressionSwitchNotExhaustive.java 2018-08-01 08:09:24.451825088 +0200
+++ new/test/langtools/tools/javac/switchexpr/ExpressionSwitchNotExhaustive.java 2018-08-01 08:09:24.155825101 +0200
@@ -1,6 +1,7 @@
-/**
+/*
* @test /nodynamiccopyright/
* @bug 8206986
+ * @summary Verify behavior of not exhaustive switch expressions.
* @compile/fail/ref=ExpressionSwitchNotExhaustive.out -XDrawDiagnostics --enable-preview -source 12 ExpressionSwitchNotExhaustive.java
*/
--- old/test/langtools/tools/javac/switchexpr/ExpressionSwitchNotExhaustive.out 2018-08-01 08:09:25.123825056 +0200
+++ new/test/langtools/tools/javac/switchexpr/ExpressionSwitchNotExhaustive.out 2018-08-01 08:09:24.827825070 +0200
@@ -1,6 +1,6 @@
-ExpressionSwitchNotExhaustive.java:9:16: compiler.err.not.exhaustive
-ExpressionSwitchNotExhaustive.java:15:16: compiler.err.not.exhaustive
-ExpressionSwitchNotExhaustive.java:28:23: compiler.err.var.might.not.have.been.initialized: s
+ExpressionSwitchNotExhaustive.java:10:16: compiler.err.not.exhaustive
+ExpressionSwitchNotExhaustive.java:16:16: compiler.err.not.exhaustive
+ExpressionSwitchNotExhaustive.java:29:23: compiler.err.var.might.not.have.been.initialized: s
- compiler.note.preview.filename: ExpressionSwitchNotExhaustive.java
- compiler.note.preview.recompile
3 errors
--- old/test/langtools/tools/javac/switchexpr/ExpressionSwitchUnreachable.java 2018-08-01 08:09:25.795825025 +0200
+++ new/test/langtools/tools/javac/switchexpr/ExpressionSwitchUnreachable.java 2018-08-01 08:09:25.499825039 +0200
@@ -1,6 +1,7 @@
-/**
+/*
* @test /nodynamiccopyright/
* @bug 8206986
+ * @summary Verify reachability in switch expressions.
* @compile/fail/ref=ExpressionSwitchUnreachable.out -XDrawDiagnostics --enable-preview -source 12 ExpressionSwitchUnreachable.java
*/
--- old/test/langtools/tools/javac/switchexpr/ExpressionSwitchUnreachable.out 2018-08-01 08:09:26.463824994 +0200
+++ new/test/langtools/tools/javac/switchexpr/ExpressionSwitchUnreachable.out 2018-08-01 08:09:26.171825007 +0200
@@ -1,9 +1,9 @@
-ExpressionSwitchUnreachable.java:14:17: compiler.err.unreachable.stmt
-ExpressionSwitchUnreachable.java:21:17: compiler.err.unreachable.stmt
-ExpressionSwitchUnreachable.java:29:17: compiler.err.unreachable.stmt
-ExpressionSwitchUnreachable.java:36:17: compiler.err.unreachable.stmt
-ExpressionSwitchUnreachable.java:44:17: compiler.err.unreachable.stmt
-ExpressionSwitchUnreachable.java:51:17: compiler.err.unreachable.stmt
+ExpressionSwitchUnreachable.java:15:17: compiler.err.unreachable.stmt
+ExpressionSwitchUnreachable.java:22:17: compiler.err.unreachable.stmt
+ExpressionSwitchUnreachable.java:30:17: compiler.err.unreachable.stmt
+ExpressionSwitchUnreachable.java:37:17: compiler.err.unreachable.stmt
+ExpressionSwitchUnreachable.java:45:17: compiler.err.unreachable.stmt
+ExpressionSwitchUnreachable.java:52:17: compiler.err.unreachable.stmt
- compiler.note.preview.filename: ExpressionSwitchUnreachable.java
- compiler.note.preview.recompile
6 errors
\ No newline at end of file
--- old/test/langtools/tools/javac/switchexpr/ParseIncomplete.java 2018-08-01 08:09:27.139824962 +0200
+++ new/test/langtools/tools/javac/switchexpr/ParseIncomplete.java 2018-08-01 08:09:26.843824976 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 20018, Oracle and/or its affiliates. All rights reserved.
+ * 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
--- old/test/langtools/tools/javac/switchexpr/ParserRecovery.java 2018-08-01 08:09:27.803824931 +0200
+++ new/test/langtools/tools/javac/switchexpr/ParserRecovery.java 2018-08-01 08:09:27.507824945 +0200
@@ -1,6 +1,7 @@
-/**
+/*
* @test /nodynamiccopyright/
* @bug 8206986
+ * @summary Verify the parser handles broken input gracefully.
* @compile/fail/ref=ParserRecovery.out -XDrawDiagnostics --enable-preview -source 12 ParserRecovery.java
*/
--- old/test/langtools/tools/javac/switchexpr/ParserRecovery.out 2018-08-01 08:09:28.475824900 +0200
+++ new/test/langtools/tools/javac/switchexpr/ParserRecovery.out 2018-08-01 08:09:28.175824914 +0200
@@ -1,5 +1,5 @@
-ParserRecovery.java:9:39: compiler.err.expected: :
-ParserRecovery.java:12:31: compiler.err.expected: :
+ParserRecovery.java:10:39: compiler.err.expected: :
+ParserRecovery.java:13:31: compiler.err.expected: :
- compiler.note.preview.filename: ParserRecovery.java
- compiler.note.preview.recompile
2 errors
--- old/test/langtools/tools/javac/switchextra/MultipleLabelsExpression-old.out 2018-08-01 08:09:29.151824869 +0200
+++ new/test/langtools/tools/javac/switchextra/MultipleLabelsExpression-old.out 2018-08-01 08:09:28.855824882 +0200
@@ -1,4 +1,4 @@
-MultipleLabelsExpression.java:30:16: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.switch.expressions)
-MultipleLabelsExpression.java:31:20: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.switch.rules)
-MultipleLabelsExpression.java:32:19: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.multiple.case.labels)
+MultipleLabelsExpression.java:31:16: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.switch.expressions)
+MultipleLabelsExpression.java:32:20: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.switch.rules)
+MultipleLabelsExpression.java:33:19: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.multiple.case.labels)
3 errors
--- old/test/langtools/tools/javac/switchextra/MultipleLabelsExpression.java 2018-08-01 08:09:29.827824837 +0200
+++ new/test/langtools/tools/javac/switchextra/MultipleLabelsExpression.java 2018-08-01 08:09:29.531824851 +0200
@@ -1,6 +1,7 @@
-/**
+/*
* @test /nodynamiccopyright/
* @bug 8206986
+ * @summary Verify cases with multiple labels work properly.
* @compile/fail/ref=MultipleLabelsExpression-old.out -source 9 -Xlint:-options -XDrawDiagnostics MultipleLabelsExpression.java
* @compile --enable-preview -source 12 MultipleLabelsExpression.java
* @run main/othervm --enable-preview MultipleLabelsExpression
--- old/test/langtools/tools/javac/switchextra/MultipleLabelsStatement-old.out 2018-08-01 08:09:30.491824806 +0200
+++ new/test/langtools/tools/javac/switchextra/MultipleLabelsStatement-old.out 2018-08-01 08:09:30.199824820 +0200
@@ -1,2 +1,2 @@
-MultipleLabelsStatement.java:34:21: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.multiple.case.labels)
+MultipleLabelsStatement.java:35:21: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.multiple.case.labels)
1 error
--- old/test/langtools/tools/javac/switchextra/MultipleLabelsStatement.java 2018-08-01 08:09:31.171824774 +0200
+++ new/test/langtools/tools/javac/switchextra/MultipleLabelsStatement.java 2018-08-01 08:09:30.871824788 +0200
@@ -1,6 +1,7 @@
-/**
+/*
* @test /nodynamiccopyright/
* @bug 8206986
+ * @summary Verify cases with multiple labels work properly.
* @compile/fail/ref=MultipleLabelsStatement-old.out -source 9 -Xlint:-options -XDrawDiagnostics MultipleLabelsStatement.java
* @compile --enable-preview -source 12 MultipleLabelsStatement.java
* @run main/othervm --enable-preview MultipleLabelsStatement
--- old/test/langtools/tools/javac/switchextra/SwitchNoExtraTypes.java 2018-08-01 08:09:31.839824743 +0200
+++ new/test/langtools/tools/javac/switchextra/SwitchNoExtraTypes.java 2018-08-01 08:09:31.535824757 +0200
@@ -1,6 +1,7 @@
-/**
+/*
* @test /nodynamiccopyright/
* @bug 8206986
+ * @summary Verify switch over boolean/long/float/double is not allowed.
* @compile/fail/ref=SwitchNoExtraTypes.out -XDrawDiagnostics SwitchNoExtraTypes.java
*/
--- old/test/langtools/tools/javac/switchextra/SwitchNoExtraTypes.out 2018-08-01 08:09:32.507824712 +0200
+++ new/test/langtools/tools/javac/switchextra/SwitchNoExtraTypes.out 2018-08-01 08:09:32.211824726 +0200
@@ -1,5 +1,5 @@
-SwitchNoExtraTypes.java:10:16: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: boolean, int)
-SwitchNoExtraTypes.java:16:16: compiler.err.prob.found.req: (compiler.misc.possible.loss.of.precision: long, int)
-SwitchNoExtraTypes.java:22:16: compiler.err.prob.found.req: (compiler.misc.possible.loss.of.precision: float, int)
-SwitchNoExtraTypes.java:28:16: compiler.err.prob.found.req: (compiler.misc.possible.loss.of.precision: double, int)
+SwitchNoExtraTypes.java:11:16: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: boolean, int)
+SwitchNoExtraTypes.java:17:16: compiler.err.prob.found.req: (compiler.misc.possible.loss.of.precision: long, int)
+SwitchNoExtraTypes.java:23:16: compiler.err.prob.found.req: (compiler.misc.possible.loss.of.precision: float, int)
+SwitchNoExtraTypes.java:29:16: compiler.err.prob.found.req: (compiler.misc.possible.loss.of.precision: double, int)
4 errors
--- old/test/langtools/tools/javac/switchextra/SwitchObject.java 2018-08-01 08:09:33.187824680 +0200
+++ new/test/langtools/tools/javac/switchextra/SwitchObject.java 2018-08-01 08:09:32.887824694 +0200
@@ -1,6 +1,7 @@
/*
* @test /nodynamiccopyright/
* @bug 8206986
+ * @summary Verify switch over Object is not allowed.
* @compile/fail/ref=SwitchObject.out -XDrawDiagnostics SwitchObject.java
*/
public class SwitchObject {
@@ -13,4 +14,4 @@
}
}
-}
\ No newline at end of file
+}
--- old/test/langtools/tools/javac/switchextra/SwitchObject.out 2018-08-01 08:09:33.859824649 +0200
+++ new/test/langtools/tools/javac/switchextra/SwitchObject.out 2018-08-01 08:09:33.559824663 +0200
@@ -1,2 +1,2 @@
-SwitchObject.java:9:16: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Object, int)
+SwitchObject.java:10:16: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Object, int)
1 error
--- old/test/langtools/tools/javac/switchextra/SwitchStatementArrow-old.out 2018-08-01 08:09:34.527824618 +0200
+++ new/test/langtools/tools/javac/switchextra/SwitchStatementArrow-old.out 2018-08-01 08:09:34.231824632 +0200
@@ -1,3 +1,3 @@
-SwitchStatementArrow.java:39:20: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.switch.rules)
-SwitchStatementArrow.java:40:21: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.multiple.case.labels)
+SwitchStatementArrow.java:40:20: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.switch.rules)
+SwitchStatementArrow.java:41:21: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.multiple.case.labels)
2 errors
--- old/test/langtools/tools/javac/switchextra/SwitchStatementArrow.java 2018-08-01 08:09:35.195824587 +0200
+++ new/test/langtools/tools/javac/switchextra/SwitchStatementArrow.java 2018-08-01 08:09:34.903824600 +0200
@@ -1,6 +1,7 @@
-/**
+/*
* @test /nodymaticcopyright/
* @bug 8206986
+ * @summary Verify rule cases work properly.
* @compile/fail/ref=SwitchStatementArrow-old.out -source 9 -Xlint:-options -XDrawDiagnostics SwitchStatementArrow.java
* @compile --enable-preview -source 12 SwitchStatementArrow.java
* @run main/othervm --enable-preview SwitchStatementArrow
--- old/test/langtools/tools/javac/switchextra/SwitchStatementBroken.java 2018-08-01 08:09:35.871824555 +0200
+++ new/test/langtools/tools/javac/switchextra/SwitchStatementBroken.java 2018-08-01 08:09:35.575824569 +0200
@@ -1,6 +1,7 @@
-/**
+/*
* @test /nodynamiccopyright/
* @bug 8206986
+ * @summary Verify that rule and ordinary cases cannot be mixed.
* @compile/fail/ref=SwitchStatementBroken.out -XDrawDiagnostics --enable-preview -source 12 SwitchStatementBroken.java
*/
@@ -12,6 +13,8 @@
switch (i) {
case 0 -> { res = "NULL-A"; }
case 1: { res = "NULL-A"; break; }
+ case 2: { res = "NULL-A"; break; }
+ default -> { res = "NULL-A"; break; }
}
}
--- old/test/langtools/tools/javac/switchextra/SwitchStatementBroken.out 2018-08-01 08:09:36.551824524 +0200
+++ new/test/langtools/tools/javac/switchextra/SwitchStatementBroken.out 2018-08-01 08:09:36.247824538 +0200
@@ -1,4 +1,4 @@
-SwitchStatementBroken.java:14:13: compiler.err.switch.mixing.case.types
+SwitchStatementBroken.java:15:13: compiler.err.switch.mixing.case.types
- compiler.note.preview.filename: SwitchStatementBroken.java
- compiler.note.preview.recompile
1 error
--- old/test/langtools/tools/javac/switchextra/SwitchStatementBroken2.java 2018-08-01 08:09:37.235824492 +0200
+++ new/test/langtools/tools/javac/switchextra/SwitchStatementBroken2.java 2018-08-01 08:09:36.943824505 +0200
@@ -1,6 +1,7 @@
-/**
+/*
* @test /nodynamiccopyright/
* @bug 8206986
+ * @summary Verify that not allowed types of statements cannot be used in rule case.
* @compile/fail/ref=SwitchStatementBroken2.out -XDrawDiagnostics --enable-preview -source 12 SwitchStatementBroken2.java
*/
--- old/test/langtools/tools/javac/switchextra/SwitchStatementBroken2.out 2018-08-01 08:09:37.911824460 +0200
+++ new/test/langtools/tools/javac/switchextra/SwitchStatementBroken2.out 2018-08-01 08:09:37.615824474 +0200
@@ -1,7 +1,7 @@
-SwitchStatementBroken2.java:16:23: compiler.err.switch.case.unexpected.statement
SwitchStatementBroken2.java:17:23: compiler.err.switch.case.unexpected.statement
SwitchStatementBroken2.java:18:23: compiler.err.switch.case.unexpected.statement
-SwitchStatementBroken2.java:21:24: compiler.err.switch.case.unexpected.statement
+SwitchStatementBroken2.java:19:23: compiler.err.switch.case.unexpected.statement
+SwitchStatementBroken2.java:22:24: compiler.err.switch.case.unexpected.statement
- compiler.note.preview.filename: SwitchStatementBroken2.java
- compiler.note.preview.recompile
4 errors
--- old/test/langtools/tools/javac/switchnull/SwitchNullDisabled.java 2018-08-01 08:09:38.583824429 +0200
+++ new/test/langtools/tools/javac/switchnull/SwitchNullDisabled.java 2018-08-01 08:09:38.283824443 +0200
@@ -1,6 +1,7 @@
-/**
+/*
* @test /nodynamiccopyright/
* @bug 8206986
+ * @summary Verify "case null" is not allowed.
* @compile/fail/ref=SwitchNullDisabled.out -XDrawDiagnostics SwitchNullDisabled.java
*/
--- old/test/langtools/tools/javac/switchnull/SwitchNullDisabled.out 2018-08-01 08:09:39.259824397 +0200
+++ new/test/langtools/tools/javac/switchnull/SwitchNullDisabled.out 2018-08-01 08:09:38.963824411 +0200
@@ -1,2 +1,2 @@
-SwitchNullDisabled.java:10:18: compiler.err.switch.null.not.allowed
+SwitchNullDisabled.java:11:18: compiler.err.switch.null.not.allowed
1 error
--- /dev/null 2018-07-31 07:28:32.999928974 +0200
+++ new/test/langtools/tools/javac/diags/examples/SwitchExpressionEmpty.java 2018-08-01 08:09:39.635824380 +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.switch.expression.empty
+// key: compiler.note.preview.filename
+// key: compiler.note.preview.recompile
+// options: --enable-preview -source 12
+
+class BreakOutsideSwitchExpression {
+ String t(E e) {
+ return switch (e) {
+ };
+ }
+ enum E {}
+}
--- /dev/null 2018-07-31 07:28:32.999928974 +0200
+++ new/test/langtools/tools/javac/switchexpr/EmptySwitch.java 2018-08-01 08:09:40.339824347 +0200
@@ -0,0 +1,39 @@
+/*
+ * 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
+ * @bug 8206986
+ * @summary Verify than an empty switch expression is rejected.
+ * @compile/fail/ref=EmptySwitch.out --enable-preview -source 12 -XDrawDiagnostics EmptySwitch.java
+ */
+
+public class EmptySwitch {
+ private void print(EmptySwitchEnum t) {
+ (switch (t) {
+ }).toString();
+ }
+
+ enum EmptySwitchEnum {
+ }
+}
--- /dev/null 2018-07-31 07:28:32.999928974 +0200
+++ new/test/langtools/tools/javac/switchexpr/EmptySwitch.out 2018-08-01 08:09:41.047824314 +0200
@@ -0,0 +1,4 @@
+EmptySwitch.java:33:10: compiler.err.switch.expression.empty
+- compiler.note.preview.filename: EmptySwitch.java
+- compiler.note.preview.recompile
+1 error
--- old/test/langtools/tools/javac/diags/examples/NeitherConditionalSubtype.java 2018-08-01 08:09:42.059824267 +0200
+++ /dev/null 2018-07-31 07:28:32.999928974 +0200
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2010, 2014, 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.neither.conditional.subtype
-
-class NeitherConditionalSubtype {
- public int test(boolean cond, Object o) {
- // Should fail to compile since Object.wait() has a void return type.
- (o instanceof String ? o.hashCode() : o.wait()).toString();
- return 0;
- }
-}
-
-