8042406: javac.jvm.ClassReader.readClassFile() is using Target to verify valid major versions
authorntoda
Tue, 20 May 2014 15:50:17 -0700
changeset 24606 12c0ca21f8dc
parent 24605 265027386d51
child 24607 e6dff6ac377e
8042406: javac.jvm.ClassReader.readClassFile() is using Target to verify valid major versions Reviewed-by: jjg
langtools/src/share/classes/com/sun/tools/javac/jvm/ClassFile.java
langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassFile.java	Fri May 16 17:08:42 2014 -0400
+++ b/langtools/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/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Fri May 16 17:08:42 2014 -0400
+++ b/langtools/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",