8196551: Update TestSourceVersion.java to be robust across version changes
authordarcy
Thu, 01 Feb 2018 09:16:03 -0800
changeset 48694 b0a54e2ba484
parent 48693 a2d550f08617
child 48695 a7ce228abcd7
8196551: Update TestSourceVersion.java to be robust across version changes Reviewed-by: vromero
test/langtools/tools/javac/processing/model/TestSourceVersion.java
--- a/test/langtools/tools/javac/processing/model/TestSourceVersion.java	Thu Feb 01 09:07:25 2018 -0800
+++ b/test/langtools/tools/javac/processing/model/TestSourceVersion.java	Thu Feb 01 09:16:03 2018 -0800
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 7025809 8028543 6415644 8028544 8029942 8187951 8193291
+ * @bug 7025809 8028543 6415644 8028544 8029942 8187951 8193291 8196551
  * @summary Test latest, latestSupported, underscore as keyword, etc.
  * @author  Joseph D. Darcy
  * @modules java.compiler
@@ -46,11 +46,20 @@
     }
 
     private static void testLatestSupported() {
-        if (SourceVersion.latest() != RELEASE_11 ||
-            SourceVersion.latestSupported() != RELEASE_10)
+        SourceVersion[] values = SourceVersion.values();
+        SourceVersion last = values[values.length - 1];
+        SourceVersion latest = SourceVersion.latest();
+        SourceVersion latestSupported = SourceVersion.latestSupported();
+
+        if (latest == last &&
+            latestSupported == SourceVersion.valueOf("RELEASE_" + Runtime.version().feature()) &&
+            (latest == latestSupported || (latest.ordinal() - latestSupported.ordinal() == 1)) )
+            return;
+        else {
             throw new RuntimeException("Unexpected release value(s) found:\n" +
-                                       "latest:\t" + SourceVersion.latest() + "\n" +
-                                       "latestSupported:\t" + SourceVersion.latestSupported());
+                                       "latest:\t" + latest + "\n" +
+                                       "latestSupported:\t" + latestSupported);
+        }
     }
 
     private static void testVersionVaryingKeywords() {