Skip to content

Commit

Permalink
8235513: Change JVM to check for preview features using JVM_CLASSFILE…
Browse files Browse the repository at this point in the history
…_MAJOR_VERSION

Check for JVM_CLASSFILE_MAJOR_VERSION instead of a hard-wired version number

Reviewed-by: dholmes, coleenp
  • Loading branch information
Harold Seigel committed Dec 10, 2019
1 parent c2bce5e commit 02039fd
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/hotspot/share/classfile/classFileParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3477,7 +3477,7 @@ void ClassFileParser::parse_classfile_bootstrap_methods_attribute(const ClassFil
}

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();
}
Expand Down Expand Up @@ -3722,14 +3722,19 @@ void ClassFileParser::parse_classfile_attributes(const ClassFileStream* const cf
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 {
Expand Down

0 comments on commit 02039fd

Please sign in to comment.