8321182: SourceExample.SOURCE_14 comment should refer to 'switch expressions' instead of 'text blocks'

Reviewed-by: darcy
This commit is contained in:
Eirik Bjorsnos 2023-12-01 21:15:46 +00:00 committed by Joe Darcy
parent 3a09a052bc
commit 2f299e4a73

View File

@ -42,9 +42,7 @@ import javax.tools.JavaFileObject;
import javax.tools.StandardJavaFileManager;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Set;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
/*
@ -240,16 +238,8 @@ public class Versions {
protected void check(String major, List<String> args) {
printargs("check", args);
List<String> jcargs = new ArrayList<>();
jcargs.add("-Xlint:-options");
// add in args conforming to List requrements of JavaCompiler
for (String onearg : args) {
String[] fields = onearg.split(" ");
for (String onefield : fields) {
jcargs.add(onefield);
}
}
List<String> jcargs = javaCompilerOptions(args);
boolean creturn = compile("Base.java", jcargs);
if (!creturn) {
@ -264,6 +254,25 @@ public class Versions {
}
}
/**
* Create a list of options suitable for use with {@link JavaCompiler}
* @param args a list of space-delimited options, such as "-source 11"
* @return a list of arguments suitable for use with {@link JavaCompiler}
*/
private static List<String> javaCompilerOptions(List<String> args) {
List<String> jcargs = new ArrayList<>();
jcargs.add("-Xlint:-options");
// add in args conforming to List requirements of JavaCompiler
for (String onearg : args) {
String[] fields = onearg.split(" ");
for (String onefield : fields) {
jcargs.add(onefield);
}
}
return jcargs;
}
/**
* The BASE source example is expected to compile on all source
* levels. Otherwise, an example is expected to compile on its
@ -311,7 +320,7 @@ public class Versions {
"""),
SOURCE_14(14, "New14.java",
// New feature in 14: text blocks
// New feature in 14: switch expressions
"""
public class New14 {
static {
@ -427,16 +436,7 @@ public class Versions {
protected void pass(List<String> args) {
printargs("pass", args);
List<String> jcargs = new ArrayList<>();
jcargs.add("-Xlint:-options");
// add in args conforming to List requrements of JavaCompiler
for (String onearg : args) {
String[] fields = onearg.split(" ");
for (String onefield : fields) {
jcargs.add(onefield);
}
}
List<String> jcargs = javaCompilerOptions(args);
// empty list is error
if (jcargs.isEmpty()) {
@ -464,16 +464,7 @@ public class Versions {
protected void fail(List<String> args) {
printargs("fail", args);
List<String> jcargs = new ArrayList<>();
jcargs.add("-Xlint:-options");
// add in args conforming to List requrements of JavaCompiler
for (String onearg : args) {
String[] fields = onearg.split(" ");
for (String onefield : fields) {
jcargs.add(onefield);
}
}
List<String> jcargs = javaCompilerOptions(args);
// empty list is error
if (jcargs.isEmpty()) {