JDK 9 RFR for JDK-8028543 Add SourceVersion.RELEASE_9

Joseph Darcy joe.darcy at oracle.com
Fri Dec 6 14:11:30 PST 2013


Hello,

With JDK 9 going to get underway soon, please review the patch below to 
address

     JDK-8028543 Add SourceVersion.RELEASE_9
     https://bugs.openjdk.java.net/browse/JDK-8028543

     http://cr.openjdk.java.net/~darcy/8028543.0/

Thanks,

-Joe

--- old/src/share/classes/javax/lang/model/SourceVersion.java 2013-12-06 
14:06:51.000000000 -0800
+++ new/src/share/classes/javax/lang/model/SourceVersion.java 2013-12-06 
14:06:51.000000000 -0800
@@ -55,6 +55,7 @@
       * 1.6: no changes
       * 1.7: diamond syntax, try-with-resources, etc.
       * 1.8: lambda expressions and default methods
+     * 1.9: To be determined
       */

      /**
@@ -138,7 +139,15 @@
       * Additions in this release include lambda expressions and 
default methods.
       * @since 1.8
       */
-    RELEASE_8;
+    RELEASE_8,
+
+    /**
+     * The version recognized by the Java Platform, Standard Edition
+     * 9.
+     *
+     * @since 1.9
+     */
+     RELEASE_9;

      // Note that when adding constants for newer releases, the
      // behavior of latest() and latestSupported() must be updated too.
@@ -149,21 +158,23 @@
       * @return the latest source version that can be modeled
       */
      public static SourceVersion latest() {
-        return RELEASE_8;
+        return RELEASE_9;
      }

      private static final SourceVersion latestSupported = 
getLatestSupported();

      private static SourceVersion getLatestSupported() {
          try {
-            String specVersion = 
System.getProperty("java.specification.version");
-
-            if ("1.8".equals(specVersion))
+            switch (System.getProperty("java.specification.version")) {
+            case "1.9":
+                return RELEASE_9;
+            case "1.8":
                  return RELEASE_8;
-            else if("1.7".equals(specVersion))
+            case "1.7":
                  return RELEASE_7;
-            else if("1.6".equals(specVersion))
+            case "1.6":
                  return RELEASE_6;
+            }
          } catch (SecurityException se) {}

          return RELEASE_5;
@@ -269,7 +280,6 @@
       * @return {@code true} if {@code s} is a keyword or literal, 
{@code false} otherwise.
       */
      public static boolean isKeyword(CharSequence s) {
-        String keywordOrLiteral = s.toString();
-        return keywords.contains(keywordOrLiteral);
+        return keywords.contains(s.toString());
      }
  }
--- old/test/tools/javac/processing/model/TestSourceVersion.java 
2013-12-06 14:06:51.000000000 -0800
+++ new/test/tools/javac/processing/model/TestSourceVersion.java 
2013-12-06 14:06:51.000000000 -0800
@@ -1,5 +1,5 @@
  /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, 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 @@

  /*
   * @test
- * @bug 7025809
+ * @bug 7025809 8028543
   * @summary Test latest and latestSupported
   * @author  Joseph D. Darcy
   */
@@ -36,8 +36,8 @@
   */
  public class TestSourceVersion {
      public static void main(String... args) {
-        if (SourceVersion.latest() != RELEASE_8 ||
-            SourceVersion.latestSupported() != RELEASE_8)
+        if (SourceVersion.latest() != RELEASE_9 ||
+            SourceVersion.latestSupported() != RELEASE_9)
              throw new RuntimeException("Unexpected release value(s) 
found:\n" +
                                         "latest:\t" + 
SourceVersion.latest() + "\n" +
                                         "latestSupported:\t" + 
SourceVersion.latestSupported());



More information about the compiler-dev mailing list