-
Notifications
You must be signed in to change notification settings - Fork 274
JBMC Java Core models library #1735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ed008f9
34216f5
f66288b
a8e659c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,7 @@ src/ansi-c/gcc_builtin_headers_tm.inc | |
src/ansi-c/gcc_builtin_headers_mips.inc | ||
src/ansi-c/gcc_builtin_headers_power.inc | ||
src/ansi-c/gcc_builtin_headers_ubsan.inc | ||
src/java_bytecode/java_core_models.inc | ||
|
||
# regression/test files | ||
*.out | ||
|
@@ -115,6 +116,8 @@ src/ansi-c/file_converter | |
src/ansi-c/file_converter.exe | ||
src/ansi-c/library/converter | ||
src/ansi-c/library/converter.exe | ||
src/java_bytecode/converter | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about the .exe variant? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
src/java_bytecode/converter.exe | ||
src/util/irep_ids_convert | ||
src/util/irep_ids_convert.exe | ||
build/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CORE | ||
test.class | ||
--show-symbol-table | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
^Symbol\s*\.*\: java\:\:org\.cprover\.CProver\.\<clinit\>\:\(\)V$ | ||
-- | ||
-- | ||
tests that the core models are being loaded by checking if the static initializer for the CProver class was |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import org.cprover.CProver; | ||
class test | ||
{ | ||
public static void main(String[] args) | ||
{ | ||
int i=CProver.nondetInt(); | ||
assert(i!=0); | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,7 @@ Author: Daniel Kroening, [email protected] | |
void java_bytecode_languaget::get_language_options(const cmdlinet &cmd) | ||
{ | ||
assume_inputs_non_null=cmd.isset("java-assume-inputs-non-null"); | ||
java_class_loader.use_core_models=!cmd.isset("no-core-models"); | ||
string_refinement_enabled=cmd.isset("refine-strings"); | ||
throw_runtime_exceptions=cmd.isset("java-throw-runtime-exceptions"); | ||
if(cmd.isset("java-max-input-array-length")) | ||
|
@@ -267,6 +268,24 @@ bool java_bytecode_languaget::typecheck( | |
if(string_refinement_enabled) | ||
string_preprocess.initialize_conversion_table(); | ||
|
||
// Must load java.lang.Object first to avoid stubbing | ||
// This ordering could alternatively be enforced by | ||
// moving the code below to the class loader. | ||
java_class_loadert::class_mapt::const_iterator it= | ||
java_class_loader.class_map.find("java.lang.Object"); | ||
if(it!=java_class_loader.class_map.end()) | ||
{ | ||
if(java_bytecode_convert_class( | ||
it->second, | ||
symbol_table, | ||
get_message_handler(), | ||
max_user_array_length, | ||
method_bytecode, | ||
lazy_methods_mode, | ||
string_preprocess)) | ||
return true; | ||
} | ||
|
||
// first generate a new struct symbol for each class and a new function symbol | ||
// for every method | ||
for(java_class_loadert::class_mapt::const_iterator | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ Author: Daniel Kroening, [email protected] | |
#include <java_bytecode/select_pointer_type.h> | ||
|
||
#define JAVA_BYTECODE_LANGUAGE_OPTIONS /*NOLINT*/ \ | ||
"(no-core-models)" \ | ||
"(java-assume-inputs-non-null)" \ | ||
"(java-throw-runtime-exceptions)" \ | ||
"(java-max-input-array-length):" \ | ||
|
@@ -35,19 +36,21 @@ Author: Daniel Kroening, [email protected] | |
"(java-load-class):" | ||
|
||
#define JAVA_BYTECODE_LANGUAGE_OPTIONS_HELP /*NOLINT*/ \ | ||
" --java-assume-inputs-non-null never initialize reference-typed parameter to the\n" \ | ||
" entry point with null\n" \ | ||
" --java-throw-runtime-exceptions make implicit runtime exceptions explicit\n" \ | ||
" --java-max-input-array-length N limit input array size to <= N\n" \ | ||
" --java-max-input-tree-depth N object references are (deterministically) set to null in\n"\ | ||
" the object\n" \ | ||
" --java-max-vla-length limit the length of user-code-created arrays\n" \ | ||
" --java-cp-include-files regexp or JSON list of files to load (with '@' prefix)\n" \ | ||
" --lazy-methods only translate methods that appear to be reachable from\n" \ | ||
" the --function entry point or main class\n" \ | ||
" --lazy-methods-extra-entry-point METHODNAME\n" \ | ||
" treat METHODNAME as a possible program entry point for\n" \ | ||
" the purpose of lazy method loading\n" \ | ||
" --no-core-models don't load internally provided models for core classes in\n"/* NOLINT(*) */ \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use // clang-format off There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @peterschrammel just to clarify: I should replace the /* NOLINT(*) */ with // clang-format off ? should this be done for all options or just the one added? |
||
" the Java Class Library\n" /* NOLINT(*) */ \ | ||
" --java-assume-inputs-non-null never initialize reference-typed parameter to the\n" /* NOLINT(*) */ \ | ||
" entry point with null\n" /* NOLINT(*) */ \ | ||
" --java-throw-runtime-exceptions make implicit runtime exceptions explicit\n" /* NOLINT(*) */ \ | ||
" --java-max-input-array-length N limit input array size to <= N\n" /* NOLINT(*) */ \ | ||
" --java-max-input-tree-depth N object references are (deterministically) set to null in\n" /* NOLINT(*) */ \ | ||
" the object\n" /* NOLINT(*) */ \ | ||
" --java-max-vla-length limit the length of user-code-created arrays\n" /* NOLINT(*) */ \ | ||
" --java-cp-include-files regexp or JSON list of files to load (with '@' prefix)\n" /* NOLINT(*) */ \ | ||
" --lazy-methods only translate methods that appear to be reachable from\n" /* NOLINT(*) */ \ | ||
" the --function entry point or main class\n" /* NOLINT(*) */ \ | ||
" --lazy-methods-extra-entry-point METHODNAME\n" /* NOLINT(*) */ \ | ||
" treat METHODNAME as a possible program entry point for\n" /* NOLINT(*) */ \ | ||
" the purpose of lazy method loading\n" /* NOLINT(*) */ \ | ||
" A '.*' wildcard is allowed to specify all class members\n" | ||
|
||
#define MAX_NONDET_ARRAY_LENGTH_DEFAULT 5 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rephrase the commit message as follows:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done