Skip to content

Commit 1b8f38b

Browse files
Goto checkers for Java require further preprocessing
1 parent f1c6488 commit 1b8f38b

File tree

4 files changed

+100
-0
lines changed

4 files changed

+100
-0
lines changed

jbmc/src/java_bytecode/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ SRC = bytecode_info.cpp \
77
generic_parameter_specialization_map_keys.cpp \
88
jar_file.cpp \
99
jar_pool.cpp \
10+
java_bmc_util.cpp \
1011
java_bytecode_convert_class.cpp \
1112
java_bytecode_convert_method.cpp \
1213
java_bytecode_concurrency_instrumentation.cpp \
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*******************************************************************\
2+
3+
Module: Bounded Model Checking Utils for Java
4+
5+
Author: Daniel Kroening, Peter Schrammel
6+
7+
\*******************************************************************/
8+
9+
/// \file
10+
/// Bounded Model Checking Utils for Java
11+
12+
#include "java_bmc_util.h"
13+
14+
#include <goto-checker/symex_bmc.h>
15+
#include <goto-programs/abstract_goto_model.h>
16+
#include <java_bytecode/java_enum_static_init_unwind_handler.h>
17+
18+
void java_setup_symex(
19+
const optionst &options,
20+
abstract_goto_modelt &goto_model,
21+
symex_bmct &symex)
22+
{
23+
// unwinds <clinit> loops to number of enum elements
24+
if(options.get_bool_option("java-unwind-enum-static"))
25+
{
26+
// clang-format off
27+
// (it asks for the body to be at the same indent level as the parameters
28+
// for some reason)
29+
symex.add_loop_unwind_handler(
30+
[&goto_model](
31+
const goto_symex_statet::call_stackt &context,
32+
unsigned loop_num,
33+
unsigned unwind,
34+
unsigned &max_unwind)
35+
{ // NOLINT (*)
36+
return java_enum_static_init_unwind_handler(
37+
context, loop_num, unwind, max_unwind, goto_model.get_symbol_table());
38+
});
39+
// clang-format on
40+
}
41+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*******************************************************************\
2+
3+
Module: Bounded Model Checking Utils for Java
4+
5+
Author: Daniel Kroening, Peter Schrammel
6+
7+
\*******************************************************************/
8+
9+
/// \file
10+
/// Bounded Model Checking Utils for Java
11+
12+
#ifndef CPROVER_JAVA_BYTECODE_JAVA_BMC_UTIL_H
13+
#define CPROVER_JAVA_BYTECODE_JAVA_BMC_UTIL_H
14+
15+
class abstract_goto_modelt;
16+
class optionst;
17+
class symex_bmct;
18+
19+
/// Registers Java-specific preprocessing handlers with goto-symex
20+
void java_setup_symex(
21+
const optionst &options,
22+
abstract_goto_modelt &goto_model,
23+
symex_bmct &symex);
24+
25+
#endif // CPROVER_JAVA_BYTECODE_JAVA_BMC_UTIL_H
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*******************************************************************\
2+
3+
Module: Goto Checker using Bounded Model Checking for Java
4+
5+
Author: Daniel Kroening, Peter Schrammel
6+
7+
\*******************************************************************/
8+
9+
/// \file
10+
/// Goto Checker using Bounded Model Checking for Java
11+
12+
#ifndef CPROVER_JAVA_BYTECODE_JAVA_MULTI_PATH_SYMEX_ONLY_CHECKER_H
13+
#define CPROVER_JAVA_BYTECODE_JAVA_MULTI_PATH_SYMEX_ONLY_CHECKER_H
14+
15+
#include <goto-checker/multi_path_symex_only_checker.h>
16+
17+
#include "java_bmc_util.h"
18+
19+
class java_multi_path_symex_only_checkert
20+
: public multi_path_symex_only_checkert
21+
{
22+
public:
23+
java_multi_path_symex_only_checkert(
24+
const optionst &options,
25+
ui_message_handlert &ui_message_handler,
26+
abstract_goto_modelt &goto_model)
27+
: multi_path_symex_only_checkert(options, ui_message_handler, goto_model)
28+
{
29+
java_setup_symex(options, goto_model, symex);
30+
}
31+
};
32+
33+
#endif // CPROVER_JAVA_BYTECODE_JAVA_MULTI_PATH_SYMEX_ONLY_CHECKER_H

0 commit comments

Comments
 (0)