Skip to content

Commit 86a34c9

Browse files
authored
Merge pull request diffblue#1765 from smowton/smowton/fix/ci-lazy-methods-array-element-types
CI lazy methods: re-explore array types with different element types
2 parents f17e2c8 + 1e11f6d commit 86a34c9

File tree

8 files changed

+43
-1
lines changed

8 files changed

+43
-1
lines changed
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
public class A {
2+
3+
public int f() {
4+
return 1;
5+
}
6+
7+
}
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
public class B {
2+
3+
public int g() {
4+
return 5;
5+
}
6+
7+
}
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
public class Test {
2+
3+
A[] arrayA;
4+
B[] arrayB;
5+
6+
public static void check(Test t) {
7+
if (t == null || t.arrayA == null || t.arrayB == null ||
8+
t.arrayA.length == 0 || t.arrayB.length == 0 ||
9+
t.arrayA[0] == null || t.arrayB[0] == null)
10+
return;
11+
int i = t.arrayA[0].f();
12+
int j = t.arrayB[0].g();
13+
int sum = i + j;
14+
assert(sum == 6);
15+
}
16+
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
Test.class
3+
--lazy-methods --verbosity 10 --function Test.check
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
elaborate java::A\.f:\(\)I
7+
elaborate java::B\.g:\(\)I
8+
VERIFICATION SUCCESSFUL

src/java_bytecode/ci_lazy_methods.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,10 @@ void ci_lazy_methodst::initialize_needed_classes_from_pointer(
344344
const symbol_typet &class_type=to_symbol_type(pointer_type.subtype());
345345
const auto &param_classid=class_type.get_identifier();
346346

347-
if(needed_lazy_methods.add_needed_class(param_classid))
347+
// Note here: different arrays may have different element types, so we should
348+
// explore again even if we've seen this classid before in the array case.
349+
if(needed_lazy_methods.add_needed_class(param_classid) ||
350+
is_java_array_tag(param_classid))
348351
{
349352
gather_field_types(pointer_type.subtype(), ns, needed_lazy_methods);
350353
}

0 commit comments

Comments
 (0)