changeset 57317:819be120e63d

8235513: Change JVM to check for preview features using JVM_CLASSFILE_MAJOR_VERSION Summary: Check for JVM_CLASSFILE_MAJOR_VERSION instead of a hard-wired version number Reviewed-by: dholmes, coleenp
author hseigel
date Tue, 10 Dec 2019 15:00:01 +0000
parents 94b120e510d2
children 3333517d634e
files src/hotspot/share/classfile/classFileParser.cpp
diffstat 1 files changed, 12 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/classfile/classFileParser.cpp	Tue Dec 10 13:50:10 2019 +0000
+++ b/src/hotspot/share/classfile/classFileParser.cpp	Tue Dec 10 15:00:01 2019 +0000
@@ -3477,7 +3477,7 @@
 }
 
 bool ClassFileParser::supports_records() {
-  return _major_version == JAVA_14_VERSION &&
+  return _major_version == JVM_CLASSFILE_MAJOR_VERSION &&
     _minor_version == JAVA_PREVIEW_MINOR_VERSION &&
     Arguments::enable_preview();
 }
@@ -3722,14 +3722,19 @@
               record_attribute_length = attribute_length;
             } else if (log_is_enabled(Info, class, record)) {
               // Log why the Record attribute was ignored.  Note that if the
-              // class file version is 58.65535 and --enable-preview wasn't
-              // specified then a java.lang.UnsupportedClassVersionError
+              // class file version is JVM_CLASSFILE_MAJOR_VERSION.65535 and
+              // --enable-preview wasn't specified then a java.lang.UnsupportedClassVersionError
               // exception would have been thrown.
               ResourceMark rm(THREAD);
-              log_info(class, record)("Ignoring Record attribute in class %s because %s",
-                _class_name->as_C_string(),
-                supports_records() ? "super type is not java.lang.Record" :
-                                     "class file version is not 58.65535");
+              if (supports_records()) {
+                log_info(class, record)(
+                  "Ignoring Record attribute in class %s because super type is not java.lang.Record",
+                  _class_name->as_C_string());
+              } else {
+                log_info(class, record)(
+                  "Ignoring Record attribute in class %s because class file version is not %d.65535",
+                   _class_name->as_C_string(), JVM_CLASSFILE_MAJOR_VERSION);
+              }
             }
             cfs->skip_u1(attribute_length, CHECK);
           } else {