Skip to content

Commit e6531b1

Browse files
Joel Allredromainbrenguier
Joel Allred
authored andcommitted
Overwrite String type
String classes that are present in a loaded model will generate a type that may be different from the internal type constructed for Java strings in cbmc. Thus we now create a String type and write it in the table, possibly overwriting a pre-existing Java string type.
1 parent ae79ea4 commit e6531b1

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/java_bytecode/java_bytecode_convert_class.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,14 @@ class java_bytecode_convert_classt:public messaget
4545
{
4646
add_array_types();
4747

48-
if(parse_tree.loading_successful)
48+
bool loading_success=parse_tree.loading_successful;
49+
if(loading_success)
4950
convert(parse_tree.parsed_class);
50-
else if(string_preprocess.is_known_string_type(
51-
parse_tree.parsed_class.name))
51+
52+
if(string_preprocess.is_known_string_type(parse_tree.parsed_class.name))
5253
string_preprocess.add_string_type(
5354
parse_tree.parsed_class.name, symbol_table);
54-
else
55+
else if(!loading_success)
5556
generate_class_stub(parse_tree.parsed_class.name);
5657
}
5758

src/java_bytecode/java_string_library_preprocess.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,10 @@ void java_string_library_preprocesst::add_string_type(
319319
string_symbol.type=string_type;
320320
string_symbol.is_type=true;
321321

322-
symbol_table.add(string_symbol);
322+
// Overwrite any pre-existing symbol in the table, e.g. created by
323+
// a loaded model.
324+
symbol_table.remove(string_symbol.name);
325+
assert(!symbol_table.add(string_symbol));
323326
}
324327

325328
/*******************************************************************\

0 commit comments

Comments
 (0)