-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #981 from GaloisInc/bh-jvm
Add `jvm_static_field_is` command for specifying static fields in JVM.
- Loading branch information
Showing
12 changed files
with
249 additions
and
2 deletions.
There are no files selected for viewing
Submodule crucible
updated
19 files
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
%.class: %.java | ||
javac -g $< |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
class A | ||
{ | ||
static long x; | ||
static long y; | ||
static void setX(long v) { | ||
x = v; | ||
} | ||
static void setY(long v) { | ||
y = v; | ||
} | ||
static long getSum() { | ||
return x + y; | ||
} | ||
} | ||
|
||
class B extends A | ||
{ | ||
static long y; | ||
static void setY(long v) { | ||
y = v; | ||
} | ||
} | ||
|
||
class C extends B | ||
{ | ||
static long getSum() { | ||
return x + y; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
enable_experimental; | ||
a <- java_load_class "A"; | ||
print a; | ||
b <- java_load_class "B"; | ||
c <- java_load_class "C"; | ||
|
||
print "Verifying class A"; | ||
|
||
a_setX <- | ||
jvm_verify a "setX" [] false | ||
do { | ||
x <- jvm_fresh_var "x" java_long; | ||
v <- jvm_fresh_var "v" java_long; | ||
jvm_static_field_is "x" (jvm_term x); | ||
jvm_execute_func [jvm_term v]; | ||
jvm_static_field_is "x" (jvm_term v); | ||
} | ||
z3; | ||
|
||
a_setY <- | ||
jvm_verify a "setY" [] false | ||
do { | ||
y <- jvm_fresh_var "y" java_long; | ||
v <- jvm_fresh_var "v" java_long; | ||
jvm_static_field_is "y" (jvm_term y); | ||
jvm_execute_func [jvm_term v]; | ||
jvm_static_field_is "y" (jvm_term v); | ||
} | ||
z3; | ||
|
||
a_getSum <- | ||
jvm_verify a "getSum" [] false | ||
do { | ||
x <- jvm_fresh_var "x" java_long; | ||
y <- jvm_fresh_var "y" java_long; | ||
jvm_static_field_is "x" (jvm_term x); | ||
jvm_static_field_is "y" (jvm_term y); | ||
jvm_execute_func []; | ||
jvm_return (jvm_term {{ x + y }}); | ||
} | ||
z3; | ||
|
||
print "Verifying class B"; | ||
|
||
b_setX <- | ||
jvm_verify b "setX" [] false | ||
do { | ||
x <- jvm_fresh_var "x" java_long; | ||
v <- jvm_fresh_var "v" java_long; | ||
jvm_static_field_is "x" (jvm_term x); | ||
jvm_execute_func [jvm_term v]; | ||
jvm_static_field_is "x" (jvm_term v); | ||
} | ||
z3; | ||
|
||
b_setY <- | ||
jvm_verify b "setY" [] false | ||
do { | ||
y <- jvm_fresh_var "y" java_long; | ||
v <- jvm_fresh_var "v" java_long; | ||
jvm_static_field_is "y" (jvm_term y); | ||
jvm_execute_func [jvm_term v]; | ||
jvm_static_field_is "y" (jvm_term v); | ||
} | ||
z3; | ||
|
||
fails ( | ||
jvm_verify b "getSum" [] false | ||
do { | ||
x <- jvm_fresh_var "x" java_long; | ||
y <- jvm_fresh_var "y" java_long; | ||
jvm_static_field_is "x" (jvm_term x); | ||
// This fails because "getSum" is inherited from class A, | ||
// which has its own static field called "y", which in turn | ||
// is shadowed by field "y" from class B. | ||
jvm_static_field_is "y" (jvm_term y); | ||
jvm_execute_func []; | ||
jvm_return (jvm_term {{ x + y }}); | ||
} | ||
z3); | ||
|
||
b_getSum <- | ||
jvm_verify b "getSum" [] false | ||
do { | ||
x <- jvm_fresh_var "x" java_long; | ||
y <- jvm_fresh_var "y" java_long; | ||
jvm_static_field_is "x" (jvm_term x); | ||
// Because field "A.y" is shadowed by another field named "y" | ||
// in class "B", we must use the qualified field name. | ||
jvm_static_field_is "A.y" (jvm_term y); | ||
jvm_execute_func []; | ||
jvm_return (jvm_term {{ x + y }}); | ||
} | ||
z3; | ||
|
||
print "Verifying class C"; | ||
|
||
c_setX <- | ||
jvm_verify c "setX" [] false | ||
do { | ||
x <- jvm_fresh_var "x" java_long; | ||
v <- jvm_fresh_var "v" java_long; | ||
jvm_static_field_is "x" (jvm_term x); | ||
jvm_execute_func [jvm_term v]; | ||
jvm_static_field_is "x" (jvm_term v); | ||
} | ||
z3; | ||
|
||
c_setY <- | ||
jvm_verify c "setY" [] false | ||
do { | ||
y <- jvm_fresh_var "y" java_long; | ||
v <- jvm_fresh_var "v" java_long; | ||
jvm_static_field_is "y" (jvm_term y); | ||
jvm_execute_func [jvm_term v]; | ||
jvm_static_field_is "y" (jvm_term v); | ||
} | ||
z3; | ||
|
||
c_getSum <- | ||
jvm_verify c "getSum" [] false | ||
do { | ||
x <- jvm_fresh_var "x" java_long; | ||
y <- jvm_fresh_var "y" java_long; | ||
jvm_static_field_is "x" (jvm_term x); | ||
jvm_static_field_is "y" (jvm_term y); | ||
jvm_execute_func []; | ||
jvm_return (jvm_term {{ x + y }}); | ||
} | ||
z3; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
$SAW test.saw |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters