diff --git a/test/langtools/TEST.ROOT b/test/langtools/TEST.ROOT
index f9dcfd9e360..db2d21f0b07 100644
--- a/test/langtools/TEST.ROOT
+++ b/test/langtools/TEST.ROOT
@@ -15,7 +15,7 @@ keys=intermittent randomness
 groups=TEST.groups
 
 # Minimum jtreg version
-requiredVersion=4.2 b13
+requiredVersion=4.2 b14
 
 # Use new module options
 useNewOptions=true
diff --git a/test/langtools/tools/javac/6330997/T6330997.java b/test/langtools/tools/javac/6330997/T6330997.java
index 297d448c24e..8ddf40e4557 100644
--- a/test/langtools/tools/javac/6330997/T6330997.java
+++ b/test/langtools/tools/javac/6330997/T6330997.java
@@ -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.
  *
  * 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.util
  * @clean T1 T2
- * @compile -source 12 -target 13 T1.java
- * @compile -source 12 -target 13 T2.java
+ * @compile T1.java
+ * @compile T2.java
  * @run main/othervm T6330997
  */
 
diff --git a/test/langtools/tools/javac/ConditionalWithVoid.java b/test/langtools/tools/javac/ConditionalWithVoid.java
index 93a918d1c1c..710f2753c64 100644
--- a/test/langtools/tools/javac/ConditionalWithVoid.java
+++ b/test/langtools/tools/javac/ConditionalWithVoid.java
@@ -4,7 +4,7 @@
  * @summary The compiler was allowing void types in its parsing of conditional expressions.
  * @author tball
  *
- * @compile/fail/ref=ConditionalWithVoid.out --enable-preview -source 13 -XDrawDiagnostics ConditionalWithVoid.java
+ * @compile/fail/ref=ConditionalWithVoid.out --enable-preview -source ${jdk.version} -XDrawDiagnostics ConditionalWithVoid.java
  */
 public class ConditionalWithVoid {
     public void test(Object o, String s) {
diff --git a/test/langtools/tools/javac/diags/Example.java b/test/langtools/tools/javac/diags/Example.java
index 8cadd96a4c3..14cfa488141 100644
--- a/test/langtools/tools/javac/diags/Example.java
+++ b/test/langtools/tools/javac/diags/Example.java
@@ -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.
  *
  * 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(classesDir.getPath());
         if (options != null)
-            opts.addAll(options);
+            opts.addAll(evalProperties(options));
 
         if (procFiles.size() > 0) {
             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 {
         File servicesDir = new File(new File(dir, "META-INF"), "services");
         servicesDir.mkdirs();
diff --git a/test/langtools/tools/javac/diags/examples/BreakAmbiguousTarget.java b/test/langtools/tools/javac/diags/examples/BreakAmbiguousTarget.java
index c28960a8fbb..1eb668e126c 100644
--- a/test/langtools/tools/javac/diags/examples/BreakAmbiguousTarget.java
+++ b/test/langtools/tools/javac/diags/examples/BreakAmbiguousTarget.java
@@ -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.
  *
  * 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.note.preview.filename
 // key: compiler.note.preview.recompile
-// options: --enable-preview -source 13
+// options: --enable-preview -source ${jdk.version}
 
 class BreakAmbiguousTarget {
     void m(int i, int j) {
diff --git a/test/langtools/tools/javac/diags/examples/BreakExprNotImmediate.java b/test/langtools/tools/javac/diags/examples/BreakExprNotImmediate.java
index 0eb1ab3799e..4296521fa93 100644
--- a/test/langtools/tools/javac/diags/examples/BreakExprNotImmediate.java
+++ b/test/langtools/tools/javac/diags/examples/BreakExprNotImmediate.java
@@ -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.
  *
  * 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.recompile
 // key: compiler.note.note
-// options: --enable-preview -source 13
+// options: --enable-preview -source ${jdk.version}
 // run: backdoor
 
 class BreakExprNotImmediate {
diff --git a/test/langtools/tools/javac/diags/examples/BreakMissingValue.java b/test/langtools/tools/javac/diags/examples/BreakMissingValue.java
index 0ea668ba305..ecc9f68e960 100644
--- a/test/langtools/tools/javac/diags/examples/BreakMissingValue.java
+++ b/test/langtools/tools/javac/diags/examples/BreakMissingValue.java
@@ -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.
  *
  * 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.note.preview.filename
 // key: compiler.note.preview.recompile
-// options: --enable-preview -source 13
+// options: --enable-preview -source ${jdk.version}
 
 class BreakMissingValue {
     int t(int i) {
diff --git a/test/langtools/tools/javac/diags/examples/BreakOutsideSwitchExpression.java b/test/langtools/tools/javac/diags/examples/BreakOutsideSwitchExpression.java
index f980c5e4720..aa7d7d2fcd4 100644
--- a/test/langtools/tools/javac/diags/examples/BreakOutsideSwitchExpression.java
+++ b/test/langtools/tools/javac/diags/examples/BreakOutsideSwitchExpression.java
@@ -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.
  *
  * 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.note.preview.filename
 // key: compiler.note.preview.recompile
-// options: --enable-preview -source 13
+// options: --enable-preview -source ${jdk.version}
 
 class BreakOutsideSwitchExpression {
     int t(int i) {
diff --git a/test/langtools/tools/javac/diags/examples/ContinueOutsideSwitchExpression.java b/test/langtools/tools/javac/diags/examples/ContinueOutsideSwitchExpression.java
index f5d1d278dcc..c7ae16d6a89 100644
--- a/test/langtools/tools/javac/diags/examples/ContinueOutsideSwitchExpression.java
+++ b/test/langtools/tools/javac/diags/examples/ContinueOutsideSwitchExpression.java
@@ -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.
  *
  * 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.note.preview.filename
 // key: compiler.note.preview.recompile
-// options: --enable-preview -source 13
+// options: --enable-preview -source ${jdk.version}
 
 class ContinueOutsideSwitchExpression {
     int t(int i) {
diff --git a/test/langtools/tools/javac/diags/examples/IncompatibleTypesInSwitchExpression.java b/test/langtools/tools/javac/diags/examples/IncompatibleTypesInSwitchExpression.java
index bba166c3eb1..56e3d32eb75 100644
--- a/test/langtools/tools/javac/diags/examples/IncompatibleTypesInSwitchExpression.java
+++ b/test/langtools/tools/javac/diags/examples/IncompatibleTypesInSwitchExpression.java
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,7 @@
 // key: compiler.misc.inconvertible.types
 // key: compiler.note.preview.filename
 // key: compiler.note.preview.recompile
-// options: --enable-preview -source 13
+// options: --enable-preview -source ${jdk.version}
 
 
 class IncompatibleTypesInSwitchExpression {
diff --git a/test/langtools/tools/javac/diags/examples/MultipleCaseLabels.java b/test/langtools/tools/javac/diags/examples/MultipleCaseLabels.java
index 0db0884115c..57be2f20126 100644
--- a/test/langtools/tools/javac/diags/examples/MultipleCaseLabels.java
+++ b/test/langtools/tools/javac/diags/examples/MultipleCaseLabels.java
@@ -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.
  *
  * 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.warn.preview.feature.use.plural
-// options: --enable-preview -source 13 -Xlint:preview
+// options: --enable-preview -source ${jdk.version} -Xlint:preview
 
 class MultipleCaseLabels {
     void m(int i) {
diff --git a/test/langtools/tools/javac/diags/examples/NotExhaustive.java b/test/langtools/tools/javac/diags/examples/NotExhaustive.java
index 846bc9cdeb5..8f4e2be47bf 100644
--- a/test/langtools/tools/javac/diags/examples/NotExhaustive.java
+++ b/test/langtools/tools/javac/diags/examples/NotExhaustive.java
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,7 +24,7 @@
 // key: compiler.err.not.exhaustive
 // key: compiler.note.preview.filename
 // key: compiler.note.preview.recompile
-// options: --enable-preview -source 13
+// options: --enable-preview -source ${jdk.version}
 
 class NotExhaustive {
     int t(int i) {
diff --git a/test/langtools/tools/javac/diags/examples/PreviewFeatureUse.java b/test/langtools/tools/javac/diags/examples/PreviewFeatureUse.java
index 3dbb2270c4e..99a7596cb0e 100644
--- a/test/langtools/tools/javac/diags/examples/PreviewFeatureUse.java
+++ b/test/langtools/tools/javac/diags/examples/PreviewFeatureUse.java
@@ -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.
  *
  * 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.misc.feature.diamond
 //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;
 
diff --git a/test/langtools/tools/javac/diags/examples/PreviewFilename.java b/test/langtools/tools/javac/diags/examples/PreviewFilename.java
index 04edcdf8715..b424851311a 100644
--- a/test/langtools/tools/javac/diags/examples/PreviewFilename.java
+++ b/test/langtools/tools/javac/diags/examples/PreviewFilename.java
@@ -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.
  *
  * 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.recompile
-// options: -XDforcePreview  -source 13 --enable-preview
+// options: -XDforcePreview  -source ${jdk.version} --enable-preview
 
 import java.util.ArrayList;
 import java.util.List;
diff --git a/test/langtools/tools/javac/diags/examples/PreviewFilenameAdditional.java b/test/langtools/tools/javac/diags/examples/PreviewFilenameAdditional.java
index 3d5430de389..60ee874a8c5 100644
--- a/test/langtools/tools/javac/diags/examples/PreviewFilenameAdditional.java
+++ b/test/langtools/tools/javac/diags/examples/PreviewFilenameAdditional.java
@@ -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.
  *
  * 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.warn.preview.feature.use
 // 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;
 
diff --git a/test/langtools/tools/javac/diags/examples/PreviewPlural/PreviewPlural.java b/test/langtools/tools/javac/diags/examples/PreviewPlural/PreviewPlural.java
index e9b92af8ded..abd93b5e3ce 100644
--- a/test/langtools/tools/javac/diags/examples/PreviewPlural/PreviewPlural.java
+++ b/test/langtools/tools/javac/diags/examples/PreviewPlural/PreviewPlural.java
@@ -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.
  *
  * 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.recompile
-// options: -XDforcePreview  -source 13 --enable-preview
+// options: -XDforcePreview  -source ${jdk.version} --enable-preview
 
 import java.util.ArrayList;
 
diff --git a/test/langtools/tools/javac/diags/examples/ReturnOutsideSwitchExpression.java b/test/langtools/tools/javac/diags/examples/ReturnOutsideSwitchExpression.java
index 9811287efc9..4db3dcdfa5a 100644
--- a/test/langtools/tools/javac/diags/examples/ReturnOutsideSwitchExpression.java
+++ b/test/langtools/tools/javac/diags/examples/ReturnOutsideSwitchExpression.java
@@ -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.
  *
  * 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.note.preview.filename
 // key: compiler.note.preview.recompile
-// options: --enable-preview -source 13
+// options: --enable-preview -source ${jdk.version}
 
 class ReturnOutsideSwitchExpression {
     int t(int i) {
diff --git a/test/langtools/tools/javac/diags/examples/RuleCompletesNormally.java b/test/langtools/tools/javac/diags/examples/RuleCompletesNormally.java
index bb876ac9de2..69fe3325061 100644
--- a/test/langtools/tools/javac/diags/examples/RuleCompletesNormally.java
+++ b/test/langtools/tools/javac/diags/examples/RuleCompletesNormally.java
@@ -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.
  *
  * 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.note.preview.filename
 // key: compiler.note.preview.recompile
-// options: --enable-preview -source 13
+// options: --enable-preview -source ${jdk.version}
 
 class RuleCompletesNormally {
     public String convert(int i) {
diff --git a/test/langtools/tools/javac/diags/examples/SwitchCaseUnexpectedStatement.java b/test/langtools/tools/javac/diags/examples/SwitchCaseUnexpectedStatement.java
index d3509b0756b..025343b385a 100644
--- a/test/langtools/tools/javac/diags/examples/SwitchCaseUnexpectedStatement.java
+++ b/test/langtools/tools/javac/diags/examples/SwitchCaseUnexpectedStatement.java
@@ -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.
  *
  * 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.note.preview.filename
 // key: compiler.note.preview.recompile
-// options: --enable-preview -source 13
+// options: --enable-preview -source ${jdk.version}
 
 class ReturnOutsideSwitchExpression {
     void t(int i) {
diff --git a/test/langtools/tools/javac/diags/examples/SwitchExpressionCompletesNormally.java b/test/langtools/tools/javac/diags/examples/SwitchExpressionCompletesNormally.java
index f3fef28165a..49daf1f1011 100644
--- a/test/langtools/tools/javac/diags/examples/SwitchExpressionCompletesNormally.java
+++ b/test/langtools/tools/javac/diags/examples/SwitchExpressionCompletesNormally.java
@@ -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.
  *
  * 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.note.preview.filename
 // key: compiler.note.preview.recompile
-// options: --enable-preview -source 13
+// options: --enable-preview -source ${jdk.version}
 
 class SwitchExpressionCompletesNormally {
     public String convert(int i) {
diff --git a/test/langtools/tools/javac/diags/examples/SwitchExpressionEmpty.java b/test/langtools/tools/javac/diags/examples/SwitchExpressionEmpty.java
index 61c1d43cc04..8998ef0244f 100644
--- a/test/langtools/tools/javac/diags/examples/SwitchExpressionEmpty.java
+++ b/test/langtools/tools/javac/diags/examples/SwitchExpressionEmpty.java
@@ -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.
  *
  * 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.note.preview.filename
 // key: compiler.note.preview.recompile
-// options: --enable-preview -source 13
+// options: --enable-preview -source ${jdk.version}
 
 class BreakOutsideSwitchExpression {
     String t(E e) {
diff --git a/test/langtools/tools/javac/diags/examples/SwitchExpressionTargetCantBeVoid.java b/test/langtools/tools/javac/diags/examples/SwitchExpressionTargetCantBeVoid.java
index 96a52cdcf87..26d7cbd3aff 100644
--- a/test/langtools/tools/javac/diags/examples/SwitchExpressionTargetCantBeVoid.java
+++ b/test/langtools/tools/javac/diags/examples/SwitchExpressionTargetCantBeVoid.java
@@ -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.
  *
  * 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.note.preview.filename
 // key: compiler.note.preview.recompile
-// options: --enable-preview -source 13
+// options: --enable-preview -source ${jdk.version}
 
 class SwitchExpressionTargetCantBeVoid {
 
diff --git a/test/langtools/tools/javac/diags/examples/SwitchExpressions.java b/test/langtools/tools/javac/diags/examples/SwitchExpressions.java
index e386b651bd0..596814bfd64 100644
--- a/test/langtools/tools/javac/diags/examples/SwitchExpressions.java
+++ b/test/langtools/tools/javac/diags/examples/SwitchExpressions.java
@@ -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.
  *
  * 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.warn.preview.feature.use.plural
-// options: --enable-preview -source 13 -Xlint:preview
+// options: --enable-preview -source ${jdk.version} -Xlint:preview
 
 class SwitchExpressions {
     int m(int i) {
diff --git a/test/langtools/tools/javac/diags/examples/SwitchMixingCaseTypes.java b/test/langtools/tools/javac/diags/examples/SwitchMixingCaseTypes.java
index dcfcbbf0fc4..1c9747af7b5 100644
--- a/test/langtools/tools/javac/diags/examples/SwitchMixingCaseTypes.java
+++ b/test/langtools/tools/javac/diags/examples/SwitchMixingCaseTypes.java
@@ -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.
  *
  * 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.note.preview.filename
 // key: compiler.note.preview.recompile
-// options: --enable-preview -source 13
+// options: --enable-preview -source ${jdk.version}
 
 class SwitchMixingCaseTypes {
 
diff --git a/test/langtools/tools/javac/diags/examples/SwitchRules.java b/test/langtools/tools/javac/diags/examples/SwitchRules.java
index fe99b8366bd..5604cf4e821 100644
--- a/test/langtools/tools/javac/diags/examples/SwitchRules.java
+++ b/test/langtools/tools/javac/diags/examples/SwitchRules.java
@@ -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.
  *
  * 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.warn.preview.feature.use.plural
-// options: --enable-preview -source 13 -Xlint:preview
+// options: --enable-preview -source ${jdk.version} -Xlint:preview
 
 class SwitchExpressions {
     void m(int i) {
diff --git a/test/langtools/tools/javac/expswitch/ExpSwitchNestingTest.java b/test/langtools/tools/javac/expswitch/ExpSwitchNestingTest.java
index 84270313db0..9e65902c455 100644
--- a/test/langtools/tools/javac/expswitch/ExpSwitchNestingTest.java
+++ b/test/langtools/tools/javac/expswitch/ExpSwitchNestingTest.java
@@ -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.
  *
  * 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) {
         String s = "class C { static boolean cond = false; static int x = 0; void m() { # } }";
diff --git a/test/langtools/tools/javac/lambda/BadSwitchExpressionLambda.java b/test/langtools/tools/javac/lambda/BadSwitchExpressionLambda.java
index 14fe01726d7..9ad491c37d1 100644
--- a/test/langtools/tools/javac/lambda/BadSwitchExpressionLambda.java
+++ b/test/langtools/tools/javac/lambda/BadSwitchExpressionLambda.java
@@ -2,7 +2,7 @@
  * @test /nodynamiccopyright/
  * @bug 8206986
  * @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 {
diff --git a/test/langtools/tools/javac/parser/JavacParserTest.java b/test/langtools/tools/javac/parser/JavacParserTest.java
index 6844282258f..20e8f745efb 100644
--- a/test/langtools/tools/javac/parser/JavacParserTest.java
+++ b/test/langtools/tools/javac/parser/JavacParserTest.java
@@ -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.
  *
  * 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 {
     static final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
     static final JavaFileManager fm = tool.getStandardFileManager(null, null, null);
+    public static final String SOURCE_VERSION =
+        Integer.toString(Runtime.version().feature());
 
     private JavacParserTest(){}
 
     public static void main(String... args) throws Exception {
-        try {
+        try (fm) {
             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";
         StringWriter out = new StringWriter();
         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)));
 
         CompilationUnitTree cut = ct.parse().iterator().next();
diff --git a/test/langtools/tools/javac/preview/classReaderTest/Client.java b/test/langtools/tools/javac/preview/classReaderTest/Client.java
index 4c122887033..74bb99327d6 100644
--- a/test/langtools/tools/javac/preview/classReaderTest/Client.java
+++ b/test/langtools/tools/javac/preview/classReaderTest/Client.java
@@ -2,9 +2,9 @@
  * @test /nodynamiccopyright/
  * @bug 8199194
  * @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.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 {
diff --git a/test/langtools/tools/javac/switchexpr/BlockExpression.java b/test/langtools/tools/javac/switchexpr/BlockExpression.java
index 0534ccb180c..3411a01d3d6 100644
--- a/test/langtools/tools/javac/switchexpr/BlockExpression.java
+++ b/test/langtools/tools/javac/switchexpr/BlockExpression.java
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
  * @test
  * @bug 8206986
  * @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
  */
 
diff --git a/test/langtools/tools/javac/switchexpr/BooleanNumericNonNumeric.java b/test/langtools/tools/javac/switchexpr/BooleanNumericNonNumeric.java
index 2f5aac13fce..76f757fce4c 100644
--- a/test/langtools/tools/javac/switchexpr/BooleanNumericNonNumeric.java
+++ b/test/langtools/tools/javac/switchexpr/BooleanNumericNonNumeric.java
@@ -2,7 +2,7 @@
  * @test /nodynamiccopyright/
  * @bug 8206986
  * @summary Verify the type of a conditional expression with nested switch expression is computed properly
- * @compile/fail/ref=BooleanNumericNonNumeric.out -XDrawDiagnostics --enable-preview -source 13 BooleanNumericNonNumeric.java
+ * @compile/fail/ref=BooleanNumericNonNumeric.out -XDrawDiagnostics --enable-preview -source ${jdk.version} BooleanNumericNonNumeric.java
  */
 
 public class BooleanNumericNonNumeric {
diff --git a/test/langtools/tools/javac/switchexpr/BreakTest.java b/test/langtools/tools/javac/switchexpr/BreakTest.java
index ea8b22580e5..92676c58c87 100644
--- a/test/langtools/tools/javac/switchexpr/BreakTest.java
+++ b/test/langtools/tools/javac/switchexpr/BreakTest.java
@@ -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.
  *
  * 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 {
         final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        String sourceVersion = Integer.toString(Runtime.version().feature());
         assert tool != null;
         DiagnosticListener<JavaFileObject> noErrors = d -> {};
 
         StringWriter out = new StringWriter();
         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)));
         List<String> labels = new ArrayList<>();
         new TreePathScanner<Void, Void>() {
diff --git a/test/langtools/tools/javac/switchexpr/CRT.java b/test/langtools/tools/javac/switchexpr/CRT.java
index efaf656d822..b16b2265250 100644
--- a/test/langtools/tools/javac/switchexpr/CRT.java
+++ b/test/langtools/tools/javac/switchexpr/CRT.java
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -48,6 +48,8 @@ public class CRT {
         new CRT().run();
     }
 
+    private static final String SOURCE_VERSION = Integer.toString(Runtime.version().feature());
+
     private ToolBox tb = new ToolBox();
 
     private void run() throws Exception {
@@ -151,7 +153,7 @@ public class CRT {
         new JavacTask(tb)
                 .options("-Xjcov",
                          "--enable-preview",
-                         "-source", "13")
+                         "-source", SOURCE_VERSION)
                 .outdir(classes)
                 .sources("public class Test {\n" +
                          code +
diff --git a/test/langtools/tools/javac/switchexpr/DefiniteAssignment1.java b/test/langtools/tools/javac/switchexpr/DefiniteAssignment1.java
index d58c23bbb59..6e12f39f1bc 100644
--- a/test/langtools/tools/javac/switchexpr/DefiniteAssignment1.java
+++ b/test/langtools/tools/javac/switchexpr/DefiniteAssignment1.java
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
  * @test
  * @bug 8214031
  * @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
  */
 public class DefiniteAssignment1 {
diff --git a/test/langtools/tools/javac/switchexpr/DefiniteAssignment2.java b/test/langtools/tools/javac/switchexpr/DefiniteAssignment2.java
index 706b83d5ab8..bfd358f8c1a 100644
--- a/test/langtools/tools/javac/switchexpr/DefiniteAssignment2.java
+++ b/test/langtools/tools/javac/switchexpr/DefiniteAssignment2.java
@@ -2,7 +2,7 @@
  * @test /nodynamiccopyright/
  * @bug 8214031
  * @summary Verify that definite assignment when true works (illegal code)
- * @compile/fail/ref=DefiniteAssignment2.out --enable-preview --source 13 -XDrawDiagnostics DefiniteAssignment2.java
+ * @compile/fail/ref=DefiniteAssignment2.out --enable-preview --source ${jdk.version} -XDrawDiagnostics DefiniteAssignment2.java
  */
 public class DefiniteAssignment2 {
 
diff --git a/test/langtools/tools/javac/switchexpr/EmptySwitch.java b/test/langtools/tools/javac/switchexpr/EmptySwitch.java
index bf26578ea1b..553d9031024 100644
--- a/test/langtools/tools/javac/switchexpr/EmptySwitch.java
+++ b/test/langtools/tools/javac/switchexpr/EmptySwitch.java
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
  * @test
  * @bug 8206986
  * @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 {
diff --git a/test/langtools/tools/javac/switchexpr/ExhaustiveEnumSwitch.java b/test/langtools/tools/javac/switchexpr/ExhaustiveEnumSwitch.java
index bbe728a5300..7b38e291a6b 100644
--- a/test/langtools/tools/javac/switchexpr/ExhaustiveEnumSwitch.java
+++ b/test/langtools/tools/javac/switchexpr/ExhaustiveEnumSwitch.java
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
  * @test
  * @bug 8206986
  * @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
  * @run main/othervm --enable-preview ExhaustiveEnumSwitch
  */
diff --git a/test/langtools/tools/javac/switchexpr/ExpressionSwitch.java b/test/langtools/tools/javac/switchexpr/ExpressionSwitch.java
index 67c0fbb61d7..8acb340a9ab 100644
--- a/test/langtools/tools/javac/switchexpr/ExpressionSwitch.java
+++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitch.java
@@ -3,7 +3,7 @@
  * @bug 8206986
  * @summary Check expression switch works.
  * @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
  */
 
diff --git a/test/langtools/tools/javac/switchexpr/ExpressionSwitchBreaks1.java b/test/langtools/tools/javac/switchexpr/ExpressionSwitchBreaks1.java
index 198350e8862..f17b845a804 100644
--- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchBreaks1.java
+++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchBreaks1.java
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
  * @test
  * @bug 8206986
  * @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
  */
 
diff --git a/test/langtools/tools/javac/switchexpr/ExpressionSwitchBreaks2.java b/test/langtools/tools/javac/switchexpr/ExpressionSwitchBreaks2.java
index 66e9023b4ef..c9a5ba8fdd5 100644
--- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchBreaks2.java
+++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchBreaks2.java
@@ -2,7 +2,7 @@
  * @test /nodynamiccopyright/
  * @bug 8206986
  * @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 {
diff --git a/test/langtools/tools/javac/switchexpr/ExpressionSwitchBugs.java b/test/langtools/tools/javac/switchexpr/ExpressionSwitchBugs.java
index 873f9d1b59a..e26957e79b9 100644
--- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchBugs.java
+++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchBugs.java
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
  * @test
  * @bug 8206986 8214114 8214529
  * @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
  */
 
diff --git a/test/langtools/tools/javac/switchexpr/ExpressionSwitchBugsInGen.java b/test/langtools/tools/javac/switchexpr/ExpressionSwitchBugsInGen.java
index 9dd0c5e4b63..731a7d05441 100644
--- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchBugsInGen.java
+++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchBugsInGen.java
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
  * @test
  * @bug 8214031
  * @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
  */
 
diff --git a/test/langtools/tools/javac/switchexpr/ExpressionSwitchCodeFromJLS.java b/test/langtools/tools/javac/switchexpr/ExpressionSwitchCodeFromJLS.java
index f9564bafc86..b6547c2eb2e 100644
--- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchCodeFromJLS.java
+++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchCodeFromJLS.java
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
  * @test
  * @bug 8206986
  * @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
  */
 
diff --git a/test/langtools/tools/javac/switchexpr/ExpressionSwitchDA.java b/test/langtools/tools/javac/switchexpr/ExpressionSwitchDA.java
index 9815b27dd48..d54780c691e 100644
--- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchDA.java
+++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchDA.java
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
  * @test
  * @bug 8206986
  * @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
  */
 
diff --git a/test/langtools/tools/javac/switchexpr/ExpressionSwitchEmbedding.java b/test/langtools/tools/javac/switchexpr/ExpressionSwitchEmbedding.java
index 997b69ce927..f868e58ea36 100644
--- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchEmbedding.java
+++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchEmbedding.java
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
  * @test
  * @bug 8214031 8214114
  * @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
  */
 
diff --git a/test/langtools/tools/javac/switchexpr/ExpressionSwitchFallThrough.java b/test/langtools/tools/javac/switchexpr/ExpressionSwitchFallThrough.java
index f51e51ad9a0..e4d9fa37397 100644
--- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchFallThrough.java
+++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchFallThrough.java
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
  * @test
  * @bug 8206986
  * @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
  */
 
diff --git a/test/langtools/tools/javac/switchexpr/ExpressionSwitchFallThrough1.java b/test/langtools/tools/javac/switchexpr/ExpressionSwitchFallThrough1.java
index 2f60e88c7e5..e4db669707a 100644
--- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchFallThrough1.java
+++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchFallThrough1.java
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
  * @test
  * @bug 8206986
  * @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
  */
 
diff --git a/test/langtools/tools/javac/switchexpr/ExpressionSwitchFlow.java b/test/langtools/tools/javac/switchexpr/ExpressionSwitchFlow.java
index f5cd71af5cb..9125b23e08d 100644
--- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchFlow.java
+++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchFlow.java
@@ -2,7 +2,7 @@
  * @test /nodynamiccopyright/
  * @bug 8212982
  * @summary Verify a compile-time error is produced if switch expression does not provide a value
- * @compile/fail/ref=ExpressionSwitchFlow.out --enable-preview -source 13 -XDrawDiagnostics ExpressionSwitchFlow.java
+ * @compile/fail/ref=ExpressionSwitchFlow.out --enable-preview -source ${jdk.version} -XDrawDiagnostics ExpressionSwitchFlow.java
  */
 
 public class ExpressionSwitchFlow {
diff --git a/test/langtools/tools/javac/switchexpr/ExpressionSwitchInExpressionSwitch.java b/test/langtools/tools/javac/switchexpr/ExpressionSwitchInExpressionSwitch.java
index 6d57ffa16ea..76c262dc19b 100644
--- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchInExpressionSwitch.java
+++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchInExpressionSwitch.java
@@ -25,7 +25,7 @@
  * @test
  * @bug 8206986
  * @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
  */
 
diff --git a/test/langtools/tools/javac/switchexpr/ExpressionSwitchInfer.java b/test/langtools/tools/javac/switchexpr/ExpressionSwitchInfer.java
index 8b6d32535eb..72bd01f7e3c 100644
--- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchInfer.java
+++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchInfer.java
@@ -2,7 +2,7 @@
  * @test /nodynamiccopyright/
  * @bug 8206986
  * @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;
diff --git a/test/langtools/tools/javac/switchexpr/ExpressionSwitchIntersectionTypes.java b/test/langtools/tools/javac/switchexpr/ExpressionSwitchIntersectionTypes.java
index a1f13b83d76..f02853cee56 100644
--- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchIntersectionTypes.java
+++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchIntersectionTypes.java
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
  * @test
  * @bug 8206986
  * @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
  */
 
diff --git a/test/langtools/tools/javac/switchexpr/ExpressionSwitchNotExhaustive.java b/test/langtools/tools/javac/switchexpr/ExpressionSwitchNotExhaustive.java
index 8f4ea2e80c6..0f611e0e2ff 100644
--- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchNotExhaustive.java
+++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchNotExhaustive.java
@@ -2,7 +2,7 @@
  * @test /nodynamiccopyright/
  * @bug 8206986
  * @summary Verify behavior of not exhaustive switch expressions.
- * @compile/fail/ref=ExpressionSwitchNotExhaustive.out -XDrawDiagnostics --enable-preview -source 13 ExpressionSwitchNotExhaustive.java
+ * @compile/fail/ref=ExpressionSwitchNotExhaustive.out -XDrawDiagnostics --enable-preview -source ${jdk.version} ExpressionSwitchNotExhaustive.java
  */
 
 public class ExpressionSwitchNotExhaustive {
diff --git a/test/langtools/tools/javac/switchexpr/ExpressionSwitchUnreachable.java b/test/langtools/tools/javac/switchexpr/ExpressionSwitchUnreachable.java
index 978e49e1088..88c6dfe031c 100644
--- a/test/langtools/tools/javac/switchexpr/ExpressionSwitchUnreachable.java
+++ b/test/langtools/tools/javac/switchexpr/ExpressionSwitchUnreachable.java
@@ -2,7 +2,7 @@
  * @test /nodynamiccopyright/
  * @bug 8206986
  * @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 {
diff --git a/test/langtools/tools/javac/switchexpr/ParseIncomplete.java b/test/langtools/tools/javac/switchexpr/ParseIncomplete.java
index 159ba634d96..b5b886f2cb9 100644
--- a/test/langtools/tools/javac/switchexpr/ParseIncomplete.java
+++ b/test/langtools/tools/javac/switchexpr/ParseIncomplete.java
@@ -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.
  *
  * 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();
         assert tool != null;
         DiagnosticListener<JavaFileObject> noErrors = d -> {};
+        String sourceVersion = Integer.toString(Runtime.version().feature());
 
         for (int i = 0; i < CODE.length(); i++) {
             String code = CODE.substring(0, i + 1);
             StringWriter out = new StringWriter();
             try {
                 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)));
                 ct.parse().iterator().next();
             } catch (Throwable t) {
diff --git a/test/langtools/tools/javac/switchexpr/ParserRecovery.java b/test/langtools/tools/javac/switchexpr/ParserRecovery.java
index 7c197c288b8..f3f657a5006 100644
--- a/test/langtools/tools/javac/switchexpr/ParserRecovery.java
+++ b/test/langtools/tools/javac/switchexpr/ParserRecovery.java
@@ -2,7 +2,7 @@
  * @test /nodynamiccopyright/
  * @bug 8206986
  * @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 {
diff --git a/test/langtools/tools/javac/switchexpr/SwitchExpressionIsNotAConstant.java b/test/langtools/tools/javac/switchexpr/SwitchExpressionIsNotAConstant.java
index 1cae5e7ade9..b2ec637ba42 100644
--- a/test/langtools/tools/javac/switchexpr/SwitchExpressionIsNotAConstant.java
+++ b/test/langtools/tools/javac/switchexpr/SwitchExpressionIsNotAConstant.java
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,7 @@
  * @bug 8214113
  * @summary Verify the switch expression's type does not have a constant attached,
  *          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
  */
 public class SwitchExpressionIsNotAConstant {
diff --git a/test/langtools/tools/javac/switchexpr/SwitchExpressionScopesIsolated.java b/test/langtools/tools/javac/switchexpr/SwitchExpressionScopesIsolated.java
index 295a1dc9119..66d842e3f6e 100644
--- a/test/langtools/tools/javac/switchexpr/SwitchExpressionScopesIsolated.java
+++ b/test/langtools/tools/javac/switchexpr/SwitchExpressionScopesIsolated.java
@@ -2,7 +2,7 @@
  * @test /nodynamiccopyright/
  * @bug 8206986
  * @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 {
diff --git a/test/langtools/tools/javac/switchexpr/SwitchExpressionSimpleVisitorTest.java b/test/langtools/tools/javac/switchexpr/SwitchExpressionSimpleVisitorTest.java
index 4df450874c6..116c59297bb 100644
--- a/test/langtools/tools/javac/switchexpr/SwitchExpressionSimpleVisitorTest.java
+++ b/test/langtools/tools/javac/switchexpr/SwitchExpressionSimpleVisitorTest.java
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -89,7 +89,7 @@ public class SwitchExpressionSimpleVisitorTest {
 
         StringWriter out = new StringWriter();
         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)));
         return ct.parse().iterator().next();
     }
diff --git a/test/langtools/tools/javac/switchexpr/TryCatch.java b/test/langtools/tools/javac/switchexpr/TryCatch.java
index 768292b3b5d..cc8aadf5998 100644
--- a/test/langtools/tools/javac/switchexpr/TryCatch.java
+++ b/test/langtools/tools/javac/switchexpr/TryCatch.java
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
  * @test
  * @bug 8214114
  * @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
  */
 public class TryCatch {
diff --git a/test/langtools/tools/javac/switchextra/CaseTest.java b/test/langtools/tools/javac/switchextra/CaseTest.java
index 99315e79213..b678582c25d 100644
--- a/test/langtools/tools/javac/switchextra/CaseTest.java
+++ b/test/langtools/tools/javac/switchextra/CaseTest.java
@@ -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.
  *
  * 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 static void main(String[] args) throws Exception {
-        new CaseTest().testLabels();
-        new CaseTest().testStatement();
-        new CaseTest().testRule();
+        String sourceVersion = Integer.toString(Runtime.version().feature());
+        new CaseTest().testLabels(sourceVersion);
+        new CaseTest().testStatement(sourceVersion);
+        new CaseTest().testRule(sourceVersion);
     }
 
-    void testLabels() throws Exception {
+    void testLabels(String sourceVersion) throws Exception {
         String code = "class Test {\n" +
                       "    void t(int i) {\n" +
                       "         switch(i) {\n" +
@@ -72,7 +73,7 @@ public class CaseTest {
                                                 .collect(Collectors.joining(",", "[", "]")));
                 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", "[]");
 
@@ -81,7 +82,7 @@ public class CaseTest {
         }
     }
 
-    void testStatement() throws Exception {
+    void testStatement(String sourceVersion) throws Exception {
         String code = "class Test {\n" +
                       "    void t(int i) {\n" +
                       "         switch(i) {\n" +
@@ -102,10 +103,10 @@ public class CaseTest {
                 }
                 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" +
                       "    void t(int i) {\n" +
                       "         switch(i) {\n" +
@@ -126,17 +127,17 @@ public class CaseTest {
                 }
                 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();
         assert tool != null;
         DiagnosticListener<JavaFileObject> noErrors = d -> {};
 
         StringWriter out = new StringWriter();
         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)));
         return ct.parse().iterator().next();
     }
diff --git a/test/langtools/tools/javac/switchextra/MultipleLabelsExpression.java b/test/langtools/tools/javac/switchextra/MultipleLabelsExpression.java
index 170da1b3375..9a57143c10d 100644
--- a/test/langtools/tools/javac/switchextra/MultipleLabelsExpression.java
+++ b/test/langtools/tools/javac/switchextra/MultipleLabelsExpression.java
@@ -3,7 +3,7 @@
  * @bug 8206986
  * @summary Verify cases with multiple labels work properly.
  * @compile/fail/ref=MultipleLabelsExpression-old.out -source 9 -Xlint:-options -XDrawDiagnostics MultipleLabelsExpression.java
- * @compile --enable-preview -source 13 MultipleLabelsExpression.java
+ * @compile --enable-preview -source ${jdk.version} MultipleLabelsExpression.java
  * @run main/othervm --enable-preview MultipleLabelsExpression
  */
 
diff --git a/test/langtools/tools/javac/switchextra/MultipleLabelsStatement.java b/test/langtools/tools/javac/switchextra/MultipleLabelsStatement.java
index b674e92b960..9477baa7579 100644
--- a/test/langtools/tools/javac/switchextra/MultipleLabelsStatement.java
+++ b/test/langtools/tools/javac/switchextra/MultipleLabelsStatement.java
@@ -3,7 +3,7 @@
  * @bug 8206986
  * @summary Verify cases with multiple labels work properly.
  * @compile/fail/ref=MultipleLabelsStatement-old.out -source 9 -Xlint:-options -XDrawDiagnostics MultipleLabelsStatement.java
- * @compile --enable-preview -source 13 MultipleLabelsStatement.java
+ * @compile --enable-preview -source ${jdk.version} MultipleLabelsStatement.java
  * @run main/othervm --enable-preview MultipleLabelsStatement
  */
 
diff --git a/test/langtools/tools/javac/switchextra/RuleParsingTest.java b/test/langtools/tools/javac/switchextra/RuleParsingTest.java
index afdaa929edc..affda29ba04 100644
--- a/test/langtools/tools/javac/switchextra/RuleParsingTest.java
+++ b/test/langtools/tools/javac/switchextra/RuleParsingTest.java
@@ -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.
  *
  * 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 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 = {
             "(a)",
             "a",
@@ -94,7 +95,7 @@ public class RuleParsingTest {
 
         StringWriter out = new StringWriter();
         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())));
         CompilationUnitTree cut = ct.parse().iterator().next();
         Trees trees = Trees.instance(ct);
diff --git a/test/langtools/tools/javac/switchextra/SwitchArrowBrokenConstant.java b/test/langtools/tools/javac/switchextra/SwitchArrowBrokenConstant.java
index e1cec5ac34d..c8beda59080 100644
--- a/test/langtools/tools/javac/switchextra/SwitchArrowBrokenConstant.java
+++ b/test/langtools/tools/javac/switchextra/SwitchArrowBrokenConstant.java
@@ -3,7 +3,7 @@
  * @bug 8206986
  * @summary Verify reasonable errors are produced when neither ':' nor '->'
  *          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 {
diff --git a/test/langtools/tools/javac/switchextra/SwitchStatementArrow.java b/test/langtools/tools/javac/switchextra/SwitchStatementArrow.java
index 599adacc97f..f8fd3092ab1 100644
--- a/test/langtools/tools/javac/switchextra/SwitchStatementArrow.java
+++ b/test/langtools/tools/javac/switchextra/SwitchStatementArrow.java
@@ -3,7 +3,7 @@
  * @bug 8206986
  * @summary Verify rule cases work properly.
  * @compile/fail/ref=SwitchStatementArrow-old.out -source 9 -Xlint:-options -XDrawDiagnostics SwitchStatementArrow.java
- * @compile --enable-preview -source 13 SwitchStatementArrow.java
+ * @compile --enable-preview -source ${jdk.version} SwitchStatementArrow.java
  * @run main/othervm --enable-preview SwitchStatementArrow
  */
 
diff --git a/test/langtools/tools/javac/switchextra/SwitchStatementBroken.java b/test/langtools/tools/javac/switchextra/SwitchStatementBroken.java
index 6882c2d0e1e..d9ef86150e8 100644
--- a/test/langtools/tools/javac/switchextra/SwitchStatementBroken.java
+++ b/test/langtools/tools/javac/switchextra/SwitchStatementBroken.java
@@ -2,7 +2,7 @@
  * @test /nodynamiccopyright/
  * @bug 8206986
  * @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 {
diff --git a/test/langtools/tools/javac/switchextra/SwitchStatementBroken2.java b/test/langtools/tools/javac/switchextra/SwitchStatementBroken2.java
index 8bb6bc018ef..2af02092254 100644
--- a/test/langtools/tools/javac/switchextra/SwitchStatementBroken2.java
+++ b/test/langtools/tools/javac/switchextra/SwitchStatementBroken2.java
@@ -2,7 +2,7 @@
  * @test /nodynamiccopyright/
  * @bug 8206986
  * @summary Verify that not allowed types of statements cannot be used in rule case.
- * @compile/fail/ref=SwitchStatementBroken2.out -XDrawDiagnostics --enable-preview -source 13 SwitchStatementBroken2.java
+ * @compile/fail/ref=SwitchStatementBroken2.out -XDrawDiagnostics --enable-preview -source ${jdk.version} SwitchStatementBroken2.java
  */
 
 public class SwitchStatementBroken2 {
diff --git a/test/langtools/tools/javac/switchextra/SwitchStatementScopesIsolated.java b/test/langtools/tools/javac/switchextra/SwitchStatementScopesIsolated.java
index 896a4d9ca3b..88036c524d4 100644
--- a/test/langtools/tools/javac/switchextra/SwitchStatementScopesIsolated.java
+++ b/test/langtools/tools/javac/switchextra/SwitchStatementScopesIsolated.java
@@ -2,7 +2,7 @@
  * @test /nodynamiccopyright/
  * @bug 8206986
  * @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 {