@@ -186,6 +186,11 @@ class java_bytecode_parsert:public parsert
186
186
{
187
187
return read_bytes (8 );
188
188
}
189
+
190
+ void store_unknown_method_handle (
191
+ classt &parsed_class,
192
+ size_t bootstrap_method_index,
193
+ u2_valuest u2_values) const ;
189
194
};
190
195
191
196
#define CONSTANT_Class 7
@@ -1824,12 +1829,8 @@ void java_bytecode_parsert::read_bootstrapmethods_entry(classt &parsed_class)
1824
1829
// try parsing bootstrap method handle
1825
1830
if (num_bootstrap_arguments < 3 )
1826
1831
{
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));
1833
1834
error () << " ERROR: num_bootstrap_arguments must be at least 3" << eom;
1834
1835
continue ;
1835
1836
}
@@ -1876,11 +1877,8 @@ void java_bytecode_parsert::read_bootstrapmethods_entry(classt &parsed_class)
1876
1877
if (!recognized)
1877
1878
{
1878
1879
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));
1884
1882
continue ;
1885
1883
}
1886
1884
@@ -1894,12 +1892,9 @@ void java_bytecode_parsert::read_bootstrapmethods_entry(classt &parsed_class)
1894
1892
method_handle_argument.tag == CONSTANT_MethodHandle &&
1895
1893
method_type_argument.tag == CONSTANT_MethodType))
1896
1894
{
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));
1903
1898
continue ;
1904
1899
}
1905
1900
@@ -1909,12 +1904,9 @@ void java_bytecode_parsert::read_bootstrapmethods_entry(classt &parsed_class)
1909
1904
1910
1905
if (!lambda_method_handle.has_value ())
1911
1906
{
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));
1918
1910
continue ;
1919
1911
}
1920
1912
@@ -1946,3 +1938,19 @@ void java_bytecode_parsert::read_bootstrapmethods_entry(classt &parsed_class)
1946
1938
1947
1939
}
1948
1940
}
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