8186209: Tool support for ConstantDynamic

8186046: Minimal ConstantDynamic support
8190972: Ensure that AOT/Graal filters out class files containing CONSTANT_Dynamic ahead of full AOT support

Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: John Rose <john.r.rose@oracle.com>
Reviewed-by: acorn, coleenp, kvn
This commit is contained in:
Paul Sandoz 2017-09-08 10:46:46 -07:00
parent 52d3bf29b2
commit e55a05957d
114 changed files with 11762 additions and 404 deletions

View file

@ -204,6 +204,21 @@ void ClassFileParser::parse_constant_pool_entries(const ClassFileStream* const s
}
break;
}
case JVM_CONSTANT_Dynamic : {
if (_major_version < Verifier::DYNAMICCONSTANT_MAJOR_VERSION) {
classfile_parse_error(
"Class file version does not support constant tag %u in class file %s",
tag, CHECK);
}
cfs->guarantee_more(5, CHECK); // bsm_index, nt, tag/access_flags
const u2 bootstrap_specifier_index = cfs->get_u2_fast();
const u2 name_and_type_index = cfs->get_u2_fast();
if (_max_bootstrap_specifier_index < (int) bootstrap_specifier_index) {
_max_bootstrap_specifier_index = (int) bootstrap_specifier_index; // collect for later
}
cp->dynamic_constant_at_put(index, bootstrap_specifier_index, name_and_type_index);
break;
}
case JVM_CONSTANT_InvokeDynamic : {
if (_major_version < Verifier::INVOKEDYNAMIC_MAJOR_VERSION) {
classfile_parse_error(
@ -536,6 +551,21 @@ void ClassFileParser::parse_constant_pool(const ClassFileStream* const stream,
ref_index, CHECK);
break;
}
case JVM_CONSTANT_Dynamic: {
const int name_and_type_ref_index =
cp->invoke_dynamic_name_and_type_ref_index_at(index);
check_property(valid_cp_range(name_and_type_ref_index, length) &&
cp->tag_at(name_and_type_ref_index).is_name_and_type(),
"Invalid constant pool index %u in class file %s",
name_and_type_ref_index, CHECK);
// bootstrap specifier index must be checked later,
// when BootstrapMethods attr is available
// Mark the constant pool as having a CONSTANT_Dynamic_info structure
cp->set_has_dynamic_constant();
break;
}
case JVM_CONSTANT_InvokeDynamic: {
const int name_and_type_ref_index =
cp->invoke_dynamic_name_and_type_ref_index_at(index);
@ -628,6 +658,27 @@ void ClassFileParser::parse_constant_pool(const ClassFileStream* const stream,
}
break;
}
case JVM_CONSTANT_Dynamic: {
const int name_and_type_ref_index =
cp->name_and_type_ref_index_at(index);
// already verified to be utf8
const int name_ref_index =
cp->name_ref_index_at(name_and_type_ref_index);
// already verified to be utf8
const int signature_ref_index =
cp->signature_ref_index_at(name_and_type_ref_index);
const Symbol* const name = cp->symbol_at(name_ref_index);
const Symbol* const signature = cp->symbol_at(signature_ref_index);
if (_need_verify) {
// CONSTANT_Dynamic's name and signature are verified above, when iterating NameAndType_info.
// Need only to be sure signature is non-zero length and the right type.
if (signature->utf8_length() == 0 ||
signature->byte_at(0) == JVM_SIGNATURE_FUNC) {
throwIllegalSignature("CONSTANT_Dynamic", name, signature, CHECK);
}
}
break;
}
case JVM_CONSTANT_InvokeDynamic:
case JVM_CONSTANT_Fieldref:
case JVM_CONSTANT_Methodref: