mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8235513: Change JVM to check for preview features using JVM_CLASSFILE_MAJOR_VERSION
Check for JVM_CLASSFILE_MAJOR_VERSION instead of a hard-wired version number Reviewed-by: dholmes, coleenp
This commit is contained in:
parent
c2bce5e902
commit
02039fd33a
1 changed files with 12 additions and 7 deletions
|
@ -3477,7 +3477,7 @@ void ClassFileParser::parse_classfile_bootstrap_methods_attribute(const ClassFil
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ClassFileParser::supports_records() {
|
bool ClassFileParser::supports_records() {
|
||||||
return _major_version == JAVA_14_VERSION &&
|
return _major_version == JVM_CLASSFILE_MAJOR_VERSION &&
|
||||||
_minor_version == JAVA_PREVIEW_MINOR_VERSION &&
|
_minor_version == JAVA_PREVIEW_MINOR_VERSION &&
|
||||||
Arguments::enable_preview();
|
Arguments::enable_preview();
|
||||||
}
|
}
|
||||||
|
@ -3722,14 +3722,19 @@ void ClassFileParser::parse_classfile_attributes(const ClassFileStream* const cf
|
||||||
record_attribute_length = attribute_length;
|
record_attribute_length = attribute_length;
|
||||||
} else if (log_is_enabled(Info, class, record)) {
|
} else if (log_is_enabled(Info, class, record)) {
|
||||||
// Log why the Record attribute was ignored. Note that if the
|
// Log why the Record attribute was ignored. Note that if the
|
||||||
// class file version is 58.65535 and --enable-preview wasn't
|
// class file version is JVM_CLASSFILE_MAJOR_VERSION.65535 and
|
||||||
// specified then a java.lang.UnsupportedClassVersionError
|
// --enable-preview wasn't specified then a java.lang.UnsupportedClassVersionError
|
||||||
// exception would have been thrown.
|
// exception would have been thrown.
|
||||||
ResourceMark rm(THREAD);
|
ResourceMark rm(THREAD);
|
||||||
log_info(class, record)("Ignoring Record attribute in class %s because %s",
|
if (supports_records()) {
|
||||||
_class_name->as_C_string(),
|
log_info(class, record)(
|
||||||
supports_records() ? "super type is not java.lang.Record" :
|
"Ignoring Record attribute in class %s because super type is not java.lang.Record",
|
||||||
"class file version is not 58.65535");
|
_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);
|
cfs->skip_u1(attribute_length, CHECK);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue