@@ -792,50 +792,52 @@ code_blockt get_user_specified_clinit_body(
792
792
&class_to_declared_symbols_map)
793
793
{
794
794
const irep_idt &real_clinit_name = clinit_function_name (class_id);
795
+ const auto clinit_func = symbol_table.lookup (real_clinit_name);
796
+ if (clinit_func == nullptr )
797
+ {
798
+ // Case where the real clinit doesn't appear in the symbol table, even
799
+ // though their is user specifed one. This may occur when some class
800
+ // substitution happened after compilation.
801
+ return code_blockt{};
802
+ }
795
803
const auto class_entry =
796
804
static_values_json.find (id2string (strip_java_namespace_prefix (class_id)));
797
- if (class_entry != static_values_json.end ())
805
+ if (class_entry != static_values_json.end () && class_entry-> second . is_object () )
798
806
{
799
- const auto &class_json_value = class_entry->second ;
800
- if (class_json_value.is_object ())
807
+ const auto &class_json_object = to_json_object (class_entry->second );
808
+ std::map<symbol_exprt, jsont> static_field_values;
809
+ for (const auto &symbol_pair :
810
+ equal_range (class_to_declared_symbols_map, class_id))
801
811
{
802
- const auto &class_json_object = to_json_object (class_json_value);
803
- std::map<symbol_exprt, jsont> static_field_values;
804
- for (const auto &class_symbol_pair :
805
- equal_range (class_to_declared_symbols_map, class_id))
812
+ const symbolt &symbol = symbol_pair.second ;
813
+ if (symbol.is_static_lifetime )
806
814
{
807
- const symbolt &symbol = class_symbol_pair.second ;
808
- if (symbol.is_static_lifetime )
815
+ const symbol_exprt &static_field_expr = symbol.symbol_expr ();
816
+ const auto &static_field_entry =
817
+ class_json_object.find (id2string (symbol.base_name ));
818
+ if (static_field_entry != class_json_object.end ())
809
819
{
810
- const symbol_exprt &static_field_expr = symbol.symbol_expr ();
811
- const auto &static_field_entry =
812
- class_json_object.find (id2string (symbol.base_name ));
813
- if (static_field_entry != class_json_object.end ())
814
- {
815
- static_field_values.insert (
816
- {static_field_expr, static_field_entry->second });
817
- }
820
+ static_field_values.insert (
821
+ {static_field_expr, static_field_entry->second });
818
822
}
819
823
}
820
- code_blockt body;
821
- for (const auto &value_pair : static_field_values)
822
- {
823
- assign_from_json (
824
- value_pair.first ,
825
- value_pair.second ,
826
- real_clinit_name,
827
- body,
828
- symbol_table,
829
- needed_lazy_methods,
830
- max_user_array_length,
831
- references);
832
- }
833
- return body;
834
824
}
825
+ code_blockt body;
826
+ for (const auto &value_pair : static_field_values)
827
+ {
828
+ assign_from_json (
829
+ value_pair.first ,
830
+ value_pair.second ,
831
+ real_clinit_name,
832
+ body,
833
+ symbol_table,
834
+ needed_lazy_methods,
835
+ max_user_array_length,
836
+ references);
837
+ }
838
+ return body;
835
839
}
836
- if (const auto clinit_func = symbol_table.lookup (real_clinit_name))
837
- return code_blockt{{code_function_callt{clinit_func->symbol_expr ()}}};
838
- return code_blockt{};
840
+ return code_blockt{{code_function_callt{clinit_func->symbol_expr ()}}};
839
841
}
840
842
841
843
// / Create static initializer wrappers and possibly user-specified functions for
0 commit comments