Skip to content

Commit 024036b

Browse files
author
thk123
committed
Extend lazy-methods-extra-entry-point to support regex methods
This will allow for loading for example, all constructors or all methods called getSomething. Tests using this require minor modifications when they have specified the descriptor as the brackets must be escaped for the regex. However, the new code handles the case where no descriptor is provided (in which case it will match all overloads) and the case where no java:: prefix has been provided, leaving similar behaviour. Correcting documentation for the extra entry points
1 parent 1e55404 commit 024036b

File tree

8 files changed

+19
-13
lines changed

8 files changed

+19
-13
lines changed
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
CORE symex-driven-lazy-loading-expected-failure
22
test.class
33
--lazy-methods --verbosity 10 --function test.f --lazy-methods-extra-entry-point test.sety
4-
^EXIT=6$
54
^SIGNAL=0$
6-
entry point 'test\.sety' is ambiguous between:
7-
test\.sety:\(I\)V
8-
test\.sety:\(F\)V
5+
CI lazy methods: elaborate java::test\.sety:\(I\)V
6+
CI lazy methods: elaborate java::test\.sety:\(F\)V
97
--
108
--
119
This doesn't work under symex-driven lazy loading because it is incompatible with --lazy-methods

jbmc/regression/jbmc/lazyloading11/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE symex-driven-lazy-loading-expected-failure
22
test.class
3-
--lazy-methods --verbosity 10 --function test.f --lazy-methods-extra-entry-point 'test.sety:(I)V' --lazy-methods-extra-entry-point 'test.sety:(F)V'
3+
--lazy-methods --verbosity 10 --function test.f --lazy-methods-extra-entry-point 'test.sety:\(I\)V' --lazy-methods-extra-entry-point 'test.sety:\(F\)V'
44
^EXIT=0$
55
^SIGNAL=0$
66
VERIFICATION SUCCESSFUL

jbmc/regression/jbmc/lazyloading7/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE symex-driven-lazy-loading-expected-failure
22
test.class
3-
--lazy-methods --verbosity 10 --function test.f --lazy-methods-extra-entry-point 'test.sety:(I)V'
3+
--lazy-methods --verbosity 10 --function test.f --lazy-methods-extra-entry-point 'test.sety:\(I\)V'
44
^EXIT=0$
55
^SIGNAL=0$
66
VERIFICATION SUCCESSFUL

jbmc/regression/jbmc/lazyloading8/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE symex-driven-lazy-loading-expected-failure
22
test.class
3-
--lazy-methods --verbosity 10 --function test.f --lazy-methods-extra-entry-point 'test.sety:(F)V'
3+
--lazy-methods --verbosity 10 --function test.f --lazy-methods-extra-entry-point 'test.sety:\(F\)V'
44
^EXIT=0$
55
^SIGNAL=0$
66
VERIFICATION SUCCESSFUL

jbmc/src/java_bytecode/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ SRC = bytecode_info.cpp \
3232
java_string_literals.cpp \
3333
java_types.cpp \
3434
java_utils.cpp \
35+
load_method_by_regex.cpp \
3536
mz_zip_archive.cpp \
3637
remove_exceptions.cpp \
3738
remove_instanceof.cpp \

jbmc/src/java_bytecode/java_bytecode_language.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Author: Daniel Kroening, [email protected]
3737
#include "ci_lazy_methods.h"
3838

3939
#include "expr2java.h"
40+
#include "load_method_by_regex.h"
4041

4142
/// Consume options that are java bytecode specific.
4243
/// \param Command:line options
@@ -94,10 +95,11 @@ void java_bytecode_languaget::get_language_options(const cmdlinet &cmd)
9495

9596
const std::list<std::string> &extra_entry_points=
9697
cmd.get_values("lazy-methods-extra-entry-point");
97-
lazy_methods_extra_entry_points.insert(
98-
lazy_methods_extra_entry_points.end(),
98+
std::transform(
9999
extra_entry_points.begin(),
100-
extra_entry_points.end());
100+
extra_entry_points.end(),
101+
std::back_inserter(extra_methods),
102+
build_load_method_by_regex);
101103

102104
if(cmd.isset("java-cp-include-files"))
103105
{
@@ -815,7 +817,7 @@ bool java_bytecode_languaget::do_ci_lazy_method_conversion(
815817
symbol_table,
816818
main_class,
817819
main_jar_classes,
818-
lazy_methods_extra_entry_points,
820+
extra_methods,
819821
java_class_loader,
820822
java_load_classes,
821823
get_pointer_type_selector(),

jbmc/src/java_bytecode/java_bytecode_language.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ Author: Daniel Kroening, [email protected]
6262
" --lazy-methods-extra-entry-point METHODNAME\n" /* NOLINT(*) */ \
6363
" treat METHODNAME as a possible program entry point for\n" /* NOLINT(*) */ \
6464
" the purpose of lazy method loading\n" /* NOLINT(*) */ \
65-
" A '.*' wildcard is allowed to specify all class members\n"
65+
" METHODNAME can be a regex that will be matched against\n" /* NOLINT(*) */ \
66+
" all symbols. If missing a java:: prefix will be added\n" /* NOLINT(*) */ \
67+
" If no descriptor is found, all overloads of a method will\n"/* NOLINT(*) */ \
68+
" also be added." /* NOLINT(*) */
6669
// clang-format on
6770

6871
class symbolt;
@@ -173,7 +176,6 @@ class java_bytecode_languaget:public languaget
173176
size_t max_user_array_length; // max size for user code created arrays
174177
method_bytecodet method_bytecode;
175178
lazy_methods_modet lazy_methods_mode;
176-
std::vector<irep_idt> lazy_methods_extra_entry_points;
177179
bool string_refinement_enabled;
178180
bool throw_runtime_exceptions;
179181
bool assert_uncaught_exceptions;
@@ -195,6 +197,8 @@ class java_bytecode_languaget:public languaget
195197
class_hierarchyt class_hierarchy;
196198
// List of classes to never load
197199
std::unordered_set<std::string> no_load_classes;
200+
201+
std::vector<load_extra_methodst> extra_methods;
198202
};
199203

200204
std::unique_ptr<languaget> new_java_bytecode_language();

jbmc/unit/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ SRC += java_bytecode/goto-programs/class_hierarchy_output.cpp \
2121
java_bytecode/java_types/java_generic_symbol_type.cpp \
2222
java_bytecode/java_types/java_type_from_string.cpp \
2323
java_bytecode/java_utils_test.cpp \
24+
java_bytecode/load_method_by_regex.cpp \
2425
java_bytecode/inherited_static_fields/inherited_static_fields.cpp \
2526
pointer-analysis/custom_value_set_analysis.cpp \
2627
solvers/refinement/string_constraint_instantiation/instantiate_not_contains.cpp \

0 commit comments

Comments
 (0)