@@ -103,6 +103,7 @@ class java_bytecode_convert_classt:public messaget
103
103
typedef java_bytecode_parse_treet::classt classt;
104
104
typedef java_bytecode_parse_treet::fieldt fieldt;
105
105
typedef java_bytecode_parse_treet::methodt methodt;
106
+ typedef java_bytecode_parse_treet::annotationt annotationt;
106
107
107
108
private:
108
109
symbol_tablet &symbol_table;
@@ -372,6 +373,10 @@ void java_bytecode_convert_classt::convert(
372
373
" java::" + id2string (lambda_entry.second .lambda_method_ref ));
373
374
}
374
375
376
+ // Load annotations
377
+ if (!c.annotations .empty ())
378
+ convert_annotations (c.annotations , class_type.get_annotations ());
379
+
375
380
// produce class symbol
376
381
symbolt new_symbol;
377
382
new_symbol.base_name =c.name ;
@@ -638,6 +643,14 @@ void java_bytecode_convert_classt::convert(
638
643
ns,
639
644
get_message_handler ());
640
645
646
+ // Load annotations
647
+ if (!f.annotations .empty ())
648
+ {
649
+ convert_annotations (
650
+ f.annotations ,
651
+ static_cast <annotated_typet &>(new_symbol.type ).get_annotations ());
652
+ }
653
+
641
654
// Do we have the static field symbol already?
642
655
const auto s_it=symbol_table.symbols .find (new_symbol.name );
643
656
if (s_it!=symbol_table.symbols .end ())
@@ -650,7 +663,7 @@ void java_bytecode_convert_classt::convert(
650
663
{
651
664
class_typet &class_type=to_class_type (class_symbol.type );
652
665
653
- class_type.components ().push_back ( class_typet::componentt () );
666
+ class_type.components ().emplace_back ( );
654
667
class_typet::componentt &component=class_type.components ().back ();
655
668
656
669
component.set_name (f.name );
@@ -666,6 +679,14 @@ void java_bytecode_convert_classt::convert(
666
679
component.set_access (ID_public);
667
680
else
668
681
component.set_access (ID_default);
682
+
683
+ // Load annotations
684
+ if (!f.annotations .empty ())
685
+ {
686
+ convert_annotations (
687
+ f.annotations ,
688
+ static_cast <annotated_typet &>(component.type ()).get_annotations ());
689
+ }
669
690
}
670
691
}
671
692
@@ -979,6 +1000,29 @@ static void find_and_replace_parameters(
979
1000
}
980
1001
}
981
1002
1003
+ // / Convert parsed annotations into the symbol table
1004
+ // / \param parsed_annotations: The parsed annotations to convert
1005
+ // / \param annotations: The java_annotationt collection to populate
1006
+ void convert_annotations (
1007
+ const java_bytecode_parse_treet::annotationst &parsed_annotations,
1008
+ std::vector<java_annotationt> &annotations)
1009
+ {
1010
+ for (const auto &annotation : parsed_annotations)
1011
+ {
1012
+ annotations.emplace_back (annotation.type );
1013
+ std::vector<java_annotationt::valuet> &values =
1014
+ annotations.back ().get_values ();
1015
+ std::transform (
1016
+ annotation.element_value_pairs .begin (),
1017
+ annotation.element_value_pairs .end (),
1018
+ std::back_inserter (values),
1019
+ [](const decltype (annotation.element_value_pairs )::value_type &value)
1020
+ {
1021
+ return java_annotationt::valuet (value.element_name , value.value );
1022
+ });
1023
+ }
1024
+ }
1025
+
982
1026
// / Checks if the class is implicitly generic, i.e., it is an inner class of
983
1027
// / any generic class. All uses of the implicit generic type parameters within
984
1028
// / the inner class are updated to point to the type parameters of the
0 commit comments