Skip to content

Commit c0a0a4d

Browse files
Assert that there is uncaught exception
An uncaught exception makes the JVM abort. That's the default error behaviour the JBMC should check.
1 parent e57f572 commit c0a0a4d

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed
+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
CORE
22
Test.class
33
--function Test.goo
4-
^EXIT=0$
4+
^EXIT=10$
55
^SIGNAL=0$
6-
^VERIFICATION SUCCESSFUL$
6+
^VERIFICATION FAILED$
7+
no uncaught exception: FAILURE
78
--
89
^warning: ignoring

src/java_bytecode/java_entry_point.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,16 @@ void java_record_outputs(
294294
output.add_source_location()=function.location;
295295

296296
init_code.move_to_operands(output);
297+
298+
// check that there is no uncaught exception
299+
code_assertt assert_no_exception;
300+
assert_no_exception.assertion() =
301+
equal_exprt(exc_symbol.symbol_expr(),
302+
null_pointer_exprt(to_pointer_type(exc_symbol.type)));
303+
source_locationt assert_location = function.location;
304+
assert_location.set_comment("no uncaught exception");
305+
assert_no_exception.add_source_location() = assert_location;
306+
init_code.move_to_operands(assert_no_exception);
297307
}
298308

299309
main_function_resultt get_main_symbol(

0 commit comments

Comments
 (0)