Use jdk 5 for-each-loop (app, cm, cm.test, common)

Replace most simple uses of Iterator with a corresponding for-each-loop.
Also add missing braces on loops as necessary.

Change-Id: I0dcaa50a43e0ff3b450f386dfa856d75bdcb6cbf
Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/Activator.java b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/Activator.java
index 5773e07..9834f8b 100644
--- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/Activator.java
+++ b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/Activator.java
@@ -225,9 +225,11 @@
 		if (bundles == null)
 			return null;
 		//Return the first bundle that is not installed or uninstalled
-		for (int i = 0; i < bundles.length; i++)
-			if ((bundles[i].getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0)
-				return bundles[i];
+		for (Bundle bundle : bundles) {
+			if ((bundle.getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0) {
+				return bundle;
+			}
+		}
 		return null;
 	}
 
diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/AppCommands.java b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/AppCommands.java
index b8c5718..a436959 100644
--- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/AppCommands.java
+++ b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/AppCommands.java
@@ -176,8 +176,9 @@
 	private Dictionary<String, Object> getServiceProps(ServiceReference ref) {
 		String[] keys = ref.getPropertyKeys();
 		Hashtable<String, Object> props = new Hashtable<>(keys.length);
-		for (int i = 0; i < keys.length; i++)
-			props.put(keys[i], ref.getProperty(keys[i]));
+		for (String key : keys) {
+			props.put(key, ref.getProperty(key));
+		}
 		return props;
 	}
 
@@ -187,8 +188,8 @@
 			intp.println("No applications found."); //$NON-NLS-1$
 			return;
 		}
-		for (int i = 0; i < apps.length; i++) {
-			String application = (String) apps[i].getProperty(ApplicationDescriptor.APPLICATION_PID);
+		for (ServiceReference app : apps) {
+			String application = (String) app.getProperty(ApplicationDescriptor.APPLICATION_PID);
 			intp.print(application);
 
 			if (getApplication(applicationHandles.getServiceReferences(), application, ApplicationHandle.APPLICATION_DESCRIPTOR, true) != null)
@@ -196,14 +197,14 @@
 
 			if (getApplication(scheduledApplications.getServiceReferences(), application, ScheduledApplication.APPLICATION_PID, true) != null)
 				intp.print(" [scheduled]"); //$NON-NLS-1$ 
-
-			if (!launchableApp.match(getServiceProps(apps[i])))
+			if (!launchableApp.match(getServiceProps(app))) {
 				intp.print(" [not launchable]"); //$NON-NLS-1$ 
-			else
+			} else {
 				intp.print(" [launchable]"); //$NON-NLS-1$ 
-
-			if (lockedApp.match(getServiceProps(apps[i])))
+			}
+			if (lockedApp.match(getServiceProps(app))) {
 				intp.print(" [locked]"); //$NON-NLS-1$ 
+			}
 			intp.println();
 		}
 	}
@@ -214,10 +215,10 @@
 			intp.println("No active applications found"); //$NON-NLS-1$
 			return;
 		}
-		for (int i = 0; i < active.length; i++) {
-			intp.print(active[i].getProperty(ApplicationHandle.APPLICATION_PID));
+		for (ServiceReference r : active) {
+			intp.print(r.getProperty(ApplicationHandle.APPLICATION_PID));
 			intp.print(" ["); //$NON-NLS-1$
-			intp.print(activeApp.match(getServiceProps(active[i])) ? "running" : "stopping"); //$NON-NLS-1$ //$NON-NLS-2$
+			intp.print(activeApp.match(getServiceProps(r)) ? "running" : "stopping"); //$NON-NLS-1$ //$NON-NLS-2$
 			intp.println("]"); //$NON-NLS-1$
 		}
 	}
@@ -228,16 +229,17 @@
 
 		ServiceReference result = null;
 		boolean ambigous = false;
-		for (int i = 0; i < apps.length; i++) {
-			String id = (String) apps[i].getProperty(idKey);
-			if (targetId.equals(id))
-				return apps[i]; // always return a perfect match
+		for (ServiceReference app : apps) {
+			String id = (String) app.getProperty(idKey);
+			if (targetId.equals(id)) {
+				return app; // always return a perfect match
+			}
 			if (perfectMatch)
 				continue;
 			if (id.contains(targetId)) {
 				if (result != null)
 					ambigous = true;
-				result = apps[i];
+				result = app;
 			}
 		}
 		return ambigous ? null : result;
diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/AppPersistence.java b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/AppPersistence.java
index 188f57e..cf18f42 100644
--- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/AppPersistence.java
+++ b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/AppPersistence.java
@@ -359,14 +359,15 @@
 							continue;
 						apps = timerApps.toArray(new EclipseScheduledApplication[timerApps.size()]);
 					}
-					for (int i = 0; i < apps.length; i++) {
+					for (EclipseScheduledApplication app : apps) {
 						try {
-							String filterString = apps[i].getEventFilter();
+							String filterString = app.getEventFilter();
 							Filter filter = filterString == null ? null : FrameworkUtil.createFilter(filterString);
-							if (filter == null || filter.match(props))
-								apps[i].handleEvent(timerEvent);
+							if (filter == null || filter.match(props)) {
+								app.handleEvent(timerEvent);
+							}
 						} catch (Throwable t) {
-							String message = NLS.bind(Messages.scheduled_app_launch_error, apps[i].getAppPid());
+							String message = NLS.bind(Messages.scheduled_app_launch_error, app.getAppPid());
 							Activator.log(new FrameworkLogEntry(Activator.PI_APP, FrameworkLogEntry.WARNING, 0, message, 0, t, null));
 						}
 					}
diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseAppContainer.java b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseAppContainer.java
index 65709f6..6ad8658 100644
--- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseAppContainer.java
+++ b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseAppContainer.java
@@ -272,8 +272,9 @@
 	 */
 	private void registerAppDescriptors() {
 		IExtension[] availableApps = getAvailableAppExtensions();
-		for (int i = 0; i < availableApps.length; i++)
-			createAppDescriptor(availableApps[i]);
+		for (IExtension availableApp : availableApps) {
+			createAppDescriptor(availableApp);
+		}
 	}
 
 	private void registerAppDescriptor(String applicationId) {
@@ -382,8 +383,8 @@
 		try {
 			ServiceReference[] runningRefs = context.getServiceReferences(ApplicationHandle.class.getName(), "(!(application.state=STOPPING))"); //$NON-NLS-1$
 			if (runningRefs != null)
-				for (int i = 0; i < runningRefs.length; i++) {
-					ApplicationHandle handle = (ApplicationHandle) context.getService(runningRefs[i]);
+				for (ServiceReference runningRef : runningRefs) {
+					ApplicationHandle handle = (ApplicationHandle) context.getService(runningRef);
 					try {
 						if (handle != null)
 							handle.destroy();
@@ -391,8 +392,9 @@
 						String message = NLS.bind(Messages.application_error_stopping, handle.getInstanceId());
 						Activator.log(new FrameworkLogEntry(Activator.PI_APP, FrameworkLogEntry.WARNING, 0, message, 0, t, null));
 					} finally {
-						if (handle != null)
-							context.ungetService(runningRefs[i]);
+						if (handle != null) {
+							context.ungetService(runningRef);
+						}
 					}
 				}
 		} catch (InvalidSyntaxException e) {
@@ -439,16 +441,15 @@
 		}
 		IConfigurationElement[] elements = extensionRegistry.getConfigurationElementsFor(PI_RUNTIME, PT_PRODUCTS);
 		List<FrameworkLogEntry> logEntries = null;
-		for (int i = 0; i < elements.length; i++) {
-			IConfigurationElement element = elements[i];
+		for (IConfigurationElement element : elements) {
 			if (element.getName().equalsIgnoreCase("provider")) { //$NON-NLS-1$
 				try {
 					Object provider = element.createExecutableExtension("run"); //$NON-NLS-1$
 					Object[] products = (Object[]) EclipseAppContainer.callMethod(provider, "getProducts", null, null); //$NON-NLS-1$
 					if (products != null)
-						for (int j = 0; j < products.length; j++) {
-							if (productId.equalsIgnoreCase((String) EclipseAppContainer.callMethod(products[j], "getId", null, null))) { //$NON-NLS-1$
-								branding = new ProviderExtensionBranding(products[j]);
+						for (Object product : products) {
+							if (productId.equalsIgnoreCase((String) EclipseAppContainer.callMethod(product, "getId", null, null))) { //$NON-NLS-1$
+								branding = new ProviderExtensionBranding(product);
 								return branding;
 							}
 						}
@@ -633,8 +634,9 @@
 
 	@Override
 	public void added(IExtension[] extensions) {
-		for (int i = 0; i < extensions.length; i++)
-			createAppDescriptor(extensions[i]);
+		for (IExtension extension : extensions) {
+			createAppDescriptor(extension);
+		}
 	}
 
 	@Override
@@ -644,8 +646,9 @@
 
 	@Override
 	public void removed(IExtension[] extensions) {
-		for (int i = 0; i < extensions.length; i++)
-			removeAppDescriptor(extensions[i].getUniqueIdentifier());
+		for (IExtension extension : extensions) {
+			removeAppDescriptor(extension.getUniqueIdentifier());
+		}
 	}
 
 	@Override
diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseAppHandle.java b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseAppHandle.java
index b884eb4..23f3c5c 100644
--- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseAppHandle.java
+++ b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/EclipseAppHandle.java
@@ -273,11 +273,11 @@
 
 			@Override
 			public void run() throws Exception {
-				for (int i = 0; i < monitors.length; i++) {
-					StartupMonitor monitor = (StartupMonitor) Activator.getContext().getService(monitors[i]);
+				for (ServiceReference m : monitors) {
+					StartupMonitor monitor = (StartupMonitor) Activator.getContext().getService(m);
 					if (monitor != null) {
 						monitor.applicationRunning();
-						Activator.getContext().ungetService(monitors[i]);
+						Activator.getContext().ungetService(m);
 					}
 				}
 			}
diff --git a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/ProductExtensionBranding.java b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/ProductExtensionBranding.java
index 445f742..8187e8b 100644
--- a/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/ProductExtensionBranding.java
+++ b/bundles/org.eclipse.equinox.app/src/org/eclipse/equinox/internal/app/ProductExtensionBranding.java
@@ -43,8 +43,7 @@
 	private void loadProperties(IConfigurationElement element) {
 		IConfigurationElement[] children = element.getChildren();
 		properties = new HashMap<>(children.length);
-		for (int i = 0; i < children.length; i++) {
-			IConfigurationElement child = children[i];
+		for (IConfigurationElement child : children) {
 			String key = child.getAttribute(ATTR_NAME);
 			String value = child.getAttribute(ATTR_VALUE);
 			if (key != null && value != null)
diff --git a/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/Activator.java b/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/Activator.java
index fab882f..8e59b6a 100644
--- a/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/Activator.java
+++ b/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/Activator.java
@@ -54,9 +54,9 @@
 		if (bundles == null)
 			return null;
 		//Return the first bundle that is not installed or uninstalled
-		for (int i = 0; i < bundles.length; i++) {
-			if ((bundles[i].getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0) {
-				return bundles[i];
+		for (Bundle bundle : bundles) {
+			if ((bundle.getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0) {
+				return bundle;
 			}
 		}
 		return null;
diff --git a/bundles/org.eclipse.equinox.cm/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.cm/META-INF/MANIFEST.MF
index b9171b0..8a1b917 100644
--- a/bundles/org.eclipse.equinox.cm/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.cm/META-INF/MANIFEST.MF
@@ -4,7 +4,7 @@
 Bundle-Vendor: %providerName
 Bundle-Localization: plugin
 Bundle-SymbolicName: org.eclipse.equinox.cm
-Bundle-Version: 1.4.0.qualifier
+Bundle-Version: 1.4.100.qualifier
 Bundle-Activator: org.eclipse.equinox.internal.cm.Activator
 Import-Package: org.osgi.framework;version="1.7.0",
  org.osgi.service.cm;version="[1.6,1.7)",
diff --git a/bundles/org.eclipse.equinox.cm/pom.xml b/bundles/org.eclipse.equinox.cm/pom.xml
index a066412..a3ce854 100644
--- a/bundles/org.eclipse.equinox.cm/pom.xml
+++ b/bundles/org.eclipse.equinox.cm/pom.xml
@@ -5,7 +5,7 @@
   are made available under the terms of the Eclipse Distribution License v1.0
   which accompanies this distribution, and is available at
   http://www.eclipse.org/org/documents/edl-v10.php
- 
+
   Contributors:
      Igor Fedorenko - initial implementation
 -->
@@ -19,6 +19,6 @@
   </parent>
   <groupId>org.eclipse.equinox</groupId>
   <artifactId>org.eclipse.equinox.cm</artifactId>
-  <version>1.4.0-SNAPSHOT</version>
+  <version>1.4.100-SNAPSHOT</version>
   <packaging>eclipse-plugin</packaging>
 </project>
diff --git a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationAdminImpl.java b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationAdminImpl.java
index 1cb31fb..296cc76 100644
--- a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationAdminImpl.java
+++ b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationAdminImpl.java
@@ -103,13 +103,13 @@
 
 		List<Configuration> result = new ArrayList<>(configs.length);
 		SecurityManager sm = System.getSecurityManager();
-		for (int i = 0; i < configs.length; i++) {
+		for (ConfigurationImpl config : configs) {
 			try {
 				if (sm != null) {
-					this.configurationAdminFactory.checkConfigurePermission(configs[i].getLocation(), bundleLocation);
+					this.configurationAdminFactory.checkConfigurePermission(config.getLocation(), bundleLocation);
 				}
-				result.add(configs[i]);
-			} catch (SecurityException e) {
+				result.add(config);
+			}catch (SecurityException e) {
 				// ignore;
 			}
 		}
diff --git a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/reliablefile/ReliableFile.java b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/reliablefile/ReliableFile.java
index 4384211..9ed2445 100644
--- a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/reliablefile/ReliableFile.java
+++ b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/reliablefile/ReliableFile.java
@@ -202,12 +202,12 @@
 			List<Integer> list = new ArrayList<>(defaultMaxGenerations);
 			if (file.exists())
 				list.add(Integer.valueOf(0)); //base file exists
-			for (int i = 0; i < files.length; i++) {
-				if (files[i].startsWith(prefix)) {
+			for (String n : files) {
+				if (n.startsWith(prefix)) {
 					try {
-						int id = Integer.parseInt(files[i].substring(prefixLen));
+						int id = Integer.parseInt(n.substring(prefixLen));
 						list.add(Integer.valueOf(id));
-					} catch (NumberFormatException e) {/*ignore*/
+					}catch (NumberFormatException e) {/*ignore*/
 					}
 				}
 			}
@@ -531,12 +531,12 @@
 		String[] files = parent.list();
 		if (files == null)
 			return false;
-		for (int i = 0; i < files.length; i++) {
-			if (files[i].startsWith(prefix)) {
+		for (String n : files) {
+			if (n.startsWith(prefix)) {
 				try {
-					Integer.parseInt(files[i].substring(prefixLen));
+					Integer.parseInt(n.substring(prefixLen));
 					return true;
-				} catch (NumberFormatException e) {/*ignore*/
+				}catch (NumberFormatException e) {/*ignore*/
 				}
 			}
 		}
@@ -630,8 +630,7 @@
 			throw new IOException("Not a valid directory"); //$NON-NLS-1$
 		String files[] = directory.list();
 		Set<String> list = new HashSet<>(files.length / 2);
-		for (int idx = 0; idx < files.length; idx++) {
-			String file = files[idx];
+		for (String file : files) {
 			int pos = file.lastIndexOf('.');
 			if (pos == -1)
 				continue;
diff --git a/bundles/org.eclipse.equinox.common.tests/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.common.tests/META-INF/MANIFEST.MF
index 101dfc7..f1a6a6d 100644
--- a/bundles/org.eclipse.equinox.common.tests/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.common.tests/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
 Bundle-ManifestVersion: 2
 Bundle-Name: Common Eclipse Runtime Tests
 Bundle-SymbolicName: org.eclipse.equinox.common.tests;singleton:=true
-Bundle-Version: 3.10.300.qualifier
+Bundle-Version: 3.10.400.qualifier
 Automatic-Module-Name: org.eclipse.equinox.common.tests
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
 Bundle-ActivationPolicy: lazy
diff --git a/bundles/org.eclipse.equinox.common.tests/pom.xml b/bundles/org.eclipse.equinox.common.tests/pom.xml
index 3544fea..c6593e5 100644
--- a/bundles/org.eclipse.equinox.common.tests/pom.xml
+++ b/bundles/org.eclipse.equinox.common.tests/pom.xml
@@ -5,7 +5,7 @@
   are made available under the terms of the Eclipse Distribution License v1.0
   which accompanies this distribution, and is available at
   http://www.eclipse.org/org/documents/edl-v10.php
- 
+
   Contributors:
      Julian Honnen - initial implementation
 -->
@@ -19,6 +19,6 @@
   </parent>
   <groupId>org.eclipse.equinox</groupId>
   <artifactId>org.eclipse.equinox.common.tests</artifactId>
-  <version>3.10.300-SNAPSHOT</version>
+  <version>3.10.400-SNAPSHOT</version>
   <packaging>eclipse-test-plugin</packaging>
 </project>
diff --git a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/WaitingRegistryListener.java b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/WaitingRegistryListener.java
index d5c95a6..b3d8f3d 100644
--- a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/WaitingRegistryListener.java
+++ b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/registry/WaitingRegistryListener.java
@@ -177,11 +177,11 @@
 		if (children == null) {
 			return true;
 		}
-		for (int i = 0; i < children.length; i++) {
-			if (!children[i].isValid()) {
+		for (IConfigurationElement child : children) {
+			if (!child.isValid()) {
 				return false;
 			}
-			if (!validContents(children[i].getChildren())) {
+			if (!validContents(child.getChildren())) {
 				return false;
 			}
 		}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/Activator.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/Activator.java
index 4d1981d..578c365 100644
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/Activator.java
+++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/Activator.java
@@ -148,9 +148,9 @@
 		if (bundles == null)
 			return null;
 		//Return the first bundle that is not installed or uninstalled
-		for (int i = 0; i < bundles.length; i++) {
-			if ((bundles[i].getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0) {
-				return bundles[i];
+		for (Bundle bundle : bundles) {
+			if ((bundle.getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0) {
+				return bundle;
 			}
 		}
 		return null;
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/AdapterManager.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/AdapterManager.java
index 12f006f..7a1f881 100644
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/AdapterManager.java
+++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/AdapterManager.java
@@ -107,14 +107,15 @@
 			IAdapterFactory factory = factoryList.get(i);
 			if (factory instanceof IAdapterFactoryExt) {
 				String[] adapters = ((IAdapterFactoryExt) factory).getAdapterNames();
-				for (int j = 0; j < adapters.length; j++) {
-					if (table.get(adapters[j]) == null)
-						table.put(adapters[j], factory);
+				for (String adapter : adapters) {
+					if (table.get(adapter) == null) {
+						table.put(adapter, factory);
+					}
 				}
 			} else {
 				Class<?>[] adapters = factory.getAdapterList();
-				for (int j = 0; j < adapters.length; j++) {
-					String adapterName = adapters[j].getName();
+				for (Class<?> adapter : adapters) {
+					String adapterName = adapter.getName();
 					if (table.get(adapterName) == null)
 						table.put(adapterName, factory);
 				}
@@ -172,9 +173,9 @@
 						return null;
 					Class<?>[] adapterList = factory.getAdapterList();
 					clazz = null;
-					for (int i = 0; i < adapterList.length; i++) {
-						if (typeName.equals(adapterList[i].getName())) {
-							clazz = adapterList[i];
+					for (Class<?> adapter : adapterList) {
+						if (typeName.equals(adapter.getName())) {
+							clazz = adapter;
 							break;
 						}
 					}
@@ -208,8 +209,9 @@
 			// calculate adapters for the class
 			table = new HashMap<>(4);
 			Class<?>[] classes = computeClassOrder(adaptable);
-			for (int i = 0; i < classes.length; i++)
-				addFactoriesFor(classes[i].getName(), table);
+			for (Class<?> cl : classes) {
+				addFactoriesFor(cl.getName(), table);
+			}
 			// cache the table
 			lookup.put(adaptable.getName(), table);
 		}
@@ -253,15 +255,15 @@
 		}
 		//now traverse interface hierarchy for each class
 		Class<?>[] classHierarchy = classes.toArray(new Class[classes.size()]);
-		for (int i = 0; i < classHierarchy.length; i++)
-			computeInterfaceOrder(classHierarchy[i].getInterfaces(), classes, seen);
+		for (Class<?> cl : classHierarchy) {
+			computeInterfaceOrder(cl.getInterfaces(), classes, seen);
+		}
 		return classes.toArray(new Class[classes.size()]);
 	}
 
 	private void computeInterfaceOrder(Class<?>[] interfaces, Collection<Class<?>> classes, Set<Class<?>> seen) {
 		List<Class<?>> newInterfaces = new ArrayList<>(interfaces.length);
-		for (int i = 0; i < interfaces.length; i++) {
-			Class<?> interfac = interfaces[i];
+		for (Class<?> interfac : interfaces) {
 			if (seen.add(interfac)) {
 				//note we cannot recurse here without changing the resulting interface order
 				classes.add(interfac);
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/FindSupport.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/FindSupport.java
index 7cac8c7..41275dc 100644
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/FindSupport.java
+++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/FindSupport.java
@@ -215,8 +215,8 @@
 			return null;
 
 		URL result = null;
-		for (int i = 0; i < nlVariants.length; i++) {
-			IPath filePath = new Path(nlVariants[i]).append(path);
+		for (String nlVariant : nlVariants) {
+			IPath filePath = new Path(nlVariant).append(path);
 			result = findInPlugin(b, filePath, multiple);
 			if (result != null && multiple == null)
 				return result;
@@ -250,8 +250,8 @@
 		if (multiple != null)
 			multiple.ensureCapacity(fragments.length + 1);
 
-		for (int i = 0; i < fragments.length; i++) {
-			URL fileURL = fragments[i].getEntry(filePath.toString());
+		for (Bundle fragment : fragments) {
+			URL fileURL = fragment.getEntry(filePath.toString());
 			if (fileURL != null) {
 				if (multiple == null)
 					return fileURL;
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformLogWriter.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformLogWriter.java
index f046ee2..952547c 100644
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformLogWriter.java
+++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformLogWriter.java
@@ -78,8 +78,8 @@
 
 		if (status.isMultiStatus()) {
 			IStatus[] children = status.getChildren();
-			for (int i = 0; i < children.length; i++) {
-				childlist.add(getLog(children[i]));
+			for (IStatus child : children) {
+				childlist.add(getLog(child));
 			}
 		}
 
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PrintStackUtil.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PrintStackUtil.java
index 5adc994..ce48f25 100644
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PrintStackUtil.java
+++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PrintStackUtil.java
@@ -23,12 +23,12 @@
 		IStatus[] children = status.getChildren();
 		if (children == null || children.length == 0)
 			return;
-		for (int i = 0; i < children.length; i++) {
-			output.println("Contains: " + children[i].getMessage()); //$NON-NLS-1$
-			Throwable exception = children[i].getException();
+		for (IStatus child : children) {
+			output.println("Contains: " + child.getMessage()); //$NON-NLS-1$
+			Throwable exception = child.getException();
 			if (exception != null)
 				exception.printStackTrace(output);
-			printChildren(children[i], output);
+			printChildren(child, output);
 		}
 	}
 
@@ -36,13 +36,13 @@
 		IStatus[] children = status.getChildren();
 		if (children == null || children.length == 0)
 			return;
-		for (int i = 0; i < children.length; i++) {
-			output.println("Contains: " + children[i].getMessage()); //$NON-NLS-1$
+		for (IStatus child : children) {
+			output.println("Contains: " + child.getMessage()); //$NON-NLS-1$
 			output.flush(); // call to synchronize output
-			Throwable exception = children[i].getException();
+			Throwable exception = child.getException();
 			if (exception != null)
 				exception.printStackTrace(output);
-			printChildren(children[i], output);
+			printChildren(child, output);
 		}
 	}
 
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ReferenceHashSet.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ReferenceHashSet.java
index d997ee1..83c0be1 100644
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ReferenceHashSet.java
+++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ReferenceHashSet.java
@@ -325,10 +325,11 @@
 		cleanupGarbageCollectedValues();
 		Object[] result = new Object[elementSize];
 		int resultSize = 0;
-		for (int i = 0; i < values.length; i++) {
-			if (values[i] == null)
+		for (HashedReference<T> value : values) {
+			if (value == null) {
 				continue;
-			Object tmp = values[i].get();
+			}
+			Object tmp = value.get();
 			if (tmp != null)
 				result[resultSize++] = tmp;
 		}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ResourceTranslator.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ResourceTranslator.java
index 4bd6d11..f0b5a57 100644
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ResourceTranslator.java
+++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ResourceTranslator.java
@@ -95,8 +95,8 @@
 			ManifestElement[] prereqs = ManifestElement.parseHeader(Constants.REQUIRE_BUNDLE, b.getHeaders("").get(Constants.REQUIRE_BUNDLE)); //$NON-NLS-1$
 			if (prereqs == null)
 				return false;
-			for (int i = 0; i < prereqs.length; i++) {
-				if ("2.1".equals(prereqs[i].getAttribute(Constants.BUNDLE_VERSION_ATTRIBUTE)) && "org.eclipse.core.runtime".equals(prereqs[i].getValue())) { //$NON-NLS-1$//$NON-NLS-2$
+			for (ManifestElement prereq : prereqs) {
+				if ("2.1".equals(prereq.getAttribute(Constants.BUNDLE_VERSION_ATTRIBUTE)) && "org.eclipse.core.runtime".equals(prereq.getValue())) {//$NON-NLS-1$//$NON-NLS-2$
 					return true;
 				}
 			}
@@ -124,9 +124,9 @@
 		if (fragments == null)
 			return;
 
-		for (int i = 0; i < fragments.length; i++) {
-			addClasspathEntries(fragments[i], classpath);
-			addDevEntries(fragments[i], classpath);
+		for (Bundle fragment : fragments) {
+			addClasspathEntries(fragment, classpath);
+			addDevEntries(fragment, classpath);
 		}
 	}
 
@@ -136,8 +136,8 @@
 			classpathElements = ManifestElement.parseHeader(Constants.BUNDLE_CLASSPATH, b.getHeaders("").get(Constants.BUNDLE_CLASSPATH)); //$NON-NLS-1$
 			if (classpathElements == null)
 				return;
-			for (int i = 0; i < classpathElements.length; i++) {
-				URL classpathEntry = b.getEntry(classpathElements[i].getValue());
+			for (ManifestElement classpathElement : classpathElements) {
+				URL classpathEntry = b.getEntry(classpathElement.getValue());
 				if (classpathEntry != null)
 					classpath.add(classpathEntry);
 			}
@@ -155,8 +155,8 @@
 			return;
 
 		String[] binaryPaths = DevClassPathHelper.getDevClassPath(b.getSymbolicName());
-		for (int i = 0; i < binaryPaths.length; i++) {
-			URL classpathEntry = b.getEntry(binaryPaths[i]);
+		for (String binaryPath : binaryPaths) {
+			URL classpathEntry = b.getEntry(binaryPath);
 			if (classpathEntry != null)
 				classpath.add(classpathEntry);
 		}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/RuntimeLog.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/RuntimeLog.java
index 321eb4d..c461d68 100644
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/RuntimeLog.java
+++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/RuntimeLog.java
@@ -101,10 +101,10 @@
 			return;
 		}
 		if (listeners != null) {
-			for (int i = 0; i < listeners.length; i++) {
+			for (ILogListener listener : listeners) {
 				try {
-					listeners[i].logging(status, IRuntimeConstants.PI_RUNTIME);
-				} catch (Exception | LinkageError e) {
+					listener.logging(status, IRuntimeConstants.PI_RUNTIME);
+				}catch (Exception | LinkageError e) {
 					handleException(e);
 				}
 			}
@@ -146,8 +146,8 @@
 			queued = queuedMessages.toArray(new IStatus[queuedMessages.size()]);
 			queuedMessages.clear();
 		}
-		for (int i = 0; i < queued.length; i++) {
-			log(queued[i]);
+		for (IStatus s : queued) {
+			log(s);
 		}
 	}
 
@@ -157,10 +157,10 @@
 		synchronized (logListeners) {
 			listeners = logListeners.toArray(new ILogListener[logListeners.size()]);
 		}
-		for (int i = 0; i < listeners.length; i++) {
+		for (ILogListener listener : listeners) {
 			try {
-				listeners[i].logging(status, IRuntimeConstants.PI_RUNTIME);
-			} catch (Exception | LinkageError e) {
+				listener.logging(status, IRuntimeConstants.PI_RUNTIME);
+			}catch (Exception | LinkageError e) {
 				handleException(e);
 			}
 		}