48
48
#include < goto-instrument/reachability_slicer.h>
49
49
#include < goto-instrument/nondet_static.h>
50
50
51
+ #include < linking/static_lifetime_init.h>
52
+
51
53
#include < pointer-analysis/add_failed_symbols.h>
52
54
53
55
#include < langapi/mode.h>
58
60
#include < java_bytecode/remove_instanceof.h>
59
61
#include < java_bytecode/remove_java_new.h>
60
62
#include < java_bytecode/replace_java_nondet.h>
63
+ #include < java_bytecode/simple_method_stubbing.h>
61
64
62
65
#include < cbmc/version.h>
63
66
@@ -522,6 +525,21 @@ int jbmc_parse_optionst::doit()
522
525
};
523
526
}
524
527
528
+ object_factory_params.max_nondet_array_length =
529
+ cmdline.isset (" java-max-input-array-length" )
530
+ ? std::stoul (cmdline.get_value (" java-max-input-array-length" ))
531
+ : MAX_NONDET_ARRAY_LENGTH_DEFAULT;
532
+ object_factory_params.max_nondet_string_length =
533
+ cmdline.isset (" string-max-input-length" )
534
+ ? std::stoul (cmdline.get_value (" string-max-input-length" ))
535
+ : MAX_NONDET_STRING_LENGTH;
536
+ object_factory_params.max_nondet_tree_depth =
537
+ cmdline.isset (" java-max-input-tree-depth" )
538
+ ? std::stoul (cmdline.get_value (" java-max-input-tree-depth" ))
539
+ : MAX_NONDET_TREE_DEPTH;
540
+
541
+ stub_objects_are_not_null = cmdline.isset (" java-assume-inputs-non-null" );
542
+
525
543
if (!cmdline.isset (" symex-driven-lazy-loading" ))
526
544
{
527
545
std::unique_ptr<goto_modelt> goto_model_ptr;
@@ -757,23 +775,11 @@ void jbmc_parse_optionst::process_goto_function(
757
775
replace_java_nondet (function);
758
776
759
777
// Similar removal of java nondet statements:
760
- // TODO Should really get this from java_bytecode_language somehow, but we
761
- // don't have an instance of that here.
762
- object_factory_parameterst factory_params;
763
- factory_params.max_nondet_array_length =
764
- cmdline.isset (" java-max-input-array-length" )
765
- ? std::stoul (cmdline.get_value (" java-max-input-array-length" ))
766
- : MAX_NONDET_ARRAY_LENGTH_DEFAULT;
767
- factory_params.max_nondet_string_length =
768
- cmdline.isset (" string-max-input-length" )
769
- ? std::stoul (cmdline.get_value (" string-max-input-length" ))
770
- : MAX_NONDET_STRING_LENGTH;
771
- factory_params.max_nondet_tree_depth =
772
- cmdline.isset (" java-max-input-tree-depth" )
773
- ? std::stoul (cmdline.get_value (" java-max-input-tree-depth" ))
774
- : MAX_NONDET_TREE_DEPTH;
775
-
776
- convert_nondet (function, get_message_handler (), factory_params, ID_java);
778
+ convert_nondet (
779
+ function,
780
+ get_message_handler (),
781
+ object_factory_params,
782
+ ID_java);
777
783
778
784
// add generic checks
779
785
goto_check (ns, options, ID_java, function.get_goto_function ());
@@ -1014,7 +1020,9 @@ bool jbmc_parse_optionst::process_goto_functions(
1014
1020
1015
1021
bool jbmc_parse_optionst::can_generate_function_body (const irep_idt &name)
1016
1022
{
1017
- return false ;
1023
+ static const irep_idt initialize_id = INITIALIZE_FUNCTION;
1024
+
1025
+ return name != goto_functionst::entry_point () && name != initialize_id;
1018
1026
}
1019
1027
1020
1028
bool jbmc_parse_optionst::generate_function_body (
@@ -1023,7 +1031,33 @@ bool jbmc_parse_optionst::generate_function_body(
1023
1031
goto_functiont &function,
1024
1032
bool body_available)
1025
1033
{
1026
- return false ;
1034
+ // Provide a simple stub implementation for any function we don't have a
1035
+ // bytecode implementation for:
1036
+
1037
+ if (body_available)
1038
+ return false ;
1039
+
1040
+ if (!can_generate_function_body (function_name))
1041
+ return false ;
1042
+
1043
+ if (symbol_table.lookup_ref (function_name).mode == ID_java)
1044
+ {
1045
+ java_generate_simple_method_stub (
1046
+ function_name,
1047
+ symbol_table,
1048
+ stub_objects_are_not_null,
1049
+ object_factory_params,
1050
+ get_message_handler ());
1051
+
1052
+ goto_convert_functionst converter (symbol_table, get_message_handler ());
1053
+ converter.convert_function (function_name, function);
1054
+
1055
+ return true ;
1056
+ }
1057
+ else
1058
+ {
1059
+ return false ;
1060
+ }
1027
1061
}
1028
1062
1029
1063
// / display command line help
0 commit comments