8219254: Update explicit uses of latest source/target in langtools tests to a property
8219256: Update javac diags tests to use properties Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com> Reviewed-by: jjg, jlahoda, darcy, iignatyev
This commit is contained in:
parent
86e513bd48
commit
bf2d27c5a4
test/langtools
TEST.ROOT
tools/javac
6330997
ConditionalWithVoid.javadiags
Example.java
examples
BreakAmbiguousTarget.javaBreakExprNotImmediate.javaBreakMissingValue.javaBreakOutsideSwitchExpression.javaContinueOutsideSwitchExpression.javaIncompatibleTypesInSwitchExpression.javaMultipleCaseLabels.javaNotExhaustive.javaPreviewFeatureUse.javaPreviewFilename.javaPreviewFilenameAdditional.java
PreviewPlural
ReturnOutsideSwitchExpression.javaRuleCompletesNormally.javaSwitchCaseUnexpectedStatement.javaSwitchExpressionCompletesNormally.javaSwitchExpressionEmpty.javaSwitchExpressionTargetCantBeVoid.javaSwitchExpressions.javaSwitchMixingCaseTypes.javaSwitchRules.javaexpswitch
lambda
parser
preview/classReaderTest
switchexpr
BlockExpression.javaBooleanNumericNonNumeric.javaBreakTest.javaCRT.javaDefiniteAssignment1.javaDefiniteAssignment2.javaEmptySwitch.javaExhaustiveEnumSwitch.javaExpressionSwitch.javaExpressionSwitchBreaks1.javaExpressionSwitchBreaks2.javaExpressionSwitchBugs.javaExpressionSwitchBugsInGen.javaExpressionSwitchCodeFromJLS.javaExpressionSwitchDA.javaExpressionSwitchEmbedding.javaExpressionSwitchFallThrough.javaExpressionSwitchFallThrough1.javaExpressionSwitchFlow.javaExpressionSwitchInExpressionSwitch.javaExpressionSwitchInfer.javaExpressionSwitchIntersectionTypes.javaExpressionSwitchNotExhaustive.javaExpressionSwitchUnreachable.javaParseIncomplete.javaParserRecovery.javaSwitchExpressionIsNotAConstant.javaSwitchExpressionScopesIsolated.javaSwitchExpressionSimpleVisitorTest.javaTryCatch.java
switchextra
@ -15,7 +15,7 @@ keys=intermittent randomness
|
|||||||
groups=TEST.groups
|
groups=TEST.groups
|
||||||
|
|
||||||
# Minimum jtreg version
|
# Minimum jtreg version
|
||||||
requiredVersion=4.2 b13
|
requiredVersion=4.2 b14
|
||||||
|
|
||||||
# Use new module options
|
# Use new module options
|
||||||
useNewOptions=true
|
useNewOptions=true
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2006, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -32,8 +32,8 @@
|
|||||||
* jdk.compiler/com.sun.tools.javac.main
|
* jdk.compiler/com.sun.tools.javac.main
|
||||||
* jdk.compiler/com.sun.tools.javac.util
|
* jdk.compiler/com.sun.tools.javac.util
|
||||||
* @clean T1 T2
|
* @clean T1 T2
|
||||||
* @compile -source 12 -target 13 T1.java
|
* @compile T1.java
|
||||||
* @compile -source 12 -target 13 T2.java
|
* @compile T2.java
|
||||||
* @run main/othervm T6330997
|
* @run main/othervm T6330997
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* @summary The compiler was allowing void types in its parsing of conditional expressions.
|
* @summary The compiler was allowing void types in its parsing of conditional expressions.
|
||||||
* @author tball
|
* @author tball
|
||||||
*
|
*
|
||||||
* @compile/fail/ref=ConditionalWithVoid.out --enable-preview -source 13 -XDrawDiagnostics ConditionalWithVoid.java
|
* @compile/fail/ref=ConditionalWithVoid.out --enable-preview -source ${jdk.version} -XDrawDiagnostics ConditionalWithVoid.java
|
||||||
*/
|
*/
|
||||||
public class ConditionalWithVoid {
|
public class ConditionalWithVoid {
|
||||||
public void test(Object o, String s) {
|
public void test(Object o, String s) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -288,7 +288,7 @@ class Example implements Comparable<Example> {
|
|||||||
opts.add("-d");
|
opts.add("-d");
|
||||||
opts.add(classesDir.getPath());
|
opts.add(classesDir.getPath());
|
||||||
if (options != null)
|
if (options != null)
|
||||||
opts.addAll(options);
|
opts.addAll(evalProperties(options));
|
||||||
|
|
||||||
if (procFiles.size() > 0) {
|
if (procFiles.size() > 0) {
|
||||||
List<String> pOpts = new ArrayList<>(Arrays.asList("-d", classesDir.getPath()));
|
List<String> pOpts = new ArrayList<>(Arrays.asList("-d", classesDir.getPath()));
|
||||||
@ -355,6 +355,51 @@ class Example implements Comparable<Example> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static List<String> evalProperties(List<String> args) {
|
||||||
|
boolean fast = true;
|
||||||
|
for (String arg : args) {
|
||||||
|
fast = fast && (arg.indexOf("${") == -1);
|
||||||
|
}
|
||||||
|
if (fast) {
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
List<String> newArgs = new ArrayList<>();
|
||||||
|
for (String arg : args) {
|
||||||
|
newArgs.add(evalProperties(arg));
|
||||||
|
}
|
||||||
|
return newArgs;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final Pattern namePattern = Pattern.compile("\\$\\{([A-Za-z0-9._]+)\\}");
|
||||||
|
private static final String jdkVersion = Integer.toString(Runtime.version().feature());
|
||||||
|
|
||||||
|
private static String evalProperties(String arg) {
|
||||||
|
Matcher m = namePattern.matcher(arg);
|
||||||
|
StringBuilder sb = null;
|
||||||
|
while (m.find()) {
|
||||||
|
if (sb == null) {
|
||||||
|
sb = new StringBuilder();
|
||||||
|
}
|
||||||
|
String propName = m.group(1);
|
||||||
|
String propValue;
|
||||||
|
switch (propName) {
|
||||||
|
case "jdk.version":
|
||||||
|
propValue = jdkVersion;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
propValue = System.getProperty(propName);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
m.appendReplacement(sb, propValue != null ? propValue : m.group(0).replace("$", "\\$"));
|
||||||
|
}
|
||||||
|
if (sb == null) {
|
||||||
|
return arg;
|
||||||
|
} else {
|
||||||
|
m.appendTail(sb);
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void createAnnotationServicesFile(File dir, List<File> procFiles) throws IOException {
|
void createAnnotationServicesFile(File dir, List<File> procFiles) throws IOException {
|
||||||
File servicesDir = new File(new File(dir, "META-INF"), "services");
|
File servicesDir = new File(new File(dir, "META-INF"), "services");
|
||||||
servicesDir.mkdirs();
|
servicesDir.mkdirs();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -24,7 +24,7 @@
|
|||||||
// key: compiler.err.break.ambiguous.target
|
// key: compiler.err.break.ambiguous.target
|
||||||
// key: compiler.note.preview.filename
|
// key: compiler.note.preview.filename
|
||||||
// key: compiler.note.preview.recompile
|
// key: compiler.note.preview.recompile
|
||||||
// options: --enable-preview -source 13
|
// options: --enable-preview -source ${jdk.version}
|
||||||
|
|
||||||
class BreakAmbiguousTarget {
|
class BreakAmbiguousTarget {
|
||||||
void m(int i, int j) {
|
void m(int i, int j) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -33,7 +33,7 @@
|
|||||||
// key: compiler.note.preview.filename
|
// key: compiler.note.preview.filename
|
||||||
// key: compiler.note.preview.recompile
|
// key: compiler.note.preview.recompile
|
||||||
// key: compiler.note.note
|
// key: compiler.note.note
|
||||||
// options: --enable-preview -source 13
|
// options: --enable-preview -source ${jdk.version}
|
||||||
// run: backdoor
|
// run: backdoor
|
||||||
|
|
||||||
class BreakExprNotImmediate {
|
class BreakExprNotImmediate {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -24,7 +24,7 @@
|
|||||||
// key: compiler.err.break.missing.value
|
// key: compiler.err.break.missing.value
|
||||||
// key: compiler.note.preview.filename
|
// key: compiler.note.preview.filename
|
||||||
// key: compiler.note.preview.recompile
|
// key: compiler.note.preview.recompile
|
||||||
// options: --enable-preview -source 13
|
// options: --enable-preview -source ${jdk.version}
|
||||||
|
|
||||||
class BreakMissingValue {
|
class BreakMissingValue {
|
||||||
int t(int i) {
|
int t(int i) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -24,7 +24,7 @@
|
|||||||
// key: compiler.err.break.outside.switch.expression
|
// key: compiler.err.break.outside.switch.expression
|
||||||
// key: compiler.note.preview.filename
|
// key: compiler.note.preview.filename
|
||||||
// key: compiler.note.preview.recompile
|
// key: compiler.note.preview.recompile
|
||||||
// options: --enable-preview -source 13
|
// options: --enable-preview -source ${jdk.version}
|
||||||
|
|
||||||
class BreakOutsideSwitchExpression {
|
class BreakOutsideSwitchExpression {
|
||||||
int t(int i) {
|
int t(int i) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -24,7 +24,7 @@
|
|||||||
// key: compiler.err.continue.outside.switch.expression
|
// key: compiler.err.continue.outside.switch.expression
|
||||||
// key: compiler.note.preview.filename
|
// key: compiler.note.preview.filename
|
||||||
// key: compiler.note.preview.recompile
|
// key: compiler.note.preview.recompile
|
||||||
// options: --enable-preview -source 13
|
// options: --enable-preview -source ${jdk.version}
|
||||||
|
|
||||||
class ContinueOutsideSwitchExpression {
|
class ContinueOutsideSwitchExpression {
|
||||||
int t(int i) {
|
int t(int i) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -26,7 +26,7 @@
|
|||||||
// key: compiler.misc.inconvertible.types
|
// key: compiler.misc.inconvertible.types
|
||||||
// key: compiler.note.preview.filename
|
// key: compiler.note.preview.filename
|
||||||
// key: compiler.note.preview.recompile
|
// key: compiler.note.preview.recompile
|
||||||
// options: --enable-preview -source 13
|
// options: --enable-preview -source ${jdk.version}
|
||||||
|
|
||||||
|
|
||||||
class IncompatibleTypesInSwitchExpression {
|
class IncompatibleTypesInSwitchExpression {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
// key: compiler.misc.feature.multiple.case.labels
|
// key: compiler.misc.feature.multiple.case.labels
|
||||||
// key: compiler.warn.preview.feature.use.plural
|
// key: compiler.warn.preview.feature.use.plural
|
||||||
// options: --enable-preview -source 13 -Xlint:preview
|
// options: --enable-preview -source ${jdk.version} -Xlint:preview
|
||||||
|
|
||||||
class MultipleCaseLabels {
|
class MultipleCaseLabels {
|
||||||
void m(int i) {
|
void m(int i) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -24,7 +24,7 @@
|
|||||||
// key: compiler.err.not.exhaustive
|
// key: compiler.err.not.exhaustive
|
||||||
// key: compiler.note.preview.filename
|
// key: compiler.note.preview.filename
|
||||||
// key: compiler.note.preview.recompile
|
// key: compiler.note.preview.recompile
|
||||||
// options: --enable-preview -source 13
|
// options: --enable-preview -source ${jdk.version}
|
||||||
|
|
||||||
class NotExhaustive {
|
class NotExhaustive {
|
||||||
int t(int i) {
|
int t(int i) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -25,7 +25,7 @@
|
|||||||
//key: compiler.warn.preview.feature.use.plural
|
//key: compiler.warn.preview.feature.use.plural
|
||||||
//key: compiler.misc.feature.diamond
|
//key: compiler.misc.feature.diamond
|
||||||
//key: compiler.misc.feature.lambda
|
//key: compiler.misc.feature.lambda
|
||||||
//options: -Xlint:preview -XDforcePreview -source 13 --enable-preview
|
//options: -Xlint:preview -XDforcePreview -source ${jdk.version} --enable-preview
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
// key: compiler.note.preview.filename
|
// key: compiler.note.preview.filename
|
||||||
// key: compiler.note.preview.recompile
|
// key: compiler.note.preview.recompile
|
||||||
// options: -XDforcePreview -source 13 --enable-preview
|
// options: -XDforcePreview -source ${jdk.version} --enable-preview
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -24,7 +24,7 @@
|
|||||||
// key: compiler.note.preview.filename.additional
|
// key: compiler.note.preview.filename.additional
|
||||||
// key: compiler.warn.preview.feature.use
|
// key: compiler.warn.preview.feature.use
|
||||||
// key: compiler.misc.feature.diamond
|
// key: compiler.misc.feature.diamond
|
||||||
// options: -Xlint:preview -Xmaxwarns 1 -XDforcePreview -source 13 --enable-preview
|
// options: -Xlint:preview -Xmaxwarns 1 -XDforcePreview -source ${jdk.version} --enable-preview
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
// key: compiler.note.preview.plural
|
// key: compiler.note.preview.plural
|
||||||
// key: compiler.note.preview.recompile
|
// key: compiler.note.preview.recompile
|
||||||
// options: -XDforcePreview -source 13 --enable-preview
|
// options: -XDforcePreview -source ${jdk.version} --enable-preview
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -24,7 +24,7 @@
|
|||||||
// key: compiler.err.return.outside.switch.expression
|
// key: compiler.err.return.outside.switch.expression
|
||||||
// key: compiler.note.preview.filename
|
// key: compiler.note.preview.filename
|
||||||
// key: compiler.note.preview.recompile
|
// key: compiler.note.preview.recompile
|
||||||
// options: --enable-preview -source 13
|
// options: --enable-preview -source ${jdk.version}
|
||||||
|
|
||||||
class ReturnOutsideSwitchExpression {
|
class ReturnOutsideSwitchExpression {
|
||||||
int t(int i) {
|
int t(int i) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -24,7 +24,7 @@
|
|||||||
// key: compiler.err.rule.completes.normally
|
// key: compiler.err.rule.completes.normally
|
||||||
// key: compiler.note.preview.filename
|
// key: compiler.note.preview.filename
|
||||||
// key: compiler.note.preview.recompile
|
// key: compiler.note.preview.recompile
|
||||||
// options: --enable-preview -source 13
|
// options: --enable-preview -source ${jdk.version}
|
||||||
|
|
||||||
class RuleCompletesNormally {
|
class RuleCompletesNormally {
|
||||||
public String convert(int i) {
|
public String convert(int i) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -24,7 +24,7 @@
|
|||||||
// key: compiler.err.switch.case.unexpected.statement
|
// key: compiler.err.switch.case.unexpected.statement
|
||||||
// key: compiler.note.preview.filename
|
// key: compiler.note.preview.filename
|
||||||
// key: compiler.note.preview.recompile
|
// key: compiler.note.preview.recompile
|
||||||
// options: --enable-preview -source 13
|
// options: --enable-preview -source ${jdk.version}
|
||||||
|
|
||||||
class ReturnOutsideSwitchExpression {
|
class ReturnOutsideSwitchExpression {
|
||||||
void t(int i) {
|
void t(int i) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -24,7 +24,7 @@
|
|||||||
// key: compiler.err.switch.expression.completes.normally
|
// key: compiler.err.switch.expression.completes.normally
|
||||||
// key: compiler.note.preview.filename
|
// key: compiler.note.preview.filename
|
||||||
// key: compiler.note.preview.recompile
|
// key: compiler.note.preview.recompile
|
||||||
// options: --enable-preview -source 13
|
// options: --enable-preview -source ${jdk.version}
|
||||||
|
|
||||||
class SwitchExpressionCompletesNormally {
|
class SwitchExpressionCompletesNormally {
|
||||||
public String convert(int i) {
|
public String convert(int i) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -24,7 +24,7 @@
|
|||||||
// key: compiler.err.switch.expression.empty
|
// key: compiler.err.switch.expression.empty
|
||||||
// key: compiler.note.preview.filename
|
// key: compiler.note.preview.filename
|
||||||
// key: compiler.note.preview.recompile
|
// key: compiler.note.preview.recompile
|
||||||
// options: --enable-preview -source 13
|
// options: --enable-preview -source ${jdk.version}
|
||||||
|
|
||||||
class BreakOutsideSwitchExpression {
|
class BreakOutsideSwitchExpression {
|
||||||
String t(E e) {
|
String t(E e) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -26,7 +26,7 @@
|
|||||||
// key: compiler.misc.switch.expression.target.cant.be.void
|
// key: compiler.misc.switch.expression.target.cant.be.void
|
||||||
// key: compiler.note.preview.filename
|
// key: compiler.note.preview.filename
|
||||||
// key: compiler.note.preview.recompile
|
// key: compiler.note.preview.recompile
|
||||||
// options: --enable-preview -source 13
|
// options: --enable-preview -source ${jdk.version}
|
||||||
|
|
||||||
class SwitchExpressionTargetCantBeVoid {
|
class SwitchExpressionTargetCantBeVoid {
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
// key: compiler.misc.feature.switch.expressions
|
// key: compiler.misc.feature.switch.expressions
|
||||||
// key: compiler.warn.preview.feature.use.plural
|
// key: compiler.warn.preview.feature.use.plural
|
||||||
// options: --enable-preview -source 13 -Xlint:preview
|
// options: --enable-preview -source ${jdk.version} -Xlint:preview
|
||||||
|
|
||||||
class SwitchExpressions {
|
class SwitchExpressions {
|
||||||
int m(int i) {
|
int m(int i) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -24,7 +24,7 @@
|
|||||||
// key: compiler.err.switch.mixing.case.types
|
// key: compiler.err.switch.mixing.case.types
|
||||||
// key: compiler.note.preview.filename
|
// key: compiler.note.preview.filename
|
||||||
// key: compiler.note.preview.recompile
|
// key: compiler.note.preview.recompile
|
||||||
// options: --enable-preview -source 13
|
// options: --enable-preview -source ${jdk.version}
|
||||||
|
|
||||||
class SwitchMixingCaseTypes {
|
class SwitchMixingCaseTypes {
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
// key: compiler.misc.feature.switch.rules
|
// key: compiler.misc.feature.switch.rules
|
||||||
// key: compiler.warn.preview.feature.use.plural
|
// key: compiler.warn.preview.feature.use.plural
|
||||||
// options: --enable-preview -source 13 -Xlint:preview
|
// options: --enable-preview -source ${jdk.version} -Xlint:preview
|
||||||
|
|
||||||
class SwitchExpressions {
|
class SwitchExpressions {
|
||||||
void m(int i) {
|
void m(int i) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -75,7 +75,8 @@ public class ExpSwitchNestingTest extends JavacTemplateTestBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String[] PREVIEW_OPTIONS = {"--enable-preview", "-source", "13"};
|
private static String[] PREVIEW_OPTIONS = {"--enable-preview", "-source",
|
||||||
|
Integer.toString(Runtime.version().feature())};
|
||||||
|
|
||||||
private void program(String... constructs) {
|
private void program(String... constructs) {
|
||||||
String s = "class C { static boolean cond = false; static int x = 0; void m() { # } }";
|
String s = "class C { static boolean cond = false; static int x = 0; void m() { # } }";
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @test /nodynamiccopyright/
|
* @test /nodynamiccopyright/
|
||||||
* @bug 8206986
|
* @bug 8206986
|
||||||
* @summary Adding switch expressions
|
* @summary Adding switch expressions
|
||||||
* @compile/fail/ref=BadSwitchExpressionLambda.out -XDrawDiagnostics --enable-preview -source 13 BadSwitchExpressionLambda.java
|
* @compile/fail/ref=BadSwitchExpressionLambda.out -XDrawDiagnostics --enable-preview -source ${jdk.version} BadSwitchExpressionLambda.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class BadSwitchExpressionLambda {
|
class BadSwitchExpressionLambda {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -88,14 +88,14 @@ import com.sun.source.util.TreePathScanner;
|
|||||||
public class JavacParserTest extends TestCase {
|
public class JavacParserTest extends TestCase {
|
||||||
static final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
|
static final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
|
||||||
static final JavaFileManager fm = tool.getStandardFileManager(null, null, null);
|
static final JavaFileManager fm = tool.getStandardFileManager(null, null, null);
|
||||||
|
public static final String SOURCE_VERSION =
|
||||||
|
Integer.toString(Runtime.version().feature());
|
||||||
|
|
||||||
private JavacParserTest(){}
|
private JavacParserTest(){}
|
||||||
|
|
||||||
public static void main(String... args) throws Exception {
|
public static void main(String... args) throws Exception {
|
||||||
try {
|
try (fm) {
|
||||||
new JavacParserTest().run(args);
|
new JavacParserTest().run(args);
|
||||||
} finally {
|
|
||||||
fm.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1096,7 +1096,7 @@ public class JavacParserTest extends TestCase {
|
|||||||
String expectedErrors = "Test.java:1:178: compiler.err.switch.case.unexpected.statement\n";
|
String expectedErrors = "Test.java:1:178: compiler.err.switch.case.unexpected.statement\n";
|
||||||
StringWriter out = new StringWriter();
|
StringWriter out = new StringWriter();
|
||||||
JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(out, fm, null,
|
JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(out, fm, null,
|
||||||
Arrays.asList("-XDrawDiagnostics", "--enable-preview", "-source", "13"),
|
Arrays.asList("-XDrawDiagnostics", "--enable-preview", "-source", SOURCE_VERSION),
|
||||||
null, Arrays.asList(new MyFileObject(code)));
|
null, Arrays.asList(new MyFileObject(code)));
|
||||||
|
|
||||||
CompilationUnitTree cut = ct.parse().iterator().next();
|
CompilationUnitTree cut = ct.parse().iterator().next();
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
* @test /nodynamiccopyright/
|
* @test /nodynamiccopyright/
|
||||||
* @bug 8199194
|
* @bug 8199194
|
||||||
* @summary smoke test for --enabled-preview classreader support
|
* @summary smoke test for --enabled-preview classreader support
|
||||||
* @compile -XDforcePreview --enable-preview -source 13 Bar.java
|
* @compile -XDforcePreview --enable-preview -source ${jdk.version} Bar.java
|
||||||
* @compile/fail/ref=Client.nopreview.out -Xlint:preview -XDrawDiagnostics Client.java
|
* @compile/fail/ref=Client.nopreview.out -Xlint:preview -XDrawDiagnostics Client.java
|
||||||
* @compile/fail/ref=Client.preview.out -Werror -Xlint:preview -XDrawDiagnostics --enable-preview -source 13 Client.java
|
* @compile/fail/ref=Client.preview.out -Werror -Xlint:preview -XDrawDiagnostics --enable-preview -source ${jdk.version} Client.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Client {
|
public class Client {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -25,7 +25,7 @@
|
|||||||
* @test
|
* @test
|
||||||
* @bug 8206986
|
* @bug 8206986
|
||||||
* @summary Verify rule cases with expression statements and throw statements work.
|
* @summary Verify rule cases with expression statements and throw statements work.
|
||||||
* @compile --enable-preview -source 13 BlockExpression.java
|
* @compile --enable-preview -source ${jdk.version} BlockExpression.java
|
||||||
* @run main/othervm --enable-preview BlockExpression
|
* @run main/othervm --enable-preview BlockExpression
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @test /nodynamiccopyright/
|
* @test /nodynamiccopyright/
|
||||||
* @bug 8206986
|
* @bug 8206986
|
||||||
* @summary Verify the type of a conditional expression with nested switch expression is computed properly
|
* @summary Verify the type of a conditional expression with nested switch expression is computed properly
|
||||||
* @compile/fail/ref=BooleanNumericNonNumeric.out -XDrawDiagnostics --enable-preview -source 13 BooleanNumericNonNumeric.java
|
* @compile/fail/ref=BooleanNumericNonNumeric.out -XDrawDiagnostics --enable-preview -source ${jdk.version} BooleanNumericNonNumeric.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class BooleanNumericNonNumeric {
|
public class BooleanNumericNonNumeric {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -61,12 +61,13 @@ public class BreakTest {
|
|||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
|
final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
|
||||||
|
String sourceVersion = Integer.toString(Runtime.version().feature());
|
||||||
assert tool != null;
|
assert tool != null;
|
||||||
DiagnosticListener<JavaFileObject> noErrors = d -> {};
|
DiagnosticListener<JavaFileObject> noErrors = d -> {};
|
||||||
|
|
||||||
StringWriter out = new StringWriter();
|
StringWriter out = new StringWriter();
|
||||||
JavacTask ct = (JavacTask) tool.getTask(out, null, noErrors,
|
JavacTask ct = (JavacTask) tool.getTask(out, null, noErrors,
|
||||||
List.of("-XDdev", "--enable-preview", "-source", "13"), null,
|
List.of("-XDdev", "--enable-preview", "-source", sourceVersion), null,
|
||||||
Arrays.asList(new MyFileObject(CODE)));
|
Arrays.asList(new MyFileObject(CODE)));
|
||||||
List<String> labels = new ArrayList<>();
|
List<String> labels = new ArrayList<>();
|
||||||
new TreePathScanner<Void, Void>() {
|
new TreePathScanner<Void, Void>() {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -48,6 +48,8 @@ public class CRT {
|
|||||||
new CRT().run();
|
new CRT().run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final String SOURCE_VERSION = Integer.toString(Runtime.version().feature());
|
||||||
|
|
||||||
private ToolBox tb = new ToolBox();
|
private ToolBox tb = new ToolBox();
|
||||||
|
|
||||||
private void run() throws Exception {
|
private void run() throws Exception {
|
||||||
@ -151,7 +153,7 @@ public class CRT {
|
|||||||
new JavacTask(tb)
|
new JavacTask(tb)
|
||||||
.options("-Xjcov",
|
.options("-Xjcov",
|
||||||
"--enable-preview",
|
"--enable-preview",
|
||||||
"-source", "13")
|
"-source", SOURCE_VERSION)
|
||||||
.outdir(classes)
|
.outdir(classes)
|
||||||
.sources("public class Test {\n" +
|
.sources("public class Test {\n" +
|
||||||
code +
|
code +
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -25,7 +25,7 @@
|
|||||||
* @test
|
* @test
|
||||||
* @bug 8214031
|
* @bug 8214031
|
||||||
* @summary Verify that definite assignment when true works (legal code)
|
* @summary Verify that definite assignment when true works (legal code)
|
||||||
* @compile --enable-preview --source 13 DefiniteAssignment1.java
|
* @compile --enable-preview --source ${jdk.version} DefiniteAssignment1.java
|
||||||
* @run main/othervm --enable-preview DefiniteAssignment1
|
* @run main/othervm --enable-preview DefiniteAssignment1
|
||||||
*/
|
*/
|
||||||
public class DefiniteAssignment1 {
|
public class DefiniteAssignment1 {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @test /nodynamiccopyright/
|
* @test /nodynamiccopyright/
|
||||||
* @bug 8214031
|
* @bug 8214031
|
||||||
* @summary Verify that definite assignment when true works (illegal code)
|
* @summary Verify that definite assignment when true works (illegal code)
|
||||||
* @compile/fail/ref=DefiniteAssignment2.out --enable-preview --source 13 -XDrawDiagnostics DefiniteAssignment2.java
|
* @compile/fail/ref=DefiniteAssignment2.out --enable-preview --source ${jdk.version} -XDrawDiagnostics DefiniteAssignment2.java
|
||||||
*/
|
*/
|
||||||
public class DefiniteAssignment2 {
|
public class DefiniteAssignment2 {
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -25,7 +25,7 @@
|
|||||||
* @test
|
* @test
|
||||||
* @bug 8206986
|
* @bug 8206986
|
||||||
* @summary Verify than an empty switch expression is rejected.
|
* @summary Verify than an empty switch expression is rejected.
|
||||||
* @compile/fail/ref=EmptySwitch.out --enable-preview -source 13 -XDrawDiagnostics EmptySwitch.java
|
* @compile/fail/ref=EmptySwitch.out --enable-preview -source ${jdk.version} -XDrawDiagnostics EmptySwitch.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class EmptySwitch {
|
public class EmptySwitch {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -25,7 +25,7 @@
|
|||||||
* @test
|
* @test
|
||||||
* @bug 8206986
|
* @bug 8206986
|
||||||
* @summary Verify that an switch expression over enum can be exhaustive without default.
|
* @summary Verify that an switch expression over enum can be exhaustive without default.
|
||||||
* @compile --enable-preview -source 13 ExhaustiveEnumSwitch.java
|
* @compile --enable-preview -source ${jdk.version} ExhaustiveEnumSwitch.java
|
||||||
* @compile ExhaustiveEnumSwitchExtra.java
|
* @compile ExhaustiveEnumSwitchExtra.java
|
||||||
* @run main/othervm --enable-preview ExhaustiveEnumSwitch
|
* @run main/othervm --enable-preview ExhaustiveEnumSwitch
|
||||||
*/
|
*/
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* @bug 8206986
|
* @bug 8206986
|
||||||
* @summary Check expression switch works.
|
* @summary Check expression switch works.
|
||||||
* @compile/fail/ref=ExpressionSwitch-old.out -source 9 -Xlint:-options -XDrawDiagnostics ExpressionSwitch.java
|
* @compile/fail/ref=ExpressionSwitch-old.out -source 9 -Xlint:-options -XDrawDiagnostics ExpressionSwitch.java
|
||||||
* @compile --enable-preview -source 13 ExpressionSwitch.java
|
* @compile --enable-preview -source ${jdk.version} ExpressionSwitch.java
|
||||||
* @run main/othervm --enable-preview ExpressionSwitch
|
* @run main/othervm --enable-preview ExpressionSwitch
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -25,7 +25,7 @@
|
|||||||
* @test
|
* @test
|
||||||
* @bug 8206986
|
* @bug 8206986
|
||||||
* @summary Verify behavior of various kinds of breaks.
|
* @summary Verify behavior of various kinds of breaks.
|
||||||
* @compile --enable-preview -source 13 ExpressionSwitchBreaks1.java
|
* @compile --enable-preview -source ${jdk.version} ExpressionSwitchBreaks1.java
|
||||||
* @run main/othervm --enable-preview ExpressionSwitchBreaks1
|
* @run main/othervm --enable-preview ExpressionSwitchBreaks1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @test /nodynamiccopyright/
|
* @test /nodynamiccopyright/
|
||||||
* @bug 8206986
|
* @bug 8206986
|
||||||
* @summary Check behavior for invalid breaks.
|
* @summary Check behavior for invalid breaks.
|
||||||
* @compile/fail/ref=ExpressionSwitchBreaks2.out -XDrawDiagnostics --enable-preview -source 13 ExpressionSwitchBreaks2.java
|
* @compile/fail/ref=ExpressionSwitchBreaks2.out -XDrawDiagnostics --enable-preview -source ${jdk.version} ExpressionSwitchBreaks2.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ExpressionSwitchBreaks2 {
|
public class ExpressionSwitchBreaks2 {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -25,7 +25,7 @@
|
|||||||
* @test
|
* @test
|
||||||
* @bug 8206986 8214114 8214529
|
* @bug 8206986 8214114 8214529
|
||||||
* @summary Verify various corner cases with nested switch expressions.
|
* @summary Verify various corner cases with nested switch expressions.
|
||||||
* @compile --enable-preview -source 13 ExpressionSwitchBugs.java
|
* @compile --enable-preview -source ${jdk.version} ExpressionSwitchBugs.java
|
||||||
* @run main/othervm --enable-preview ExpressionSwitchBugs
|
* @run main/othervm --enable-preview ExpressionSwitchBugs
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -25,7 +25,7 @@
|
|||||||
* @test
|
* @test
|
||||||
* @bug 8214031
|
* @bug 8214031
|
||||||
* @summary Verify various corner cases with nested switch expressions.
|
* @summary Verify various corner cases with nested switch expressions.
|
||||||
* @compile --enable-preview -source 13 ExpressionSwitchBugsInGen.java
|
* @compile --enable-preview -source ${jdk.version} ExpressionSwitchBugsInGen.java
|
||||||
* @run main/othervm --enable-preview ExpressionSwitchBugsInGen
|
* @run main/othervm --enable-preview ExpressionSwitchBugsInGen
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -25,7 +25,7 @@
|
|||||||
* @test
|
* @test
|
||||||
* @bug 8206986
|
* @bug 8206986
|
||||||
* @summary Check switch expressions
|
* @summary Check switch expressions
|
||||||
* @compile --enable-preview -source 13 ExpressionSwitchCodeFromJLS.java
|
* @compile --enable-preview -source ${jdk.version} ExpressionSwitchCodeFromJLS.java
|
||||||
* @run main/othervm --enable-preview ExpressionSwitchCodeFromJLS
|
* @run main/othervm --enable-preview ExpressionSwitchCodeFromJLS
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -25,7 +25,7 @@
|
|||||||
* @test
|
* @test
|
||||||
* @bug 8206986
|
* @bug 8206986
|
||||||
* @summary Check definite (un)assignment for in switch expressions.
|
* @summary Check definite (un)assignment for in switch expressions.
|
||||||
* @compile --enable-preview -source 13 ExpressionSwitchDA.java
|
* @compile --enable-preview -source ${jdk.version} ExpressionSwitchDA.java
|
||||||
* @run main/othervm --enable-preview ExpressionSwitchDA
|
* @run main/othervm --enable-preview ExpressionSwitchDA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -25,7 +25,7 @@
|
|||||||
* @test
|
* @test
|
||||||
* @bug 8214031 8214114
|
* @bug 8214031 8214114
|
||||||
* @summary Verify switch expressions embedded in various statements work properly.
|
* @summary Verify switch expressions embedded in various statements work properly.
|
||||||
* @compile --enable-preview -source 13 ExpressionSwitchEmbedding.java
|
* @compile --enable-preview -source ${jdk.version} ExpressionSwitchEmbedding.java
|
||||||
* @run main/othervm --enable-preview ExpressionSwitchEmbedding
|
* @run main/othervm --enable-preview ExpressionSwitchEmbedding
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -25,7 +25,7 @@
|
|||||||
* @test
|
* @test
|
||||||
* @bug 8206986
|
* @bug 8206986
|
||||||
* @summary Check fall through in switch expressions.
|
* @summary Check fall through in switch expressions.
|
||||||
* @compile --enable-preview -source 13 ExpressionSwitchFallThrough.java
|
* @compile --enable-preview -source ${jdk.version} ExpressionSwitchFallThrough.java
|
||||||
* @run main/othervm --enable-preview ExpressionSwitchFallThrough
|
* @run main/othervm --enable-preview ExpressionSwitchFallThrough
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -25,7 +25,7 @@
|
|||||||
* @test
|
* @test
|
||||||
* @bug 8206986
|
* @bug 8206986
|
||||||
* @summary Check fall through in switch expressions.
|
* @summary Check fall through in switch expressions.
|
||||||
* @compile --enable-preview -source 13 ExpressionSwitchFallThrough1.java
|
* @compile --enable-preview -source ${jdk.version} ExpressionSwitchFallThrough1.java
|
||||||
* @run main/othervm --enable-preview ExpressionSwitchFallThrough1
|
* @run main/othervm --enable-preview ExpressionSwitchFallThrough1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @test /nodynamiccopyright/
|
* @test /nodynamiccopyright/
|
||||||
* @bug 8212982
|
* @bug 8212982
|
||||||
* @summary Verify a compile-time error is produced if switch expression does not provide a value
|
* @summary Verify a compile-time error is produced if switch expression does not provide a value
|
||||||
* @compile/fail/ref=ExpressionSwitchFlow.out --enable-preview -source 13 -XDrawDiagnostics ExpressionSwitchFlow.java
|
* @compile/fail/ref=ExpressionSwitchFlow.out --enable-preview -source ${jdk.version} -XDrawDiagnostics ExpressionSwitchFlow.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ExpressionSwitchFlow {
|
public class ExpressionSwitchFlow {
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
* @test
|
* @test
|
||||||
* @bug 8206986
|
* @bug 8206986
|
||||||
* @summary Check switch expressions embedded in switch expressions.
|
* @summary Check switch expressions embedded in switch expressions.
|
||||||
* @compile --enable-preview -source 13 ExpressionSwitchInExpressionSwitch.java
|
* @compile --enable-preview -source ${jdk.version} ExpressionSwitchInExpressionSwitch.java
|
||||||
* @run main/othervm --enable-preview ExpressionSwitchInExpressionSwitch
|
* @run main/othervm --enable-preview ExpressionSwitchInExpressionSwitch
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @test /nodynamiccopyright/
|
* @test /nodynamiccopyright/
|
||||||
* @bug 8206986
|
* @bug 8206986
|
||||||
* @summary Check types inferred for switch expressions.
|
* @summary Check types inferred for switch expressions.
|
||||||
* @compile/fail/ref=ExpressionSwitchInfer.out -XDrawDiagnostics --enable-preview -source 13 ExpressionSwitchInfer.java
|
* @compile/fail/ref=ExpressionSwitchInfer.out -XDrawDiagnostics --enable-preview -source ${jdk.version} ExpressionSwitchInfer.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -25,7 +25,7 @@
|
|||||||
* @test
|
* @test
|
||||||
* @bug 8206986
|
* @bug 8206986
|
||||||
* @summary Verify behavior when an intersection type is inferred for switch expression.
|
* @summary Verify behavior when an intersection type is inferred for switch expression.
|
||||||
* @compile --enable-preview -source 13 ExpressionSwitchIntersectionTypes.java
|
* @compile --enable-preview -source ${jdk.version} ExpressionSwitchIntersectionTypes.java
|
||||||
* @run main/othervm --enable-preview ExpressionSwitchIntersectionTypes
|
* @run main/othervm --enable-preview ExpressionSwitchIntersectionTypes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @test /nodynamiccopyright/
|
* @test /nodynamiccopyright/
|
||||||
* @bug 8206986
|
* @bug 8206986
|
||||||
* @summary Verify behavior of not exhaustive switch expressions.
|
* @summary Verify behavior of not exhaustive switch expressions.
|
||||||
* @compile/fail/ref=ExpressionSwitchNotExhaustive.out -XDrawDiagnostics --enable-preview -source 13 ExpressionSwitchNotExhaustive.java
|
* @compile/fail/ref=ExpressionSwitchNotExhaustive.out -XDrawDiagnostics --enable-preview -source ${jdk.version} ExpressionSwitchNotExhaustive.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ExpressionSwitchNotExhaustive {
|
public class ExpressionSwitchNotExhaustive {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @test /nodynamiccopyright/
|
* @test /nodynamiccopyright/
|
||||||
* @bug 8206986
|
* @bug 8206986
|
||||||
* @summary Verify reachability in switch expressions.
|
* @summary Verify reachability in switch expressions.
|
||||||
* @compile/fail/ref=ExpressionSwitchUnreachable.out -XDrawDiagnostics --enable-preview -source 13 ExpressionSwitchUnreachable.java
|
* @compile/fail/ref=ExpressionSwitchUnreachable.out -XDrawDiagnostics --enable-preview -source ${jdk.version} ExpressionSwitchUnreachable.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ExpressionSwitchUnreachable {
|
public class ExpressionSwitchUnreachable {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -61,13 +61,14 @@ public class ParseIncomplete {
|
|||||||
final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
|
final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
|
||||||
assert tool != null;
|
assert tool != null;
|
||||||
DiagnosticListener<JavaFileObject> noErrors = d -> {};
|
DiagnosticListener<JavaFileObject> noErrors = d -> {};
|
||||||
|
String sourceVersion = Integer.toString(Runtime.version().feature());
|
||||||
|
|
||||||
for (int i = 0; i < CODE.length(); i++) {
|
for (int i = 0; i < CODE.length(); i++) {
|
||||||
String code = CODE.substring(0, i + 1);
|
String code = CODE.substring(0, i + 1);
|
||||||
StringWriter out = new StringWriter();
|
StringWriter out = new StringWriter();
|
||||||
try {
|
try {
|
||||||
JavacTask ct = (JavacTask) tool.getTask(out, null, noErrors,
|
JavacTask ct = (JavacTask) tool.getTask(out, null, noErrors,
|
||||||
List.of("-XDdev", "--enable-preview", "-source", "13"), null,
|
List.of("-XDdev", "--enable-preview", "-source", sourceVersion), null,
|
||||||
Arrays.asList(new MyFileObject(code)));
|
Arrays.asList(new MyFileObject(code)));
|
||||||
ct.parse().iterator().next();
|
ct.parse().iterator().next();
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @test /nodynamiccopyright/
|
* @test /nodynamiccopyright/
|
||||||
* @bug 8206986
|
* @bug 8206986
|
||||||
* @summary Verify the parser handles broken input gracefully.
|
* @summary Verify the parser handles broken input gracefully.
|
||||||
* @compile/fail/ref=ParserRecovery.out -XDrawDiagnostics --enable-preview -source 13 ParserRecovery.java
|
* @compile/fail/ref=ParserRecovery.out -XDrawDiagnostics --enable-preview -source ${jdk.version} ParserRecovery.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ParserRecovery {
|
public class ParserRecovery {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -26,7 +26,7 @@
|
|||||||
* @bug 8214113
|
* @bug 8214113
|
||||||
* @summary Verify the switch expression's type does not have a constant attached,
|
* @summary Verify the switch expression's type does not have a constant attached,
|
||||||
* and so the switch expression is not elided.
|
* and so the switch expression is not elided.
|
||||||
* @compile --enable-preview --source 13 SwitchExpressionIsNotAConstant.java
|
* @compile --enable-preview --source ${jdk.version} SwitchExpressionIsNotAConstant.java
|
||||||
* @run main/othervm --enable-preview SwitchExpressionIsNotAConstant
|
* @run main/othervm --enable-preview SwitchExpressionIsNotAConstant
|
||||||
*/
|
*/
|
||||||
public class SwitchExpressionIsNotAConstant {
|
public class SwitchExpressionIsNotAConstant {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @test /nodynamiccopyright/
|
* @test /nodynamiccopyright/
|
||||||
* @bug 8206986
|
* @bug 8206986
|
||||||
* @summary Verify that scopes in rule cases are isolated.
|
* @summary Verify that scopes in rule cases are isolated.
|
||||||
* @compile/fail/ref=SwitchExpressionScopesIsolated.out -XDrawDiagnostics --enable-preview -source 13 SwitchExpressionScopesIsolated.java
|
* @compile/fail/ref=SwitchExpressionScopesIsolated.out -XDrawDiagnostics --enable-preview -source ${jdk.version} SwitchExpressionScopesIsolated.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class SwitchExpressionScopesIsolated {
|
public class SwitchExpressionScopesIsolated {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -89,7 +89,7 @@ public class SwitchExpressionSimpleVisitorTest {
|
|||||||
|
|
||||||
StringWriter out = new StringWriter();
|
StringWriter out = new StringWriter();
|
||||||
JavacTask ct = (JavacTask) tool.getTask(out, null, noErrors,
|
JavacTask ct = (JavacTask) tool.getTask(out, null, noErrors,
|
||||||
List.of("--enable-preview", "-source", "13"), null,
|
List.of("--enable-preview", "-source", Integer.toString(Runtime.version().feature())), null,
|
||||||
Arrays.asList(new MyFileObject(code)));
|
Arrays.asList(new MyFileObject(code)));
|
||||||
return ct.parse().iterator().next();
|
return ct.parse().iterator().next();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -25,7 +25,7 @@
|
|||||||
* @test
|
* @test
|
||||||
* @bug 8214114
|
* @bug 8214114
|
||||||
* @summary Verify try-catch inside a switch expression works properly.
|
* @summary Verify try-catch inside a switch expression works properly.
|
||||||
* @compile --enable-preview -source 13 TryCatch.java
|
* @compile --enable-preview -source ${jdk.version} TryCatch.java
|
||||||
* @run main/othervm --enable-preview TryCatch
|
* @run main/othervm --enable-preview TryCatch
|
||||||
*/
|
*/
|
||||||
public class TryCatch {
|
public class TryCatch {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -47,12 +47,13 @@ import com.sun.source.util.TreePathScanner;
|
|||||||
public class CaseTest {
|
public class CaseTest {
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
new CaseTest().testLabels();
|
String sourceVersion = Integer.toString(Runtime.version().feature());
|
||||||
new CaseTest().testStatement();
|
new CaseTest().testLabels(sourceVersion);
|
||||||
new CaseTest().testRule();
|
new CaseTest().testStatement(sourceVersion);
|
||||||
|
new CaseTest().testRule(sourceVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
void testLabels() throws Exception {
|
void testLabels(String sourceVersion) throws Exception {
|
||||||
String code = "class Test {\n" +
|
String code = "class Test {\n" +
|
||||||
" void t(int i) {\n" +
|
" void t(int i) {\n" +
|
||||||
" switch(i) {\n" +
|
" switch(i) {\n" +
|
||||||
@ -72,7 +73,7 @@ public class CaseTest {
|
|||||||
.collect(Collectors.joining(",", "[", "]")));
|
.collect(Collectors.joining(",", "[", "]")));
|
||||||
return super.visitCase(node, p);
|
return super.visitCase(node, p);
|
||||||
}
|
}
|
||||||
}.scan(parse(code), null);
|
}.scan(parse(code, sourceVersion), null);
|
||||||
|
|
||||||
List<String> expected = Arrays.asList("0", "[0]", "1", "[1,2]", "null", "[]");
|
List<String> expected = Arrays.asList("0", "[0]", "1", "[1,2]", "null", "[]");
|
||||||
|
|
||||||
@ -81,7 +82,7 @@ public class CaseTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void testStatement() throws Exception {
|
void testStatement(String sourceVersion) throws Exception {
|
||||||
String code = "class Test {\n" +
|
String code = "class Test {\n" +
|
||||||
" void t(int i) {\n" +
|
" void t(int i) {\n" +
|
||||||
" switch(i) {\n" +
|
" switch(i) {\n" +
|
||||||
@ -102,10 +103,10 @@ public class CaseTest {
|
|||||||
}
|
}
|
||||||
return super.visitCase(node, p);
|
return super.visitCase(node, p);
|
||||||
}
|
}
|
||||||
}.scan(parse(code), null);
|
}.scan(parse(code, sourceVersion), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
void testRule() throws Exception {
|
void testRule(String sourceVersion) throws Exception {
|
||||||
String code = "class Test {\n" +
|
String code = "class Test {\n" +
|
||||||
" void t(int i) {\n" +
|
" void t(int i) {\n" +
|
||||||
" switch(i) {\n" +
|
" switch(i) {\n" +
|
||||||
@ -126,17 +127,17 @@ public class CaseTest {
|
|||||||
}
|
}
|
||||||
return super.visitCase(node, p);
|
return super.visitCase(node, p);
|
||||||
}
|
}
|
||||||
}.scan(parse(code), null);
|
}.scan(parse(code, sourceVersion), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CompilationUnitTree parse(String code) throws IOException {
|
private CompilationUnitTree parse(String code, String sourceVersion) throws IOException {
|
||||||
final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
|
final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
|
||||||
assert tool != null;
|
assert tool != null;
|
||||||
DiagnosticListener<JavaFileObject> noErrors = d -> {};
|
DiagnosticListener<JavaFileObject> noErrors = d -> {};
|
||||||
|
|
||||||
StringWriter out = new StringWriter();
|
StringWriter out = new StringWriter();
|
||||||
JavacTask ct = (JavacTask) tool.getTask(out, null, noErrors,
|
JavacTask ct = (JavacTask) tool.getTask(out, null, noErrors,
|
||||||
List.of("-XDdev", "--enable-preview", "-source", "13"), null,
|
List.of("-XDdev", "--enable-preview", "-source", sourceVersion), null,
|
||||||
Arrays.asList(new MyFileObject(code)));
|
Arrays.asList(new MyFileObject(code)));
|
||||||
return ct.parse().iterator().next();
|
return ct.parse().iterator().next();
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* @bug 8206986
|
* @bug 8206986
|
||||||
* @summary Verify cases with multiple labels work properly.
|
* @summary Verify cases with multiple labels work properly.
|
||||||
* @compile/fail/ref=MultipleLabelsExpression-old.out -source 9 -Xlint:-options -XDrawDiagnostics MultipleLabelsExpression.java
|
* @compile/fail/ref=MultipleLabelsExpression-old.out -source 9 -Xlint:-options -XDrawDiagnostics MultipleLabelsExpression.java
|
||||||
* @compile --enable-preview -source 13 MultipleLabelsExpression.java
|
* @compile --enable-preview -source ${jdk.version} MultipleLabelsExpression.java
|
||||||
* @run main/othervm --enable-preview MultipleLabelsExpression
|
* @run main/othervm --enable-preview MultipleLabelsExpression
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* @bug 8206986
|
* @bug 8206986
|
||||||
* @summary Verify cases with multiple labels work properly.
|
* @summary Verify cases with multiple labels work properly.
|
||||||
* @compile/fail/ref=MultipleLabelsStatement-old.out -source 9 -Xlint:-options -XDrawDiagnostics MultipleLabelsStatement.java
|
* @compile/fail/ref=MultipleLabelsStatement-old.out -source 9 -Xlint:-options -XDrawDiagnostics MultipleLabelsStatement.java
|
||||||
* @compile --enable-preview -source 13 MultipleLabelsStatement.java
|
* @compile --enable-preview -source ${jdk.version} MultipleLabelsStatement.java
|
||||||
* @run main/othervm --enable-preview MultipleLabelsStatement
|
* @run main/othervm --enable-preview MultipleLabelsStatement
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -48,10 +48,11 @@ import com.sun.source.util.Trees;
|
|||||||
public class RuleParsingTest {
|
public class RuleParsingTest {
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
new RuleParsingTest().testParseComplexExpressions();
|
String sourceVersion = Integer.toString(Runtime.version().feature());
|
||||||
|
new RuleParsingTest().testParseComplexExpressions(sourceVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
void testParseComplexExpressions() throws Exception {
|
void testParseComplexExpressions(String sourceVersion) throws Exception {
|
||||||
String[] expressions = {
|
String[] expressions = {
|
||||||
"(a)",
|
"(a)",
|
||||||
"a",
|
"a",
|
||||||
@ -94,7 +95,7 @@ public class RuleParsingTest {
|
|||||||
|
|
||||||
StringWriter out = new StringWriter();
|
StringWriter out = new StringWriter();
|
||||||
JavacTask ct = (JavacTask) tool.getTask(out, null, noErrors,
|
JavacTask ct = (JavacTask) tool.getTask(out, null, noErrors,
|
||||||
List.of("--enable-preview", "-source", "13"), null,
|
List.of("--enable-preview", "-source", sourceVersion), null,
|
||||||
Arrays.asList(new MyFileObject(code.toString())));
|
Arrays.asList(new MyFileObject(code.toString())));
|
||||||
CompilationUnitTree cut = ct.parse().iterator().next();
|
CompilationUnitTree cut = ct.parse().iterator().next();
|
||||||
Trees trees = Trees.instance(ct);
|
Trees trees = Trees.instance(ct);
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* @bug 8206986
|
* @bug 8206986
|
||||||
* @summary Verify reasonable errors are produced when neither ':' nor '->'
|
* @summary Verify reasonable errors are produced when neither ':' nor '->'
|
||||||
* is found are the expression of a case
|
* is found are the expression of a case
|
||||||
* @compile/fail/ref=SwitchArrowBrokenConstant.out -source 13 --enable-preview -Xlint:-preview -XDrawDiagnostics SwitchArrowBrokenConstant.java
|
* @compile/fail/ref=SwitchArrowBrokenConstant.out -source ${jdk.version} --enable-preview -Xlint:-preview -XDrawDiagnostics SwitchArrowBrokenConstant.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class SwitchArrowBrokenConstant {
|
public class SwitchArrowBrokenConstant {
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* @bug 8206986
|
* @bug 8206986
|
||||||
* @summary Verify rule cases work properly.
|
* @summary Verify rule cases work properly.
|
||||||
* @compile/fail/ref=SwitchStatementArrow-old.out -source 9 -Xlint:-options -XDrawDiagnostics SwitchStatementArrow.java
|
* @compile/fail/ref=SwitchStatementArrow-old.out -source 9 -Xlint:-options -XDrawDiagnostics SwitchStatementArrow.java
|
||||||
* @compile --enable-preview -source 13 SwitchStatementArrow.java
|
* @compile --enable-preview -source ${jdk.version} SwitchStatementArrow.java
|
||||||
* @run main/othervm --enable-preview SwitchStatementArrow
|
* @run main/othervm --enable-preview SwitchStatementArrow
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @test /nodynamiccopyright/
|
* @test /nodynamiccopyright/
|
||||||
* @bug 8206986
|
* @bug 8206986
|
||||||
* @summary Verify that rule and ordinary cases cannot be mixed.
|
* @summary Verify that rule and ordinary cases cannot be mixed.
|
||||||
* @compile/fail/ref=SwitchStatementBroken.out -XDrawDiagnostics --enable-preview -source 13 SwitchStatementBroken.java
|
* @compile/fail/ref=SwitchStatementBroken.out -XDrawDiagnostics --enable-preview -source ${jdk.version} SwitchStatementBroken.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class SwitchStatementBroken {
|
public class SwitchStatementBroken {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @test /nodynamiccopyright/
|
* @test /nodynamiccopyright/
|
||||||
* @bug 8206986
|
* @bug 8206986
|
||||||
* @summary Verify that not allowed types of statements cannot be used in rule case.
|
* @summary Verify that not allowed types of statements cannot be used in rule case.
|
||||||
* @compile/fail/ref=SwitchStatementBroken2.out -XDrawDiagnostics --enable-preview -source 13 SwitchStatementBroken2.java
|
* @compile/fail/ref=SwitchStatementBroken2.out -XDrawDiagnostics --enable-preview -source ${jdk.version} SwitchStatementBroken2.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class SwitchStatementBroken2 {
|
public class SwitchStatementBroken2 {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @test /nodynamiccopyright/
|
* @test /nodynamiccopyright/
|
||||||
* @bug 8206986
|
* @bug 8206986
|
||||||
* @summary Verify that scopes in rule cases are isolated.
|
* @summary Verify that scopes in rule cases are isolated.
|
||||||
* @compile/fail/ref=SwitchStatementScopesIsolated.out -XDrawDiagnostics --enable-preview -source 13 SwitchStatementScopesIsolated.java
|
* @compile/fail/ref=SwitchStatementScopesIsolated.out -XDrawDiagnostics --enable-preview -source ${jdk.version} SwitchStatementScopesIsolated.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class SwitchStatementScopesIsolated {
|
public class SwitchStatementScopesIsolated {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user