Skip to content

Commit 1db68a5

Browse files
thk123Matthias Güdemann
thk123
authored and
Matthias Güdemann
committed
Moved the first condition to after the explanation of our assumptions
Here it is clearer why we need at least 3 arguments. Also documented this explictly above the condition. Also changed to a debug as there is nothing in the java spec requiring entries to have at least 3 parameters, it is simpyl our assumption about what entries can appear in the bootstrap methods table
1 parent c1aa16c commit 1db68a5

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/java_bytecode/java_bytecode_parser.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1827,13 +1827,6 @@ void java_bytecode_parsert::read_bootstrapmethods_entry(classt &parsed_class)
18271827
u2_values[i] = read_u2();
18281828

18291829
// try parsing bootstrap method handle
1830-
if(num_bootstrap_arguments < 3)
1831-
{
1832-
store_unknown_method_handle(
1833-
parsed_class, bootstrap_method_index, std::move(u2_values));
1834-
error() << "ERROR: num_bootstrap_arguments must be at least 3" << eom;
1835-
continue;
1836-
}
18371830
// each entry contains a MethodHandle structure
18381831
// u2 tag
18391832
// u2 reference kind which must be in the range from 1 to 9
@@ -1860,6 +1853,19 @@ void java_bytecode_parsert::read_bootstrapmethods_entry(classt &parsed_class)
18601853
// We read the three arguments here to see whether they correspond to
18611854
// our hypotheses for this being a lambda function entry.
18621855

1856+
// Need at least 3 arguments, the interface type, the method hanlde
1857+
// and the method_type, otherwise it doesn't look like a call that we
1858+
// understand
1859+
if(num_bootstrap_arguments < 3)
1860+
{
1861+
store_unknown_method_handle(
1862+
parsed_class, bootstrap_method_index, std::move(u2_values));
1863+
debug()
1864+
<< "format of BootstrapMethods entry not recognized: too few arguments"
1865+
<< eom;
1866+
continue;
1867+
}
1868+
18631869
u2 interface_type_index = u2_values[0];
18641870
u2 method_handle_index = u2_values[1];
18651871
u2 method_type_index = u2_values[2];

0 commit comments

Comments
 (0)