Skip to content

Commit 438d9f0

Browse files
author
Thomas Kiley
authored
Merge pull request diffblue#1401 from janmroczkowski/janmroczkowski/java_bytecode_convert_classt-add_array_types-fix
Fix to java_bytecode_convert_classt.add_array_types
2 parents 875d554 + b9dfda9 commit 438d9f0

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

src/java_bytecode/java_bytecode_convert_class.cpp

+8-18
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,6 @@ class java_bytecode_convert_classt:public messaget
7575
lazy_methods_modet lazy_methods_mode;
7676
java_string_library_preprocesst &string_preprocess;
7777

78-
/// This field will be initialized to false, and set to true when
79-
/// add_array_types() is executed. It serves as a sentinel to make sure that
80-
/// the code using this class calls add_array_types() at least once.
81-
static bool add_array_types_executed;
82-
8378
// conversion
8479
void convert(const classt &c);
8580
void convert(symbolt &class_symbol, const fieldt &f);
@@ -88,9 +83,6 @@ class java_bytecode_convert_classt:public messaget
8883
static void add_array_types(symbol_tablet &symbol_table);
8984
};
9085

91-
// initialization of static field
92-
bool java_bytecode_convert_classt::add_array_types_executed=false;
93-
9486
void java_bytecode_convert_classt::convert(const classt &c)
9587
{
9688
std::string qualified_classname="java::"+id2string(c.name);
@@ -256,23 +248,21 @@ void java_bytecode_convert_classt::convert(
256248
/// java::array[X] where X is byte, float, int, char...
257249
void java_bytecode_convert_classt::add_array_types(symbol_tablet &symbol_table)
258250
{
259-
// this method only adds stuff to the symbol table, no need to execute it more
260-
// than once
261-
if(add_array_types_executed)
262-
return;
263-
add_array_types_executed=true;
264-
265251
const std::string letters="ijsbcfdza";
266252

267253
for(const char l : letters)
268254
{
269255
symbol_typet symbol_type=
270256
to_symbol_type(java_array_type(l).subtype());
271257

258+
const irep_idt &symbol_type_identifier=symbol_type.get_identifier();
259+
if(symbol_table.has_symbol(symbol_type_identifier))
260+
return;
261+
272262
struct_typet struct_type;
273263
// we have the base class, java.lang.Object, length and data
274264
// of appropriate type
275-
struct_type.set_tag(symbol_type.get_identifier());
265+
struct_type.set_tag(symbol_type_identifier);
276266

277267
struct_type.components().reserve(3);
278268
struct_typet::componentt
@@ -298,7 +288,7 @@ void java_bytecode_convert_classt::add_array_types(symbol_tablet &symbol_table)
298288
"object that doesn't match expectations");
299289

300290
symbolt symbol;
301-
symbol.name=symbol_type.get_identifier();
291+
symbol.name=symbol_type_identifier;
302292
symbol.base_name=symbol_type.get(ID_C_base_name);
303293
symbol.is_type=true;
304294
symbol.type=struct_type;
@@ -308,7 +298,7 @@ void java_bytecode_convert_classt::add_array_types(symbol_tablet &symbol_table)
308298
// ----------------------------
309299

310300
const irep_idt clone_name=
311-
id2string(symbol_type.get_identifier())+".clone:()Ljava/lang/Object;";
301+
id2string(symbol_type_identifier)+".clone:()Ljava/lang/Object;";
312302
code_typet clone_type;
313303
clone_type.return_type()=
314304
java_reference_type(symbol_typet("java::java.lang.Object"));
@@ -413,7 +403,7 @@ void java_bytecode_convert_classt::add_array_types(symbol_tablet &symbol_table)
413403
symbolt clone_symbol;
414404
clone_symbol.name=clone_name;
415405
clone_symbol.pretty_name=
416-
id2string(symbol_type.get_identifier())+".clone:()";
406+
id2string(symbol_type_identifier)+".clone:()";
417407
clone_symbol.base_name="clone";
418408
clone_symbol.type=clone_type;
419409
clone_symbol.value=clone_body;

0 commit comments

Comments
 (0)