@@ -170,7 +170,7 @@ symbolt synthetic_class_symbol(
170
170
return synthetic_class_symbol;
171
171
}
172
172
173
- static symbolt create_constructor_symbol (
173
+ static symbolt constructor_symbol (
174
174
synthetic_methods_mapt &synthetic_methods,
175
175
const irep_idt &synthetic_class_name,
176
176
java_method_typet constructor_type) // dynamic_method_type
@@ -212,7 +212,7 @@ static symbolt create_constructor_symbol(
212
212
return constructor_symbol;
213
213
}
214
214
215
- symbolt create_implemented_method_symbol (
215
+ symbolt implemented_method_symbol (
216
216
synthetic_methods_mapt &synthetic_methods,
217
217
const symbolt &interface_method_symbol,
218
218
const struct_tag_typet &implemented_interface_tag,
@@ -268,85 +268,73 @@ void create_invokedynamic_synthetic_classes(
268
268
synthetic_methods_mapt &synthetic_methods,
269
269
message_handlert &message_handler)
270
270
{
271
- messaget log{message_handler};
272
- namespacet ns{symbol_table};
271
+ const messaget log{message_handler};
273
272
274
273
for (const auto &instruction : instructions)
275
274
{
276
- if (!strcmp (bytecode_info[instruction.bytecode ].mnemonic , " invokedynamic" ))
275
+ if (strcmp (bytecode_info[instruction.bytecode ].mnemonic , " invokedynamic" ))
276
+ continue ;
277
+ // invokedynamic will be called with operands that should be stored in a
278
+ // synthetic object implementing the interface type that it returns. For
279
+ // example, "invokedynamic f(a, b, c) -> MyInterface" should result in the
280
+ // creation of the synthetic class:
281
+ // public class SyntheticCapture implements MyInterface {
282
+ // private int a;
283
+ // private float b;
284
+ // private Other c;
285
+ // public SyntheticCapture(int a, float b, Other c) {
286
+ // this.a = a; this.b = b; this.c = c;
287
+ // }
288
+ // public void myInterfaceMethod(int d) {
289
+ // f(a, b, c, d);
290
+ // }
291
+ // }
292
+ // This method just creates the outline; the methods will be populated on
293
+ // demand via java_bytecode_languaget::convert_lazy_method.
294
+
295
+ // Check that we understand the lambda method handle; if we don't then
296
+ // we will not create a synthetic class at all, and the corresponding
297
+ // invoke instruction will return null when eventually converted by
298
+ // java_bytecode_convert_method.
299
+ const auto &dynamic_method_type =
300
+ to_java_method_type (instruction.args .at (0 ).type ());
301
+ const auto lambda_method_name = ::lambda_method_name (
302
+ symbol_table, method_identifier, dynamic_method_type);
303
+ if (!lambda_method_name)
277
304
{
278
- // invokedynamic will be called with operands that should be stored in a
279
- // synthetic object implementing the interface type that it returns. For
280
- // example, "invokedynamic f(a, b, c) -> MyInterface" should result in the
281
- // creation of the synthetic class:
282
- // public class SyntheticCapture implements MyInterface {
283
- // private int a;
284
- // private float b;
285
- // private Other c;
286
- // public SyntheticCapture(int a, float b, Other c) {
287
- // this.a = a; this.b = b; this.c = c;
288
- // }
289
- // public void myInterfaceMethod(int d) {
290
- // f(a, b, c, d);
291
- // }
292
- // }
293
- // This method just creates the outline; the methods will be populated on
294
- // demand via java_bytecode_languaget::convert_lazy_method.
295
-
296
- // Check that we understand the lambda method handle; if we don't then
297
- // we will not create a synthetic class at all, and the corresponding
298
- // invoke instruction will return null when eventually converted by
299
- // java_bytecode_convert_method.
300
-
301
- const auto &dynamic_method_type =
302
- to_java_method_type (instruction.args .at (0 ).type ());
303
-
304
- const auto lambda_method_name = ::lambda_method_name (
305
- symbol_table, method_identifier, dynamic_method_type);
306
- if (!lambda_method_name)
307
- {
308
- log.debug () << " ignoring invokedynamic at " << method_identifier
309
- << " address " << instruction.address
310
- << " with unknown handle type" << messaget::eom;
311
- continue ;
312
- }
313
-
314
- const auto &implemented_interface_tag = to_struct_tag_type (
315
- to_java_reference_type (dynamic_method_type.return_type ()).subtype ());
316
- const auto interface_method_id = ::interface_method_id (
317
- symbol_table,
318
- implemented_interface_tag,
319
- method_identifier,
320
- instruction.address ,
321
- log);
322
- if (!interface_method_id)
323
- continue ;
324
-
325
- log.debug () << " identified invokedynamic at " << method_identifier
305
+ log.debug () << " ignoring invokedynamic at " << method_identifier
326
306
<< " address " << instruction.address
327
- << " for lambda: " << *lambda_method_name
328
- << messaget::eom;
329
-
330
- // Create the class symbol:
331
-
332
- const irep_idt synthetic_class_name =
333
- lambda_synthetic_class_name (method_identifier, instruction.address );
334
-
335
- symbol_table.add (create_constructor_symbol (
336
- synthetic_methods, synthetic_class_name, dynamic_method_type));
337
-
338
- symbol_table.add (create_implemented_method_symbol (
339
- synthetic_methods,
340
- ns.lookup (*interface_method_id),
341
- implemented_interface_tag,
342
- synthetic_class_name));
343
-
344
- symbol_table.add (synthetic_class_symbol (
345
- synthetic_class_name,
346
- *lambda_method_name,
347
- implemented_interface_tag,
348
- dynamic_method_type));
307
+ << " with unknown handle type" << messaget::eom;
308
+ continue ;
349
309
}
310
+ const auto &implemented_interface_tag = to_struct_tag_type (
311
+ to_java_reference_type (dynamic_method_type.return_type ()).subtype ());
312
+ const auto interface_method_id = ::interface_method_id (
313
+ symbol_table,
314
+ implemented_interface_tag,
315
+ method_identifier,
316
+ instruction.address ,
317
+ log);
318
+ if (!interface_method_id)
319
+ continue ;
320
+ log.debug () << " identified invokedynamic at " << method_identifier
321
+ << " address " << instruction.address
322
+ << " for lambda: " << *lambda_method_name
323
+ << messaget::eom;
324
+ const irep_idt synthetic_class_name =
325
+ lambda_synthetic_class_name (method_identifier, instruction.address );
326
+ symbol_table.add (constructor_symbol (
327
+ synthetic_methods, synthetic_class_name, dynamic_method_type));
328
+ symbol_table.add (implemented_method_symbol (
329
+ synthetic_methods,
330
+ symbol_table.lookup_ref (*interface_method_id),
331
+ implemented_interface_tag,
332
+ synthetic_class_name));
333
+ symbol_table.add (synthetic_class_symbol (
334
+ synthetic_class_name,
335
+ *lambda_method_name,
336
+ implemented_interface_tag,
337
+ dynamic_method_type));
350
338
}
351
339
}
352
340
0 commit comments