src/share/vm/classfile/classFileParser.cpp
Print this page
rev 7343 : 8058313: Mismatch of method descriptor and MethodParameters.parameters_count should cause MalformedParameterException
Summary: Allow hotspot to store and report zero-length MethodParameters attribute data
Reviewed-by: coleenp, jiangli
@@ -2057,11 +2057,11 @@
u2 max_lvtt_cnt = INITIAL_MAX_LVT_NUMBER;
u2* localvariable_table_length;
u2** localvariable_table_start;
u2* localvariable_type_table_length;
u2** localvariable_type_table_start;
- u2 method_parameters_length = 0;
+ int method_parameters_length = -1;
u1* method_parameters_data = NULL;
bool method_parameters_seen = false;
bool parsed_code_attribute = false;
bool parsed_checked_exceptions_attribute = false;
bool parsed_stackmap_attribute = false;
@@ -2276,21 +2276,22 @@
if (method_parameters_seen) {
classfile_parse_error("Multiple MethodParameters attributes in class file %s", CHECK_(nullHandle));
}
method_parameters_seen = true;
method_parameters_length = cfs->get_u1_fast();
- if (method_attribute_length != (method_parameters_length * 4u) + 1u) {
+ const u2 real_length = (method_parameters_length * 4u) + 1u;
+ if (method_attribute_length != real_length) {
classfile_parse_error(
"Invalid MethodParameters method attribute length %u in class file",
method_attribute_length, CHECK_(nullHandle));
}
method_parameters_data = cfs->get_u1_buffer();
cfs->skip_u2_fast(method_parameters_length);
cfs->skip_u2_fast(method_parameters_length);
// ignore this attribute if it cannot be reflected
if (!SystemDictionary::Parameter_klass_loaded())
- method_parameters_length = 0;
+ method_parameters_length = -1;
} else if (method_attribute_name == vmSymbols::tag_synthetic()) {
if (method_attribute_length != 0) {
classfile_parse_error(
"Invalid Synthetic method attribute length %u in class file %s",
method_attribute_length, CHECK_(nullHandle));