@@ -51,7 +51,8 @@ irep_idt lambda_synthetic_class_name(
5151// / methods) of the class where the lambda is called
5252// / \param index: Index of the lambda method handle in the vector
5353// / \return Symbol of the lambda method if the method handle has a known type
54- static optionalt<symbolt> get_lambda_method_symbol (
54+ static optionalt<java_class_typet::java_lambda_method_handlet>
55+ get_lambda_method_handle (
5556 const symbol_table_baset &symbol_table,
5657 const java_class_typet::java_lambda_method_handlest &lambda_method_handles,
5758 const size_t index)
@@ -62,15 +63,18 @@ static optionalt<symbolt> get_lambda_method_symbol(
6263 // internally by the string solver.
6364 if (index >= lambda_method_handles.size ())
6465 return {};
65- const irept &lambda_method_handle = lambda_method_handles.at (index);
66+ const auto &lambda_method_handle = lambda_method_handles.at (index);
6667 // If the lambda method handle has an unknown type, it does not refer to
6768 // any symbol (it has an empty identifier)
68- if (!lambda_method_handle.id ().empty ())
69- return symbol_table.lookup_ref (lambda_method_handle.id ());
69+ if (
70+ lambda_method_handle.get_handle_type () !=
71+ java_class_typet::method_handle_typet::UNKNOWN_HANDLE)
72+ return lambda_method_handle;
7073 return {};
7174}
7275
73- static optionalt<irep_idt> lambda_method_name (
76+ static optionalt<java_class_typet::java_lambda_method_handlet>
77+ lambda_method_handle (
7478 const symbol_tablet &symbol_table,
7579 const irep_idt &method_identifier,
7680 const java_method_typet &dynamic_method_type)
@@ -84,11 +88,8 @@ static optionalt<irep_idt> lambda_method_name(
8488 const auto &lambda_method_handles = class_type.lambda_method_handles ();
8589 auto lambda_handle_index =
8690 dynamic_method_type.get_int (ID_java_lambda_method_handle_index);
87- const auto lambda_method_symbol = get_lambda_method_symbol (
91+ return get_lambda_method_handle (
8892 symbol_table, lambda_method_handles, lambda_handle_index);
89- if (lambda_method_symbol)
90- return lambda_method_symbol->name ;
91- return {};
9293}
9394
9495static optionalt<irep_idt> interface_method_id (
@@ -131,7 +132,7 @@ static optionalt<irep_idt> interface_method_id(
131132
132133symbolt synthetic_class_symbol (
133134 const irep_idt &synthetic_class_name,
134- const irep_idt &lambda_method_name ,
135+ const java_class_typet::java_lambda_method_handlet &lambda_method_handle ,
135136 const struct_tag_typet &functional_interface_tag,
136137 const java_method_typet &dynamic_method_type)
137138{
@@ -142,8 +143,7 @@ symbolt synthetic_class_symbol(
142143 strip_java_namespace_prefix (synthetic_class_name));
143144 synthetic_class_type.set_name (synthetic_class_name);
144145 synthetic_class_type.set_synthetic (true );
145- synthetic_class_type.set (
146- ID_java_lambda_method_identifier, lambda_method_name);
146+ synthetic_class_type.set (ID_java_lambda_method_handle, lambda_method_handle);
147147 struct_tag_typet base_tag (" java::java.lang.Object" );
148148 synthetic_class_type.add_base (base_tag);
149149 synthetic_class_type.add_base (functional_interface_tag);
@@ -309,9 +309,9 @@ void create_invokedynamic_synthetic_classes(
309309 continue ;
310310 const auto &dynamic_method_type =
311311 to_java_method_type (instruction.args .at (0 ).type ());
312- const auto lambda_method_name = :: lambda_method_name (
312+ const auto lambda_handle = lambda_method_handle (
313313 symbol_table, method_identifier, dynamic_method_type);
314- if (!lambda_method_name )
314+ if (!lambda_handle )
315315 {
316316 log.debug () << " ignoring invokedynamic at " << method_identifier
317317 << " address " << instruction.address
@@ -329,8 +329,9 @@ void create_invokedynamic_synthetic_classes(
329329 if (!interface_method_id)
330330 continue ;
331331 log.debug () << " identified invokedynamic at " << method_identifier
332- << " address " << instruction.address
333- << " for lambda: " << *lambda_method_name << messaget::eom;
332+ << " address " << instruction.address << " for lambda: "
333+ << lambda_handle->get_lambda_method_identifier ()
334+ << messaget::eom;
334335 const irep_idt synthetic_class_name =
335336 lambda_synthetic_class_name (method_identifier, instruction.address );
336337 symbol_table.add (constructor_symbol (
@@ -342,7 +343,7 @@ void create_invokedynamic_synthetic_classes(
342343 synthetic_class_name));
343344 symbol_table.add (synthetic_class_symbol (
344345 synthetic_class_name,
345- *lambda_method_name ,
346+ *lambda_handle ,
346347 functional_interface_tag,
347348 dynamic_method_type));
348349 }
@@ -488,8 +489,13 @@ codet invokedynamic_synthetic_method(
488489 lambda_method_args.push_back (param_symbol.symbol_expr ());
489490 }
490491
492+ const auto &lambda_method_handle =
493+ static_cast <const java_class_typet::java_lambda_method_handlet &>(
494+ class_type.find (ID_java_lambda_method_handle));
495+
491496 const auto &lambda_method_symbol =
492- ns.lookup (class_type.get (ID_java_lambda_method_identifier));
497+ ns.lookup (lambda_method_handle.get_lambda_method_identifier ());
498+ const auto handle_type = lambda_method_handle.get_handle_type ();
493499
494500 if (return_type != empty_typet ())
495501 {
0 commit comments