Skip to content

Commit df3085b

Browse files
author
svorenova
committed
Pass lambda method handles to method instruction conversion
1 parent 716b968 commit df3085b

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

src/java_bytecode/java_bytecode_convert_method.cpp

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,15 @@ code_typet member_type_lazy(
303303
return to_code_type(member_type_from_descriptor);
304304
}
305305

306+
symbolt java_bytecode_convert_methodt::get_lambda_method_symbol(
307+
const java_class_typet::java_lambda_method_handlest &lambda_method_handles,
308+
const irep_idt &index)
309+
{
310+
const symbol_exprt &lambda_method_handle =
311+
lambda_method_handles.at(std::stoi(id2string(index)));
312+
return symbol_table.lookup_ref(lambda_method_handle.get_identifier());
313+
}
314+
306315
/// This creates a method symbol in the symtab, but doesn't actually perform
307316
/// method conversion just yet. The caller should call
308317
/// java_bytecode_convert_method later to give the symbol/method a body.
@@ -552,7 +561,11 @@ void java_bytecode_convert_methodt::convert(
552561
current_method=method_symbol.name;
553562
method_has_this=code_type.has_this();
554563
if((!m.is_abstract) && (!m.is_native))
555-
method_symbol.value=convert_instructions(m, code_type, method_symbol.name);
564+
method_symbol.value = convert_instructions(
565+
m,
566+
code_type,
567+
method_symbol.name,
568+
to_java_class_type(class_symbol.type).lambda_method_handles());
556569
}
557570

558571
const bytecode_infot &java_bytecode_convert_methodt::get_bytecode_info(
@@ -923,7 +936,8 @@ static unsigned get_bytecode_type_width(const typet &ty)
923936
codet java_bytecode_convert_methodt::convert_instructions(
924937
const methodt &method,
925938
const code_typet &method_type,
926-
const irep_idt &method_name)
939+
const irep_idt &method_name,
940+
const java_class_typet::java_lambda_method_handlest &lambda_method_handles)
927941
{
928942
const instructionst &instructions=method.instructions;
929943

@@ -1208,7 +1222,14 @@ codet java_bytecode_convert_methodt::convert_instructions(
12081222
else if(statement=="invokedynamic")
12091223
{
12101224
// not used in Java
1211-
code_typet &code_type=to_code_type(arg0.type());
1225+
code_typet &code_type = to_code_type(arg0.type());
1226+
1227+
const symbolt &lambda_method_symbol = get_lambda_method_symbol(
1228+
lambda_method_handles,
1229+
code_type.get(ID_java_lambda_method_handle_index));
1230+
debug() << "Converting invokedynamic for lambda: "
1231+
<< lambda_method_symbol.name << eom;
1232+
12121233
const code_typet::parameterst &parameters(code_type.parameters());
12131234

12141235
pop(parameters.size());

src/java_bytecode/java_bytecode_convert_method_class.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,13 +235,18 @@ class java_bytecode_convert_methodt:public messaget
235235
const address_mapt &amap,
236236
bool allow_merge=true);
237237

238+
symbolt get_lambda_method_symbol(
239+
const java_class_typet::java_lambda_method_handlest &lambda_method_handles,
240+
const irep_idt &index);
241+
238242
// conversion
239243
void convert(const symbolt &class_symbol, const methodt &);
240244

241245
codet convert_instructions(
242246
const methodt &,
243247
const code_typet &,
244-
const irep_idt &);
248+
const irep_idt &,
249+
const java_class_typet::java_lambda_method_handlest &);
245250

246251
const bytecode_infot &get_bytecode_info(const irep_idt &statement);
247252

0 commit comments

Comments
 (0)