@@ -9,9 +9,11 @@ Author: Daniel Kroening, kroening@kroening.com
9
9
#include " java_entry_point.h"
10
10
11
11
#include < util/config.h>
12
+ #include < util/expr_initializer.h>
12
13
#include < util/string_constant.h>
13
14
#include < util/suffix.h>
14
15
16
+ #include < goto-programs/class_identifier.h>
15
17
#include < goto-programs/goto_functions.h>
16
18
17
19
#include < linking/static_lifetime_init.h>
@@ -117,7 +119,8 @@ static void java_static_lifetime_init(
117
119
bool assume_init_pointers_not_null,
118
120
const object_factory_parameterst &object_factory_parameters,
119
121
const select_pointer_typet &pointer_type_selector,
120
- bool string_refinement_enabled)
122
+ bool string_refinement_enabled,
123
+ message_handlert &message_handler)
121
124
{
122
125
symbolt &initialize_symbol=*symbol_table.get_writeable (INITIALIZE_FUNCTION);
123
126
code_blockt &code_block=to_code_block (to_code (initialize_symbol.value ));
@@ -188,6 +191,19 @@ static void java_static_lifetime_init(
188
191
args.push_back (
189
192
constant_bool (class_symbol.type .get_bool (ID_enumeration)));
190
193
194
+ // First initialize the object as prior to a constructor:
195
+ namespacet ns (symbol_table);
196
+
197
+ exprt zero_object =
198
+ zero_initializer (
199
+ sym.type , source_locationt (), ns, message_handler);
200
+ set_class_identifier (
201
+ to_struct_expr (zero_object), ns, to_symbol_type (sym.type ));
202
+
203
+ code_block.copy_to_operands (
204
+ code_assignt (sym.symbol_expr (), zero_object));
205
+
206
+ // Then call the init function:
191
207
code_block.move_to_operands (initializer_call);
192
208
}
193
209
else if (sym.value .is_nil () && sym.type !=empty_typet ())
@@ -530,7 +546,8 @@ bool java_entry_point(
530
546
assume_init_pointers_not_null,
531
547
object_factory_parameters,
532
548
pointer_type_selector,
533
- string_refinement_enabled);
549
+ string_refinement_enabled,
550
+ message_handler);
534
551
535
552
return generate_java_start_function (
536
553
symbol,
0 commit comments