@@ -186,6 +186,11 @@ class java_bytecode_parsert:public parsert
186186 {
187187 return read_bytes (8 );
188188 }
189+
190+ void store_unknown_method_handle (
191+ classt &parsed_class,
192+ size_t bootstrap_method_index,
193+ u2_valuest u2_values) const ;
189194};
190195
191196#define CONSTANT_Class 7
@@ -1824,12 +1829,8 @@ void java_bytecode_parsert::read_bootstrapmethods_entry(classt &parsed_class)
18241829 // try parsing bootstrap method handle
18251830 if (num_bootstrap_arguments < 3 )
18261831 {
1827- lambda_method_handlet lambda_method_handle;
1828- lambda_method_handle.handle_type = method_handle_typet::UNKNOWN_HANDLE;
1829- lambda_method_handle.u2_values = std::move (u2_values);
1830- parsed_class.lambda_method_handle_map [{parsed_class.name ,
1831- bootstrap_method_index}] =
1832- lambda_method_handle;
1832+ store_unknown_method_handle (
1833+ parsed_class, bootstrap_method_index, std::move (u2_values));
18331834 error () << " ERROR: num_bootstrap_arguments must be at least 3" << eom;
18341835 continue ;
18351836 }
@@ -1876,11 +1877,8 @@ void java_bytecode_parsert::read_bootstrapmethods_entry(classt &parsed_class)
18761877 if (!recognized)
18771878 {
18781879 debug () << " format of BootstrapMethods entry not recognized" << eom;
1879- lambda_method_handlet lambda_method_handle;
1880- lambda_method_handle.handle_type = method_handle_typet::UNKNOWN_HANDLE;
1881- lambda_method_handle.u2_values = std::move (u2_values);
1882- parsed_class.lambda_method_handle_map [{parsed_class.name , bootstrap_method_index}] =
1883- lambda_method_handle;
1880+ store_unknown_method_handle (
1881+ parsed_class, bootstrap_method_index, std::move (u2_values));
18841882 continue ;
18851883 }
18861884
@@ -1894,12 +1892,9 @@ void java_bytecode_parsert::read_bootstrapmethods_entry(classt &parsed_class)
18941892 method_handle_argument.tag == CONSTANT_MethodHandle &&
18951893 method_type_argument.tag == CONSTANT_MethodType))
18961894 {
1897- lambda_method_handlet lambda_method_handle;
1898- lambda_method_handle.handle_type =
1899- method_handle_typet::UNKNOWN_HANDLE;
1900- lambda_method_handle.u2_values = std::move (u2_values);
1901- parsed_class.lambda_method_handle_map [{parsed_class.name , bootstrap_method_index}] =
1902- lambda_method_handle;
1895+ debug () << " format of BootstrapMethods entry not recognized" << eom;
1896+ store_unknown_method_handle (
1897+ parsed_class, bootstrap_method_index, std::move (u2_values));
19031898 continue ;
19041899 }
19051900
@@ -1909,12 +1904,9 @@ void java_bytecode_parsert::read_bootstrapmethods_entry(classt &parsed_class)
19091904
19101905 if (!lambda_method_handle.has_value ())
19111906 {
1912- lambda_method_handlet lambda_method_handle;
1913- lambda_method_handle.handle_type =
1914- method_handle_typet::UNKNOWN_HANDLE;
1915- lambda_method_handle.u2_values = std::move (u2_values);
1916- parsed_class.lambda_method_handle_map [{parsed_class.name , bootstrap_method_index}] =
1917- lambda_method_handle;
1907+ debug () << " format of BootstrapMethods entry not recognized" << eom;
1908+ store_unknown_method_handle (
1909+ parsed_class, bootstrap_method_index, std::move (u2_values));
19181910 continue ;
19191911 }
19201912
@@ -1946,3 +1938,19 @@ void java_bytecode_parsert::read_bootstrapmethods_entry(classt &parsed_class)
19461938
19471939 }
19481940}
1941+
1942+ // / Creates an unknown method handle and puts it into the parsed_class
1943+ // / \param parsed_class: The class whose bootstrap method handles we are using
1944+ // / \param bootstrap_method_index: The current index in the boostrap entry table
1945+ // / \param u2_values: The indices of the arguments for the call
1946+ void java_bytecode_parsert::store_unknown_method_handle (
1947+ java_bytecode_parsert::classt &parsed_class,
1948+ size_t bootstrap_method_index,
1949+ java_bytecode_parsert::u2_valuest u2_values) const
1950+ {
1951+ const lambda_method_handlet lambda_method_handle =
1952+ lambda_method_handlet::create_unknown_handle (move (u2_values));
1953+ parsed_class
1954+ .lambda_method_handle_map [{parsed_class.name , bootstrap_method_index}] =
1955+ lambda_method_handle;
1956+ }
0 commit comments