Skip to content

Model for String and StringBuilder getChars #16

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

Merged
merged 2 commits into from
Nov 26, 2018
Merged
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
27 changes: 16 additions & 11 deletions src/main/java/java/lang/String.java
Original file line number Diff line number Diff line change
Expand Up @@ -964,20 +964,25 @@ public int offsetByCodePoints(int index, int codePointOffset) {
* <li>{@code dstBegin+(srcEnd-srcBegin)} is larger than
* {@code dst.length}</ul>
*
* @diffblue.noSupport
* @diffblue.fullSupport
* @diffblue.untested
*/
public void getChars(int srcBegin, int srcEnd, char dst[], int dstBegin) {
CProver.notModelled();
// if (srcBegin < 0) {
// throw new StringIndexOutOfBoundsException(srcBegin);
// }
// if (srcEnd > value.length) {
// throw new StringIndexOutOfBoundsException(srcEnd);
// }
// if (srcBegin > srcEnd) {
// throw new StringIndexOutOfBoundsException(srcEnd - srcBegin);
// }
if (srcBegin < 0) {
throw new StringIndexOutOfBoundsException(srcBegin);
}
if (srcEnd > length()) {
throw new StringIndexOutOfBoundsException(srcEnd);
}
if (srcBegin > srcEnd) {
throw new StringIndexOutOfBoundsException(srcEnd - srcBegin);
}
// DIFFBLUE MODEL LIBRARY we inline System.arraycopy here so that we
// can specialize it for characters.
// System.arraycopy(value, srcBegin, dst, dstBegin, srcEnd - srcBegin);
for(int i = 0; i < srcEnd - srcBegin; i++) {
dst[dstBegin + i] = CProverString.charAt(this, srcBegin + i);
}
}

/**
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/java/lang/StringBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -662,4 +662,13 @@ public String toString() {
// value = (char[]) s.readObject();
// }

// DIFFBLUE MODEL LIBRARY This should be inherited from AbstractStringBuilder
/**
* @diffblue.fullSupport
* @diffblue.untested
*/
public void getChars(int srcBegin, int srcEnd, char dst[], int dstBegin) {
toString().getChars(srcBegin, srcEnd, dst, dstBegin);
}

}