8232684: Make switch expressions final
Reviewed-by: alanb, mcimadamore, kvn
This commit is contained in:
parent
f390c87d8d
commit
29852ecd80
src
java.base/share/classes/jdk/internal
jdk.compiler/share/classes/com/sun
test
hotspot/jtreg
runtime/execstack
vmTestbase
gc/gctests/gctest02
jit/regression/b4446672
nsk
monitoring/stress/thread
share
jdi
jpda
locks
runner
stress
jdk
com/sun/jdi
java/awt/Graphics2D/MTGraphicsAccessTest
jdk/jfr/event/runtime
langtools/tools/javac
ConditionalWithVoid.javaConditionalWithVoid.out
diags
examples.not-yet.txt
examples
BreakOutsideSwitchExpression.javaContinueOutsideSwitchExpression.javaIllegalRefToRestrictedType.javaIncompatibleTypesInSwitchExpression.javaInvalidYield.javaInvalidYieldWarning.javaMultipleCaseLabels.javaNoSwitchExpression.javaNoSwitchExpressionQualify.javaNotExhaustive.javaRestrictedTypeNotAllowedPreview.javaReturnOutsideSwitchExpression.javaRuleCompletesNormally.javaSwitchCaseUnexpectedStatement.javaSwitchExpressionCompletesNormally.javaSwitchExpressionEmpty.javaSwitchExpressionNoResultExpressions.javaSwitchExpressionTargetCantBeVoid.javaSwitchExpressions.javaSwitchMixingCaseTypes.javaSwitchRules.java
expswitch
lambda
parser
switchexpr
BlockExpression.javaBooleanNumericNonNumeric.javaBooleanNumericNonNumeric.outBreakTest.javaCRT.javaDefiniteAssignment1.javaDefiniteAssignment2.javaDefiniteAssignment2.outEmptySwitch.javaEmptySwitch.outExhaustiveEnumSwitch.javaExpressionSwitch-old.outExpressionSwitch.javaExpressionSwitchBreaks1.javaExpressionSwitchBreaks2.javaExpressionSwitchBreaks2.outExpressionSwitchBugs.javaExpressionSwitchBugsInGen.javaExpressionSwitchCodeFromJLS.javaExpressionSwitchDA.javaExpressionSwitchEmbedding.javaExpressionSwitchFallThrough.javaExpressionSwitchFallThrough1.javaExpressionSwitchFlow.javaExpressionSwitchFlow.outExpressionSwitchInExpressionSwitch.javaExpressionSwitchInfer.javaExpressionSwitchInfer.outExpressionSwitchIntersectionTypes.javaExpressionSwitchNotExhaustive.javaExpressionSwitchNotExhaustive.outExpressionSwitchToString.javaExpressionSwitchUnreachable.javaExpressionSwitchUnreachable.outLambdaCapture.javaParseIncomplete.java
@ -54,7 +54,6 @@ public @interface PreviewFeature {
|
||||
public boolean essentialAPI() default false;
|
||||
|
||||
public enum Feature {
|
||||
SWITCH_EXPRESSIONS,
|
||||
TEXT_BLOCKS;
|
||||
}
|
||||
}
|
||||
|
@ -51,29 +51,18 @@ public interface CaseTree extends Tree {
|
||||
* {@code null} if this is the default case.
|
||||
* If this case has multiple labels, returns the first label.
|
||||
* @return the expression for the case, or null
|
||||
* @deprecated Please use {@link #getExpressions()}.
|
||||
*/
|
||||
@Deprecated
|
||||
ExpressionTree getExpression();
|
||||
|
||||
/**
|
||||
* {@preview Associated with switch expressions, a preview feature of
|
||||
* the Java language.
|
||||
*
|
||||
* This method is associated with <i>switch expressions</i>, a preview
|
||||
* feature of the Java language. Preview features
|
||||
* may be removed in a future release, or upgraded to permanent
|
||||
* features of the Java language.}
|
||||
*
|
||||
* Returns the labels for this case.
|
||||
* For default case, returns an empty list.
|
||||
*
|
||||
* @return labels for this case
|
||||
* @since 12
|
||||
*
|
||||
* @preview 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.
|
||||
*/
|
||||
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS)
|
||||
List<? extends ExpressionTree> getExpressions();
|
||||
|
||||
/**
|
||||
@ -86,14 +75,6 @@ public interface CaseTree extends Tree {
|
||||
List<? extends StatementTree> getStatements();
|
||||
|
||||
/**
|
||||
* {@preview Associated with switch expressions, a preview feature of
|
||||
* the Java language.
|
||||
*
|
||||
* This method is associated with <i>switch expressions</i>, a preview
|
||||
* feature of the Java language. Preview features
|
||||
* may be removed in a future release, or upgraded to permanent
|
||||
* features of the Java language.}
|
||||
*
|
||||
* For case with kind {@linkplain CaseKind#RULE},
|
||||
* returns the statement or expression after the arrow.
|
||||
* Returns {@code null} for case with kind
|
||||
@ -102,40 +83,21 @@ public interface CaseTree extends Tree {
|
||||
* @return case value or null
|
||||
* @since 12
|
||||
*/
|
||||
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS)
|
||||
public default Tree getBody() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@preview Associated with switch expressions, a preview feature of
|
||||
* the Java language.
|
||||
*
|
||||
* This method is associated with <i>switch expressions</i>, a preview
|
||||
* feature of the Java language. Preview features
|
||||
* may be removed in a future release, or upgraded to permanent
|
||||
* features of the Java language.}
|
||||
*
|
||||
* Returns the kind of this case.
|
||||
*
|
||||
* @return the kind of this case
|
||||
* @since 12
|
||||
*/
|
||||
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS)
|
||||
@SuppressWarnings("preview")
|
||||
public default CaseKind getCaseKind() {
|
||||
return CaseKind.STATEMENT;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@preview Associated with switch expressions, a preview feature of
|
||||
* the Java language.
|
||||
*
|
||||
* This enum is associated with <i>switch expressions</i>, a preview
|
||||
* feature of the Java language. Preview features
|
||||
* may be removed in a future release, or upgraded to permanent
|
||||
* features of the Java language.}
|
||||
*
|
||||
* The syntatic form of this case:
|
||||
* <ul>
|
||||
* <li>STATEMENT: {@code case <expression>: <statements>}</li>
|
||||
@ -144,8 +106,6 @@ public interface CaseTree extends Tree {
|
||||
*
|
||||
* @since 12
|
||||
*/
|
||||
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS)
|
||||
@SuppressWarnings("preview")
|
||||
public enum CaseKind {
|
||||
/**
|
||||
* Case is in the form: {@code case <expression>: <statements>}.
|
||||
|
@ -28,14 +28,6 @@ package com.sun.source.tree;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* {@preview Associated with switch expressions, a preview feature of
|
||||
* the Java language.
|
||||
*
|
||||
* This interface is associated with <i>switch expressions</i>, a preview
|
||||
* feature of the Java language. Preview features
|
||||
* may be removed in a future release, or upgraded to permanent
|
||||
* features of the Java language.}
|
||||
*
|
||||
* A tree node for a {@code switch} expression.
|
||||
*
|
||||
* For example:
|
||||
@ -49,7 +41,6 @@ import java.util.List;
|
||||
*
|
||||
* @since 12
|
||||
*/
|
||||
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS)
|
||||
public interface SwitchExpressionTree extends ExpressionTree {
|
||||
/**
|
||||
* Returns the expression for the {@code switch} expression.
|
||||
|
@ -240,20 +240,10 @@ public interface Tree {
|
||||
SWITCH(SwitchTree.class),
|
||||
|
||||
/**
|
||||
* {@preview Associated with switch expressions, a preview feature of
|
||||
* the Java language.
|
||||
*
|
||||
* This enum constant is associated with <i>switch expressions</i>, a preview
|
||||
* feature of the Java language. Preview features
|
||||
* may be removed in a future release, or upgraded to permanent
|
||||
* features of the Java language.}
|
||||
*
|
||||
* Used for instances of {@link SwitchExpressionTree}.
|
||||
*
|
||||
* @since 12
|
||||
*/
|
||||
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS)
|
||||
@SuppressWarnings("preview")
|
||||
SWITCH_EXPRESSION(SwitchExpressionTree.class),
|
||||
|
||||
/**
|
||||
@ -662,20 +652,10 @@ public interface Tree {
|
||||
OTHER(null),
|
||||
|
||||
/**
|
||||
* {@preview Associated with switch expressions, a preview feature of
|
||||
* the Java language.
|
||||
*
|
||||
* This enum constant is associated with <i>switch expressions</i>, a preview
|
||||
* feature of the Java language. Preview features
|
||||
* may be removed in a future release, or upgraded to permanent
|
||||
* features of the Java language.}
|
||||
*
|
||||
* Used for instances of {@link YieldTree}.
|
||||
*
|
||||
* @since 13
|
||||
*/
|
||||
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS)
|
||||
@SuppressWarnings("preview")
|
||||
YIELD(YieldTree.class);
|
||||
|
||||
|
||||
|
@ -354,14 +354,6 @@ public interface TreeVisitor<R,P> {
|
||||
R visitSwitch(SwitchTree node, P p);
|
||||
|
||||
/**
|
||||
* {@preview Associated with switch expressions, a preview feature of
|
||||
* the Java language.
|
||||
*
|
||||
* This method is associated with <i>switch expressions</i>, a preview
|
||||
* feature of the Java language. Preview features
|
||||
* may be removed in a future release, or upgraded to permanent
|
||||
* features of the Java language.}
|
||||
*
|
||||
* Visits a SwitchExpressionTree node.
|
||||
*
|
||||
* @param node the node being visited
|
||||
@ -369,8 +361,6 @@ public interface TreeVisitor<R,P> {
|
||||
* @return a result value
|
||||
* @since 12
|
||||
*/
|
||||
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS)
|
||||
@SuppressWarnings("preview")
|
||||
R visitSwitchExpression(SwitchExpressionTree node, P p);
|
||||
|
||||
/**
|
||||
@ -560,21 +550,11 @@ public interface TreeVisitor<R,P> {
|
||||
R visitOther(Tree node, P p);
|
||||
|
||||
/**
|
||||
* {@preview Associated with switch expressions, a preview feature of
|
||||
* the Java language.
|
||||
*
|
||||
* This method is associated with <i>switch expressions</i>, a preview
|
||||
* feature of the Java language. Preview features
|
||||
* may be removed in a future release, or upgraded to permanent
|
||||
* features of the Java language.}
|
||||
*
|
||||
* Visits a YieldTree node.
|
||||
* @param node the node being visited
|
||||
* @param p a parameter value
|
||||
* @return a result value
|
||||
* @since 13
|
||||
*/
|
||||
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS)
|
||||
@SuppressWarnings("preview")
|
||||
R visitYield(YieldTree node, P p);
|
||||
}
|
||||
|
@ -26,14 +26,6 @@
|
||||
package com.sun.source.tree;
|
||||
|
||||
/**
|
||||
* {@preview Associated with switch expressions, a preview feature of
|
||||
* the Java language.
|
||||
*
|
||||
* This method is associated with <i>switch expressions</i>, a preview
|
||||
* feature of the Java language. Preview features
|
||||
* may be removed in a future release, or upgraded to permanent
|
||||
* features of the Java language.}
|
||||
*
|
||||
* A tree node for a {@code yield} statement.
|
||||
*
|
||||
* For example:
|
||||
@ -45,7 +37,6 @@ package com.sun.source.tree;
|
||||
*
|
||||
* @since 13
|
||||
*/
|
||||
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS)
|
||||
public interface YieldTree extends StatementTree {
|
||||
|
||||
/**
|
||||
|
@ -264,14 +264,6 @@ public class SimpleTreeVisitor <R,P> implements TreeVisitor<R,P> {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@preview Associated with switch expressions, a preview feature of
|
||||
* the Java language.
|
||||
*
|
||||
* This method is associated with <i>switch expressions</i>, a preview
|
||||
* feature of the Java language. Preview features
|
||||
* may be removed in a future release, or upgraded to permanent
|
||||
* features of the Java language.}
|
||||
*
|
||||
* {@inheritDoc} This implementation calls {@code defaultAction}.
|
||||
*
|
||||
* @param node {@inheritDoc}
|
||||
@ -279,8 +271,6 @@ public class SimpleTreeVisitor <R,P> implements TreeVisitor<R,P> {
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
@Override
|
||||
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS)
|
||||
@SuppressWarnings("preview")
|
||||
public R visitSwitchExpression(SwitchExpressionTree node, P p) {
|
||||
return defaultAction(node, p);
|
||||
}
|
||||
@ -794,8 +784,6 @@ public class SimpleTreeVisitor <R,P> implements TreeVisitor<R,P> {
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
@Override
|
||||
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS)
|
||||
@SuppressWarnings("preview")
|
||||
public R visitYield(YieldTree node, P p) {
|
||||
return defaultAction(node, p);
|
||||
}
|
||||
|
@ -334,14 +334,6 @@ public class TreeScanner<R,P> implements TreeVisitor<R,P> {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@preview Associated with switch expressions, a preview feature of
|
||||
* the Java language.
|
||||
*
|
||||
* This method is associated with <i>switch expressions</i>, a preview
|
||||
* feature of the Java language. Preview features
|
||||
* may be removed in a future release, or upgraded to permanent
|
||||
* features of the Java language.}
|
||||
*
|
||||
* {@inheritDoc} This implementation scans the children in left to right order.
|
||||
*
|
||||
* @param node {@inheritDoc}
|
||||
@ -349,8 +341,6 @@ public class TreeScanner<R,P> implements TreeVisitor<R,P> {
|
||||
* @return the result of scanning
|
||||
*/
|
||||
@Override
|
||||
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS)
|
||||
@SuppressWarnings("preview")
|
||||
public R visitSwitchExpression(SwitchExpressionTree node, P p) {
|
||||
R r = scan(node.getExpression(), p);
|
||||
r = scanAndReduce(node.getCases(), p, r);
|
||||
@ -365,7 +355,6 @@ public class TreeScanner<R,P> implements TreeVisitor<R,P> {
|
||||
* @return the result of scanning
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("preview")
|
||||
public R visitCase(CaseTree node, P p) {
|
||||
R r = scan(node.getExpressions(), p);
|
||||
if (node.getCaseKind() == CaseTree.CaseKind.RULE)
|
||||
@ -938,14 +927,6 @@ public class TreeScanner<R,P> implements TreeVisitor<R,P> {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@preview Associated with switch expressions, a preview feature of
|
||||
* the Java language.
|
||||
*
|
||||
* This method is associated with <i>switch expressions</i>, a preview
|
||||
* feature of the Java language. Preview features
|
||||
* may be removed in a future release, or upgraded to permanent
|
||||
* features of the Java language.}
|
||||
*
|
||||
* {@inheritDoc} This implementation returns {@code null}.
|
||||
*
|
||||
* @param node {@inheritDoc}
|
||||
@ -953,8 +934,6 @@ public class TreeScanner<R,P> implements TreeVisitor<R,P> {
|
||||
* @return the result of scanning
|
||||
*/
|
||||
@Override
|
||||
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS)
|
||||
@SuppressWarnings("preview")
|
||||
public R visitYield(YieldTree node, P p) {
|
||||
return scan(node.getValue(), p);
|
||||
}
|
||||
|
@ -165,10 +165,7 @@ public class Preview {
|
||||
* @return true, if given feature is a preview feature.
|
||||
*/
|
||||
public boolean isPreview(Feature feature) {
|
||||
if (feature == Feature.SWITCH_EXPRESSION ||
|
||||
feature == Feature.SWITCH_MULTIPLE_CASE_LABELS ||
|
||||
feature == Feature.SWITCH_RULE ||
|
||||
feature == Feature.TEXT_BLOCKS)
|
||||
if (feature == Feature.TEXT_BLOCKS)
|
||||
return true;
|
||||
//Note: this is a backdoor which allows to optionally treat all features as 'preview' (for testing).
|
||||
//When real preview features will be added, this method can be implemented to return 'true'
|
||||
|
@ -1467,7 +1467,6 @@ public class Attr extends JCTree.Visitor {
|
||||
// check that there are no duplicate case labels or default clauses.
|
||||
Set<Object> labels = new HashSet<>(); // The set of case labels.
|
||||
boolean hasDefault = false; // Is there a default label?
|
||||
@SuppressWarnings("preview")
|
||||
CaseTree.CaseKind caseKind = null;
|
||||
boolean wasError = false;
|
||||
for (List<JCCase> l = cases; l.nonEmpty(); l = l.tail) {
|
||||
|
@ -1432,7 +1432,6 @@ public class JavacParser implements Parser {
|
||||
}
|
||||
List<JCStatement> stats = null;
|
||||
JCTree body = null;
|
||||
@SuppressWarnings("preview")
|
||||
CaseTree.CaseKind kind;
|
||||
switch (token.kind) {
|
||||
case ARROW:
|
||||
@ -2897,7 +2896,6 @@ public class JavacParser implements Parser {
|
||||
nextToken();
|
||||
checkSourceLevel(Feature.SWITCH_MULTIPLE_CASE_LABELS);
|
||||
};
|
||||
@SuppressWarnings("preview")
|
||||
CaseTree.CaseKind caseKind;
|
||||
JCTree body = null;
|
||||
if (token.kind == ARROW) {
|
||||
@ -2922,7 +2920,6 @@ public class JavacParser implements Parser {
|
||||
}
|
||||
case DEFAULT: {
|
||||
nextToken();
|
||||
@SuppressWarnings("preview")
|
||||
CaseTree.CaseKind caseKind;
|
||||
JCTree body = null;
|
||||
if (token.kind == ARROW) {
|
||||
@ -3300,7 +3297,7 @@ public class JavacParser implements Parser {
|
||||
if (allowYieldStatement) {
|
||||
return true;
|
||||
} else if (shouldWarn) {
|
||||
log.warning(pos, Warnings.RestrictedTypeNotAllowedPreview(name, Source.JDK13));
|
||||
log.warning(pos, Warnings.RestrictedTypeNotAllowed(name, Source.JDK14));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -1249,17 +1249,14 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
|
||||
public static class JCCase extends JCStatement implements CaseTree {
|
||||
//as CaseKind is deprecated for removal (as it is part of a preview feature),
|
||||
//using indirection through these fields to avoid unnecessary @SuppressWarnings:
|
||||
@SuppressWarnings("preview")
|
||||
public static final CaseKind STATEMENT = CaseKind.STATEMENT;
|
||||
@SuppressWarnings("preview")
|
||||
public static final CaseKind RULE = CaseKind.RULE;
|
||||
@SuppressWarnings("preview")
|
||||
public final CaseKind caseKind;
|
||||
public List<JCExpression> pats;
|
||||
public List<JCStatement> stats;
|
||||
public JCTree body;
|
||||
public boolean completesNormally;
|
||||
protected JCCase(@SuppressWarnings("preview") CaseKind caseKind, List<JCExpression> pats,
|
||||
protected JCCase(CaseKind caseKind, List<JCExpression> pats,
|
||||
List<JCStatement> stats, JCTree body) {
|
||||
Assert.checkNonNull(pats);
|
||||
Assert.check(pats.isEmpty() || pats.head != null);
|
||||
@ -1273,21 +1270,17 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
|
||||
|
||||
@Override @DefinedBy(Api.COMPILER_TREE)
|
||||
public Kind getKind() { return Kind.CASE; }
|
||||
@Override @DefinedBy(Api.COMPILER_TREE)
|
||||
@Override @Deprecated @DefinedBy(Api.COMPILER_TREE)
|
||||
public JCExpression getExpression() { return pats.head; }
|
||||
@Override @DefinedBy(Api.COMPILER_TREE)
|
||||
@SuppressWarnings("preview")
|
||||
public List<JCExpression> getExpressions() { return pats; }
|
||||
@Override @DefinedBy(Api.COMPILER_TREE)
|
||||
@SuppressWarnings("preview")
|
||||
public List<JCStatement> getStatements() {
|
||||
return caseKind == CaseKind.STATEMENT ? stats : null;
|
||||
}
|
||||
@Override @DefinedBy(Api.COMPILER_TREE)
|
||||
@SuppressWarnings("preview")
|
||||
public JCTree getBody() { return body; }
|
||||
@Override @DefinedBy(Api.COMPILER_TREE)
|
||||
@SuppressWarnings("preview")
|
||||
public CaseKind getCaseKind() {
|
||||
return caseKind;
|
||||
}
|
||||
@ -1304,7 +1297,6 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
|
||||
/**
|
||||
* A "switch ( ) { }" construction.
|
||||
*/
|
||||
@SuppressWarnings("preview")
|
||||
public static class JCSwitchExpression extends JCPolyExpression implements SwitchExpressionTree {
|
||||
public JCExpression selector;
|
||||
public List<JCCase> cases;
|
||||
@ -1585,7 +1577,6 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
|
||||
/**
|
||||
* A break-with from a switch expression.
|
||||
*/
|
||||
@SuppressWarnings("preview")
|
||||
public static class JCYield extends JCStatement implements YieldTree {
|
||||
public JCExpression value;
|
||||
public JCTree target;
|
||||
@ -3104,7 +3095,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
|
||||
JCLabeledStatement Labelled(Name label, JCStatement body);
|
||||
JCSwitch Switch(JCExpression selector, List<JCCase> cases);
|
||||
JCSwitchExpression SwitchExpression(JCExpression selector, List<JCCase> cases);
|
||||
JCCase Case(@SuppressWarnings("preview") CaseTree.CaseKind caseKind, List<JCExpression> pat,
|
||||
JCCase Case(CaseTree.CaseKind caseKind, List<JCExpression> pat,
|
||||
List<JCStatement> stats, JCTree body);
|
||||
JCSynchronized Synchronized(JCExpression lock, JCBlock body);
|
||||
JCTry Try(JCBlock body, List<JCCatch> catchers, JCBlock finalizer);
|
||||
|
@ -144,7 +144,6 @@ public class TreeCopier<P> implements TreeVisitor<JCTree,P> {
|
||||
}
|
||||
|
||||
@DefinedBy(Api.COMPILER_TREE)
|
||||
@SuppressWarnings("preview")
|
||||
public JCTree visitYield(YieldTree node, P p) {
|
||||
JCYield t = (JCYield) node;
|
||||
JCExpression value = copy(t.value, p);
|
||||
@ -380,7 +379,6 @@ public class TreeCopier<P> implements TreeVisitor<JCTree,P> {
|
||||
}
|
||||
|
||||
@DefinedBy(Api.COMPILER_TREE)
|
||||
@SuppressWarnings("preview")
|
||||
public JCTree visitSwitchExpression(SwitchExpressionTree node, P p) {
|
||||
JCSwitchExpression t = (JCSwitchExpression) node;
|
||||
JCExpression selector = copy(t.selector, p);
|
||||
|
@ -274,7 +274,7 @@ public class TreeMaker implements JCTree.Factory {
|
||||
return tree;
|
||||
}
|
||||
|
||||
public JCCase Case(@SuppressWarnings("preview") CaseTree.CaseKind caseKind, List<JCExpression> pats,
|
||||
public JCCase Case(CaseTree.CaseKind caseKind, List<JCExpression> pats,
|
||||
List<JCStatement> stats, JCTree body) {
|
||||
JCCase tree = new JCCase(caseKind, pats, stats, body);
|
||||
tree.pos = pos;
|
||||
|
@ -78,7 +78,7 @@ class TestMT {
|
||||
public void run() {
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
TestMT.run(getName());
|
||||
yield();
|
||||
Thread.yield();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ class Escaper extends Thread {
|
||||
while ( ThreadCount.get() > 0 ) {
|
||||
int buf[] = new int[32];
|
||||
{
|
||||
yield();
|
||||
Thread.yield();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ public class b4446672 {
|
||||
System.out.println ("GCThread synchronized.");
|
||||
while (!done) {
|
||||
gcing=true;
|
||||
yield();
|
||||
Thread.yield();
|
||||
System.gc();
|
||||
}
|
||||
}
|
||||
|
@ -362,7 +362,7 @@ class RunningThread extends Thread {
|
||||
|
||||
currentDepth++;
|
||||
if (maxDepth > currentDepth) {
|
||||
yield();
|
||||
Thread.yield();
|
||||
if (mixed) {
|
||||
int result = recursionNative(maxDepth, currentDepth, true);
|
||||
|
||||
|
@ -232,7 +232,7 @@ abstract public class JDIEventsDebuggee extends AbstractJDIDebuggee {
|
||||
|
||||
public void run() {
|
||||
while (!startExecution)
|
||||
yield();
|
||||
Thread.yield();
|
||||
|
||||
for (int i = 0; (i < actionsNumber) && !stopExecution; i++)
|
||||
executor.doEventAction();
|
||||
|
@ -53,7 +53,7 @@ class MonitorWaitExecutor extends EventActionsExecutor {
|
||||
public void run() {
|
||||
// wait when interrupted thread switches state to 'TIMED_WAITING'
|
||||
while ((threadToInterrupt.getState() != Thread.State.WAITING) && !exitedFromWait) {
|
||||
yield();
|
||||
Thread.yield();
|
||||
}
|
||||
|
||||
// threadToInterrupt 'spuriously' exited from wait()
|
||||
@ -236,7 +236,7 @@ class MonitorEnterExecutor extends EventActionsExecutor {
|
||||
public void run() {
|
||||
// wait when blocked thread switches state to 'BLOCKED'
|
||||
while (blockedThread.getState() != Thread.State.BLOCKED)
|
||||
yield();
|
||||
Thread.yield();
|
||||
|
||||
lockingThread.releaseLock();
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ public class StateTestThread extends Thread {
|
||||
start();
|
||||
|
||||
while (!isRunning)
|
||||
yield();
|
||||
Thread.yield();
|
||||
|
||||
break;
|
||||
case 2:
|
||||
@ -119,7 +119,7 @@ public class StateTestThread extends Thread {
|
||||
isRunning = false;
|
||||
|
||||
while (this.getState() != Thread.State.TIMED_WAITING)
|
||||
yield();
|
||||
Thread.yield();
|
||||
|
||||
break;
|
||||
case 3:
|
||||
@ -129,7 +129,7 @@ public class StateTestThread extends Thread {
|
||||
interrupt();
|
||||
|
||||
while (getState() != Thread.State.WAITING)
|
||||
yield();
|
||||
Thread.yield();
|
||||
|
||||
break;
|
||||
case 4:
|
||||
@ -141,7 +141,7 @@ public class StateTestThread extends Thread {
|
||||
}
|
||||
|
||||
while (!readyToBeBlocked || (getState() != Thread.State.BLOCKED))
|
||||
yield();
|
||||
Thread.yield();
|
||||
|
||||
break;
|
||||
case 5:
|
||||
|
@ -325,7 +325,7 @@ public class LockingThread extends Thread {
|
||||
throw new TestBug("Locking thread can't reach required state (state: " + requiredState + " wasn't reached) in 1 minute");
|
||||
}
|
||||
|
||||
yield();
|
||||
Thread.yield();
|
||||
}
|
||||
|
||||
requiredState = null;
|
||||
|
@ -78,7 +78,7 @@ public class MonitorLockingThread extends Thread {
|
||||
* should already occur) and then force MonitorLockingThread to release lock
|
||||
*/
|
||||
while (blockedThread.getState() != Thread.State.BLOCKED)
|
||||
yield();
|
||||
Thread.yield();
|
||||
|
||||
lockingThread.releaseLock();
|
||||
}
|
||||
@ -98,7 +98,7 @@ public class MonitorLockingThread extends Thread {
|
||||
synchronized (lockToHold) {
|
||||
holdsLock = true;
|
||||
while (isRunning)
|
||||
yield();
|
||||
Thread.yield();
|
||||
}
|
||||
holdsLock = false;
|
||||
}
|
||||
@ -106,12 +106,12 @@ public class MonitorLockingThread extends Thread {
|
||||
public void releaseLock() {
|
||||
isRunning = false;
|
||||
while (holdsLock)
|
||||
yield();
|
||||
Thread.yield();
|
||||
}
|
||||
|
||||
public void acquireLock() {
|
||||
start();
|
||||
while (!holdsLock)
|
||||
yield();
|
||||
Thread.yield();
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ public class ThreadsRunner implements MultiRunner, LogAware, RunParamsAware {
|
||||
stresser.start(runParams.getIterations());
|
||||
while (!this.isInterrupted() && stresser.iteration()) {
|
||||
test.run();
|
||||
yield();
|
||||
Thread.yield();
|
||||
}
|
||||
waitForOtherThreads();
|
||||
} catch (OutOfMemoryError oom) {
|
||||
|
@ -84,7 +84,7 @@ class GarbageGenerator extends Thread {
|
||||
while (!done) {
|
||||
for (g = 0; g < ringSize; g++) {
|
||||
gr.add(allocSize);
|
||||
yield();
|
||||
Thread.yield();
|
||||
}
|
||||
gr.discard();
|
||||
try {
|
||||
|
@ -295,7 +295,7 @@ class strace001Thread extends Thread {
|
||||
}
|
||||
|
||||
if (strace001.DEPTH - currentDepth > 0) {
|
||||
yield();
|
||||
Thread.yield();
|
||||
recursiveMethod();
|
||||
}
|
||||
|
||||
|
@ -304,7 +304,7 @@ class strace002Thread extends Thread {
|
||||
}
|
||||
|
||||
if (strace002.DEPTH - currentDepth > 0) {
|
||||
yield();
|
||||
Thread.yield();
|
||||
recursiveMethod();
|
||||
}
|
||||
|
||||
|
@ -387,7 +387,7 @@ class strace005Thread extends Thread {
|
||||
|
||||
if (strace005.DEPTH - currentDepth > 0) {
|
||||
try {
|
||||
yield();
|
||||
Thread.yield();
|
||||
recursiveMethod2();
|
||||
} catch (StackOverflowError e) {
|
||||
// ignore this exception
|
||||
|
@ -331,7 +331,7 @@ class strace006Thread extends Thread {
|
||||
|
||||
if (strace006.DEPTH - currentDepth > 0) {
|
||||
try {
|
||||
yield();
|
||||
Thread.yield();
|
||||
recursiveMethod2();
|
||||
} catch (StackOverflowError e) {
|
||||
// ignore this exception
|
||||
|
@ -160,7 +160,7 @@ public class thread005 extends Thread {
|
||||
*/
|
||||
public void run() {
|
||||
while (!GO && !timeout())
|
||||
yield();
|
||||
Thread.yield();
|
||||
while (!STOP && !timeout())
|
||||
;
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ public class thread006 extends Thread {
|
||||
*/
|
||||
public void run() {
|
||||
while (!GO && !timeout())
|
||||
yield();
|
||||
Thread.yield();
|
||||
while (!STOP && !timeout())
|
||||
;
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ class InvokeHangTarg extends Thread {
|
||||
// This is called from the debugger via invokeMethod
|
||||
public double invokeee() {
|
||||
System.out.println("Debuggee: invokeee in thread "+Thread.currentThread().toString());
|
||||
yield();
|
||||
Thread.yield();
|
||||
return longMethod(2);
|
||||
}
|
||||
public double longMethod(int n) {
|
||||
|
@ -71,7 +71,7 @@ class SimulResumerTarg extends Thread {
|
||||
|
||||
public void bkpt1(int i) {
|
||||
synchronized(name1) {
|
||||
yield();
|
||||
Thread.yield();
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,7 +85,7 @@ class SimulResumerTarg extends Thread {
|
||||
|
||||
public void bkpt2(int i) {
|
||||
synchronized(name2) {
|
||||
yield();
|
||||
Thread.yield();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ class TwoThreadsTarg extends Thread {
|
||||
}
|
||||
|
||||
public void bkpt1(int i) {
|
||||
yield();
|
||||
Thread.yield();
|
||||
}
|
||||
|
||||
public void run1() {
|
||||
@ -82,7 +82,7 @@ class TwoThreadsTarg extends Thread {
|
||||
}
|
||||
|
||||
public void bkpt2(int i) {
|
||||
yield();
|
||||
Thread.yield();
|
||||
}
|
||||
|
||||
public void run2() {
|
||||
|
@ -197,7 +197,7 @@ public class MTGraphicsAccessTest {
|
||||
while (!done) {
|
||||
try {
|
||||
testRunnable.run();
|
||||
yield();
|
||||
Thread.yield();
|
||||
} catch (Throwable t) {
|
||||
numexceptions++;
|
||||
t.printStackTrace();
|
||||
|
@ -107,7 +107,7 @@ public class TestThreadCpuTimeEvent {
|
||||
} catch (BrokenBarrierException e) {
|
||||
// Another thread has been interrupted - wait for us to be interrupted as well
|
||||
while (!interrupted()) {
|
||||
yield();
|
||||
Thread.yield();
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
// Normal way of stopping the thread
|
||||
|
@ -4,7 +4,7 @@
|
||||
* @summary The compiler was allowing void types in its parsing of conditional expressions.
|
||||
* @author tball
|
||||
*
|
||||
* @compile/fail/ref=ConditionalWithVoid.out --enable-preview -source ${jdk.version} -XDrawDiagnostics ConditionalWithVoid.java
|
||||
* @compile/fail/ref=ConditionalWithVoid.out -XDrawDiagnostics ConditionalWithVoid.java
|
||||
*/
|
||||
public class ConditionalWithVoid {
|
||||
public void test(Object o, String s) {
|
||||
|
@ -2,6 +2,4 @@ ConditionalWithVoid.java:12:71: compiler.err.void.not.allowed.here
|
||||
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
|
||||
|
@ -116,6 +116,7 @@ compiler.warn.is.preview # difficult to produce r
|
||||
compiler.warn.override.bridge
|
||||
compiler.warn.position.overflow # CRTable: caused by files with long lines >= 1024 chars
|
||||
compiler.warn.proc.type.already.exists # JavacFiler: just mentioned in TODO
|
||||
compiler.warn.restricted.type.not.allowed.preview # not produced by the compiler right now
|
||||
compiler.warn.unchecked.assign # DEAD, replaced by compiler.misc.unchecked.assign
|
||||
compiler.warn.unchecked.cast.to.type # DEAD, replaced by compiler.misc.unchecked.cast.to.type
|
||||
compiler.warn.unexpected.archive.file # Paths: zip file with unknown extn
|
||||
|
@ -22,9 +22,6 @@
|
||||
*/
|
||||
|
||||
// key: compiler.err.break.outside.switch.expression
|
||||
// key: compiler.note.preview.filename
|
||||
// key: compiler.note.preview.recompile
|
||||
// options: --enable-preview -source ${jdk.version}
|
||||
|
||||
class BreakOutsideSwitchExpression {
|
||||
int t(int i) {
|
||||
|
@ -22,9 +22,6 @@
|
||||
*/
|
||||
|
||||
// key: compiler.err.continue.outside.switch.expression
|
||||
// key: compiler.note.preview.filename
|
||||
// key: compiler.note.preview.recompile
|
||||
// options: --enable-preview -source ${jdk.version}
|
||||
|
||||
class ContinueOutsideSwitchExpression {
|
||||
int t(int i) {
|
||||
|
@ -22,7 +22,8 @@
|
||||
*/
|
||||
|
||||
// key: compiler.warn.illegal.ref.to.restricted.type
|
||||
// key: compiler.warn.restricted.type.not.allowed.preview
|
||||
// key: compiler.warn.restricted.type.not.allowed
|
||||
// options: -Xlint:-options -source 13
|
||||
|
||||
class IllegalRefToVarType {
|
||||
yield list() { return null; }
|
||||
|
@ -24,9 +24,6 @@
|
||||
// key: compiler.err.prob.found.req
|
||||
// key: compiler.misc.incompatible.type.in.switch.expression
|
||||
// key: compiler.misc.inconvertible.types
|
||||
// key: compiler.note.preview.filename
|
||||
// key: compiler.note.preview.recompile
|
||||
// options: --enable-preview -source ${jdk.version}
|
||||
|
||||
|
||||
class IncompatibleTypesInSwitchExpression {
|
||||
|
@ -22,7 +22,6 @@
|
||||
*/
|
||||
|
||||
// key: compiler.err.invalid.yield
|
||||
// options: --enable-preview --source ${jdk.version}
|
||||
|
||||
class BreakComplexValueNoSwitchExpressions {
|
||||
void t() {
|
||||
|
@ -22,7 +22,7 @@
|
||||
*/
|
||||
|
||||
// key: compiler.warn.invalid.yield
|
||||
// options: --source ${jdk.version}
|
||||
// options: -Xlint:-options --source 13
|
||||
|
||||
class BreakComplexValueNoSwitchExpressions {
|
||||
void t() {
|
||||
|
@ -22,8 +22,8 @@
|
||||
*/
|
||||
|
||||
// key: compiler.misc.feature.multiple.case.labels
|
||||
// key: compiler.warn.preview.feature.use.plural
|
||||
// options: --enable-preview -source ${jdk.version} -Xlint:preview
|
||||
// key: compiler.err.feature.not.supported.in.source.plural
|
||||
// options: -Xlint:-options -source 13
|
||||
|
||||
class MultipleCaseLabels {
|
||||
void m(int i) {
|
||||
|
@ -22,7 +22,6 @@
|
||||
*/
|
||||
|
||||
// key: compiler.err.no.switch.expression
|
||||
// options: --enable-preview --source ${jdk.version}
|
||||
|
||||
class BreakComplexValueNoSwitchExpressions {
|
||||
void t() {
|
||||
|
@ -22,7 +22,6 @@
|
||||
*/
|
||||
|
||||
// key: compiler.err.no.switch.expression.qualify
|
||||
// options: --enable-preview --source ${jdk.version}
|
||||
|
||||
class BreakComplexValueNoSwitchExpressions {
|
||||
void t() {
|
||||
|
@ -22,9 +22,6 @@
|
||||
*/
|
||||
|
||||
// key: compiler.err.not.exhaustive
|
||||
// key: compiler.note.preview.filename
|
||||
// key: compiler.note.preview.recompile
|
||||
// options: --enable-preview -source ${jdk.version}
|
||||
|
||||
class NotExhaustive {
|
||||
int t(int i) {
|
||||
|
@ -1,26 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.restricted.type.not.allowed.preview
|
||||
|
||||
class yield { }
|
@ -22,9 +22,6 @@
|
||||
*/
|
||||
|
||||
// key: compiler.err.return.outside.switch.expression
|
||||
// key: compiler.note.preview.filename
|
||||
// key: compiler.note.preview.recompile
|
||||
// options: --enable-preview -source ${jdk.version}
|
||||
|
||||
class ReturnOutsideSwitchExpression {
|
||||
int t(int i) {
|
||||
|
@ -22,9 +22,6 @@
|
||||
*/
|
||||
|
||||
// key: compiler.err.rule.completes.normally
|
||||
// key: compiler.note.preview.filename
|
||||
// key: compiler.note.preview.recompile
|
||||
// options: --enable-preview -source ${jdk.version}
|
||||
|
||||
class RuleCompletesNormally {
|
||||
public String convert(int i) {
|
||||
|
@ -22,9 +22,6 @@
|
||||
*/
|
||||
|
||||
// key: compiler.err.switch.case.unexpected.statement
|
||||
// key: compiler.note.preview.filename
|
||||
// key: compiler.note.preview.recompile
|
||||
// options: --enable-preview -source ${jdk.version}
|
||||
|
||||
class ReturnOutsideSwitchExpression {
|
||||
void t(int i) {
|
||||
|
@ -22,9 +22,6 @@
|
||||
*/
|
||||
|
||||
// key: compiler.err.switch.expression.completes.normally
|
||||
// key: compiler.note.preview.filename
|
||||
// key: compiler.note.preview.recompile
|
||||
// options: --enable-preview -source ${jdk.version}
|
||||
|
||||
class SwitchExpressionCompletesNormally {
|
||||
public String convert(int i) {
|
||||
|
@ -22,9 +22,6 @@
|
||||
*/
|
||||
|
||||
// key: compiler.err.switch.expression.empty
|
||||
// key: compiler.note.preview.filename
|
||||
// key: compiler.note.preview.recompile
|
||||
// options: --enable-preview -source ${jdk.version}
|
||||
|
||||
class BreakOutsideSwitchExpression {
|
||||
String t(E e) {
|
||||
|
@ -22,9 +22,6 @@
|
||||
*/
|
||||
|
||||
// key: compiler.err.switch.expression.no.result.expressions
|
||||
// key: compiler.note.preview.filename
|
||||
// key: compiler.note.preview.recompile
|
||||
// options: --enable-preview -source ${jdk.version}
|
||||
|
||||
class SwitchExpressionCompletesNormally {
|
||||
public String convert(int i) {
|
||||
|
@ -24,9 +24,6 @@
|
||||
// key: compiler.err.prob.found.req
|
||||
// key: compiler.misc.incompatible.ret.type.in.lambda
|
||||
// key: compiler.misc.switch.expression.target.cant.be.void
|
||||
// key: compiler.note.preview.filename
|
||||
// key: compiler.note.preview.recompile
|
||||
// options: --enable-preview -source ${jdk.version}
|
||||
|
||||
class SwitchExpressionTargetCantBeVoid {
|
||||
|
||||
|
@ -22,8 +22,8 @@
|
||||
*/
|
||||
|
||||
// key: compiler.misc.feature.switch.expressions
|
||||
// key: compiler.warn.preview.feature.use.plural
|
||||
// options: --enable-preview -source ${jdk.version} -Xlint:preview
|
||||
// key: compiler.err.feature.not.supported.in.source.plural
|
||||
// options: -Xlint:-options -source 13
|
||||
|
||||
class SwitchExpressions {
|
||||
int m(int i) {
|
||||
|
@ -22,9 +22,6 @@
|
||||
*/
|
||||
|
||||
// key: compiler.err.switch.mixing.case.types
|
||||
// key: compiler.note.preview.filename
|
||||
// key: compiler.note.preview.recompile
|
||||
// options: --enable-preview -source ${jdk.version}
|
||||
|
||||
class SwitchMixingCaseTypes {
|
||||
|
||||
|
@ -22,8 +22,8 @@
|
||||
*/
|
||||
|
||||
// key: compiler.misc.feature.switch.rules
|
||||
// key: compiler.warn.preview.feature.use.plural
|
||||
// options: --enable-preview -source ${jdk.version} -Xlint:preview
|
||||
// key: compiler.err.feature.not.supported.in.source.plural
|
||||
// options: -Xlint:-options -source 13
|
||||
|
||||
class SwitchExpressions {
|
||||
void m(int i) {
|
||||
|
@ -76,9 +76,6 @@ public class ExpSwitchNestingTest extends JavacTemplateTestBase {
|
||||
}
|
||||
}
|
||||
|
||||
private static String[] PREVIEW_OPTIONS = {"--enable-preview", "-source",
|
||||
Integer.toString(Runtime.version().feature())};
|
||||
|
||||
private void program(String... constructs) {
|
||||
String s = "class C { static boolean cond = false; static int x = 0; void m() { # } }";
|
||||
for (String c : constructs)
|
||||
@ -88,7 +85,7 @@ public class ExpSwitchNestingTest extends JavacTemplateTestBase {
|
||||
|
||||
private void assertOK(String... constructs) {
|
||||
reset();
|
||||
addCompileOptions(PREVIEW_OPTIONS);
|
||||
addCompileOptions();
|
||||
program(constructs);
|
||||
try {
|
||||
compile();
|
||||
@ -101,7 +98,7 @@ public class ExpSwitchNestingTest extends JavacTemplateTestBase {
|
||||
|
||||
private void assertOKWithWarning(String warning, String... constructs) {
|
||||
reset();
|
||||
addCompileOptions(PREVIEW_OPTIONS);
|
||||
addCompileOptions();
|
||||
program(constructs);
|
||||
try {
|
||||
compile();
|
||||
@ -114,7 +111,7 @@ public class ExpSwitchNestingTest extends JavacTemplateTestBase {
|
||||
|
||||
private void assertFail(String expectedDiag, String... constructs) {
|
||||
reset();
|
||||
addCompileOptions(PREVIEW_OPTIONS);
|
||||
addCompileOptions();
|
||||
program(constructs);
|
||||
try {
|
||||
compile();
|
||||
|
@ -2,7 +2,7 @@
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8206986
|
||||
* @summary Adding switch expressions
|
||||
* @compile/fail/ref=BadSwitchExpressionLambda.out -XDrawDiagnostics --enable-preview -source ${jdk.version} BadSwitchExpressionLambda.java
|
||||
* @compile/fail/ref=BadSwitchExpressionLambda.out -XDrawDiagnostics BadSwitchExpressionLambda.java
|
||||
*/
|
||||
|
||||
class BadSwitchExpressionLambda {
|
||||
|
@ -1,6 +1,4 @@
|
||||
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
|
||||
3 errors
|
||||
|
@ -1096,7 +1096,7 @@ public class JavacParserTest extends TestCase {
|
||||
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", "--enable-preview", "-source", SOURCE_VERSION),
|
||||
Arrays.asList("-XDrawDiagnostics"),
|
||||
null, Arrays.asList(new MyFileObject(code)));
|
||||
|
||||
CompilationUnitTree cut = ct.parse().iterator().next();
|
||||
|
@ -25,8 +25,8 @@
|
||||
* @test
|
||||
* @bug 8206986
|
||||
* @summary Verify rule cases with expression statements and throw statements work.
|
||||
* @compile --enable-preview -source ${jdk.version} BlockExpression.java
|
||||
* @run main/othervm --enable-preview BlockExpression
|
||||
* @compile BlockExpression.java
|
||||
* @run main BlockExpression
|
||||
*/
|
||||
|
||||
public class BlockExpression {
|
||||
|
@ -2,7 +2,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 ${jdk.version} BooleanNumericNonNumeric.java
|
||||
* @compile/fail/ref=BooleanNumericNonNumeric.out -XDrawDiagnostics BooleanNumericNonNumeric.java
|
||||
*/
|
||||
|
||||
public class BooleanNumericNonNumeric {
|
||||
|
@ -1,5 +1,3 @@
|
||||
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
|
||||
|
@ -67,7 +67,7 @@ public class BreakTest {
|
||||
|
||||
StringWriter out = new StringWriter();
|
||||
JavacTask ct = (JavacTask) tool.getTask(out, null, noErrors,
|
||||
List.of("-XDdev", "--enable-preview", "-source", sourceVersion), null,
|
||||
List.of("-XDdev"), null,
|
||||
Arrays.asList(new MyFileObject(CODE)));
|
||||
List<String> labels = new ArrayList<>();
|
||||
new TreePathScanner<Void, Void>() {
|
||||
|
@ -151,9 +151,7 @@ public class CRT {
|
||||
tb.createDirectories(classes);
|
||||
tb.cleanDirectory(classes);
|
||||
new JavacTask(tb)
|
||||
.options("-Xjcov",
|
||||
"--enable-preview",
|
||||
"-source", SOURCE_VERSION)
|
||||
.options("-Xjcov")
|
||||
.outdir(classes)
|
||||
.sources("public class Test {\n" +
|
||||
code +
|
||||
|
@ -25,8 +25,8 @@
|
||||
* @test
|
||||
* @bug 8214031 8221413
|
||||
* @summary Verify that definite assignment when true works (legal code)
|
||||
* @compile --enable-preview --source ${jdk.version} DefiniteAssignment1.java
|
||||
* @run main/othervm --enable-preview DefiniteAssignment1
|
||||
* @compile DefiniteAssignment1.java
|
||||
* @run main DefiniteAssignment1
|
||||
*/
|
||||
public class DefiniteAssignment1 {
|
||||
public static void main(String[] args) {
|
||||
|
@ -2,7 +2,7 @@
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8214031
|
||||
* @summary Verify that definite assignment when true works (illegal code)
|
||||
* @compile/fail/ref=DefiniteAssignment2.out --enable-preview --source ${jdk.version} -XDrawDiagnostics DefiniteAssignment2.java
|
||||
* @compile/fail/ref=DefiniteAssignment2.out -XDrawDiagnostics DefiniteAssignment2.java
|
||||
*/
|
||||
public class DefiniteAssignment2 {
|
||||
|
||||
|
@ -5,6 +5,4 @@ DefiniteAssignment2.java:49:19: compiler.err.var.might.not.have.been.initialized
|
||||
DefiniteAssignment2.java:59:19: compiler.err.var.might.not.have.been.initialized: x
|
||||
DefiniteAssignment2.java:69:19: compiler.err.var.might.not.have.been.initialized: x
|
||||
DefiniteAssignment2.java:79:20: compiler.err.var.might.already.be.assigned: x
|
||||
- compiler.note.preview.filename: DefiniteAssignment2.java
|
||||
- compiler.note.preview.recompile
|
||||
7 errors
|
||||
|
@ -25,7 +25,7 @@
|
||||
* @test
|
||||
* @bug 8206986 8226510
|
||||
* @summary Verify than a switch that does not yield a value is rejected.
|
||||
* @compile/fail/ref=EmptySwitch.out --enable-preview -source ${jdk.version} -XDrawDiagnostics -XDshould-stop.at=FLOW EmptySwitch.java
|
||||
* @compile/fail/ref=EmptySwitch.out -XDrawDiagnostics -XDshould-stop.at=FLOW EmptySwitch.java
|
||||
*/
|
||||
|
||||
public class EmptySwitch {
|
||||
|
@ -3,6 +3,4 @@ EmptySwitch.java:35:10: compiler.err.switch.expression.no.result.expressions
|
||||
EmptySwitch.java:38:10: compiler.err.switch.expression.no.result.expressions
|
||||
EmptySwitch.java:44:9: compiler.err.switch.expression.completes.normally
|
||||
EmptySwitch.java:47:26: compiler.err.rule.completes.normally
|
||||
- compiler.note.preview.filename: EmptySwitch.java
|
||||
- compiler.note.preview.recompile
|
||||
5 errors
|
||||
|
@ -25,9 +25,9 @@
|
||||
* @test
|
||||
* @bug 8206986
|
||||
* @summary Verify that an switch expression over enum can be exhaustive without default.
|
||||
* @compile --enable-preview -source ${jdk.version} ExhaustiveEnumSwitch.java
|
||||
* @compile ExhaustiveEnumSwitch.java
|
||||
* @compile ExhaustiveEnumSwitchExtra.java
|
||||
* @run main/othervm --enable-preview ExhaustiveEnumSwitch
|
||||
* @run main ExhaustiveEnumSwitch
|
||||
*/
|
||||
|
||||
public class ExhaustiveEnumSwitch {
|
||||
|
@ -1,4 +1,4 @@
|
||||
ExpressionSwitch.java:40:16: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.switch.expressions)
|
||||
ExpressionSwitch.java:41:20: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.switch.rules)
|
||||
ExpressionSwitch.java:93:31: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.multiple.case.labels)
|
||||
ExpressionSwitch.java:40:16: compiler.err.feature.not.supported.in.source.plural: (compiler.misc.feature.switch.expressions), 9, 14
|
||||
ExpressionSwitch.java:41:20: compiler.err.feature.not.supported.in.source.plural: (compiler.misc.feature.switch.rules), 9, 14
|
||||
ExpressionSwitch.java:93:31: compiler.err.feature.not.supported.in.source.plural: (compiler.misc.feature.multiple.case.labels), 9, 14
|
||||
3 errors
|
||||
|
@ -3,8 +3,8 @@
|
||||
* @bug 8206986 8222169 8224031
|
||||
* @summary Check expression switch works.
|
||||
* @compile/fail/ref=ExpressionSwitch-old.out -source 9 -Xlint:-options -XDrawDiagnostics ExpressionSwitch.java
|
||||
* @compile --enable-preview -source ${jdk.version} ExpressionSwitch.java
|
||||
* @run main/othervm --enable-preview ExpressionSwitch
|
||||
* @compile ExpressionSwitch.java
|
||||
* @run main ExpressionSwitch
|
||||
*/
|
||||
|
||||
import java.util.Objects;
|
||||
|
@ -25,8 +25,8 @@
|
||||
* @test
|
||||
* @bug 8206986
|
||||
* @summary Verify behavior of various kinds of breaks.
|
||||
* @compile --enable-preview -source ${jdk.version} ExpressionSwitchBreaks1.java
|
||||
* @run main/othervm --enable-preview ExpressionSwitchBreaks1
|
||||
* @compile ExpressionSwitchBreaks1.java
|
||||
* @run main ExpressionSwitchBreaks1
|
||||
*/
|
||||
|
||||
import java.util.Objects;
|
||||
|
@ -2,7 +2,7 @@
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8206986
|
||||
* @summary Check behavior for invalid breaks.
|
||||
* @compile/fail/ref=ExpressionSwitchBreaks2.out -XDrawDiagnostics --enable-preview -source ${jdk.version} ExpressionSwitchBreaks2.java
|
||||
* @compile/fail/ref=ExpressionSwitchBreaks2.out -XDrawDiagnostics ExpressionSwitchBreaks2.java
|
||||
*/
|
||||
|
||||
public class ExpressionSwitchBreaks2 {
|
||||
|
@ -7,6 +7,4 @@ ExpressionSwitchBreaks2.java:40:17: compiler.err.no.switch.expression
|
||||
ExpressionSwitchBreaks2.java:40:29: compiler.err.cant.resolve.location: kindname.variable, undef, , , (compiler.misc.location: kindname.class, ExpressionSwitchBreaks2, null)
|
||||
ExpressionSwitchBreaks2.java:45:22: compiler.err.break.outside.switch.expression
|
||||
ExpressionSwitchBreaks2.java:49:22: compiler.err.break.outside.switch.expression
|
||||
- compiler.note.preview.filename: ExpressionSwitchBreaks2.java
|
||||
- compiler.note.preview.recompile
|
||||
9 errors
|
@ -25,8 +25,8 @@
|
||||
* @test
|
||||
* @bug 8206986 8214114 8214529
|
||||
* @summary Verify various corner cases with nested switch expressions.
|
||||
* @compile --enable-preview -source ${jdk.version} ExpressionSwitchBugs.java
|
||||
* @run main/othervm --enable-preview ExpressionSwitchBugs
|
||||
* @compile ExpressionSwitchBugs.java
|
||||
* @run main ExpressionSwitchBugs
|
||||
*/
|
||||
|
||||
public class ExpressionSwitchBugs {
|
||||
|
@ -25,8 +25,8 @@
|
||||
* @test
|
||||
* @bug 8214031
|
||||
* @summary Verify various corner cases with nested switch expressions.
|
||||
* @compile --enable-preview -source ${jdk.version} ExpressionSwitchBugsInGen.java
|
||||
* @run main/othervm --enable-preview ExpressionSwitchBugsInGen
|
||||
* @compile ExpressionSwitchBugsInGen.java
|
||||
* @run main ExpressionSwitchBugsInGen
|
||||
*/
|
||||
|
||||
public class ExpressionSwitchBugsInGen {
|
||||
|
@ -25,8 +25,8 @@
|
||||
* @test
|
||||
* @bug 8206986
|
||||
* @summary Check switch expressions
|
||||
* @compile --enable-preview -source ${jdk.version} ExpressionSwitchCodeFromJLS.java
|
||||
* @run main/othervm --enable-preview ExpressionSwitchCodeFromJLS
|
||||
* @compile ExpressionSwitchCodeFromJLS.java
|
||||
* @run main ExpressionSwitchCodeFromJLS
|
||||
*/
|
||||
|
||||
public class ExpressionSwitchCodeFromJLS {
|
||||
|
@ -25,8 +25,8 @@
|
||||
* @test
|
||||
* @bug 8206986
|
||||
* @summary Check definite (un)assignment for in switch expressions.
|
||||
* @compile --enable-preview -source ${jdk.version} ExpressionSwitchDA.java
|
||||
* @run main/othervm --enable-preview ExpressionSwitchDA
|
||||
* @compile ExpressionSwitchDA.java
|
||||
* @run main ExpressionSwitchDA
|
||||
*/
|
||||
|
||||
public class ExpressionSwitchDA {
|
||||
|
@ -25,8 +25,8 @@
|
||||
* @test
|
||||
* @bug 8214031 8214114
|
||||
* @summary Verify switch expressions embedded in various statements work properly.
|
||||
* @compile --enable-preview -source ${jdk.version} ExpressionSwitchEmbedding.java
|
||||
* @run main/othervm --enable-preview ExpressionSwitchEmbedding
|
||||
* @compile ExpressionSwitchEmbedding.java
|
||||
* @run main ExpressionSwitchEmbedding
|
||||
*/
|
||||
|
||||
public class ExpressionSwitchEmbedding {
|
||||
|
@ -25,8 +25,8 @@
|
||||
* @test
|
||||
* @bug 8206986
|
||||
* @summary Check fall through in switch expressions.
|
||||
* @compile --enable-preview -source ${jdk.version} ExpressionSwitchFallThrough.java
|
||||
* @run main/othervm --enable-preview ExpressionSwitchFallThrough
|
||||
* @compile ExpressionSwitchFallThrough.java
|
||||
* @run main ExpressionSwitchFallThrough
|
||||
*/
|
||||
|
||||
import java.util.Objects;
|
||||
|
@ -25,8 +25,8 @@
|
||||
* @test
|
||||
* @bug 8206986
|
||||
* @summary Check fall through in switch expressions.
|
||||
* @compile --enable-preview -source ${jdk.version} ExpressionSwitchFallThrough1.java
|
||||
* @run main/othervm --enable-preview ExpressionSwitchFallThrough1
|
||||
* @compile ExpressionSwitchFallThrough1.java
|
||||
* @run main ExpressionSwitchFallThrough1
|
||||
*/
|
||||
|
||||
import java.util.Objects;
|
||||
|
@ -2,7 +2,7 @@
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8212982
|
||||
* @summary Verify a compile-time error is produced if switch expression does not provide a value
|
||||
* @compile/fail/ref=ExpressionSwitchFlow.out --enable-preview -source ${jdk.version} -XDrawDiagnostics ExpressionSwitchFlow.java
|
||||
* @compile/fail/ref=ExpressionSwitchFlow.out -XDrawDiagnostics ExpressionSwitchFlow.java
|
||||
*/
|
||||
|
||||
public class ExpressionSwitchFlow {
|
||||
|
@ -7,6 +7,4 @@ ExpressionSwitchFlow.java:45:25: compiler.err.rule.completes.normally
|
||||
ExpressionSwitchFlow.java:53:9: compiler.err.switch.expression.completes.normally
|
||||
ExpressionSwitchFlow.java:61:9: compiler.err.switch.expression.completes.normally
|
||||
ExpressionSwitchFlow.java:69:9: compiler.err.switch.expression.completes.normally
|
||||
- compiler.note.preview.filename: ExpressionSwitchFlow.java
|
||||
- compiler.note.preview.recompile
|
||||
9 errors
|
||||
|
@ -25,8 +25,8 @@
|
||||
* @test
|
||||
* @bug 8206986
|
||||
* @summary Check switch expressions embedded in switch expressions.
|
||||
* @compile --enable-preview -source ${jdk.version} ExpressionSwitchInExpressionSwitch.java
|
||||
* @run main/othervm --enable-preview ExpressionSwitchInExpressionSwitch
|
||||
* @compile ExpressionSwitchInExpressionSwitch.java
|
||||
* @run main ExpressionSwitchInExpressionSwitch
|
||||
*/
|
||||
|
||||
public class ExpressionSwitchInExpressionSwitch {
|
||||
|
@ -2,7 +2,7 @@
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8206986
|
||||
* @summary Check types inferred for switch expressions.
|
||||
* @compile/fail/ref=ExpressionSwitchInfer.out -XDrawDiagnostics --enable-preview -source ${jdk.version} ExpressionSwitchInfer.java
|
||||
* @compile/fail/ref=ExpressionSwitchInfer.out -XDrawDiagnostics ExpressionSwitchInfer.java
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -1,6 +1,4 @@
|
||||
ExpressionSwitchInfer.java:17:95: compiler.err.cant.resolve.location.args: kindname.method, substring, , int, (compiler.misc.location: kindname.interface, java.lang.CharSequence, null)
|
||||
ExpressionSwitchInfer.java:26:38: compiler.err.cant.resolve.location.args: kindname.method, substring, , int, (compiler.misc.location: kindname.interface, java.lang.CharSequence, null)
|
||||
ExpressionSwitchInfer.java:30:23: compiler.err.prob.found.req: (compiler.misc.incompatible.type.in.switch.expression: (compiler.misc.inconvertible.types: int, java.lang.String))
|
||||
- compiler.note.preview.filename: ExpressionSwitchInfer.java
|
||||
- compiler.note.preview.recompile
|
||||
3 errors
|
||||
|
@ -25,8 +25,8 @@
|
||||
* @test
|
||||
* @bug 8206986
|
||||
* @summary Verify behavior when an intersection type is inferred for switch expression.
|
||||
* @compile --enable-preview -source ${jdk.version} ExpressionSwitchIntersectionTypes.java
|
||||
* @run main/othervm --enable-preview ExpressionSwitchIntersectionTypes
|
||||
* @compile ExpressionSwitchIntersectionTypes.java
|
||||
* @run main ExpressionSwitchIntersectionTypes
|
||||
*/
|
||||
|
||||
public class ExpressionSwitchIntersectionTypes<X extends java.io.Serializable & Runnable> {
|
||||
|
@ -2,7 +2,7 @@
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8206986
|
||||
* @summary Verify behavior of not exhaustive switch expressions.
|
||||
* @compile/fail/ref=ExpressionSwitchNotExhaustive.out -XDrawDiagnostics --enable-preview -source ${jdk.version} ExpressionSwitchNotExhaustive.java
|
||||
* @compile/fail/ref=ExpressionSwitchNotExhaustive.out -XDrawDiagnostics ExpressionSwitchNotExhaustive.java
|
||||
*/
|
||||
|
||||
public class ExpressionSwitchNotExhaustive {
|
||||
|
@ -1,6 +1,4 @@
|
||||
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
|
||||
|
@ -99,7 +99,7 @@ public class ExpressionSwitchToString {
|
||||
String sourceVersion = Integer.toString(Runtime.version().feature());
|
||||
|
||||
JavacTask ct = (JavacTask) tool.getTask(null, null, noErrors,
|
||||
List.of("-XDdev", "--enable-preview", "-source", sourceVersion), null,
|
||||
List.of("-XDdev"), null,
|
||||
Arrays.asList(new MyFileObject(CODE)));
|
||||
String actualCode = ct.parse().iterator().next().toString();
|
||||
actualCode = actualCode.replace(System.getProperty("line.separator"), "\n");
|
||||
|
@ -2,7 +2,7 @@
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8206986
|
||||
* @summary Verify reachability in switch expressions.
|
||||
* @compile/fail/ref=ExpressionSwitchUnreachable.out -XDrawDiagnostics --enable-preview -source ${jdk.version} ExpressionSwitchUnreachable.java
|
||||
* @compile/fail/ref=ExpressionSwitchUnreachable.out -XDrawDiagnostics ExpressionSwitchUnreachable.java
|
||||
*/
|
||||
|
||||
public class ExpressionSwitchUnreachable {
|
||||
|
@ -4,6 +4,4 @@ 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
|
@ -26,7 +26,7 @@
|
||||
* @bug 8220041
|
||||
* @summary Verify variable capture works inside switch expressions which are
|
||||
* inside variable declarations
|
||||
* @compile --enable-preview -source ${jdk.version} LambdaCapture.java
|
||||
* @compile LambdaCapture.java
|
||||
*/
|
||||
|
||||
import java.util.Objects;
|
||||
|
@ -68,7 +68,7 @@ public class ParseIncomplete {
|
||||
StringWriter out = new StringWriter();
|
||||
try {
|
||||
JavacTask ct = (JavacTask) tool.getTask(out, null, noErrors,
|
||||
List.of("-XDdev", "--enable-preview", "-source", sourceVersion), null,
|
||||
List.of("-XDdev"), null,
|
||||
Arrays.asList(new MyFileObject(code)));
|
||||
ct.parse().iterator().next();
|
||||
} catch (Throwable t) {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user