Skip to content

Commit ca3dbab

Browse files
committed
check_class_cast: don't duplicate existing assertion
java_bytecode_convert_method.cpp already creates an assertion; we should replace it with an appropriately elaborated one rather than leaving the existing one in place.
1 parent 9ab281b commit ca3dbab

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed
237 Bytes
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
test.class
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
Dynamic cast check: FAILURE
9+
^warning: ignoring
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
public class test {
3+
4+
public static void main() {
5+
test t = (test)null;
6+
}
7+
8+
}

src/java_bytecode/java_bytecode_instrument.cpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ void java_bytecode_instrumentt::instrument_code(exprt &expr)
327327
}
328328
else if(statement==ID_assert)
329329
{
330-
code_assertt code_assert=to_code_assert(code);
330+
const code_assertt &code_assert=to_code_assert(code);
331331

332332
// does this correspond to checkcast?
333333
if(code_assert.assertion().id()==ID_java_instanceof)
@@ -338,13 +338,11 @@ void java_bytecode_instrumentt::instrument_code(exprt &expr)
338338
code_assert.assertion().operands().size()==2,
339339
"Instanceof should have 2 operands");
340340

341-
block.copy_to_operands(
341+
code=
342342
check_class_cast(
343343
code_assert.assertion().op0(),
344344
code_assert.assertion().op1(),
345-
code_assert.source_location()));
346-
block.copy_to_operands(code_assert);
347-
code=block;
345+
code_assert.source_location());
348346
}
349347
}
350348
else if(statement==ID_block)

0 commit comments

Comments
 (0)