Skip to content

Commit ad55b0e

Browse files
Add static-values tests with class substitution
This adds a test in which an non-empty class is replaced by an empty class after compilation and before JBMC is called. This used to cause a crash in the retrieval of static values. This kind of substitution is not uncommon in the jar packaging of libraries. A similar error was triggered when analyising a project which used mongodb as a dependency, and mongodb seems to use such tricks.
1 parent 581fbee commit ad55b0e

File tree

6 files changed

+27
-0
lines changed

6 files changed

+27
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
public class Empty {
2+
3+
}
Binary file not shown.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
public class EmptyNonEmpty {
2+
3+
/// This test is meant to illustrate what happens when the non-empty
4+
/// class is substitued with an empty one after compilation.
5+
public int test() {
6+
int x = NonEmpty.i;
7+
return x;
8+
}
9+
}
Binary file not shown.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
public class NonEmpty {
2+
public static int i = 23;
3+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
EmptyNonEmpty.class
3+
--unwind 1 --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar` --static-values clinit-state.json --function EmptyNonEmpty.test
4+
^VERIFICATION SUCCESSFUL$
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
--
8+
--
9+
This tests what happens when the non-empty class is substitued with an empty
10+
one after compilation: After compiling EmptyNonEmpty.class and Empty.class,
11+
Empty.class is moved to NonEmpty.class.
12+
We should at least ensure that JBMC does not crash.

0 commit comments

Comments
 (0)