31
31
#include < util/std_expr.h>
32
32
#include < util/suffix.h>
33
33
34
- class java_bytecode_convert_classt : public messaget
34
+ class java_bytecode_convert_classt
35
35
{
36
36
public:
37
37
java_bytecode_convert_classt (
@@ -41,7 +41,7 @@ class java_bytecode_convert_classt:public messaget
41
41
method_bytecodet &method_bytecode,
42
42
java_string_library_preprocesst &_string_preprocess,
43
43
const std::unordered_set<std::string> &no_load_classes)
44
- : messaget (_message_handler),
44
+ : log (_message_handler),
45
45
symbol_table (_symbol_table),
46
46
max_array_length(_max_array_length),
47
47
method_bytecode(method_bytecode),
@@ -98,7 +98,7 @@ class java_bytecode_convert_classt:public messaget
98
98
generate_class_stub (
99
99
class_name,
100
100
symbol_table,
101
- get_message_handler (),
101
+ log. get_message_handler (),
102
102
struct_union_typet::componentst{});
103
103
}
104
104
@@ -108,6 +108,7 @@ class java_bytecode_convert_classt:public messaget
108
108
typedef java_bytecode_parse_treet::annotationt annotationt;
109
109
110
110
private:
111
+ messaget log;
111
112
symbol_tablet &symbol_table;
112
113
const size_t max_array_length;
113
114
method_bytecodet &method_bytecode;
@@ -274,7 +275,8 @@ void java_bytecode_convert_classt::convert(
274
275
std::string qualified_classname=" java::" +id2string (c.name );
275
276
if (symbol_table.has_symbol (qualified_classname))
276
277
{
277
- debug () << " Skip class " << c.name << " (already loaded)" << eom;
278
+ log.debug () << " Skip class " << c.name << " (already loaded)"
279
+ << messaget::eom;
278
280
return ;
279
281
}
280
282
@@ -302,10 +304,10 @@ void java_bytecode_convert_classt::convert(
302
304
}
303
305
catch (const unsupported_java_class_signature_exceptiont &e)
304
306
{
305
- debug () << " Class: " << c.name
306
- << " \n could not parse signature: " << c.signature .value ()
307
- << " \n " << e.what () << " \n ignoring that the class is generic "
308
- << eom;
307
+ log. debug () << " Class: " << c.name
308
+ << " \n could not parse signature: " << c.signature .value ()
309
+ << " \n " << e.what ()
310
+ << " \n ignoring that the class is generic " << messaget:: eom;
309
311
}
310
312
}
311
313
@@ -325,9 +327,11 @@ void java_bytecode_convert_classt::convert(
325
327
{
326
328
if (max_array_length != 0 && c.enum_elements > max_array_length)
327
329
{
328
- warning () << " Java Enum " << c.name << " won't work properly because max "
329
- << " array length (" << max_array_length << " ) is less than the "
330
- << " enum size (" << c.enum_elements << " )" << eom;
330
+ log.warning () << " Java Enum " << c.name
331
+ << " won't work properly because max "
332
+ << " array length (" << max_array_length
333
+ << " ) is less than the "
334
+ << " enum size (" << c.enum_elements << " )" << messaget::eom;
331
335
}
332
336
class_type.set (
333
337
ID_java_enum_static_unwind,
@@ -364,10 +368,12 @@ void java_bytecode_convert_classt::convert(
364
368
}
365
369
catch (const unsupported_java_class_signature_exceptiont &e)
366
370
{
367
- debug () << " Superclass: " << c.super_class << " of class: " << c.name
368
- << " \n could not parse signature: " << superclass_ref.value ()
369
- << " \n " << e.what ()
370
- << " \n ignoring that the superclass is generic" << eom;
371
+ log.debug () << " Superclass: " << c.super_class
372
+ << " of class: " << c.name
373
+ << " \n could not parse signature: "
374
+ << superclass_ref.value () << " \n " << e.what ()
375
+ << " \n ignoring that the superclass is generic"
376
+ << messaget::eom;
371
377
class_type.add_base (base);
372
378
}
373
379
}
@@ -404,10 +410,11 @@ void java_bytecode_convert_classt::convert(
404
410
}
405
411
catch (const unsupported_java_class_signature_exceptiont &e)
406
412
{
407
- debug () << " Interface: " << interface << " of class: " << c.name
408
- << " \n could not parse signature: " << interface_ref.value ()
409
- << " \n " << e.what ()
410
- << " \n ignoring that the interface is generic" << eom;
413
+ log.debug () << " Interface: " << interface << " of class: " << c.name
414
+ << " \n could not parse signature: " << interface_ref.value ()
415
+ << " \n " << e.what ()
416
+ << " \n ignoring that the interface is generic"
417
+ << messaget::eom;
411
418
class_type.add_base (base);
412
419
}
413
420
}
@@ -455,10 +462,11 @@ void java_bytecode_convert_classt::convert(
455
462
symbolt *class_symbol;
456
463
457
464
// add before we do members
458
- debug () << " Adding symbol: class '" << c.name << " '" << eom;
465
+ log. debug () << " Adding symbol: class '" << c.name << " '" << messaget:: eom;
459
466
if (symbol_table.move (new_symbol, class_symbol))
460
467
{
461
- error () << " failed to add class symbol " << new_symbol.name << eom;
468
+ log.error () << " failed to add class symbol " << new_symbol.name
469
+ << messaget::eom;
462
470
throw 0 ;
463
471
}
464
472
@@ -477,12 +485,11 @@ void java_bytecode_convert_classt::convert(
477
485
std::string err =
478
486
" Duplicate field definition for " + field_id + " in overlay class" ;
479
487
// TODO: This could just be a warning if the types match
480
- error () << err << eom;
488
+ log. error () << err << messaget:: eom;
481
489
throw err.c_str ();
482
490
}
483
- debug ()
484
- << " Adding symbol from overlay class: field '" << field.name << " '"
485
- << eom;
491
+ log.debug () << " Adding symbol from overlay class: field '" << field.name
492
+ << " '" << messaget::eom;
486
493
convert (*class_symbol, field);
487
494
POSTCONDITION (check_field_exists (field, field_id, fields));
488
495
}
@@ -493,12 +500,12 @@ void java_bytecode_convert_classt::convert(
493
500
if (check_field_exists (field, field_id, fields))
494
501
{
495
502
// TODO: This could be a warning if the types match
496
- error ()
497
- << " Field definition for " << field_id
498
- << " already loaded from overlay class" << eom;
503
+ log.error () << " Field definition for " << field_id
504
+ << " already loaded from overlay class" << messaget::eom;
499
505
continue ;
500
506
}
501
- debug () << " Adding symbol: field '" << field.name << " '" << eom;
507
+ log.debug () << " Adding symbol: field '" << field.name << " '"
508
+ << messaget::eom;
502
509
convert (*class_symbol, field);
503
510
POSTCONDITION (check_field_exists (field, field_id, fields));
504
511
}
@@ -514,9 +521,8 @@ void java_bytecode_convert_classt::convert(
514
521
+ " :" + method.descriptor ;
515
522
if (is_ignored_method (c.name , method))
516
523
{
517
- debug ()
518
- << " Ignoring method: '" << method_identifier << " '"
519
- << eom;
524
+ log.debug () << " Ignoring method: '" << method_identifier << " '"
525
+ << messaget::eom;
520
526
continue ;
521
527
}
522
528
if (method_bytecode.contains_method (method_identifier))
@@ -530,26 +536,25 @@ void java_bytecode_convert_classt::convert(
530
536
{
531
537
// This method was defined in a previous class definition without
532
538
// being marked as an overlay method
533
- warning ()
539
+ log. warning ()
534
540
<< " Method " << method_identifier
535
541
<< " exists in an overlay class without being marked as an "
536
- " overlay and also exists in another overlay class that appears "
537
- " earlier in the classpath"
538
- << eom;
542
+ " overlay and also exists in another overlay class that appears "
543
+ " earlier in the classpath"
544
+ << messaget:: eom;
539
545
}
540
546
continue ;
541
547
}
542
548
// Always run the lazy pre-stage, as it symbol-table
543
549
// registers the function.
544
- debug ()
545
- << " Adding symbol from overlay class: method '" << method_identifier
546
- << " '" << eom;
550
+ log.debug () << " Adding symbol from overlay class: method '"
551
+ << method_identifier << " '" << messaget::eom;
547
552
java_bytecode_convert_method_lazy (
548
553
*class_symbol,
549
554
method_identifier,
550
555
method,
551
556
symbol_table,
552
- get_message_handler ());
557
+ log. get_message_handler ());
553
558
method_bytecode.add (qualified_classname, method_identifier, method);
554
559
if (is_overlay_method (method))
555
560
overlay_methods.insert (method_identifier);
@@ -562,9 +567,8 @@ void java_bytecode_convert_classt::convert(
562
567
+ " :" + method.descriptor ;
563
568
if (is_ignored_method (c.name , method))
564
569
{
565
- debug ()
566
- << " Ignoring method: '" << method_identifier << " '"
567
- << eom;
570
+ log.debug () << " Ignoring method: '" << method_identifier << " '"
571
+ << messaget::eom;
568
572
continue ;
569
573
}
570
574
if (method_bytecode.contains_method (method_identifier))
@@ -577,39 +581,41 @@ void java_bytecode_convert_classt::convert(
577
581
{
578
582
// This method was defined in a previous class definition without
579
583
// being marked as an overlay method
580
- warning ()
584
+ log. warning ()
581
585
<< " Method " << method_identifier
582
586
<< " exists in an overlay class without being marked as an overlay "
583
- " and also exists in the underlying class"
584
- << eom;
587
+ " and also exists in the underlying class"
588
+ << messaget:: eom;
585
589
}
586
590
continue ;
587
591
}
588
592
// Always run the lazy pre-stage, as it symbol-table
589
593
// registers the function.
590
- debug () << " Adding symbol: method '" << method_identifier << " '" << eom;
594
+ log.debug () << " Adding symbol: method '" << method_identifier << " '"
595
+ << messaget::eom;
591
596
java_bytecode_convert_method_lazy (
592
597
*class_symbol,
593
598
method_identifier,
594
599
method,
595
600
symbol_table,
596
- get_message_handler ());
601
+ log. get_message_handler ());
597
602
method_bytecode.add (qualified_classname, method_identifier, method);
598
603
if (is_overlay_method (method))
599
604
{
600
- warning ()
605
+ log. warning ()
601
606
<< " Method " << method_identifier
602
- << " marked as an overlay where defined in the underlying class" << eom;
607
+ << " marked as an overlay where defined in the underlying class"
608
+ << messaget::eom;
603
609
}
604
610
}
605
611
if (!overlay_methods.empty ())
606
612
{
607
- error ()
613
+ log. error ()
608
614
<< " Overlay methods defined in overlay classes did not exist in the "
609
- " underlying class:\n " ;
615
+ " underlying class:\n " ;
610
616
for (const irep_idt &method_id : overlay_methods)
611
- error () << " " << method_id << " \n " ;
612
- error () << eom;
617
+ log. error () << " " << method_id << " \n " ;
618
+ log. error () << messaget:: eom;
613
619
}
614
620
615
621
// is this a root class?
@@ -744,8 +750,8 @@ void java_bytecode_convert_classt::convert(
744
750
const auto value = zero_initializer (field_type, class_symbol.location , ns);
745
751
if (!value.has_value ())
746
752
{
747
- error ().source_location = class_symbol.location ;
748
- error () << " failed to zero-initialize " << f.name << eom;
753
+ log. error ().source_location = class_symbol.location ;
754
+ log. error () << " failed to zero-initialize " << f.name << messaget:: eom;
749
755
throw 0 ;
750
756
}
751
757
new_symbol.value = *value;
@@ -1025,12 +1031,14 @@ bool java_bytecode_convert_class(
1025
1031
1026
1032
catch (const char *e)
1027
1033
{
1028
- java_bytecode_convert_class.error () << e << messaget::eom;
1034
+ messaget log{message_handler};
1035
+ log.error () << e << messaget::eom;
1029
1036
}
1030
1037
1031
1038
catch (const std::string &e)
1032
1039
{
1033
- java_bytecode_convert_class.error () << e << messaget::eom;
1040
+ messaget log{message_handler};
1041
+ log.error () << e << messaget::eom;
1034
1042
}
1035
1043
1036
1044
return true ;
0 commit comments