8188870: Bump classfile version number to 54
authorpsandoz
Fri, 03 Nov 2017 10:01:08 -0700
changeset 48081 89829dd3cc54
parent 48080 18a4438eb690
child 48082 d8c634b016c6
child 48083 b1c1b4ef4be2
8188870: Bump classfile version number to 54 Reviewed-by: alanb, dholmes, coleenp, mcimadamore
src/hotspot/share/classfile/classFileParser.cpp
src/java.base/share/classes/com/sun/java/util/jar/pack/Constants.java
src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassReader.java
src/java.base/share/classes/jdk/internal/org/objectweb/asm/Opcodes.java
src/java.base/share/native/include/classfile_constants.h
src/java.base/share/native/libjava/System.c
src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassFile.java
src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java
src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java
src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Target.java
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/classfile/Classfile.java
src/jdk.rmic/share/classes/sun/tools/java/RuntimeConstants.java
test/hotspot/jtreg/runtime/classFileParserBug/Class54.jasm
test/langtools/tools/javac/6330997/T6330997.java
test/langtools/tools/javac/classfiles/ClassVersionChecker.java
test/langtools/tools/javac/versions/Versions.java
--- a/src/hotspot/share/classfile/classFileParser.cpp	Wed Dec 06 14:33:33 2017 +0000
+++ b/src/hotspot/share/classfile/classFileParser.cpp	Fri Nov 03 10:01:08 2017 -0700
@@ -86,7 +86,7 @@
 
 #define JAVA_CLASSFILE_MAGIC              0xCAFEBABE
 #define JAVA_MIN_SUPPORTED_VERSION        45
-#define JAVA_MAX_SUPPORTED_VERSION        53
+#define JAVA_MAX_SUPPORTED_VERSION        54
 #define JAVA_MAX_SUPPORTED_MINOR_VERSION  0
 
 // Used for two backward compatibility reasons:
@@ -108,6 +108,8 @@
 
 #define JAVA_9_VERSION                    53
 
+#define JAVA_10_VERSION                   54
+
 void ClassFileParser::set_class_bad_constant_seen(short bad_constant) {
   assert((bad_constant == 19 || bad_constant == 20) && _major_version >= JAVA_9_VERSION,
          "Unexpected bad constant pool entry");
--- a/src/java.base/share/classes/com/sun/java/util/jar/pack/Constants.java	Wed Dec 06 14:33:33 2017 +0000
+++ b/src/java.base/share/classes/com/sun/java/util/jar/pack/Constants.java	Fri Nov 03 10:01:08 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, 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,6 +47,7 @@
         1.7 to 1.7.X 51,0
         1.8 to 1.8.X 52,0
         1.9 to 1.9.X 53,0
+        1.10 to 1.10.X 54,0
     */
 
     public static final Package.Version JAVA_MIN_CLASS_VERSION =
@@ -67,6 +68,9 @@
     public static final Package.Version JAVA9_MAX_CLASS_VERSION =
             Package.Version.of(53, 00);
 
+    public static final Package.Version JAVA10_MAX_CLASS_VERSION =
+            Package.Version.of(54, 00);
+
     public static final int JAVA_PACKAGE_MAGIC = 0xCAFED00D;
 
     public static final Package.Version JAVA5_PACKAGE_VERSION =
@@ -83,7 +87,7 @@
 
     // upper limit, should point to the latest class version
     public static final Package.Version JAVA_MAX_CLASS_VERSION =
-            JAVA9_MAX_CLASS_VERSION;
+            JAVA10_MAX_CLASS_VERSION;
 
     // upper limit should point to the latest package version, for version info!.
     public static final Package.Version MAX_PACKAGE_VERSION =
--- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassReader.java	Wed Dec 06 14:33:33 2017 +0000
+++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassReader.java	Fri Nov 03 10:01:08 2017 -0700
@@ -185,7 +185,7 @@
     public ClassReader(final byte[] b, final int off, final int len) {
         this.b = b;
         // checks the class version
-        if (readShort(off + 6) > Opcodes.V9) {
+        if (readShort(off + 6) > Opcodes.V10) {
             throw new IllegalArgumentException();
         }
         // parses the constant pool
--- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Opcodes.java	Wed Dec 06 14:33:33 2017 +0000
+++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Opcodes.java	Fri Nov 03 10:01:08 2017 -0700
@@ -89,6 +89,7 @@
     int V1_7 = 0 << 16 | 51;
     int V1_8 = 0 << 16 | 52;
     int V9 = 0 << 16 | 53;
+    int V10 = 0 << 16 | 54;
 
     // access flags
 
--- a/src/java.base/share/native/include/classfile_constants.h	Wed Dec 06 14:33:33 2017 +0000
+++ b/src/java.base/share/native/include/classfile_constants.h	Fri Nov 03 10:01:08 2017 -0700
@@ -31,7 +31,7 @@
 #endif
 
 /* Classfile version number for this information */
-#define JVM_CLASSFILE_MAJOR_VERSION 53
+#define JVM_CLASSFILE_MAJOR_VERSION 54
 #define JVM_CLASSFILE_MINOR_VERSION 0
 
 /* Flags */
--- a/src/java.base/share/native/libjava/System.c	Wed Dec 06 14:33:33 2017 +0000
+++ b/src/java.base/share/native/libjava/System.c	Fri Nov 03 10:01:08 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2017, 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
@@ -114,7 +114,7 @@
 #define VENDOR_URL_BUG "http://bugreport.java.com/bugreport/"
 #endif
 
-#define JAVA_MAX_SUPPORTED_VERSION 53
+#define JAVA_MAX_SUPPORTED_VERSION 54
 #define JAVA_MAX_SUPPORTED_MINOR_VERSION 0
 
 #ifdef JAVA_SPECIFICATION_VENDOR /* Third party may NOT overwrite this. */
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassFile.java	Wed Dec 06 14:33:33 2017 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassFile.java	Fri Nov 03 10:01:08 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, 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
@@ -110,7 +110,8 @@
         V50(50, 0),   // JDK 1.6: stackmaps
         V51(51, 0),   // JDK 1.7
         V52(52, 0),   // JDK 1.8: lambda, type annos, param names
-        V53(53, 0);   // JDK 1.9: modules, indy string concat
+        V53(53, 0),   // JDK 1.9: modules, indy string concat
+        V54(54, 0);   // JDK 10
         Version(int major, int minor) {
             this.major = major;
             this.minor = minor;
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Wed Dec 06 14:33:33 2017 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Fri Nov 03 10:01:08 2017 -0700
@@ -2684,7 +2684,7 @@
 
         minorVersion = nextChar();
         majorVersion = nextChar();
-        int maxMajor = 53; // Version.MAX().major;  //******* TEMPORARY *******
+        int maxMajor = Version.MAX().major;
         int maxMinor = Version.MAX().minor;
         if (majorVersion > maxMajor ||
             majorVersion * 1000 + minorVersion <
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Wed Dec 06 14:33:33 2017 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Fri Nov 03 10:01:08 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, 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
@@ -1815,15 +1815,8 @@
         acount += writeExtraClassAttributes(c);
 
         poolbuf.appendInt(JAVA_MAGIC);
-
-        if (c.owner.kind == MDL) {
-            // temporarily overide to force use of v53 for module-info.class
-            poolbuf.appendChar(0);
-            poolbuf.appendChar(53);
-        } else {
-            poolbuf.appendChar(target.minorVersion);
-            poolbuf.appendChar(target.majorVersion);
-        }
+        poolbuf.appendChar(target.minorVersion);
+        poolbuf.appendChar(target.majorVersion);
 
         writePool(c.pool);
 
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Target.java	Wed Dec 06 14:33:33 2017 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Target.java	Fri Nov 03 10:01:08 2017 -0700
@@ -63,8 +63,8 @@
     /** JDK 9. */
     JDK1_9("1.9", 53, 0),
 
-    /** JDK 10, initially an alias for 9 */
-    JDK1_10("1.10", 53, 0);
+    /** JDK 10. */
+    JDK1_10("1.10", 54, 0);
 
     private static final Context.Key<Target> targetKey = new Context.Key<>();
 
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/classfile/Classfile.java	Wed Dec 06 14:33:33 2017 +0000
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/classfile/Classfile.java	Fri Nov 03 10:01:08 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, 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
@@ -46,8 +46,8 @@
     private final ResolvedJavaType type;
     private final List<ClassfileBytecode> codeAttributes;
 
-    private static final int MAJOR_VERSION_JAVA7 = 51;
-    private static final int MAJOR_VERSION_JAVA9 = 53;
+    private static final int MAJOR_VERSION_JAVA_MIN = 51;
+    private static final int MAJOR_VERSION_JAVA_MAX = 54;
     private static final int MAGIC = 0xCAFEBABE;
 
     /**
@@ -65,7 +65,7 @@
 
         int minor = stream.readUnsignedShort();
         int major = stream.readUnsignedShort();
-        if (major < MAJOR_VERSION_JAVA7 || major > MAJOR_VERSION_JAVA9) {
+        if (major < MAJOR_VERSION_JAVA_MIN || major > MAJOR_VERSION_JAVA_MAX) {
             throw new UnsupportedClassVersionError("Unsupported class file version: " + major + "." + minor);
         }
 
--- a/src/jdk.rmic/share/classes/sun/tools/java/RuntimeConstants.java	Wed Dec 06 14:33:33 2017 +0000
+++ b/src/jdk.rmic/share/classes/sun/tools/java/RuntimeConstants.java	Fri Nov 03 10:01:08 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, 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
@@ -67,7 +67,7 @@
     /* Class File Constants */
     int JAVA_MAGIC                   = 0xcafebabe;
     int JAVA_MIN_SUPPORTED_VERSION   = 45;
-    int JAVA_MAX_SUPPORTED_VERSION   = 53;
+    int JAVA_MAX_SUPPORTED_VERSION   = 54;
     int JAVA_MAX_SUPPORTED_MINOR_VERSION = 0;
 
     /* Generate class file version for 1.1  by default */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/classFileParserBug/Class54.jasm	Fri Nov 03 10:01:08 2017 -0700
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2016, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8188870
+ * @summary Check that the JVM accepts class files with version 54
+ * @run main Class54
+ */
+
+super public class Class54 version 54:0 {
+
+    public Method "<init>":"()V" stack 1 locals 1 {
+        aload_0;
+        invokespecial    Method java/lang/Object."<init>":"()V";
+        return;
+    }
+
+    public static Method main:"([Ljava/lang/String;)V" stack 0 locals 1 {
+        return;
+    }
+
+} // end Class Class54
--- a/test/langtools/tools/javac/6330997/T6330997.java	Wed Dec 06 14:33:33 2017 +0000
+++ b/test/langtools/tools/javac/6330997/T6330997.java	Fri Nov 03 10:01:08 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2017, 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     6330997 7025789 8000961
+ * @bug     6330997 7025789 8000961 8188870
  * @summary javac should accept class files with major version of the next release
  * @author  Wei Tao
  * @modules jdk.compiler/com.sun.tools.javac.api
@@ -32,8 +32,8 @@
  *          jdk.compiler/com.sun.tools.javac.main
  *          jdk.compiler/com.sun.tools.javac.util
  * @clean T1 T2
- * @compile -source 9 -target 9 T1.java
- * @compile -source 9 -target 9 T2.java
+ * @compile -source 10 -target 10 T1.java
+ * @compile -source 10 -target 10 T2.java
  * @run main/othervm T6330997
  */
 
--- a/test/langtools/tools/javac/classfiles/ClassVersionChecker.java	Wed Dec 06 14:33:33 2017 +0000
+++ b/test/langtools/tools/javac/classfiles/ClassVersionChecker.java	Fri Nov 03 10:01:08 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2017, 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 7157626 8001112
+ * @bug 7157626 8001112 8188870
  * @summary Test major version for all legal combinations for -source and -target
  * @author sgoel
  *
@@ -38,7 +38,7 @@
 public class ClassVersionChecker {
 
     int errors;
-    String[] jdk = {"", "1.6", "1.7", "1.8", "1.9"};
+    String[] jdk = {"", "1.6", "1.7", "1.8", "1.9", "1.10"};
     File javaFile = null;
 
     public static void main(String[] args) throws Throwable {
@@ -58,10 +58,11 @@
          * -1 => invalid combinations
          */
         int[][] ver =
-                {{53, -1, -1, -1, -1},
-                 {53, 50, 51, 52, 53},
-                 {53, -1, 51, 52, 53},
-                 {53, -1, -1, 52, 53}};
+                {{54, -1, -1, -1, -1, -1},
+                 {54, 50, 51, 52, 53, 54},
+                 {54, -1, 51, 52, 53, 54},
+                 {54, -1, -1, 52, 53, 54},
+                 {54, -1, -1, -1, 53, 54}};
 
         // Loop to run all possible combinations of source/target values
         for (int i = 0; i< ver.length; i++) {
--- a/test/langtools/tools/javac/versions/Versions.java	Wed Dec 06 14:33:33 2017 +0000
+++ b/test/langtools/tools/javac/versions/Versions.java	Fri Nov 03 10:01:08 2017 -0700
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 4981566 5028634 5094412 6304984 7025786 7025789 8001112 8028545 8000961 8030610 8028546
+ * @bug 4981566 5028634 5094412 6304984 7025786 7025789 8001112 8028545 8000961 8030610 8028546 8188870
  * @summary Check interpretation of -target and -source options
  * @modules java.compiler
  *          jdk.compiler
@@ -64,12 +64,12 @@
         String TC = "";
         System.out.println("Version.java: Starting");
 
-        check("53.0");
-        check("53.0", "-source 1.6");
-        check("53.0", "-source 1.7");
-        check("53.0", "-source 1.8");
-        check("53.0", "-source 1.9");
-        check("53.0", "-source 1.10");
+        check("54.0");
+        check("54.0", "-source 1.6");
+        check("54.0", "-source 1.7");
+        check("54.0", "-source 1.8");
+        check("54.0", "-source 1.9");
+        check("54.0", "-source 1.10");
 
         check_source_target("50.0", "6", "6");
         check_source_target("51.0", "6", "7");
@@ -81,7 +81,11 @@
         check_source_target("53.0", "7", "9");
         check_source_target("53.0", "8", "9");
         check_source_target("53.0", "9", "9");
-        check_source_target("53.0", "10", "10");
+        check_source_target("54.0", "6", "10");
+        check_source_target("54.0", "7", "10");
+        check_source_target("54.0", "8", "10");
+        check_source_target("54.0", "9", "10");
+        check_source_target("54.0", "10", "10");
 
         checksrc16("-source 1.6");
         checksrc16("-source 6");
@@ -99,7 +103,6 @@
         checksrc19("-source 9");
         checksrc19("-source 1.9", "-target 1.9");
         checksrc19("-source 9", "-target 9");
-
         checksrc110();
         checksrc110("-source 1.10");
         checksrc110("-source 10");