JDK 11 RFR of 8196551: Update TestSourceVersion.java to be robust across version changes
joe darcy
joe.darcy at oracle.com
Thu Feb 1 05:42:48 UTC 2018
Hello,
Please review the patch below to address
8196551: Update TestSourceVersion.java to be robust across version
changes
As the summary implies, the intention of this change is to avoid the
need separately update the test in question when a new SourceVersion
value is added and when the version of the JDK is bumped.
Until the version is bumped, it is acceptable for latest() to be one
release ahead of latestSupported(), as is true of current builds of the
JDK 11 line of development which don't have the version increment yet.
I thought it was clearer to write the acceptable condition directly
rather than apply de Morgan to the whole boolean expression.
Thanks,
-Joe
--- a/test/langtools/tools/javac/processing/model/TestSourceVersion.java
Wed Jan 31 15:15:09 2018 -0800
+++ b/test/langtools/tools/javac/processing/model/TestSourceVersion.java
Wed Jan 31 21:38:47 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() {
More information about the compiler-dev
mailing list