Skip to content
3 changes: 1 addition & 2 deletions src/java.desktop/share/classes/javax/swing/JMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -1336,8 +1336,7 @@ private MenuElement[] buildMenuElementArray(JMenu leaf) {
break;
}
}
MenuElement[] me = new MenuElement[elements.size()];
elements.toArray(me);
MenuElement[] me = elements.toArray(new MenuElement[0]);
return me;
}

Expand Down
5 changes: 1 addition & 4 deletions src/java.desktop/share/classes/javax/swing/JOptionPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -2349,10 +2349,7 @@ private void writeObject(ObjectOutputStream s) throws IOException {
if(options[counter] instanceof Serializable)
serOptions.add(options[counter]);
if(serOptions.size() > 0) {
int optionCount = serOptions.size();
Object[] arrayOptions = new Object[optionCount];

serOptions.toArray(arrayOptions);
Object[] arrayOptions = serOptions.toArray(new Object[0]);
values.addElement("options");
values.addElement(arrayOptions);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1191,8 +1191,7 @@ void updateBidi( DefaultDocumentEvent chng ) {
removedElems[i] = bidiRoot.getElement(removeFromIndex+i);
}

Element[] addedElems = new Element[ newElements.size() ];
newElements.toArray( addedElems );
Element[] addedElems = newElements.toArray(new Element[0]);

// Update the change record.
ElementEdit ee = new ElementEdit( bidiRoot, removeFromIndex,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2108,8 +2108,7 @@ Element join(Element p, Element left, Element right, int rmOffs0, int rmOffs1) {
}

// install the children
Element[] c = new Element[children.size()];
children.toArray(c);
Element[] c = children.toArray(new Element[0]);
((BranchElement)to).replace(0, 0, c);
return to;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4267,8 +4267,7 @@ else if (rCount == 0) {
}
}
if (keyStrokes != null) {
retValue = new KeyStroke[keyStrokes.size()];
keyStrokes.toArray(retValue);
retValue = keyStrokes.toArray(new KeyStroke[0]);
}
return retValue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,7 @@ void splitZone(int index, int offs0, int offs1) {
zones.add(createZone(offs0, offs));
} while (offs < offs1);
View oldZone = getView(index);
View[] newZones = new View[zones.size()];
zones.toArray(newZones);
View[] newZones = zones.toArray(new View[0]);
replace(index, 1, newZones);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,7 @@ class RTFAttributes
a.add(new AssertiveAttribute(DOC, Constants.WidowControl,
"widowctrl", True));


RTFAttribute[] attrs = new RTFAttribute[a.size()];
a.toArray(attrs);
attributes = attrs;
attributes = a.toArray(new RTFAttribute[0]);
}

static Dictionary<String, RTFAttribute> attributesByKeyword()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ static class CharacterKeywordPair
pair.character = textKeywordDictionary.get(pair.keyword).charAt(0);
tempPairs.add(pair);
}
textKeywords = new CharacterKeywordPair[tempPairs.size()];
tempPairs.toArray(textKeywords);
textKeywords = tempPairs.toArray(new CharacterKeywordPair[0]);
}

static final char[] hexdigits = { '0', '1', '2', '3', '4', '5', '6', '7',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,7 @@ public GraphicsConfiguration[] getConfigurations() {
}
}
}
configs = new GraphicsConfiguration[v.size()];
v.toArray(configs);
configs = v.toArray(new GraphicsConfiguration[0]);
}
return configs.clone();
}
Expand Down