@@ -194,6 +194,27 @@ public String(char value[]) {
194
194
// this.value = Arrays.copyOf(value, value.length);
195
195
}
196
196
197
+ /**
198
+ * Intermediary function for modelling the constructor for
199
+ * String(char value[], int offset, int count).
200
+ * The code is copied from the original String(char value[], int offset, int count).
201
+ */
202
+ private static String CProverStringOfCharArray (char value [], int offset , int count ) {
203
+ if (offset < 0 ) {
204
+ throw new StringIndexOutOfBoundsException (offset );
205
+ }
206
+ if (count < 0 ) {
207
+ throw new StringIndexOutOfBoundsException (count );
208
+ }
209
+ // Note: offset or count might be near -1>>>1.
210
+ if (offset > value .length - count ) {
211
+ throw new StringIndexOutOfBoundsException (offset + count );
212
+ }
213
+ // DIFFBLUE MODEL LIBRARY Use CProverString function instead of array copy
214
+ return CProverString .ofCharArray (value , offset , count );
215
+ // this.value = Arrays.copyOfRange(value, offset, offset+count);
216
+ }
217
+
197
218
/**
198
219
* Allocates a new {@code String} that contains characters from a subarray
199
220
* of the character array argument. The {@code offset} argument is the
@@ -216,11 +237,11 @@ public String(char value[]) {
216
237
* characters outside the bounds of the {@code value} array
217
238
*
218
239
* @diffblue.limitedSupport
219
- * Does not throw exceptions.
220
240
* @diffblue.untested
221
241
*/
222
242
public String (char value [], int offset , int count ) {
223
- // DIFFBLUE MODEL LIBRARY This is treated internally in CBMC
243
+ // DIFFBLUE MODEL LIBRARY
244
+ this (CProverStringOfCharArray (value , offset , count ));
224
245
// if (offset < 0) {
225
246
// throw new StringIndexOutOfBoundsException(offset);
226
247
// }
0 commit comments