8188870: Bump classfile version number to 54

Reviewed-by: alanb, dholmes, coleenp, mcimadamore
This commit is contained in:
Paul Sandoz 2017-11-03 10:01:08 -07:00
parent 0c7be1d9e7
commit 2c9ed8e178
16 changed files with 96 additions and 48 deletions

View File

@ -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");

View File

@ -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 @@ class Constants {
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 @@ class Constants {
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 @@ class Constants {
// 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 =

View File

@ -185,7 +185,7 @@ public class ClassReader {
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

View File

@ -89,6 +89,7 @@ public interface Opcodes {
int V1_7 = 0 << 16 | 51;
int V1_8 = 0 << 16 | 52;
int V9 = 0 << 16 | 53;
int V10 = 0 << 16 | 54;
// access flags

View File

@ -31,7 +31,7 @@ extern "C" {
#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 */

View File

@ -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 @@ Java_java_lang_System_identityHashCode(JNIEnv *env, jobject this, jobject x)
#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. */

View File

@ -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 @@ public class ClassFile {
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;

View File

@ -2684,7 +2684,7 @@ public class ClassReader {
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 <

View File

@ -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 @@ public class ClassWriter extends ClassFile {
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);

View File

@ -63,8 +63,8 @@ public enum Target {
/** 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<>();

View File

@ -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 @@ public class Classfile {
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 @@ public class Classfile {
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);
}

View File

@ -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 @@ public interface RuntimeConstants {
/* 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 */

View File

@ -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

View File

@ -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
*/

View File

@ -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 @@ import java.util.regex.*;
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 @@ public class ClassVersionChecker {
* -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++) {

View File

@ -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 @@ public class Versions {
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 @@ public class Versions {
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 @@ public class Versions {
checksrc19("-source 9");
checksrc19("-source 1.9", "-target 1.9");
checksrc19("-source 9", "-target 9");
checksrc110();
checksrc110("-source 1.10");
checksrc110("-source 10");