@@ -31,7 +31,7 @@ Author: Daniel Kroening, kroening@kroening.com
3131#include < util/std_expr.h>
3232#include < util/suffix.h>
3333
34- class java_bytecode_convert_classt : public messaget
34+ class java_bytecode_convert_classt
3535{
3636public:
3737 java_bytecode_convert_classt (
@@ -41,7 +41,7 @@ class java_bytecode_convert_classt:public messaget
4141 method_bytecodet &method_bytecode,
4242 java_string_library_preprocesst &_string_preprocess,
4343 const std::unordered_set<std::string> &no_load_classes)
44- : messaget (_message_handler),
44+ : log (_message_handler),
4545 symbol_table (_symbol_table),
4646 max_array_length(_max_array_length),
4747 method_bytecode(method_bytecode),
@@ -98,7 +98,7 @@ class java_bytecode_convert_classt:public messaget
9898 generate_class_stub (
9999 class_name,
100100 symbol_table,
101- get_message_handler (),
101+ log. get_message_handler (),
102102 struct_union_typet::componentst{});
103103 }
104104
@@ -108,6 +108,7 @@ class java_bytecode_convert_classt:public messaget
108108 typedef java_bytecode_parse_treet::annotationt annotationt;
109109
110110private:
111+ messaget log;
111112 symbol_tablet &symbol_table;
112113 const size_t max_array_length;
113114 method_bytecodet &method_bytecode;
@@ -274,7 +275,8 @@ void java_bytecode_convert_classt::convert(
274275 std::string qualified_classname=" java::" +id2string (c.name );
275276 if (symbol_table.has_symbol (qualified_classname))
276277 {
277- debug () << " Skip class " << c.name << " (already loaded)" << eom;
278+ log.debug () << " Skip class " << c.name << " (already loaded)"
279+ << messaget::eom;
278280 return ;
279281 }
280282
@@ -302,10 +304,10 @@ void java_bytecode_convert_classt::convert(
302304 }
303305 catch (const unsupported_java_class_signature_exceptiont &e)
304306 {
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;
309311 }
310312 }
311313
@@ -325,9 +327,11 @@ void java_bytecode_convert_classt::convert(
325327 {
326328 if (max_array_length != 0 && c.enum_elements > max_array_length)
327329 {
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;
331335 }
332336 class_type.set (
333337 ID_java_enum_static_unwind,
@@ -364,10 +368,12 @@ void java_bytecode_convert_classt::convert(
364368 }
365369 catch (const unsupported_java_class_signature_exceptiont &e)
366370 {
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;
371377 class_type.add_base (base);
372378 }
373379 }
@@ -404,10 +410,11 @@ void java_bytecode_convert_classt::convert(
404410 }
405411 catch (const unsupported_java_class_signature_exceptiont &e)
406412 {
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;
411418 class_type.add_base (base);
412419 }
413420 }
@@ -455,10 +462,11 @@ void java_bytecode_convert_classt::convert(
455462 symbolt *class_symbol;
456463
457464 // add before we do members
458- debug () << " Adding symbol: class '" << c.name << " '" << eom;
465+ log. debug () << " Adding symbol: class '" << c.name << " '" << messaget:: eom;
459466 if (symbol_table.move (new_symbol, class_symbol))
460467 {
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;
462470 throw 0 ;
463471 }
464472
@@ -477,12 +485,11 @@ void java_bytecode_convert_classt::convert(
477485 std::string err =
478486 " Duplicate field definition for " + field_id + " in overlay class" ;
479487 // TODO: This could just be a warning if the types match
480- error () << err << eom;
488+ log. error () << err << messaget:: eom;
481489 throw err.c_str ();
482490 }
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;
486493 convert (*class_symbol, field);
487494 POSTCONDITION (check_field_exists (field, field_id, fields));
488495 }
@@ -493,12 +500,12 @@ void java_bytecode_convert_classt::convert(
493500 if (check_field_exists (field, field_id, fields))
494501 {
495502 // 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;
499505 continue ;
500506 }
501- debug () << " Adding symbol: field '" << field.name << " '" << eom;
507+ log.debug () << " Adding symbol: field '" << field.name << " '"
508+ << messaget::eom;
502509 convert (*class_symbol, field);
503510 POSTCONDITION (check_field_exists (field, field_id, fields));
504511 }
@@ -514,9 +521,8 @@ void java_bytecode_convert_classt::convert(
514521 + " :" + method.descriptor ;
515522 if (is_ignored_method (c.name , method))
516523 {
517- debug ()
518- << " Ignoring method: '" << method_identifier << " '"
519- << eom;
524+ log.debug () << " Ignoring method: '" << method_identifier << " '"
525+ << messaget::eom;
520526 continue ;
521527 }
522528 if (method_bytecode.contains_method (method_identifier))
@@ -530,26 +536,25 @@ void java_bytecode_convert_classt::convert(
530536 {
531537 // This method was defined in a previous class definition without
532538 // being marked as an overlay method
533- warning ()
539+ log. warning ()
534540 << " Method " << method_identifier
535541 << " 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;
539545 }
540546 continue ;
541547 }
542548 // Always run the lazy pre-stage, as it symbol-table
543549 // 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;
547552 java_bytecode_convert_method_lazy (
548553 *class_symbol,
549554 method_identifier,
550555 method,
551556 symbol_table,
552- get_message_handler ());
557+ log. get_message_handler ());
553558 method_bytecode.add (qualified_classname, method_identifier, method);
554559 if (is_overlay_method (method))
555560 overlay_methods.insert (method_identifier);
@@ -562,9 +567,8 @@ void java_bytecode_convert_classt::convert(
562567 + " :" + method.descriptor ;
563568 if (is_ignored_method (c.name , method))
564569 {
565- debug ()
566- << " Ignoring method: '" << method_identifier << " '"
567- << eom;
570+ log.debug () << " Ignoring method: '" << method_identifier << " '"
571+ << messaget::eom;
568572 continue ;
569573 }
570574 if (method_bytecode.contains_method (method_identifier))
@@ -577,39 +581,41 @@ void java_bytecode_convert_classt::convert(
577581 {
578582 // This method was defined in a previous class definition without
579583 // being marked as an overlay method
580- warning ()
584+ log. warning ()
581585 << " Method " << method_identifier
582586 << " 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;
585589 }
586590 continue ;
587591 }
588592 // Always run the lazy pre-stage, as it symbol-table
589593 // registers the function.
590- debug () << " Adding symbol: method '" << method_identifier << " '" << eom;
594+ log.debug () << " Adding symbol: method '" << method_identifier << " '"
595+ << messaget::eom;
591596 java_bytecode_convert_method_lazy (
592597 *class_symbol,
593598 method_identifier,
594599 method,
595600 symbol_table,
596- get_message_handler ());
601+ log. get_message_handler ());
597602 method_bytecode.add (qualified_classname, method_identifier, method);
598603 if (is_overlay_method (method))
599604 {
600- warning ()
605+ log. warning ()
601606 << " 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;
603609 }
604610 }
605611 if (!overlay_methods.empty ())
606612 {
607- error ()
613+ log. error ()
608614 << " Overlay methods defined in overlay classes did not exist in the "
609- " underlying class:\n " ;
615+ " underlying class:\n " ;
610616 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;
613619 }
614620
615621 // is this a root class?
@@ -744,8 +750,8 @@ void java_bytecode_convert_classt::convert(
744750 const auto value = zero_initializer (field_type, class_symbol.location , ns);
745751 if (!value.has_value ())
746752 {
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;
749755 throw 0 ;
750756 }
751757 new_symbol.value = *value;
@@ -1025,12 +1031,14 @@ bool java_bytecode_convert_class(
10251031
10261032 catch (const char *e)
10271033 {
1028- java_bytecode_convert_class.error () << e << messaget::eom;
1034+ messaget log{message_handler};
1035+ log.error () << e << messaget::eom;
10291036 }
10301037
10311038 catch (const std::string &e)
10321039 {
1033- java_bytecode_convert_class.error () << e << messaget::eom;
1040+ messaget log{message_handler};
1041+ log.error () << e << messaget::eom;
10341042 }
10351043
10361044 return true ;
0 commit comments