Skip to content

Commit 5f06e36

Browse files
Recreate initialize in final
Creates the initialize methods again taking account of symbols added to the symbol table during instantiation of lazy methods since they were first created.
1 parent aa5440b commit 5f06e36

File tree

3 files changed

+57
-1
lines changed

3 files changed

+57
-1
lines changed

src/java_bytecode/java_bytecode_language.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,13 @@ bool java_bytecode_languaget::final(symbol_table_baset &symbol_table)
466466
{
467467
PRECONDITION(language_options_initialized);
468468

469-
return false;
469+
return recreate_initialize(
470+
symbol_table,
471+
main_class,
472+
get_message_handler(),
473+
assume_inputs_non_null,
474+
object_factory_parameters,
475+
get_pointer_type_selector());
470476
}
471477

472478
void java_bytecode_languaget::show_parse(std::ostream &out)

src/java_bytecode/java_entry_point.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,48 @@ bool java_entry_point(
485485
pointer_type_selector);
486486
}
487487

488+
/// Creates the initialize methods again taking account of symbols added to the
489+
/// symbol table during instantiation of lazy methods since they were first
490+
/// created,
491+
/// \param symbol_table: global symbol table containing symbols to initialize
492+
/// \param main_class: the class containing the "main" entry point
493+
/// \param message_handler: message_handlert for logging
494+
/// \param assume_init_pointers_not_null: specifies behaviour for
495+
/// java_static_lifetime_init
496+
/// \param object_factory_parameters: specifies behaviour for
497+
/// java_static_lifetime_init
498+
/// \param pointer_type_selector: specifies behaviour for
499+
/// java_static_lifetime_init
500+
bool recreate_initialize(
501+
symbol_table_baset &symbol_table,
502+
const irep_idt &main_class,
503+
message_handlert &message_handler,
504+
bool assume_init_pointers_not_null,
505+
const object_factory_parameterst &object_factory_parameters,
506+
const select_pointer_typet &pointer_type_selector)
507+
{
508+
messaget message(message_handler);
509+
main_function_resultt res=
510+
get_main_symbol(symbol_table, main_class, message_handler);
511+
if(res.status!=main_function_resultt::Success)
512+
{
513+
// No initialization was originally created (yikes!) so we can't recreate
514+
// it now
515+
return res.status==main_function_resultt::Error;
516+
}
517+
518+
create_initialize(symbol_table);
519+
520+
java_static_lifetime_init(
521+
symbol_table,
522+
res.main_function.location,
523+
assume_init_pointers_not_null,
524+
object_factory_parameters,
525+
pointer_type_selector);
526+
527+
return false;
528+
}
529+
488530
/// Generate a _start function for a specific function. See
489531
/// java_entry_point for more details.
490532
/// \param symbol: The symbol representing the function to call

src/java_bytecode/java_entry_point.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,12 @@ bool generate_java_start_function(
7474
const object_factory_parameterst& object_factory_parameters,
7575
const select_pointer_typet &pointer_type_selector);
7676

77+
bool recreate_initialize(
78+
symbol_table_baset &symbol_table,
79+
const irep_idt &main_class,
80+
message_handlert &message_handler,
81+
bool assume_init_pointers_not_null,
82+
const object_factory_parameterst &object_factory_parameters,
83+
const select_pointer_typet &pointer_type_selector);
84+
7785
#endif // CPROVER_JAVA_BYTECODE_JAVA_ENTRY_POINT_H

0 commit comments

Comments
 (0)