8173382: Add -source 11 and -target 11 to javac

8193291: Add SourceVersion.RELEASE_11

Reviewed-by: jjg, erikj, psandoz
This commit is contained in:
Joe Darcy 2017-12-18 18:51:40 -08:00
parent 6a80c5906f
commit 691eb78732
15 changed files with 118 additions and 56 deletions

View File

@ -69,7 +69,7 @@ $(eval $(call SetupJavaCompiler,GENERATE_OLDBYTECODE, \
$(eval $(call SetupJavaCompiler,GENERATE_JDKBYTECODE, \ $(eval $(call SetupJavaCompiler,GENERATE_JDKBYTECODE, \
JVM := $(JAVA_JAVAC), \ JVM := $(JAVA_JAVAC), \
JAVAC := $(NEW_JAVAC), \ JAVAC := $(NEW_JAVAC), \
FLAGS := -source 10 -target 10 --doclint-format html5 \ FLAGS := -source 11 -target 11 --doclint-format html5 \
-encoding ascii -XDignore.symbol.file=true $(JAVAC_WARNINGS), \ -encoding ascii -XDignore.symbol.file=true $(JAVAC_WARNINGS), \
SERVER_DIR := $(SJAVAC_SERVER_DIR), \ SERVER_DIR := $(SJAVAC_SERVER_DIR), \
SERVER_JVM := $(SJAVAC_SERVER_JAVA))) SERVER_JVM := $(SJAVAC_SERVER_JAVA)))
@ -79,7 +79,7 @@ $(eval $(call SetupJavaCompiler,GENERATE_JDKBYTECODE, \
$(eval $(call SetupJavaCompiler,GENERATE_JDKBYTECODE_NOWARNINGS, \ $(eval $(call SetupJavaCompiler,GENERATE_JDKBYTECODE_NOWARNINGS, \
JVM := $(JAVA_JAVAC), \ JVM := $(JAVA_JAVAC), \
JAVAC := $(NEW_JAVAC), \ JAVAC := $(NEW_JAVAC), \
FLAGS := -source 10 -target 10 \ FLAGS := -source 11 -target 11 \
-encoding ascii -XDignore.symbol.file=true $(DISABLE_WARNINGS), \ -encoding ascii -XDignore.symbol.file=true $(DISABLE_WARNINGS), \
SERVER_DIR := $(SJAVAC_SERVER_DIR), \ SERVER_DIR := $(SJAVAC_SERVER_DIR), \
SERVER_JVM := $(SJAVAC_SERVER_JAVA))) SERVER_JVM := $(SJAVAC_SERVER_JAVA)))

View File

@ -57,6 +57,7 @@ public enum SourceVersion {
* 1.8: lambda expressions and default methods * 1.8: lambda expressions and default methods
* 9: modules, small cleanups to 1.7 and 1.8 changes * 9: modules, small cleanups to 1.7 and 1.8 changes
* 10: local-variable type inference (var) * 10: local-variable type inference (var)
* 11: to be determined changes
*/ */
/** /**
@ -162,7 +163,15 @@ public enum SourceVersion {
* *
* @since 10 * @since 10
*/ */
RELEASE_10; RELEASE_10,
/**
* The version recognized by the Java Platform, Standard Edition
* 11.
*
* @since 11
*/
RELEASE_11;
// Note that when adding constants for newer releases, the // Note that when adding constants for newer releases, the
// behavior of latest() and latestSupported() must be updated too. // behavior of latest() and latestSupported() must be updated too.
@ -173,7 +182,7 @@ public enum SourceVersion {
* @return the latest source version that can be modeled * @return the latest source version that can be modeled
*/ */
public static SourceVersion latest() { public static SourceVersion latest() {
return RELEASE_10; return RELEASE_11;
} }
private static final SourceVersion latestSupported = getLatestSupported(); private static final SourceVersion latestSupported = getLatestSupported();
@ -183,6 +192,8 @@ public enum SourceVersion {
String specVersion = System.getProperty("java.specification.version"); String specVersion = System.getProperty("java.specification.version");
switch (specVersion) { switch (specVersion) {
case "11":
return RELEASE_11;
case "10": case "10":
return RELEASE_10; return RELEASE_10;
case "9": case "9":

View File

@ -78,8 +78,11 @@ public enum Source {
/** 1.9 modularity. */ /** 1.9 modularity. */
JDK9("9"), JDK9("9"),
/** 1.10 covers the to be determined language features that will be added in JDK 10. */ /** 1.10 local-variable type inference (var). */
JDK10("10"); JDK10("10"),
/** 1.11 covers the to be determined language features that will be added in JDK 11. */
JDK11("11");
private static final Context.Key<Source> sourceKey = new Context.Key<>(); private static final Context.Key<Source> sourceKey = new Context.Key<>();
@ -108,6 +111,7 @@ public enum Source {
tab.put("1.8", JDK8); // Make 8 an alias for 1.8 tab.put("1.8", JDK8); // Make 8 an alias for 1.8
tab.put("1.9", JDK9); // Make 9 an alias for 1.9 tab.put("1.9", JDK9); // Make 9 an alias for 1.9
tab.put("1.10", JDK10); // Make 10 an alias for 1.10 tab.put("1.10", JDK10); // Make 10 an alias for 1.10
// Decline to make 1.11 an alias for 11.
} }
private Source(String name) { private Source(String name) {
@ -125,6 +129,7 @@ public enum Source {
} }
public Target requiredTarget() { public Target requiredTarget() {
if (this.compareTo(JDK11) >= 0) return Target.JDK1_11;
if (this.compareTo(JDK10) >= 0) return Target.JDK1_10; if (this.compareTo(JDK10) >= 0) return Target.JDK1_10;
if (this.compareTo(JDK9) >= 0) return Target.JDK1_9; if (this.compareTo(JDK9) >= 0) return Target.JDK1_9;
if (this.compareTo(JDK8) >= 0) return Target.JDK1_8; if (this.compareTo(JDK8) >= 0) return Target.JDK1_8;
@ -247,6 +252,8 @@ public enum Source {
return RELEASE_9; return RELEASE_9;
case JDK10: case JDK10:
return RELEASE_10; return RELEASE_10;
case JDK11:
return RELEASE_11;
default: default:
return null; return null;
} }

View File

@ -40,9 +40,9 @@ import static com.sun.tools.javac.main.Option.PROFILE;
* deletion without notice.</b> * deletion without notice.</b>
*/ */
public enum Profile { public enum Profile {
COMPACT1("compact1", 1, Target.JDK1_8, Target.JDK1_9, Target.JDK1_10), COMPACT1("compact1", 1, Target.JDK1_8, Target.JDK1_9, Target.JDK1_10, Target.JDK1_11),
COMPACT2("compact2", 2, Target.JDK1_8, Target.JDK1_9, Target.JDK1_10), COMPACT2("compact2", 2, Target.JDK1_8, Target.JDK1_9, Target.JDK1_10, Target.JDK1_11),
COMPACT3("compact3", 3, Target.JDK1_8, Target.JDK1_9, Target.JDK1_10), COMPACT3("compact3", 3, Target.JDK1_8, Target.JDK1_9, Target.JDK1_10, Target.JDK1_11),
DEFAULT { DEFAULT {
@Override @Override

View File

@ -64,7 +64,10 @@ public enum Target {
JDK1_9("1.9", 53, 0), JDK1_9("1.9", 53, 0),
/** JDK 10. */ /** JDK 10. */
JDK1_10("1.10", 54, 0); JDK1_10("1.10", 54, 0),
/** JDK 11. */
JDK1_11("11", 54, 0); // Initially an alias for JDK_10
private static final Context.Key<Target> targetKey = new Context.Key<>(); private static final Context.Key<Target> targetKey = new Context.Key<>();
@ -95,6 +98,7 @@ public enum Target {
tab.put("8", JDK1_8); tab.put("8", JDK1_8);
tab.put("9", JDK1_9); tab.put("9", JDK1_9);
tab.put("10", JDK1_10); tab.put("10", JDK1_10);
tab.put("11", JDK1_11);
} }
public final String name; public final String name;

View File

@ -55,7 +55,7 @@ import com.sun.tools.javac.util.StringUtils;
* deletion without notice.</b> * deletion without notice.</b>
*/ */
@SupportedAnnotationTypes("*") @SupportedAnnotationTypes("*")
@SupportedSourceVersion(SourceVersion.RELEASE_10) @SupportedSourceVersion(SourceVersion.RELEASE_11)
public class PrintingProcessor extends AbstractProcessor { public class PrintingProcessor extends AbstractProcessor {
PrintWriter writer; PrintWriter writer;

View File

@ -50,7 +50,7 @@ import javax.lang.model.util.Elements;
import javax.tools.Diagnostic; import javax.tools.Diagnostic;
import static javax.lang.model.SourceVersion.RELEASE_10; import static javax.lang.model.SourceVersion.RELEASE_11;
/** /**
* Annotation processor for the Deprecation Scanner tool. * Annotation processor for the Deprecation Scanner tool.
@ -58,7 +58,7 @@ import static javax.lang.model.SourceVersion.RELEASE_10;
* *
*/ */
@SupportedAnnotationTypes("java.lang.Deprecated") @SupportedAnnotationTypes("java.lang.Deprecated")
@SupportedSourceVersion(RELEASE_10) @SupportedSourceVersion(RELEASE_11)
public class LoadProc extends AbstractProcessor { public class LoadProc extends AbstractProcessor {
Elements elements; Elements elements;
Messager messager; Messager messager;

View File

@ -106,7 +106,7 @@ public class Main implements DiagnosticListener<JavaFileObject> {
// Keep these updated manually until there's a compiler API // Keep these updated manually until there's a compiler API
// that allows querying of supported releases. // that allows querying of supported releases.
final Set<String> releasesWithoutForRemoval = Set.of("6", "7", "8"); final Set<String> releasesWithoutForRemoval = Set.of("6", "7", "8");
final Set<String> releasesWithForRemoval = Set.of("9", "10"); final Set<String> releasesWithForRemoval = Set.of("9", "10", "11");
final Set<String> validReleases; final Set<String> validReleases;
{ {
@ -358,14 +358,15 @@ public class Main implements DiagnosticListener<JavaFileObject> {
* Process classes from a particular JDK release, using only information * Process classes from a particular JDK release, using only information
* in this JDK. * in this JDK.
* *
* @param release "6", "7", "8", "9", or "10" * @param release "6", "7", "8", "9", "10", or "11"
* @param classes collection of classes to process, may be empty * @param classes collection of classes to process, may be empty
* @return success value * @return success value
*/ */
boolean processRelease(String release, Collection<String> classes) throws IOException { boolean processRelease(String release, Collection<String> classes) throws IOException {
options.addAll(List.of("--release", release)); options.addAll(List.of("--release", release));
if (release.equals("9") || release.equals("10")) { if (release.equals("9") || release.equals("10") ||
release.equals("11")) {
List<String> rootMods = List.of("java.se", "java.se.ee"); List<String> rootMods = List.of("java.se", "java.se.ee");
TraverseProc proc = new TraverseProc(rootMods); TraverseProc proc = new TraverseProc(rootMods);
JavaCompiler.CompilationTask task = JavaCompiler.CompilationTask task =
@ -481,7 +482,7 @@ public class Main implements DiagnosticListener<JavaFileObject> {
String dir = null; String dir = null;
String jar = null; String jar = null;
String jdkHome = null; String jdkHome = null;
String release = "10"; String release = "11";
List<String> loadClasses = new ArrayList<>(); List<String> loadClasses = new ArrayList<>();
String csvFile = null; String csvFile = null;

View File

@ -54,6 +54,7 @@ tools/javac/annotations/typeAnnotations/referenceinfos/Lambda.java
tools/javac/annotations/typeAnnotations/referenceinfos/NestedTypes.java 8057687 generic-all emit correct byte code an attributes for type annotations tools/javac/annotations/typeAnnotations/referenceinfos/NestedTypes.java 8057687 generic-all emit correct byte code an attributes for type annotations
tools/javac/warnings/suppress/TypeAnnotations.java 8057683 generic-all improve ordering of errors with type annotations tools/javac/warnings/suppress/TypeAnnotations.java 8057683 generic-all improve ordering of errors with type annotations
tools/javac/modules/SourceInSymlinkTest.java 8180263 windows-all fails when run on a subst drive tools/javac/modules/SourceInSymlinkTest.java 8180263 windows-all fails when run on a subst drive
tools/javac/options/release/ReleaseOptionUnsupported.java 8193784 generic-all temporary until support for --release 11 is worked out
########################################################################### ###########################################################################
# #
@ -76,3 +77,5 @@ tools/sjavac/ClasspathDependencies.java 8158002 generic-all Requires i
########################################################################### ###########################################################################
# #
# jdeps # jdeps
tools/jdeprscan/tests/jdk/jdeprscan/TestNotFound.java 8193784 generic-all temporary until support for --release 11 is worked out

View File

@ -52,7 +52,7 @@ public class T6265137 {
String srcdir = System.getProperty("test.src"); String srcdir = System.getProperty("test.src");
Iterable<? extends JavaFileObject> files = Iterable<? extends JavaFileObject> files =
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(srcdir, "T6265137a.java"))); fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(srcdir, "T6265137a.java")));
javac.getTask(null, fm, dl, Arrays.asList("-target","10"), null, files).call(); javac.getTask(null, fm, dl, Arrays.asList("-target","11"), null, files).call();
} }
} }
} }

View File

@ -23,7 +23,7 @@
/* /*
* @test * @test
* @bug 6395981 6458819 7025784 8028543 8028544 * @bug 6395981 6458819 7025784 8028543 8028544 8193291
* @summary JavaCompilerTool and Tool must specify version of JLS and JVMS * @summary JavaCompilerTool and Tool must specify version of JLS and JVMS
* @author Peter von der Ah\u00e9 * @author Peter von der Ah\u00e9
* @modules java.compiler * @modules java.compiler
@ -31,7 +31,7 @@
* @run main/fail T6395981 * @run main/fail T6395981
* @run main/fail T6395981 RELEASE_3 RELEASE_5 RELEASE_6 * @run main/fail T6395981 RELEASE_3 RELEASE_5 RELEASE_6
* @run main/fail T6395981 RELEASE_0 RELEASE_1 RELEASE_2 RELEASE_3 RELEASE_4 RELEASE_5 RELEASE_6 * @run main/fail T6395981 RELEASE_0 RELEASE_1 RELEASE_2 RELEASE_3 RELEASE_4 RELEASE_5 RELEASE_6
* @run main T6395981 RELEASE_3 RELEASE_4 RELEASE_5 RELEASE_6 RELEASE_7 RELEASE_8 RELEASE_9 RELEASE_10 * @run main T6395981 RELEASE_3 RELEASE_4 RELEASE_5 RELEASE_6 RELEASE_7 RELEASE_8 RELEASE_9 RELEASE_10 RELEASE_11
*/ */
import java.util.EnumSet; import java.util.EnumSet;

View File

@ -110,7 +110,7 @@ public abstract class JavacTestingAbstractProcessor extends AbstractProcessor {
* corresponding platform visitor type. * corresponding platform visitor type.
*/ */
@SupportedSourceVersion(RELEASE_10) @SupportedSourceVersion(RELEASE_11)
public static abstract class AbstractAnnotationValueVisitor<R, P> extends AbstractAnnotationValueVisitor9<R, P> { public static abstract class AbstractAnnotationValueVisitor<R, P> extends AbstractAnnotationValueVisitor9<R, P> {
/** /**
@ -121,7 +121,7 @@ public abstract class JavacTestingAbstractProcessor extends AbstractProcessor {
} }
} }
@SupportedSourceVersion(RELEASE_10) @SupportedSourceVersion(RELEASE_11)
public static abstract class AbstractElementVisitor<R, P> extends AbstractElementVisitor9<R, P> { public static abstract class AbstractElementVisitor<R, P> extends AbstractElementVisitor9<R, P> {
/** /**
* Constructor for concrete subclasses to call. * Constructor for concrete subclasses to call.
@ -131,7 +131,7 @@ public abstract class JavacTestingAbstractProcessor extends AbstractProcessor {
} }
} }
@SupportedSourceVersion(RELEASE_10) @SupportedSourceVersion(RELEASE_11)
public static abstract class AbstractTypeVisitor<R, P> extends AbstractTypeVisitor9<R, P> { public static abstract class AbstractTypeVisitor<R, P> extends AbstractTypeVisitor9<R, P> {
/** /**
* Constructor for concrete subclasses to call. * Constructor for concrete subclasses to call.
@ -141,7 +141,7 @@ public abstract class JavacTestingAbstractProcessor extends AbstractProcessor {
} }
} }
@SupportedSourceVersion(RELEASE_10) @SupportedSourceVersion(RELEASE_11)
public static class ElementKindVisitor<R, P> extends ElementKindVisitor9<R, P> { public static class ElementKindVisitor<R, P> extends ElementKindVisitor9<R, P> {
/** /**
* Constructor for concrete subclasses; uses {@code null} for the * Constructor for concrete subclasses; uses {@code null} for the
@ -162,7 +162,7 @@ public abstract class JavacTestingAbstractProcessor extends AbstractProcessor {
} }
} }
@SupportedSourceVersion(RELEASE_10) @SupportedSourceVersion(RELEASE_11)
public static class ElementScanner<R, P> extends ElementScanner9<R, P> { public static class ElementScanner<R, P> extends ElementScanner9<R, P> {
/** /**
* Constructor for concrete subclasses; uses {@code null} for the * Constructor for concrete subclasses; uses {@code null} for the
@ -181,7 +181,7 @@ public abstract class JavacTestingAbstractProcessor extends AbstractProcessor {
} }
} }
@SupportedSourceVersion(RELEASE_10) @SupportedSourceVersion(RELEASE_11)
public static class SimpleAnnotationValueVisitor<R, P> extends SimpleAnnotationValueVisitor9<R, P> { public static class SimpleAnnotationValueVisitor<R, P> extends SimpleAnnotationValueVisitor9<R, P> {
/** /**
* Constructor for concrete subclasses; uses {@code null} for the * Constructor for concrete subclasses; uses {@code null} for the
@ -202,7 +202,7 @@ public abstract class JavacTestingAbstractProcessor extends AbstractProcessor {
} }
} }
@SupportedSourceVersion(RELEASE_10) @SupportedSourceVersion(RELEASE_11)
public static class SimpleElementVisitor<R, P> extends SimpleElementVisitor9<R, P> { public static class SimpleElementVisitor<R, P> extends SimpleElementVisitor9<R, P> {
/** /**
* Constructor for concrete subclasses; uses {@code null} for the * Constructor for concrete subclasses; uses {@code null} for the
@ -223,7 +223,7 @@ public abstract class JavacTestingAbstractProcessor extends AbstractProcessor {
} }
} }
@SupportedSourceVersion(RELEASE_10) @SupportedSourceVersion(RELEASE_11)
public static class SimpleTypeVisitor<R, P> extends SimpleTypeVisitor9<R, P> { public static class SimpleTypeVisitor<R, P> extends SimpleTypeVisitor9<R, P> {
/** /**
* Constructor for concrete subclasses; uses {@code null} for the * Constructor for concrete subclasses; uses {@code null} for the
@ -244,7 +244,7 @@ public abstract class JavacTestingAbstractProcessor extends AbstractProcessor {
} }
} }
@SupportedSourceVersion(RELEASE_10) @SupportedSourceVersion(RELEASE_11)
public static class TypeKindVisitor<R, P> extends TypeKindVisitor9<R, P> { public static class TypeKindVisitor<R, P> extends TypeKindVisitor9<R, P> {
/** /**
* Constructor for concrete subclasses to call; uses {@code null} * Constructor for concrete subclasses to call; uses {@code null}

View File

@ -23,7 +23,7 @@
/* /*
* @test * @test
* @bug 7025809 8028543 6415644 8028544 8029942 * @bug 7025809 8028543 6415644 8028544 8029942 8193291
* @summary Test latest, latestSupported, underscore as keyword, etc. * @summary Test latest, latestSupported, underscore as keyword, etc.
* @author Joseph D. Darcy * @author Joseph D. Darcy
* @modules java.compiler * @modules java.compiler
@ -45,7 +45,7 @@ public class TestSourceVersion {
} }
private static void testLatestSupported() { private static void testLatestSupported() {
if (SourceVersion.latest() != RELEASE_10 || if (SourceVersion.latest() != RELEASE_11 ||
SourceVersion.latestSupported() != RELEASE_10) SourceVersion.latestSupported() != RELEASE_10)
throw new RuntimeException("Unexpected release value(s) found:\n" + throw new RuntimeException("Unexpected release value(s) found:\n" +
"latest:\t" + SourceVersion.latest() + "\n" + "latest:\t" + SourceVersion.latest() + "\n" +

View File

@ -149,6 +149,7 @@ public class ProfileOptionTest {
break; break;
case JDK1_9: case JDK1_9:
case JDK1_10: case JDK1_10:
case JDK1_11:
if (p == Profile.DEFAULT) if (p == Profile.DEFAULT)
break; break;
if (ise == null) if (ise == null)

View File

@ -23,7 +23,7 @@
/* /*
* @test * @test
* @bug 4981566 5028634 5094412 6304984 7025786 7025789 8001112 8028545 8000961 8030610 8028546 8188870 * @bug 4981566 5028634 5094412 6304984 7025786 7025789 8001112 8028545 8000961 8030610 8028546 8188870 8173382
* @summary Check interpretation of -target and -source options * @summary Check interpretation of -target and -source options
* @modules java.compiler * @modules java.compiler
* jdk.compiler * jdk.compiler
@ -70,22 +70,24 @@ public class Versions {
check("54.0", "-source 1.8"); check("54.0", "-source 1.8");
check("54.0", "-source 1.9"); check("54.0", "-source 1.9");
check("54.0", "-source 1.10"); check("54.0", "-source 1.10");
check("54.0", "-source 11");
check_source_target("50.0", "6", "6"); check_source_target(true, "50.0", "6", "6");
check_source_target("51.0", "6", "7"); check_source_target(true, "51.0", "6", "7");
check_source_target("51.0", "7", "7"); check_source_target(true, "51.0", "7", "7");
check_source_target("52.0", "6", "8"); check_source_target(true, "52.0", "6", "8");
check_source_target("52.0", "7", "8"); check_source_target(true, "52.0", "7", "8");
check_source_target("52.0", "8", "8"); check_source_target(true, "52.0", "8", "8");
check_source_target("53.0", "6", "9"); check_source_target(true, "53.0", "6", "9");
check_source_target("53.0", "7", "9"); check_source_target(true, "53.0", "7", "9");
check_source_target("53.0", "8", "9"); check_source_target(true, "53.0", "8", "9");
check_source_target("53.0", "9", "9"); check_source_target(true, "53.0", "9", "9");
check_source_target("54.0", "6", "10"); check_source_target(true, "54.0", "6", "10");
check_source_target("54.0", "7", "10"); check_source_target(true, "54.0", "7", "10");
check_source_target("54.0", "8", "10"); check_source_target(true, "54.0", "8", "10");
check_source_target("54.0", "9", "10"); check_source_target(true, "54.0", "9", "10");
check_source_target("54.0", "10", "10"); check_source_target(true, "54.0", "10", "10");
check_source_target(false, "54.0", "11", "11");
checksrc16("-source 1.6"); checksrc16("-source 1.6");
checksrc16("-source 6"); checksrc16("-source 6");
@ -108,8 +110,9 @@ public class Versions {
checksrc110("-source 10"); checksrc110("-source 10");
checksrc110("-source 1.10", "-target 1.10"); checksrc110("-source 1.10", "-target 1.10");
checksrc110("-source 10", "-target 10"); checksrc110("-source 10", "-target 10");
checksrc110("-target 1.10"); checksrc111("-source 11");
checksrc110("-target 10"); checksrc111("-source 11", "-target 11");
checksrc111("-target 11");
fail("-source 7", "-target 1.6", "Base.java"); fail("-source 7", "-target 1.6", "Base.java");
fail("-source 8", "-target 1.6", "Base.java"); fail("-source 8", "-target 1.6", "Base.java");
@ -118,6 +121,8 @@ public class Versions {
fail("-source 9", "-target 1.8", "Base.java"); fail("-source 9", "-target 1.8", "Base.java");
fail("-source 10", "-target 1.7", "Base.java"); fail("-source 10", "-target 1.7", "Base.java");
fail("-source 10", "-target 1.8", "Base.java"); fail("-source 10", "-target 1.8", "Base.java");
fail("-source 11", "-target 1.9", "Base.java");
fail("-source 11", "-target 1.10", "Base.java");
fail("-source 1.5", "-target 1.5", "Base.java"); fail("-source 1.5", "-target 1.5", "Base.java");
fail("-source 1.4", "-target 1.4", "Base.java"); fail("-source 1.4", "-target 1.4", "Base.java");
@ -139,20 +144,24 @@ public class Versions {
System.out.printf("\n", fname); System.out.printf("\n", fname);
} }
protected void check_source_target(String... args) { protected void check_source_target(boolean dotOne, String... args) {
printargs("check_source_target", args); printargs("check_source_target", args);
check_target(args[0], args[1], args[2]); check_target(dotOne, args[0], args[1], args[2]);
check_target(args[0], "1." + args[1], args[2]); if (dotOne) {
check_target(dotOne, args[0], "1." + args[1], args[2]);
}
} }
protected void check_target(String... args) { protected void check_target(boolean dotOne, String... args) {
check(args[0], "-source " + args[1], "-target " + args[2]); check(args[0], "-source " + args[1], "-target " + args[2]);
check(args[0], "-source " + args[1], "-target 1." + args[2]); if (dotOne) {
check(args[0], "-source " + args[1], "-target 1." + args[2]);
}
} }
protected void check(String major, String... args) { protected void check(String major, String... args) {
printargs("check", args); printargs("check", args);
List<String> jcargs = new ArrayList<String>(); List<String> jcargs = new ArrayList<>();
jcargs.add("-Xlint:-options"); jcargs.add("-Xlint:-options");
// add in args conforming to List requrements of JavaCompiler // add in args conforming to List requrements of JavaCompiler
@ -207,6 +216,8 @@ public class Versions {
pass(newargs); pass(newargs);
newargs[asize] = "New18.java"; newargs[asize] = "New18.java";
pass(newargs); pass(newargs);
newargs[asize] = "New110.java";
fail(newargs);
} }
protected void checksrc19(String... args) { protected void checksrc19(String... args) {
@ -216,7 +227,20 @@ public class Versions {
protected void checksrc110(String... args) { protected void checksrc110(String... args) {
printargs("checksrc110", args); printargs("checksrc110", args);
checksrc19(args); int asize = args.length;
String[] newargs = new String[asize+1];
System.arraycopy(args, 0, newargs,0 , asize);
newargs[asize] = "New17.java";
pass(newargs);
newargs[asize] = "New18.java";
pass(newargs);
newargs[asize] = "New110.java";
pass(newargs);
}
protected void checksrc111(String... args) {
printargs("checksrc111", args);
checksrc110(args);
} }
protected void pass(String... args) { protected void pass(String... args) {
@ -347,6 +371,17 @@ public class Versions {
"} \n" "} \n"
); );
/*
* Create a file with a new feature in 1.10, not in 1.9 : var
*/
writeSourceFile("New110.java",
"public class New110 { \n" +
" void m() { \n" +
" var tmp = new Thread(() -> { }); \n" +
" } \n" +
"} \n"
);
} }
protected boolean checkClassFileVersion protected boolean checkClassFileVersion