-
Notifications
You must be signed in to change notification settings - Fork 4
Implement model for String.equals #7
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1390,11 +1390,33 @@ public byte[] getBytes() { | |
* @see #equalsIgnoreCase(String) | ||
* | ||
* @diffblue.fullSupport | ||
* @diffblue.untested | ||
*/ | ||
public boolean equals(Object anObject) { | ||
// DIFFBLUE MODEL LIBRARY This is treated internally in CBMC | ||
return CProver.nondetBoolean(); | ||
// if (this == anObject) { | ||
// return true; | ||
// } | ||
// if (anObject instanceof String) { | ||
// String anotherString = (String)anObject; | ||
// int n = value.length; | ||
// if (n == anotherString.value.length) { | ||
// char v1[] = value; | ||
// char v2[] = anotherString.value; | ||
// int i = 0; | ||
// while (n-- != 0) { | ||
// if (v1[i] != v2[i]) | ||
// return false; | ||
// i++; | ||
// } | ||
// return true; | ||
// } | ||
// } | ||
// return false; | ||
|
||
// DIFFBLUE MODEL LIBRARY Use CProverString function | ||
if (anObject instanceof String) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As in the models-lib PR, could you add the original code from the JDK, commented out? |
||
return CProverString.equals((String) anObject, this); | ||
} | ||
return false; | ||
} | ||
|
||
/** | ||
|
@@ -1611,7 +1633,7 @@ public int compareTo(String anotherString) { | |
// DIFFBLUE MODEL LIBRARY For some reason this needs to be not null for | ||
// FileReader tests to pass. | ||
public static final Comparator<String> CASE_INSENSITIVE_ORDER | ||
= CProver.nondetWithoutNullForNotModelled(); | ||
= null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the comment directly above needs to be updated There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see why this change is necessary or related to this PR? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some JBMC tests fail because the type on the left and right correspond (for jbmc). This wasn't a problem before but if we load the model of String.java for using String.equals this also gets loaded. |
||
// DIFFBLUE MODEL LIBRARY Not needed for modelling | ||
// private static class CaseInsensitiveComparator | ||
// implements Comparator<String>, java.io.Serializable { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⛏️ In the other PR, it says "method" instead of "function".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
corrected in the other PR