File tree Expand file tree Collapse file tree 7 files changed +57
-5
lines changed
jbmc/regression/jbmc/virtual_equals_object_param Expand file tree Collapse file tree 7 files changed +57
-5
lines changed Original file line number Diff line number Diff line change 1+ // Simpler test case demonstrating the virtual method resolution bug
2+ public class SimpleEquals {
3+ public static void testDirect () {
4+ // Direct call on String - this works
5+ String s1 = "hello" ;
6+ String s2 = "hello" ;
7+ assert (s1 .equals (s2 ));
8+ }
9+
10+ public static void testThroughObject (Object o1 , Object o2 ) {
11+ // Call through Object parameter - this was failing before the fix
12+ assert (o1 .equals (o2 ));
13+ }
14+
15+ public static void main (String [] args ) {
16+ testDirect ();
17+
18+ String s1 = "world" ;
19+ String s2 = "world" ;
20+ testThroughObject (s1 , s2 );
21+ }
22+ }
Original file line number Diff line number Diff line change 1+ public class equals_Pass {
2+ private static boolean myEquals (Object a , Object b ) {
3+ return (a == b ) || (a != null && a .equals (b ));
4+ }
5+
6+ public static void main (String [] args ) {
7+ String a = new String ("abc" );
8+ String b = new String ("abc" );
9+ assert ((a == b ) || (a != null && a .equals (b ))); // This passes
10+ boolean result = myEquals (a , b );
11+ assert (result ); // This fails
12+ }
13+ }
Original file line number Diff line number Diff line change 1+ CORE
2+ SimpleEquals.class
3+ --function SimpleEquals.main
4+ ^EXIT=0$
5+ ^SIGNAL=0$
6+ ^\[SimpleEquals.testDirect.assertion.1\] line 6 .*: SUCCESS$
7+ ^\[SimpleEquals.testThroughObject.assertion.1\] line 11 .*: SUCCESS$
8+ --
9+ ^warning: ignoring
Original file line number Diff line number Diff line change 1+ CORE
2+ equals_Pass.class
3+ --function equals_Pass.main
4+ ^EXIT=0$
5+ ^SIGNAL=0$
6+ ^\[equals_Pass.main.assertion.1\] line 9 .*: SUCCESS$
7+ ^\[equals_Pass.main.assertion.2\] line 11 .*: SUCCESS$
8+ --
9+ ^warning: ignoring
Original file line number Diff line number Diff line change @@ -518,13 +518,12 @@ void get_virtual_calleest::get_child_functions_rec(
518518 for (const auto &child : findit->second .children )
519519 {
520520 // Skip if we have already visited this and we found a function call that
521- // did not resolve to non java.lang.Object .
521+ // resolved to a non-Object implementation (i.e., we don't need to revisit) .
522522 auto it = entry_map.find (child);
523523 if (
524- it != entry_map.end () &&
525- (!it->second .symbol_expr .has_value () ||
526- !it->second .symbol_expr ->get_identifier ().starts_with (
527- " java::java.lang.Object" )))
524+ it != entry_map.end () && it->second .symbol_expr .has_value () &&
525+ !it->second .symbol_expr ->get_identifier ().starts_with (
526+ " java::java.lang.Object" ))
528527 {
529528 continue ;
530529 }
You can’t perform that action at this time.
0 commit comments