1
2 단계로 생성 된 ArrayList<String>
에 요소를 추가하면 비동기 배열이됩니다. 개발 된 모드가 아닌 생성 된 JS 코드에서만 발생합니다.IE8 배열 순서 버그
// The list where the bug occurs
ArrayList<String> list = new ArrayList<String>();
// Add a first element to the List
list.add("0");
//tmpList with elements that we will add at the end of the original
//list(at least 32 elements makes the bug occurs)
ArrayList<String> tmpList = new ArrayList<String>();
for(int i=1;i<33;i++) tmpList.add(""+i);
list.addAll(tmpList);
// The bug occurs when we add an element X to the position
// 1 or 2. The bug also occurs when usind addAll method
list.add(1,"X");
결과 배열은 ... 대신 예상 결과
0 X 1 2 *4* *3* *4* 5 6 7 8 9 10 11 12 13 14 15
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
는 ...
0 X 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
이 작동하는 해결책이다.
ArrayList<String> finalList = new ArrayList<String>();
for(int i=0; i<1;i++)
finalList.add(list.get(i));
finalList.add("X");
for(int i=1; i<list.size();i++)
finalList.add(list.get(i));
이는 경우 발생합니까 당신 다른 32 개 항목을 추가하기 전에 "X"요소를 추가 하시겠습니까? –
정말 빠졌나요? 다른 브라우저에서 사용해 보셨습니까? –
아니요, 다른 하나를 추가하기 전에는 발생하지 않습니다. 예, 우리는 다른 브라우저에서 시도했습니다. ie7 & ie8에서만 발생합니다. ie6에서 테스트되지 않았습니다. 그것은 파이어 폭스와 크롬 및 ie9에서 작동합니다. –