8042406: javac.jvm.ClassReader.readClassFile() is using Target to verify valid major versions

Reviewed-by: jjg
This commit is contained in:
Neil Toda 2014-05-20 15:50:17 -07:00
parent c212c43f70
commit ac4c2fe57a
2 changed files with 16 additions and 6 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2014, 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
@ -108,11 +108,21 @@ 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
// JDK9 still marked as V52 // V53(53, 0); // JDK 1.9
Version(int major, int minor) {
this.major = major;
this.minor = minor;
}
public final int major, minor;
private static final Version MIN = values()[0];
/** Return the least version supported, MIN */
public static Version MIN() { return MIN; }
private static final Version MAX = values()[values().length-1];
/** Return the largest version supported, MAX */
public static Version MAX() { return MAX; }
}

View File

@ -2012,8 +2012,8 @@ public class ClassReader {
Type type = readType(nextChar());
if (currentOwner.isInterface() &&
(flags & ABSTRACT) == 0 && !name.equals(names.clinit)) {
if (majorVersion > Target.JDK1_8.majorVersion ||
(majorVersion == Target.JDK1_8.majorVersion && minorVersion >= Target.JDK1_8.minorVersion)) {
if (majorVersion > Version.V52.major ||
(majorVersion == Version.V52.major && minorVersion >= Version.V52.minor)) {
if ((flags & STATIC) == 0) {
currentOwner.flags_field |= DEFAULT;
flags |= DEFAULT | ABSTRACT;
@ -2294,11 +2294,11 @@ public class ClassReader {
minorVersion = nextChar();
majorVersion = nextChar();
int maxMajor = Target.MAX().majorVersion;
int maxMinor = Target.MAX().minorVersion;
int maxMajor = Version.MAX().major;
int maxMinor = Version.MAX().minor;
if (majorVersion > maxMajor ||
majorVersion * 1000 + minorVersion <
Target.MIN().majorVersion * 1000 + Target.MIN().minorVersion)
Version.MIN().major * 1000 + Version.MIN().minor)
{
if (majorVersion == (maxMajor + 1))
log.warning("big.major.version",