7025784: Add SourceVersion.RELEASE_8
authordarcy
Wed, 01 Jun 2011 23:56:31 -0700
changeset 10180 b293c1f36ac4
parent 10175 9adcace810dd
child 10181 c82fc01db7a0
7025784: Add SourceVersion.RELEASE_8 7025786: Add -source 8 and -target 8 to javac 7025789: Change javac source and target default to 8 Reviewed-by: jjg
langtools/src/share/classes/com/sun/tools/javac/code/Source.java
langtools/src/share/classes/com/sun/tools/javac/jvm/Target.java
langtools/src/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java
langtools/src/share/classes/javax/lang/model/SourceVersion.java
langtools/test/tools/javac/6330997/T6330997.java
langtools/test/tools/javac/api/T6395981.java
langtools/test/tools/javac/processing/warnings/TestSourceVersionWarnings.java
langtools/test/tools/javac/quid/T6999438.java
langtools/test/tools/javac/versions/check.sh
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Source.java	Tue May 24 15:28:18 2011 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Source.java	Wed Jun 01 23:56:31 2011 -0700
@@ -64,8 +64,11 @@
     /** 1.6 reports encoding problems as errors instead of warnings. */
     JDK1_6("1.6"),
 
-    /** 1.7 covers the to be determined language features that will be added in JDK 7. */
-    JDK1_7("1.7");
+    /** 1.7 introduced try-with-resources, multi-catch, string switch, etc. */
+    JDK1_7("1.7"),
+
+    /** 1.8 covers the to be determined language features that will be added in JDK 8. */
+    JDK1_8("1.8");
 
     private static final Context.Key<Source> sourceKey
         = new Context.Key<Source>();
@@ -92,19 +95,21 @@
         tab.put("5", JDK1_5); // Make 5 an alias for 1.5
         tab.put("6", JDK1_6); // Make 6 an alias for 1.6
         tab.put("7", JDK1_7); // Make 7 an alias for 1.7
+        tab.put("8", JDK1_8); // Make 8 an alias for 1.8
     }
 
     private Source(String name) {
         this.name = name;
     }
 
-    public static final Source DEFAULT = JDK1_7;
+    public static final Source DEFAULT = JDK1_8;
 
     public static Source lookup(String name) {
         return tab.get(name);
     }
 
     public Target requiredTarget() {
+        if (this.compareTo(JDK1_8) >= 0) return Target.JDK1_8;
         if (this.compareTo(JDK1_7) >= 0) return Target.JDK1_7;
         if (this.compareTo(JDK1_6) >= 0) return Target.JDK1_6;
         if (this.compareTo(JDK1_5) >= 0) return Target.JDK1_5;
@@ -203,6 +208,8 @@
             return RELEASE_6;
         case JDK1_7:
             return RELEASE_7;
+        case JDK1_8:
+            return RELEASE_8;
         default:
             return null;
         }
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Target.java	Tue May 24 15:28:18 2011 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Target.java	Wed Jun 01 23:56:31 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2011, 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
@@ -66,7 +66,10 @@
     JDK1_6("1.6", 50, 0),
 
     /** JDK 7. */
-    JDK1_7("1.7", 51, 0);
+    JDK1_7("1.7", 51, 0),
+
+    /** JDK 8. */ // For now, a clone of 7
+    JDK1_8("1.8", 51, 0);
 
     private static final Context.Key<Target> targetKey =
         new Context.Key<Target>();
@@ -99,6 +102,7 @@
         tab.put("5", JDK1_5);
         tab.put("6", JDK1_6);
         tab.put("7", JDK1_7);
+        tab.put("8", JDK1_8);
     }
 
     public final String name;
@@ -110,7 +114,7 @@
         this.minorVersion = minorVersion;
     }
 
-    public static final Target DEFAULT = JDK1_7;
+    public static final Target DEFAULT = JDK1_8;
 
     public static Target lookup(String name) {
         return tab.get(name);
--- a/langtools/src/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java	Tue May 24 15:28:18 2011 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java	Wed Jun 01 23:56:31 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, 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,8 +48,7 @@
  * deletion without notice.</b>
  */
 @SupportedAnnotationTypes("*")
-// TODO: Change to version 7 based visitors when available
-@SupportedSourceVersion(SourceVersion.RELEASE_7)
+@SupportedSourceVersion(SourceVersion.RELEASE_8)
 public class PrintingProcessor extends AbstractProcessor {
     PrintWriter writer;
 
--- a/langtools/src/share/classes/javax/lang/model/SourceVersion.java	Tue May 24 15:28:18 2011 -0700
+++ b/langtools/src/share/classes/javax/lang/model/SourceVersion.java	Wed Jun 01 23:56:31 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, 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
@@ -124,7 +124,15 @@
      *
      * @since 1.7
      */
-    RELEASE_7;
+    RELEASE_7,
+
+    /**
+     * The version recognized by the Java Platform, Standard Edition
+     * 8.
+     *
+     * @since 1.8
+     */
+    RELEASE_8;
 
     // Note that when adding constants for newer releases, the
     // behavior of latest() and latestSupported() must be updated too.
@@ -135,7 +143,7 @@
      * @return the latest source version that can be modeled
      */
     public static SourceVersion latest() {
-        return RELEASE_7;
+        return RELEASE_8;
     }
 
     private static final SourceVersion latestSupported = getLatestSupported();
@@ -143,9 +151,12 @@
     private static SourceVersion getLatestSupported() {
         try {
             String specVersion = System.getProperty("java.specification.version");
-            if ("1.7".equals(specVersion))
+
+            if ("1.8".equals(specVersion))
+                return RELEASE_8;
+            else if("1.7".equals(specVersion))
                 return RELEASE_7;
-            else if ("1.6".equals(specVersion))
+            else if("1.6".equals(specVersion))
                 return RELEASE_6;
         } catch (SecurityException se) {}
 
--- a/langtools/test/tools/javac/6330997/T6330997.java	Tue May 24 15:28:18 2011 -0700
+++ b/langtools/test/tools/javac/6330997/T6330997.java	Wed Jun 01 23:56:31 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2011, 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,12 +23,12 @@
 
 /**
  * @test
- * @bug     6330997
+ * @bug     6330997 7025789
  * @summary javac should accept class files with major version of the next release
  * @author  Wei Tao
  * @clean T1 T2
- * @compile -target 7 T1.java
- * @compile -target 7 T2.java
+ * @compile -target 8 T1.java
+ * @compile -target 8 T2.java
  * @run main/othervm T6330997
  */
 
--- a/langtools/test/tools/javac/api/T6395981.java	Tue May 24 15:28:18 2011 -0700
+++ b/langtools/test/tools/javac/api/T6395981.java	Wed Jun 01 23:56:31 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2011 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,13 +23,13 @@
 
 /*
  * @test
- * @bug     6395981 6458819
+ * @bug     6395981 6458819 7025784
  * @summary JavaCompilerTool and Tool must specify version of JLS and JVMS
  * @author  Peter von der Ah\u00e9
  * @run main/fail T6395981
  * @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 T6395981 RELEASE_3 RELEASE_4 RELEASE_5 RELEASE_6 RELEASE_7
+ * @run main T6395981 RELEASE_3 RELEASE_4 RELEASE_5 RELEASE_6 RELEASE_7 RELEASE_8
  */
 
 import java.util.EnumSet;
--- a/langtools/test/tools/javac/processing/warnings/TestSourceVersionWarnings.java	Tue May 24 15:28:18 2011 -0700
+++ b/langtools/test/tools/javac/processing/warnings/TestSourceVersionWarnings.java	Wed Jun 01 23:56:31 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2011, 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 6376083 6376084 6458819
+ * @bug 6376083 6376084 6458819 7025784 7025786 7025789
  * @summary Test that warnings about source versions are output as expected.
  * @author  Joseph D. Darcy
  * @compile TestSourceVersionWarnings.java
@@ -35,7 +35,8 @@
  * @compile/ref=gold_sv_warn_5_6.out   -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_5 -source 1.6 -Xlint:-options HelloWorld.java
  * @compile/ref=gold_sv_none.out       -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_6 -source 1.6 -Xlint:-options HelloWorld.java
  * @compile/ref=gold_unsp_warn.out     -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_6 -source 1.6 -Xlint:-options -Aunsupported HelloWorld.java
- * @compile/ref=gold_sv_none.out       -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_7 -source 1.7                 HelloWorld.java
+ * @compile/ref=gold_sv_none.out       -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_7 -source 1.7 -Xlint:-options HelloWorld.java
+ * @compile/ref=gold_sv_none.out       -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_8 -source 1.8                 HelloWorld.java
  */
 
 import java.util.Set;
@@ -51,7 +52,8 @@
 /**
  * This processor returns the supported source level as indicated by
  * the "SourceLevel" option; therefore, don't use
- * JavacTestingAbstractProcessor which returns the latest source level.
+ * JavacTestingAbstractProcessor which returns the latest source
+ * level.
  */
 @SupportedAnnotationTypes("*")
 @SupportedOptions("SourceVersion")
--- a/langtools/test/tools/javac/quid/T6999438.java	Tue May 24 15:28:18 2011 -0700
+++ b/langtools/test/tools/javac/quid/T6999438.java	Wed Jun 01 23:56:31 2011 -0700
@@ -1,7 +1,7 @@
 /* @test /nodynamiccopyright/
  * @bug 6999438
  * @summary remove support for exotic identifiers from JDK 7
- * @compile/fail/ref=T6999438.out -XDrawDiagnostics -source 7 T6999438.java
+ * @compile/fail/ref=T6999438.out -XDrawDiagnostics T6999438.java
  */
 
 class Test {
--- a/langtools/test/tools/javac/versions/check.sh	Tue May 24 15:28:18 2011 -0700
+++ b/langtools/test/tools/javac/versions/check.sh	Wed Jun 01 23:56:31 2011 -0700
@@ -22,7 +22,7 @@
 #
 
 # @test
-# @bug 4981566 5028634 5094412 6304984
+# @bug 4981566 5028634 5094412 6304984 7025786 7025789
 # @summary Check interpretation of -target and -source options
 # @build CheckClassFileVersion
 # @run shell check.sh 
@@ -65,9 +65,14 @@
 check 51.0 -source 6
 check 51.0 -source 1.7
 check 51.0 -source 7
-check 51.0 -target 1.7
-check 51.0 -target 7
+check 51.0 -source 7 -target 1.7
+check 51.0 -source 7 -target 7
 
+# Update when class file version is revved
+check 51.0 -source 1.8
+check 51.0 -source 8
+check 51.0 -target 1.8
+check 51.0 -target 8
 
 # Check source versions
 
@@ -96,6 +101,7 @@
 checksrc15() { pass $* $TC/X.java; pass $* $TC/Y.java; }
 checksrc16() { checksrc15 $* ; }
 checksrc17() { checksrc15 $* ; }
+checksrc18() { checksrc15 $* ; }
 
 checksrc14 -source 1.4
 checksrc14 -source 1.4 -target 1.5
@@ -108,16 +114,24 @@
 checksrc16 -source 1.6 -target 1.6
 checksrc16 -source 6 -target 6
 
-checksrc17
-checksrc17 -target 1.7
-checksrc17 -target 7
 checksrc17 -source 1.7
 checksrc17 -source 7
 checksrc17 -source 1.7 -target 1.7
 checksrc17 -source 7 -target 7
 
+checksrc18
+checksrc18 -target 1.8
+checksrc18 -target 8
+checksrc18 -source 1.8
+checksrc18 -source 8
+checksrc18 -source 1.8 -target 1.8
+checksrc18 -source 8 -target 8
+
 fail -source 1.5 -target 1.4 $TC/X.java
 fail -source 1.6 -target 1.4 $TC/X.java
 fail -source 6   -target 1.4 $TC/X.java
 fail -source 1.6 -target 1.5 $TC/X.java
 fail -source 6   -target 1.5 $TC/X.java
+fail -source 7   -target 1.6 $TC/X.java
+fail -source 8   -target 1.6 $TC/X.java
+fail -source 8   -target 1.7 $TC/X.java