changeset 3363:30e0e2a21c7d

8042406: javac.jvm.ClassReader.readClassFile() is using Target to verify valid major versions Reviewed-by: jjg
author ntoda
date Tue, 20 May 2014 15:50:17 -0700
parents 87491833da58
children 1948f43148ec
files src/share/classes/com/sun/tools/javac/jvm/ClassFile.java src/share/classes/com/sun/tools/javac/jvm/ClassReader.java
diffstat 2 files changed, 16 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/jvm/ClassFile.java	Fri May 16 17:08:42 2014 -0400
+++ b/src/share/classes/com/sun/tools/javac/jvm/ClassFile.java	Tue May 20 15:50:17 2014 -0700
@@ -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 @@
         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; }
     }
 
 
--- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Fri May 16 17:08:42 2014 -0400
+++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Tue May 20 15:50:17 2014 -0700
@@ -2012,8 +2012,8 @@
         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 @@
 
         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",