Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shoaib/issue#439 #465

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"java.debug.settings.onBuildFailureProceed": true
}
5 changes: 3 additions & 2 deletions src/peers/gov/nasa/jpf/vm/JPF_java_lang_String.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,11 @@ public boolean equals__Ljava_lang_Object_2__Z (MJIEnv env, int objRef, int argRe
if (argRef == MJIEnv.NULL) {
return false;
}

if (!env.isInstanceOf(argRef, "java.lang.String")) {
return false; // The object is not a String, so return false
}
String s1 = env.getStringObject(objRef);
String s2 = env.getStringObject(argRef);

return s1.equals(s2);
}

Expand Down
8 changes: 8 additions & 0 deletions src/tests/gov/nasa/jpf/test/java/lang/StringTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ public void testEquals() {
assert !a.equals(c);
}
}

@Test
public void testEqualsWithNonStringObject() {
if (verifyNoPropertyViolation()) {
String a = "one two";
assert !a.equals(new Object());
}
}

@Test
public void testIndexOf() {
Expand Down
Loading