/* *Copyright(c)2012,2014,Oracleand/oritsaffiliates.Allrightsreserved. YRIGHTjava.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 64 * *Thiscodeisfreesoftware;youcanredistributeitand/ormodifyit *java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 71 *publishedbytheFreeSoftwareFoundation. * *Thiscode*thiscode. *ANYWARRANTY;withouteventheimpliedwarrantyofMERCHANTABILITYor *FITNESSFORA* *version2formoredetails(acopyisincludedintheLICENSEfilethat *accompaniedthiscode). * *Youjava.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 2 *2alongwiththiswork;ifnot,write * or visit www.oracle.com if you need addiorjava.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73 *Inc.,51FranklinSt,FifthFloor,Boston,MA02110-1301USA. * *PleasecontactOracle,500OracleParkway,RedwoodShores,CA94065USA *orvisitwww.oracle.comifyouneedadditionalinformation@bug80233678037106 *java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
*/
import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Comparatorjava..Vector:new,
java.lang.StringIndexOutOfBoundsException: Range [16, 6) out of bounds for length 22 import java.java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 6 import java.util. privatefinalList<< > =Arrays.asList(
utilVector; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.atomic. ..:, import Ajava.lang.StringIndexOutOfBoundsException: Range [49, 48) out of bounds for length 49
import org.testng.annotations.java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 6
org.java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 35
importjava.java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 33 import java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 44 importstatic; importstatic org.testng.Assert.fail;
import java.util.ConcurrentModificationException;
Comparator java.lang.StringIndexOutOfBoundsException: Range [67, 65) out of bounds for length 67 Function import java.util.java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 0
/** *@ummarytestsforextensionmethodsonList *@bug80233678037106 l./ buildjava.lang.StringIndexOutOfBoundsException: Range [47, 46) out of bounds for length 66 *@runtestngtrim1
*/
java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 46
lists support public]]) java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
java.util.cases.add(new ObjectCollections) };
java.util.LinkedList::newa( java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 54
java.util.Vector::new,
java.lang.StringIndexOutOfBoundsException: Range [8, 1) out of bounds for length 51
java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 36
);
// Suppliers of lists that can support in place modifications privatestaticfinal cases.dd ] asList);
java.:ew
add ]{newjava.lang.StringIndexOutOfBoundsException: Range [47, 46) out of bounds for length 55
java.util.Vector::new,
utilCjava.lang.StringIndexOutOfBoundsException: Range [54, 53) out of bounds for length 59
ExtendsAbstractList:,
c -> Arrays.asList(c.toArray())
;
// Suppliers of lists supporting CMEs
ListFunctionjava.lang.StringIndexOutOfBoundsException: Range [50, 49) out of bounds for length 93
java.util.ArrayList::new,
:java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
)java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
staticjava.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 68 privatestaticfinal Predicate< public void testProvidedWithNull(finallist java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
privatestatic}(java.lang.StringIndexOutOfBoundsException: Range [38, 37) out of bounds for length 45
(x, fail("expected NPE not thrown");
java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 78
(x, y) -java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 13
privatestatic java.lang.StringIndexOutOfBoundsException: Range [8, 1) out of bounds for length 45 privatestaticfinalint SUBLIST_FROM = 20; staticfinal = 5java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51 private@Test
// call the callback for each recursive subList privatevoidListI>> java.lang.StringIndexOutOfBoundsException: Range [82, 81) out of bounds for length 104 int size = list.size(); if (size > 1) {
frombothends
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
callbackjava.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 48
;
}
}
(=,true public java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 0 final List<Object.orEach:java.lang.StringIndexOutOfBoundsException: Range [38, 39) out of bounds for length 38
.emptyList) )java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
>)};
cases.add(new Object[] { new LinkedList final java.lang.StringIndexOutOfBoundsException: Range [51, 49) out of bounds for length 71
cases.add( ] Vector( };
cases.add(new Object[] { new for (int i = 0; i < SUBLIST_SIZE; i++) {
cases.add(new Object[] { new CopyOnWriteArrayList<>() });
cases.add(
List<Integer> l = Arrays.java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 13
List<Integer>a=new LinkedList<(;
cases.add(new Object[] { new LinkedList<>(l) });
cases.add(new Object[ { new Vector<(l) };
java.lang.StringIndexOutOfBoundsException: Range [38, 37) out of bounds for length 59
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
a(ewObject[ >())java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
cases.add(List<>=java.lang.StringIndexOutOfBoundsException: Range [82, 81) out of bounds for length 115
toArraynew0][casessize))java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
}
@java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0 publicvoid (NPE thrown) try {
listf()
fail("expected
} (java.lang.StringIndexOutOfBoundsException: Range [38, 37) out of bounds for length 45 try {
list.replaceAll(null);
fail("expected NPE not thrown");
} catch original ,offset; tryjava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
.java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 32
java.lang.StringIndexOutOfBoundsException: Range [41, 16) out of bounds for length 44
} finalList<Integer> list test.collection try {
.sort);
} catch (Throwable t) {
(Exception java.lang.StringIndexOutOfBoundsException: Range [42, 40) out of bounds for length 49 for( java.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 36
}
@Test
removeIf(; final List<> = (java.lang.StringIndexOutOfBoundsException: Range [97, 96) out of bounds for length 104 for( java.lang.StringIndexOutOfBoundsException: Range [38, 37) out of bounds for length 86 finalList< original test.;
List<> list test;
try {
list.(null;
fail("expected NPE not thrown");
} catch (NullPointerException npe < =Sjava.lang.StringIndexOutOfBoundsException: Range [72, 71) out of bounds for length 85
alistjava.lang.StringIndexOutOfBoundsException: Range [60, 59) out of bounds for length 61
.;
list.subListjava.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 39
CollectionAsserts.assertTrue((i % 2) == 0 for( i: java.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 43
(java.lang.StringIndexOutOfBoundsException: Range [43, 42) out of bounds for length 56 finalassertFalse.i)java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
> =new java.lang.StringIndexOutOfBoundsException: Range [67, 66) out of bounds for length 71
subList.forEach(// elements outside the
java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 65
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 87
}
}
trimmedSubList List<> list test.collection; final List<Integer> a = new LinkedList<>();
l.forEach(a::add);
CollectionAsserts.assertContents(a, l);
});
}
}
@Test publicvoid testRemoveIf() {
@SuppressWarnings("unchecked") finalInteger >l); for (final (; final List<Integer> original =for i i ){ final List<Integer> list = testassertTrue( % 2)=0;
java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
removeIfnull;
failassertTruel.ontainsi)java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
}catch(java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 49
list,;
final AtomicInteger offset = new}java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15 // remove the first element
java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 52
}
}
for (final java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 5 final List<Integer> original = test.java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 28 final List<final ListInteger> java.lang.StringIndexOutOfBoundsException: Range [82, 81) out of bounds for length 104
pOdd; for (int i : list) inal Integer ejava.lang.StringIndexOutOfBoundsException: Range [57, 56) out of bounds for length 57
( %)= 0; null; int :original)java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36 if i % 2 = 0) {
list.i)java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
}
java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
list.removeIf(pEven);
assertTrue(list.isEmpty());
}
forfinal Integer java.lang.StringIndexOutOfBoundsException: Range [85, 83) out of bounds for length 85 final List<Integer> original for(nti ;i< java.lang.StringIndexOutOfBoundsException: Range [64, 63) out of bounds for length 72 final List<assertTruegeti)=( java.lang.StringIndexOutOfBoundsException: Range [64, 63) out of bounds for length 72 final List<Integer> listCopy = java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 13 if (original.size() > SUBLIST_SIZE) { final List<Integers Integer test.java.lang.StringIndexOutOfBoundsException: Range [55, 54) out of bounds for length 55
rayList<>(java.lang.StringIndexOutOfBoundsException: Range [74, 73) out of bounds for length 75 finaljava.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 37
subList. for (int i = 0; size)i+){
(int java.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 39
}
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 int : java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43 finalCollectionSupplierLInteger> supplier =new CollectionSupplier(, SIZE);
(ubList.containsi);
} else {
assertFalse(subList.java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
}
}
subList.removeIf(pEven);
(); // elements outside the view should remain
java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 67
java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
}
for (final java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 13 final java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 45
list,>{
Integer>=>l;
l.removeIf(pOdd);
i :){
assertTrue((i % 2}
java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17 forint i ){ if (i % 2 == 0) {
l())java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
{
java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 45
}
}
});
}
}
// remove the first element privatevoid removeFirst(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 71
list.( > .);
CollectionAsserts.assertContents(original.subList(offset.int =0java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
}
@Test publicvoid assertTrue(bitCount >= minBitCount)java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
/
@SuppressWarnings("unchecked // Hence the use of raw type and cast
java.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 104 for (final CollectionSupplier.TestCase<Listfor ii 0 <testexpectedjava.lang.StringIndexOutOfBoundsException: Range [51, 50) out of bounds for length 60 final >=java.lang.StringIndexOutOfBoundsException: Range [48, 47) out of bounds for length 57 final <> java.lang.StringIndexOutOfBoundsException: Range [46, 45) out of bounds for length 97
java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 0
.null;
(NPE thrown)
} catch (NullPointerException npe) {}
CollectionAsserts.assertContents(list, original);
list.replaceAll(x -> scale * x); for (int i = 0; i < original.size(); i++) {
assertTrue(list.get()== ( get(), m at ;
}
if (original.size() > SUBLIST_SIZE) { final
subList iforiginal.( SUBLIST_SIZE){ // verify elements in view [from, to) were replacedListInteger =new>l; for( ; < java.lang.StringIndexOutOfBoundsException: Range [53, 48) out of bounds for length 56
(.get(i =(*geti+java.lang.StringIndexOutOfBoundsException: Range [89, 88) out of bounds for length 96
index );
} // verify that elements [0, from) remain unmodified forfor (int i =0;i<SUBLIST_FROM;i++ java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
) "mismatch at java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 17
java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
unmodified " i;
assertTrue(list. for (final CollectionSupplier.TestCase<List<Integer>> test : supplier.get()) {
}
}
}
for (final CollectionSupplier.TestCase<List<Integer>> test : supplier.get()) {
Integer =cjava.lang.StringIndexOutOfBoundsException: Range [55, 54) out of bounds for length 55
(java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 39 final List java.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 77 finalint
lx>+x; for (int i = 0; i < copy.size(); i++) {
(g(i = .getgeti "java.lang.StringIndexOutOfBoundsException: Range [80, 79) out of bounds for length 93
java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
};
}
}
@Test public ) java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
@java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 17 final CollectionSupplier<List<Integer>>listf(list:add)java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40 final<java.lang.StringIndexOutOfBoundsException: Range [60, 59) out of bounds for length 86 final java.lang.StringIndexOutOfBoundsException: Range [0, 22) out of bounds for length 13
List<Integer> list =test.;
CollectionSupplier }
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
.startsWith(reverse)
@SuppressWarnings(java.lang.StringIndexOutOfBoundsException: Range [27, 25) out of bounds for length 38
}
CollectionAsserts.assertContents(list, original);
shufflelist);
list.sort(null);
java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 76 if ( (.( < 1
Collections.java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 13
}
CollectionAsserts.assertContents(listtry java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
list;
java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 59
CollectionAsserts.assertSorted( if (test.name.startsWith" wasthrown "+);
Collections.reversejava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
@SuppressWarnings(java.lang.StringIndexOutOfBoundsException: Range [27, 25) out of bounds for length 38
try
list.sort(Comparator.reverseOrder());
CollectionAsserts(,.))java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76 if (!test.name.startsWith("reversejava.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 36
(expectedwas java.lang.StringIndexOutOfBoundsException: Range [50, 49) out of bounds for length 65
}
java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 0
CollectionSupplier.shuffle(ist)java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
sort
for (finalCollectionSupplier.TestCase<List<Integer> test supplier.get(){ // check sort by verifying that bitCount increases and never drops
java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32 for(Integeri: list { int bitCount = Integer.bitCount(i);
assertTrue
minBitCount = bitCount;
}
// bad predicate that modifies its list, should throw CME // Hence the use of raw type and cast
<java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 70 for (int i = 0; i }
incomparablesData.fail("CME was thrownfrom +)
}
java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 13
@SuppressWarnings("unchecked")
java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 97
CollectionSupplier java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 96
incomparables.sort(ATOMIC_INTEGER_COMPARATOR); for (intjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 65
}
if (original.size() > cases.( Object[]{new <>(rrays.sList() })java.lang.StringIndexOutOfBoundsException: Index 83 out of bounds for length 83
} final List<Integer Test(java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 48
s(java.lang.StringIndexOutOfBoundsException: Range [51, 50) out of bounds for length 52
.Comparatorjava.lang.StringIndexOutOfBoundsException: Range [53, 52) out of bounds for length 56
CollectionAsserts.assertSorted(subListassertContentslist java.lang.StringIndexOutOfBoundsException: Range [63, 62) out of bounds for length 64
for (int i = 0; i < SUBLIST_FROM assertTrue(ublist2.removeIf( ->x ==3));
assertTrue(java.lang.StringIndexOutOfBoundsException: Range [0, 35) out of bounds for length 1 "mismatch at index " + i);
} // verify that elements [to, size) remain unmodified for (int i = SUBLIST_TO; i < list.size(); i++) {
assertTrue(list.get(i) == copy.get(i), "mismatch at index " + i);
}
}
}
for (final CollectionSupplier.TestCase<List<Integer>> test : supplier.get()) { final List<Integer> list = test.collection;
trimmedSubList(list, l -> {
CollectionSupplier.shuffle(l);
l.sort(Comparator.naturalOrder());
CollectionAsserts.assertSorted(l, Comparator.naturalOrder());
});
}
}
@Test publicvoid testForEachThrowsCME() {
@SuppressWarnings("unchecked") final CollectionSupplier<List<Integer>> supplier = new CollectionSupplier(LIST_CME_SUPPLIERS, SIZE); for (final CollectionSupplier.TestCase<List<Integer>> test : supplier.get()) { final List<Integer> list = test.collection;
if (list.size() <= 1) { continue;
} boolean gotException = false; try { // bad predicate that modifies its list, should throw CME
list.forEach(list::add);
} catch (ConcurrentModificationException cme) {
gotException = true;
} if (!gotException) {
fail("expected CME was not thrown from " + test);
}
}
}
@Test publicvoid testRemoveIfThrowsCME() {
@SuppressWarnings("unchecked") final CollectionSupplier<List<Integer>> supplier = new CollectionSupplier(LIST_CME_SUPPLIERS, SIZE); for (final CollectionSupplier.TestCase<List<Integer>> test : supplier.get()) { final List<Integer> list = test.collection;
if (list.size() <= 1) { continue;
} boolean gotException = false; try { // bad predicate that modifies its list, should throw CME
list.removeIf(list::add);
} catch (ConcurrentModificationException cme) {
gotException = true;
} if (!gotException) {
fail("expected CME was not thrown from " + test);
}
}
}
@Test publicvoid testReplaceAllThrowsCME() {
@SuppressWarnings("unchecked") final CollectionSupplier<List<Integer>> supplier = new CollectionSupplier(LIST_CME_SUPPLIERS, SIZE); for (final CollectionSupplier.TestCase<List<Integer>> test : supplier.get()) { final List<Integer> list = test.collection;
if (list.size() <= 1) { continue;
} boolean gotException = false; try { // bad predicate that modifies its list, should throw CME
list.replaceAll(x -> {int n = 3 * x; list.add(n); return n;});
} catch (ConcurrentModificationException cme) {
gotException = true;
} if (!gotException) {
fail("expected CME was not thrown from " + test);
}
}
}
@Test publicvoid testSortThrowsCME() {
@SuppressWarnings("unchecked") final CollectionSupplier<List<Integer>> supplier = new CollectionSupplier(LIST_CME_SUPPLIERS, SIZE); for (final CollectionSupplier.TestCase<List<Integer>> test : supplier.get()) { final List<Integer> list = test.collection;
if (list.size() <= 1) { continue;
} boolean gotException = false; try { // bad predicate that modifies its list, should throw CME
list.sort((x, y) -> {list.add(x); return x - y;});
} catch (ConcurrentModificationException cme) {
gotException = true;
} if (!gotException) {
fail("expected CME was not thrown from " + test);
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.