Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit322b130

Browse files
turbanoffPankaj Bansal
authored and
Pankaj Bansal
committed
8275106: Cleanup Iterator usages in java.desktop
Reviewed-by: serb, pbansal
1 parentc355704 commit322b130

File tree

18 files changed

+53
-110
lines changed

18 files changed

+53
-110
lines changed

‎src/java.desktop/macosx/classes/sun/font/CStrike.java‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011,2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011,2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -29,8 +29,6 @@
2929
importjava.awt.geom.*;
3030
importjava.util.*;
3131

32-
importsun.awt.SunHints;
33-
3432
publicfinalclassCStrikeextendsPhysicalStrike {
3533

3634
// Creates the native strike
@@ -444,9 +442,7 @@ public synchronized void dispose() {
444442

445443
// clean up everyone else
446444
if (generalCache !=null) {
447-
finalIterator<Long>i =generalCache.values().iterator();
448-
while (i.hasNext()) {
449-
finallonglongValue =i.next().longValue();
445+
for (longlongValue :generalCache.values()) {
450446
if (longValue != -1 &&longValue !=0) {
451447
removeGlyphInfoFromCache(longValue);
452448
StrikeCache.freeLongPointer(longValue);

‎src/java.desktop/share/classes/com/sun/beans/introspect/EventSetInfo.java‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014,2021,Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -132,12 +132,7 @@ public static Map<String,EventSetInfo> get(Class<?> type) {
132132
}
133133
}
134134
}
135-
Iterator<EventSetInfo>iterator =map.values().iterator();
136-
while (iterator.hasNext()) {
137-
if (!iterator.next().initialize()) {
138-
iterator.remove();
139-
}
140-
}
135+
map.values().removeIf(eventSetInfo -> !eventSetInfo.initialize());
141136
return !map.isEmpty()
142137
?Collections.unmodifiableMap(map)
143138
:Collections.emptyMap();

‎src/java.desktop/share/classes/com/sun/beans/introspect/PropertyInfo.java‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014,2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014,2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -33,7 +33,6 @@
3333
importjava.util.ArrayList;
3434
importjava.util.Collections;
3535
importjava.util.EnumMap;
36-
importjava.util.Iterator;
3736
importjava.util.List;
3837
importjava.util.Map;
3938
importjava.util.TreeMap;
@@ -303,12 +302,7 @@ public static Map<String,PropertyInfo> get(Class<?> type) {
303302
}
304303
}
305304
}
306-
Iterator<PropertyInfo>iterator =map.values().iterator();
307-
while (iterator.hasNext()) {
308-
if (!iterator.next().initialize()) {
309-
iterator.remove();
310-
}
311-
}
305+
map.values().removeIf(propertyInfo -> !propertyInfo.initialize());
312306
return !map.isEmpty()
313307
?Collections.unmodifiableMap(map)
314308
:Collections.emptyMap();

‎src/java.desktop/share/classes/java/awt/DefaultKeyboardFocusManager.java‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -887,11 +887,11 @@ public boolean dispatchKeyEvent(KeyEvent e) {
887887
booleanstopPostProcessing =false;
888888
java.util.List<KeyEventPostProcessor>processors =getKeyEventPostProcessors();
889889
if (processors !=null) {
890-
for (java.util.Iterator<KeyEventPostProcessor>iter =processors.iterator();
891-
!stopPostProcessing&&iter.hasNext(); )
892-
{
893-
stopPostProcessing =iter.next().
894-
postProcessKeyEvent(e);
890+
for (KeyEventPostProcessorprocessor :processors) {
891+
stopPostProcessing=processor.postProcessKeyEvent(e);
892+
if (stopPostProcessing){
893+
break;
894+
}
895895
}
896896
}
897897
if (!stopPostProcessing) {

‎src/java.desktop/share/classes/java/beans/beancontext/BeanContextServicesSupport.java‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,23 +1163,23 @@ protected synchronized void bcsPreSerializationHook(ObjectOutputStream oos) thro
11631163

11641164
intcount =0;
11651165

1166-
Iterator<Map.Entry<Object,BCSSServiceProvider>>i =services.entrySet().iterator();
1166+
for (Map.Entry<Object,BCSSServiceProvider>entry :services.entrySet()) {
1167+
BCSSServiceProviderbcsp;
11671168

1168-
while (i.hasNext() &&count <serializable) {
1169-
Map.Entry<Object,BCSSServiceProvider>entry =i.next();
1170-
BCSSServiceProviderbcsp =null;
1171-
1172-
try {
1169+
try {
11731170
bcsp =entry.getValue();
1174-
}catch (ClassCastExceptioncce) {
1171+
}catch (ClassCastExceptioncce) {
11751172
continue;
1176-
}
1173+
}
11771174

1178-
if (bcsp.getServiceProvider()instanceofSerializable) {
1175+
if (bcsp.getServiceProvider()instanceofSerializable) {
11791176
oos.writeObject(entry.getKey());
11801177
oos.writeObject(bcsp);
11811178
count++;
1182-
}
1179+
}
1180+
if (count >=serializable) {
1181+
break;
1182+
}
11831183
}
11841184

11851185
if (count !=serializable)

‎src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFTag.java‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005,2016, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005,2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -24,7 +24,6 @@
2424
*/
2525
packagejavax.imageio.plugins.tiff;
2626

27-
importjava.util.Iterator;
2827
importjava.util.Set;
2928
importjava.util.SortedMap;
3029
importjava.util.TreeMap;
@@ -401,11 +400,10 @@ public int[] getNamedValues() {
401400
int[]intValues =null;
402401
if (valueNames !=null) {
403402
Set<Integer>values =valueNames.keySet();
404-
Iterator<Integer>iter =values.iterator();
405403
intValues =newint[values.size()];
406404
inti =0;
407-
while (iter.hasNext()) {
408-
intValues[i++] =iter.next();
405+
for (intvalue :values) {
406+
intValues[i++] =value;
409407
}
410408
}
411409
returnintValues;

‎src/java.desktop/share/classes/javax/print/attribute/standard/PrinterStateReasons.java‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,7 @@ public PrinterStateReasonSet(Severity severity,
242242

243243
publicintsize() {
244244
intresult =0;
245-
Iterator<PrinterStateReason>iter =iterator();
246-
while (iter.hasNext()) {
247-
iter.next();
245+
for (PrinterStateReasonignored :this) {
248246
++result;
249247
}
250248
returnresult;

‎src/java.desktop/share/classes/javax/swing/JDesktopPane.java‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
importjava.io.Serial;
3636
importjava.util.ArrayList;
3737
importjava.util.Collection;
38-
importjava.util.Iterator;
3938
importjava.util.LinkedHashSet;
4039
importjava.util.List;
4140
importjava.util.Set;
@@ -328,12 +327,7 @@ public void setSelectedFrame(JInternalFrame f) {
328327
*/
329328
publicJInternalFrame[]getAllFramesInLayer(intlayer) {
330329
Collection<JInternalFrame>allFrames =getAllFrames(this);
331-
Iterator<JInternalFrame>iterator =allFrames.iterator();
332-
while (iterator.hasNext()) {
333-
if (iterator.next().getLayer() !=layer) {
334-
iterator.remove();
335-
}
336-
}
330+
allFrames.removeIf(frame ->frame.getLayer() !=layer);
337331
returnallFrames.toArray(newJInternalFrame[0]);
338332
}
339333

‎src/java.desktop/share/classes/sun/awt/datatransfer/DataTransferer.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,8 +1957,8 @@ public static long[] keysToLongArray(SortedMap<Long, ?> map) {
19571957
Set<Long>keySet =map.keySet();
19581958
long[]retval =newlong[keySet.size()];
19591959
inti =0;
1960-
for (Iterator<Long>iter =keySet.iterator();iter.hasNext();i++) {
1961-
retval[i] =iter.next();
1960+
for (longkey :keySet) {
1961+
retval[i++] =key;
19621962
}
19631963
returnretval;
19641964
}

‎src/java.desktop/share/classes/sun/awt/im/InputContext.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
importjava.security.AccessController;
4848
importjava.security.PrivilegedAction;
4949
importjava.text.MessageFormat;
50+
importjava.util.Collection;
5051
importjava.util.HashMap;
51-
importjava.util.Iterator;
5252
importjava.util.Locale;
5353
importjava.util.prefs.BackingStoreException;
5454
importjava.util.prefs.Preferences;
@@ -695,10 +695,10 @@ public synchronized void dispose() {
695695
}
696696
inputMethodLocator =null;
697697
if (usedInputMethods !=null && !usedInputMethods.isEmpty()) {
698-
Iterator<InputMethod>iterator =usedInputMethods.values().iterator();
698+
Collection<InputMethod>methods =usedInputMethods.values();
699699
usedInputMethods =null;
700-
while (iterator.hasNext()) {
701-
iterator.next().dispose();
700+
for (InputMethodmethod :methods) {
701+
method.dispose();
702702
}
703703
}
704704

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp