diff options
Diffstat (limited to 'bundles/org.eclipse.osgi/container/src/org/eclipse')
45 files changed, 433 insertions, 357 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/adaptor/EclipseStarter.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/adaptor/EclipseStarter.java index 343ce3dea..35154f84d 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/adaptor/EclipseStarter.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/adaptor/EclipseStarter.java @@ -463,18 +463,18 @@ public class EclipseStarter { } private static void ensureBundlesActive(Bundle[] bundles) { - for (int i = 0; i < bundles.length; i++) { - if (bundles[i].getState() != Bundle.ACTIVE) { - if (bundles[i].getState() == Bundle.INSTALLED) { + for (Bundle bundle : bundles) { + if (bundle.getState() != Bundle.ACTIVE) { + if (bundle.getState() == Bundle.INSTALLED) { // Log that the bundle is not resolved - log.log(new FrameworkLogEntry(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, 0, NLS.bind(Msg.ECLIPSE_STARTUP_ERROR_BUNDLE_NOT_RESOLVED, bundles[i].getLocation()), 0, null, null)); + log.log(new FrameworkLogEntry(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, 0, NLS.bind(Msg.ECLIPSE_STARTUP_ERROR_BUNDLE_NOT_RESOLVED, bundle.getLocation()), 0, null, null)); continue; } // check that the startlevel allows the bundle to be active (111550) FrameworkStartLevel fwStartLevel = context.getBundle().adapt(FrameworkStartLevel.class); - BundleStartLevel bundleStartLevel = bundles[i].adapt(BundleStartLevel.class); + BundleStartLevel bundleStartLevel = bundle.adapt(BundleStartLevel.class); if (fwStartLevel != null && (bundleStartLevel.getStartLevel() <= fwStartLevel.getStartLevel())) { - log.log(new FrameworkLogEntry(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, 0, NLS.bind(Msg.ECLIPSE_STARTUP_ERROR_BUNDLE_NOT_ACTIVE, bundles[i]), 0, null, null)); + log.log(new FrameworkLogEntry(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, 0, NLS.bind(Msg.ECLIPSE_STARTUP_ERROR_BUNDLE_NOT_ACTIVE, bundle), 0, null, null)); } } } @@ -629,15 +629,13 @@ public class EclipseStarter { if (installLocation == null) { throw new IllegalStateException(Msg.EclipseStarter_InstallLocation); } - for (int i = 0; i < installEntries.length; i++) { - String name = installEntries[i]; + for (String name : installEntries) { int level = defaultStartLevel; boolean start = false; int index = name.lastIndexOf('@'); if (index >= 0) { String[] attributes = getArrayFromList(name.substring(index + 1, name.length()), ":"); //$NON-NLS-1$ - for (int j = 0; j < attributes.length; j++) { - String attribute = attributes[j]; + for (String attribute : attributes) { if (attribute.equals("start")) //$NON-NLS-1$ start = true; else { @@ -654,7 +652,7 @@ public class EclipseStarter { try { URL location = searchForBundle(name, syspath); if (location == null) { - FrameworkLogEntry entry = new FrameworkLogEntry(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, 0, NLS.bind(Msg.ECLIPSE_STARTUP_BUNDLE_NOT_FOUND, installEntries[i]), 0, null, null); + FrameworkLogEntry entry = new FrameworkLogEntry(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, 0, NLS.bind(Msg.ECLIPSE_STARTUP_BUNDLE_NOT_FOUND, name), 0, null, null); log.log(entry); // skip this entry continue; @@ -662,7 +660,7 @@ public class EclipseStarter { location = makeRelative(installLocation.getURL(), location); String locationString = INITIAL_LOCATION + location.toExternalForm(); result.add(new InitialBundle(locationString, location, level, start)); - } catch (IOException e) { + }catch (IOException e) { log.log(new FrameworkLogEntry(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, 0, e.getMessage(), 0, e, null)); } } @@ -935,8 +933,7 @@ public class EclipseStarter { private static Bundle[] getCurrentBundles(boolean includeInitial) { Bundle[] installed = context.getBundles(); List<Bundle> initial = new ArrayList<>(); - for (int i = 0; i < installed.length; i++) { - Bundle bundle = installed[i]; + for (Bundle bundle : installed) { if (bundle.getLocation().startsWith(INITIAL_LOCATION)) { if (includeInitial) initial.add(bundle); @@ -947,8 +944,7 @@ public class EclipseStarter { } private static Bundle getBundleByLocation(String location, Bundle[] bundles) { - for (int i = 0; i < bundles.length; i++) { - Bundle bundle = bundles[i]; + for (Bundle bundle : bundles) { if (location.equalsIgnoreCase(bundle.getLocation())) return bundle; } @@ -956,35 +952,36 @@ public class EclipseStarter { } private static void uninstallBundles(Bundle[] curInitBundles, InitialBundle[] newInitBundles, List<Bundle> toRefresh) { - for (int i = 0; i < curInitBundles.length; i++) { + for (Bundle curInitBundle : curInitBundles) { boolean found = false; - for (int j = 0; j < newInitBundles.length; j++) { - if (curInitBundles[i].getLocation().equalsIgnoreCase(newInitBundles[j].locationString)) { + for (InitialBundle newInitBundle : newInitBundles) { + if (curInitBundle.getLocation().equalsIgnoreCase(newInitBundle.locationString)) { found = true; break; } } - if (!found) + if (!found) { try { - curInitBundles[i].uninstall(); - toRefresh.add(curInitBundles[i]); + curInitBundle.uninstall(); + toRefresh.add(curInitBundle); } catch (BundleException e) { - FrameworkLogEntry entry = new FrameworkLogEntry(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, 0, NLS.bind(Msg.ECLIPSE_STARTUP_FAILED_UNINSTALL, curInitBundles[i].getLocation()), 0, e, null); + FrameworkLogEntry entry = new FrameworkLogEntry(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, 0, NLS.bind(Msg.ECLIPSE_STARTUP_FAILED_UNINSTALL, curInitBundle.getLocation()), 0, e, null); log.log(entry); } + } } } private static void installBundles(InitialBundle[] initialBundles, Bundle[] curInitBundles, List<Bundle> startBundles, List<Bundle> lazyActivationBundles, List<Bundle> toRefresh) { - for (int i = 0; i < initialBundles.length; i++) { - Bundle osgiBundle = getBundleByLocation(initialBundles[i].locationString, curInitBundles); + for (InitialBundle initialBundle : initialBundles) { + Bundle osgiBundle = getBundleByLocation(initialBundle.locationString, curInitBundles); try { // don't need to install if it is already installed if (osgiBundle == null) { - InputStream in = LocationHelper.getStream(initialBundles[i].location); + InputStream in = LocationHelper.getStream(initialBundle.location); try { - osgiBundle = context.installBundle(initialBundles[i].locationString, in); - } catch (BundleException e) { + osgiBundle = context.installBundle(initialBundle.locationString, in); + }catch (BundleException e) { if (e.getType() == BundleException.DUPLICATE_BUNDLE_ERROR) { continue; // TODO should attempt to lookup the existing bundle @@ -992,22 +989,24 @@ public class EclipseStarter { throw e; } // only check for lazy activation header if this is a newly installed bundle and is not marked for persistent start - if (!initialBundles[i].start && hasLazyActivationPolicy(osgiBundle)) + if (!initialBundle.start && hasLazyActivationPolicy(osgiBundle)) { lazyActivationBundles.add(osgiBundle); + } } // always set the startlevel incase it has changed (bug 111549) // this is a no-op if the level is the same as previous launch. - if ((osgiBundle.getState() & Bundle.UNINSTALLED) == 0 && initialBundles[i].level >= 0) { - osgiBundle.adapt(BundleStartLevel.class).setStartLevel(initialBundles[i].level); + if ((osgiBundle.getState() & Bundle.UNINSTALLED) == 0 && initialBundle.level >= 0) { + osgiBundle.adapt(BundleStartLevel.class).setStartLevel(initialBundle.level); } // if this bundle is supposed to be started then add it to the start list - if (initialBundles[i].start) + if (initialBundle.start) { startBundles.add(osgiBundle); + } // include basic bundles in case they were not resolved before if ((osgiBundle.getState() & Bundle.INSTALLED) != 0) toRefresh.add(osgiBundle); } catch (BundleException | IOException e) { - FrameworkLogEntry entry = new FrameworkLogEntry(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, 0, NLS.bind(Msg.ECLIPSE_STARTUP_FAILED_INSTALL, initialBundles[i].location), 0, e, null); + FrameworkLogEntry entry = new FrameworkLogEntry(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, 0, NLS.bind(Msg.ECLIPSE_STARTUP_FAILED_INSTALL, initialBundle.location), 0, e, null); log.log(entry); } } @@ -1053,10 +1052,12 @@ public class EclipseStarter { } private static void startBundles(Bundle[] startBundles, Bundle[] lazyBundles) { - for (int i = 0; i < startBundles.length; i++) - startBundle(startBundles[i], 0); - for (int i = 0; i < lazyBundles.length; i++) - startBundle(lazyBundles[i], Bundle.START_ACTIVATION_POLICY); + for (Bundle startBundle : startBundles) { + startBundle(startBundle, 0); + } + for (Bundle lazyBundle : lazyBundles) { + startBundle(lazyBundle, Bundle.START_ACTIVATION_POLICY); + } } private static void startBundle(Bundle bundle, int options) { @@ -1223,8 +1224,7 @@ public class EclipseStarter { String result = null; Object[] maxVersion = null; boolean resultIsFile = false; - for (int i = 0; i < candidates.length; i++) { - String candidateName = candidates[i]; + for (String candidateName : candidates) { if (!candidateName.startsWith(target)) continue; boolean simpleJar = false; diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java index c55afa11e..7766a670b 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java @@ -894,8 +894,7 @@ final class ModuleResolver { List<ModuleCapability> candidates = moduleDatabase.findCapabilities(fragmentRequirement); // filter out disabled fragments and singletons filterDisabled(candidates.listIterator()); - for (Iterator<ModuleCapability> iCandidates = candidates.iterator(); iCandidates.hasNext();) { - ModuleCapability candidate = iCandidates.next(); + for (ModuleCapability candidate : candidates) { ModuleRequirement hostReq = candidate.getRevision().getModuleRequirements(HostNamespace.HOST_NAMESPACE).get(0); for (ModuleCapability hostCap : hostCaps) { if (hostReq.matches(hostCap)) { diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/builders/OSGiManifestBuilderFactory.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/builders/OSGiManifestBuilderFactory.java index 4f7cf5df0..adcce44b6 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/builders/OSGiManifestBuilderFactory.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/builders/OSGiManifestBuilderFactory.java @@ -131,20 +131,24 @@ public final class OSGiManifestBuilderFactory { } private static void validateHeaders(Map<String, String> manifest) throws BundleException { - for (int i = 0; i < DEFINED_OSGI_VALIDATE_HEADERS.length; i++) { - String header = manifest.get(DEFINED_OSGI_VALIDATE_HEADERS[i]); + for (String definedOSGiValidateHeader : DEFINED_OSGI_VALIDATE_HEADERS) { + String header = manifest.get(definedOSGiValidateHeader); if (header != null) { - ManifestElement[] elements = ManifestElement.parseHeader(DEFINED_OSGI_VALIDATE_HEADERS[i], header); - checkForDuplicateDirectivesAttributes(DEFINED_OSGI_VALIDATE_HEADERS[i], elements); - if (DEFINED_OSGI_VALIDATE_HEADERS[i] == Constants.IMPORT_PACKAGE) - checkImportExportSyntax(DEFINED_OSGI_VALIDATE_HEADERS[i], elements, false, false); - if (DEFINED_OSGI_VALIDATE_HEADERS[i] == Constants.DYNAMICIMPORT_PACKAGE) - checkImportExportSyntax(DEFINED_OSGI_VALIDATE_HEADERS[i], elements, false, true); - if (DEFINED_OSGI_VALIDATE_HEADERS[i] == Constants.EXPORT_PACKAGE) - checkImportExportSyntax(DEFINED_OSGI_VALIDATE_HEADERS[i], elements, true, false); - if (DEFINED_OSGI_VALIDATE_HEADERS[i] == Constants.FRAGMENT_HOST) - checkExtensionBundle(DEFINED_OSGI_VALIDATE_HEADERS[i], elements, manifest); - } else if (DEFINED_OSGI_VALIDATE_HEADERS[i] == Constants.BUNDLE_SYMBOLICNAME) { + ManifestElement[] elements = ManifestElement.parseHeader(definedOSGiValidateHeader, header); + checkForDuplicateDirectivesAttributes(definedOSGiValidateHeader, elements); + if (definedOSGiValidateHeader == Constants.IMPORT_PACKAGE) { + checkImportExportSyntax(definedOSGiValidateHeader, elements, false, false); + } + if (definedOSGiValidateHeader == Constants.DYNAMICIMPORT_PACKAGE) { + checkImportExportSyntax(definedOSGiValidateHeader, elements, false, true); + } + if (definedOSGiValidateHeader == Constants.EXPORT_PACKAGE) { + checkImportExportSyntax(definedOSGiValidateHeader, elements, true, false); + } + if (definedOSGiValidateHeader == Constants.FRAGMENT_HOST) { + checkExtensionBundle(definedOSGiValidateHeader, elements, manifest); + } + } else if (definedOSGiValidateHeader == Constants.BUNDLE_SYMBOLICNAME) { throw new BundleException(Constants.BUNDLE_SYMBOLICNAME + " header is required.", BundleException.MANIFEST_ERROR); //$NON-NLS-1$ } } @@ -159,17 +163,17 @@ public final class OSGiManifestBuilderFactory { for (int i = 0; i < length; i++) { // check for duplicate imports String[] packageNames = elements[i].getValueComponents(); - for (int j = 0; j < packageNames.length; j++) { - if (!export && !dynamic && packages.contains(packageNames[j])) { + for (String packageName : packageNames) { + if (!export && !dynamic && packages.contains(packageName)) { String message = NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, headerKey, elements[i].toString()); - throw new BundleException(message + " : " + NLS.bind(Msg.HEADER_PACKAGE_DUPLICATES, packageNames[j]), BundleException.MANIFEST_ERROR); //$NON-NLS-1$ + throw new BundleException(message + " : " + NLS.bind(Msg.HEADER_PACKAGE_DUPLICATES, packageName), BundleException.MANIFEST_ERROR); //$NON-NLS-1$ } // check for java.* - if (export && packageNames[j].startsWith("java.")) { //$NON-NLS-1$ + if (export && packageName.startsWith("java.")) { //$NON-NLS-1$ String message = NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, headerKey, elements[i].toString()); - throw new BundleException(message + " : " + NLS.bind(Msg.HEADER_PACKAGE_JAVA, packageNames[j]), BundleException.MANIFEST_ERROR); //$NON-NLS-1$ + throw new BundleException(message + " : " + NLS.bind(Msg.HEADER_PACKAGE_JAVA, packageName), BundleException.MANIFEST_ERROR); //$NON-NLS-1$ } - packages.add(packageNames[j]); + packages.add(packageName); } // check for version/specification version mismatch String version = elements[i].getAttribute(Constants.VERSION_ATTRIBUTE); @@ -195,25 +199,25 @@ public final class OSGiManifestBuilderFactory { private static void checkForDuplicateDirectivesAttributes(String headerKey, ManifestElement[] elements) throws BundleException { // check for duplicate directives - for (int i = 0; i < elements.length; i++) { - Enumeration<String> directiveKeys = elements[i].getDirectiveKeys(); + for (ManifestElement element : elements) { + Enumeration<String> directiveKeys = element.getDirectiveKeys(); if (directiveKeys != null) { while (directiveKeys.hasMoreElements()) { String key = directiveKeys.nextElement(); - String[] directives = elements[i].getDirectives(key); + String[] directives = element.getDirectives(key); if (directives.length > 1) { - String message = NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, headerKey, elements[i].toString()); + String message = NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, headerKey, element.toString()); throw new BundleException(NLS.bind(message + " : " + Msg.HEADER_DIRECTIVE_DUPLICATES, key), BundleException.MANIFEST_ERROR); //$NON-NLS-1$ } } } - Enumeration<String> attrKeys = elements[i].getKeys(); + Enumeration<String> attrKeys = element.getKeys(); if (attrKeys != null) { while (attrKeys.hasMoreElements()) { String key = attrKeys.nextElement(); - String[] attrs = elements[i].getAttributes(key); + String[] attrs = element.getAttributes(key); if (attrs.length > 1) { - String message = NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, headerKey, elements[i].toString()); + String message = NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, headerKey, element.toString()); throw new BundleException(message + " : " + NLS.bind(Msg.HEADER_ATTRIBUTE_DUPLICATES, key), BundleException.MANIFEST_ERROR); //$NON-NLS-1$ } } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/util/FilePath.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/util/FilePath.java index 60f9a43ec..e1d5cfc59 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/util/FilePath.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/util/FilePath.java @@ -250,8 +250,8 @@ public class FilePath { result.append(device); if (isAbsolute()) result.append(SEPARATOR); - for (int i = 0; i < segments.length; i++) { - result.append(segments[i]); + for (String segment : segments) { + result.append(segment); result.append(SEPARATOR); } if (segments.length > 0 && !hasTrailingSlash()) diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/ComputeNodeOrder.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/ComputeNodeOrder.java index 3d949e500..f54d5e11b 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/ComputeNodeOrder.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/ComputeNodeOrder.java @@ -230,8 +230,7 @@ public class ComputeNodeOrder { } int len = vertexList.size(); Object[] r = new Object[len]; - for (Iterator<Vertex> allV = vertexList.iterator(); allV.hasNext();) { - Vertex vertex = allV.next(); + for (Vertex vertex : vertexList) { int f = vertex.finishTime; // note that finish times start at 1, not 0 if (increasing) { @@ -274,8 +273,7 @@ public class ComputeNodeOrder { // find the roots of each component // Map<Vertex,List<Object>> components Map<Vertex, List<Object>> components = new HashMap<>(); - for (Iterator<Vertex> it = vertexList.iterator(); it.hasNext();) { - Vertex vertex = it.next(); + for (Vertex vertex : vertexList) { if (vertex.predecessor == null) { // this vertex is the root of a component // if component is non-trivial we will hit a child @@ -295,8 +293,7 @@ public class ComputeNodeOrder { } } List<Object[]> result = new ArrayList<>(components.size()); - for (Iterator<List<Object>> it = components.values().iterator(); it.hasNext();) { - List<Object> component = it.next(); + for (List<Object> component : components.values()) { if (component.size() > 1) { result.add(component.toArray()); } @@ -475,13 +472,15 @@ public class ComputeNodeOrder { // Step 1: Create the graph object. final Digraph g1 = new Digraph(); // add vertexes - for (int i = 0; i < objects.length; i++) - g1.addVertex(objects[i]); + for (Object object : objects) { + g1.addVertex(object); + } // add edges - for (int i = 0; i < references.length; i++) + for (Object[] reference : references) { // create an edge from q to p // to cause q to come before p in eventual result - g1.addEdge(references[i][1], references[i][0]); + g1.addEdge(reference[1], reference[0]); + } g1.freeze(); // Step 2: Create the transposed graph. This time, define the vertexes @@ -493,8 +492,9 @@ public class ComputeNodeOrder { for (Iterator<Object> it = resortedVertexes.iterator(); it.hasNext();) g2.addVertex(it.next()); // add edges - for (int i = 0; i < references.length; i++) - g2.addEdge(references[i][0], references[i][1]); + for (Object[] reference : references) { + g2.addEdge(reference[0], reference[1]); + } g2.freeze(); // Step 3: Return the vertexes in increasing order of depth-first finish diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/debug/EclipseDebugTrace.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/debug/EclipseDebugTrace.java index ad5b330b2..846ced8fb 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/debug/EclipseDebugTrace.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/debug/EclipseDebugTrace.java @@ -526,8 +526,8 @@ class EclipseDebugTrace implements DebugTrace { writeComment(traceWriter, EclipseDebugTrace.TRACE_FILE_VERBOSE_COMMENT + debugOptions.isVerbose()); writeComment(traceWriter, "The following option strings are specified for this debug session:"); //$NON-NLS-1$ final String[] allOptions = debugOptions.getAllOptions(); - for (int i = 0; i < allOptions.length; i++) { - writeComment(traceWriter, "\t" + allOptions[i]); //$NON-NLS-1$ + for (String allOption : allOptions) { + writeComment(traceWriter, "\t" + allOption); //$NON-NLS-1$ } } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/debug/FrameworkDebugOptions.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/debug/FrameworkDebugOptions.java index 6f7db2570..6f11c7b1e 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/debug/FrameworkDebugOptions.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/debug/FrameworkDebugOptions.java @@ -280,8 +280,7 @@ public class FrameworkDebugOptions implements DebugOptions, ServiceTrackerCustom if (ops == null) throw new IllegalArgumentException("The options must not be null."); //$NON-NLS-1$ Properties newOptions = new Properties(); - for (Iterator<Map.Entry<String, String>> entries = ops.entrySet().iterator(); entries.hasNext();) { - Map.Entry<String, String> entry = entries.next(); + for (Map.Entry<String, String> entry : ops.entrySet()) { if (!(entry.getKey() instanceof String) || !(entry.getValue() instanceof String)) throw new IllegalArgumentException("Option keys and values must be of type String: " + entry.getKey() + "=" + entry.getValue()); //$NON-NLS-1$ //$NON-NLS-2$ newOptions.put(entry.getKey(), entry.getValue().trim()); @@ -305,8 +304,7 @@ public class FrameworkDebugOptions implements DebugOptions, ServiceTrackerCustom } } // now check for changes to existing values - for (Iterator<Map.Entry<Object, Object>> newEntries = newOptions.entrySet().iterator(); newEntries.hasNext();) { - Map.Entry<Object, Object> entry = newEntries.next(); + for (Map.Entry<Object, Object> entry : newOptions.entrySet()) { String existingValue = (String) options.get(entry.getKey()); if (!entry.getValue().equals(existingValue)) { String symbolicName = getSymbolicName((String) entry.getKey()); @@ -490,16 +488,16 @@ public class FrameworkDebugOptions implements DebugOptions, ServiceTrackerCustom } if (listenerRefs == null) return; - for (int i = 0; i < listenerRefs.length; i++) { - DebugOptionsListener service = (DebugOptionsListener) bc.getService(listenerRefs[i]); + for (ServiceReference<?> listenerRef : listenerRefs) { + DebugOptionsListener service = (DebugOptionsListener) bc.getService(listenerRef); if (service == null) continue; try { service.optionsChanged(this); - } catch (Throwable t) { + }catch (Throwable t) { // TODO consider logging } finally { - bc.ungetService(listenerRefs[i]); + bc.ungetService(listenerRef); } } } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxBundle.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxBundle.java index b3f4a48e8..aefaac69d 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxBundle.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxBundle.java @@ -764,15 +764,17 @@ public class EquinoxBundle implements Bundle, BundleReference { if (infos.length == 0) return Collections.emptyMap(); Map<X509Certificate, List<X509Certificate>> results = new HashMap<>(infos.length); - for (int i = 0; i < infos.length; i++) { - if (signersType == SIGNERS_TRUSTED && !infos[i].isTrusted()) + for (SignerInfo info : infos) { + if (signersType == SIGNERS_TRUSTED && !info.isTrusted()) { continue; - Certificate[] certs = infos[i].getCertificateChain(); + } + Certificate[] certs = info.getCertificateChain(); if (certs == null || certs.length == 0) continue; List<X509Certificate> certChain = new ArrayList<>(); - for (int j = 0; j < certs.length; j++) - certChain.add((X509Certificate) certs[j]); + for (Certificate cert : certs) { + certChain.add((X509Certificate) cert); + } results.put((X509Certificate) certs[0], certChain); } return results; diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainer.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainer.java index 3965b2832..ce690f667 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainer.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainer.java @@ -15,8 +15,14 @@ package org.eclipse.osgi.internal.framework; import java.io.IOException; import java.security.AccessController; -import java.util.*; -import java.util.concurrent.*; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ThreadFactory; import org.eclipse.osgi.framework.eventmgr.ListenerQueue; import org.eclipse.osgi.framework.log.FrameworkLogEntry; import org.eclipse.osgi.framework.util.SecureAction; @@ -32,7 +38,11 @@ import org.eclipse.osgi.signedcontent.SignedContentFactory; import org.eclipse.osgi.storage.Storage; import org.eclipse.osgi.util.ManifestElement; import org.eclipse.osgi.util.NLS; -import org.osgi.framework.*; +import org.osgi.framework.AdminPermission; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.framework.BundleException; +import org.osgi.framework.Constants; import org.osgi.service.packageadmin.PackageAdmin; import org.osgi.service.startlevel.StartLevel; import org.osgi.util.tracker.ServiceTracker; @@ -85,17 +95,18 @@ public class EquinoxContainer implements ThreadFactory, Runnable { HashSet<String> exactMatch = new HashSet<>(bootPackages.length); List<String> stemMatch = new ArrayList<>(bootPackages.length); boolean delegateAllValue = false; - for (int i = 0; i < bootPackages.length; i++) { - if (bootPackages[i].equals("*")) { //$NON-NLS-1$ + for (String bootPackage : bootPackages) { + if (bootPackage.equals("*")) { //$NON-NLS-1$ delegateAllValue = true; exactMatch.clear(); stemMatch.clear(); break; - } else if (bootPackages[i].endsWith("*")) { //$NON-NLS-1$ - if (bootPackages[i].length() > 2 && bootPackages[i].endsWith(".*")) //$NON-NLS-1$ - stemMatch.add(bootPackages[i].substring(0, bootPackages[i].length() - 1)); + } else if (bootPackage.endsWith("*")) { //$NON-NLS-1$ + if (bootPackage.length() > 2 && bootPackage.endsWith(".*")) { //$NON-NLS-1$ + stemMatch.add(bootPackage.substring(0, bootPackage.length() - 1)); + } } else { - exactMatch.add(bootPackages[i]); + exactMatch.add(bootPackage); } } bootDelegateAll = delegateAllValue; @@ -148,9 +159,11 @@ public class EquinoxContainer implements ThreadFactory, Runnable { if (bootDelegation.contains(name)) return true; if (bootDelegationStems != null) - for (int i = 0; i < bootDelegationStems.length; i++) - if (name.startsWith(bootDelegationStems[i])) + for (String bootDelegationStem : bootDelegationStems) { + if (name.startsWith(bootDelegationStem)) { return true; + } + } return false; } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/OSGiFrameworkHooks.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/OSGiFrameworkHooks.java index bc4cf7d27..8f38c2bc7 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/OSGiFrameworkHooks.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/OSGiFrameworkHooks.java @@ -279,8 +279,7 @@ class OSGiFrameworkHooks { if (hooks.isEmpty()) return; candidates = new ShrinkableCollection<>(candidates); - for (Iterator<HookReference> iHooks = hooks.iterator(); iHooks.hasNext();) { - HookReference hookRef = iHooks.next(); + for (HookReference hookRef : hooks) { if (hookRef.reference.getBundle() == null) { handleHookException(null, hookRef.hook, "filterResolvable"); //$NON-NLS-1$ } else { @@ -305,8 +304,7 @@ class OSGiFrameworkHooks { if (hooks.isEmpty()) return; collisionCandidates = new ShrinkableCollection<>(collisionCandidates); - for (Iterator<HookReference> iHooks = hooks.iterator(); iHooks.hasNext();) { - HookReference hookRef = iHooks.next(); + for (HookReference hookRef : hooks) { if (hookRef.reference.getBundle() == null) { handleHookException(null, hookRef.hook, "filterSingletonCollisions"); //$NON-NLS-1$ } else { @@ -327,8 +325,7 @@ class OSGiFrameworkHooks { if (hooks.isEmpty()) return; candidates = new ShrinkableCollection<>(candidates); - for (Iterator<HookReference> iHooks = hooks.iterator(); iHooks.hasNext();) { - HookReference hookRef = iHooks.next(); + for (HookReference hookRef : hooks) { if (hookRef.reference.getBundle() == null) { handleHookException(null, hookRef.hook, "filterMatches"); //$NON-NLS-1$ } else { @@ -352,8 +349,7 @@ class OSGiFrameworkHooks { HookReference missingHook = null; Throwable endError = null; HookReference endBadHook = null; - for (Iterator<HookReference> iHooks = hooks.iterator(); iHooks.hasNext();) { - HookReference hookRef = iHooks.next(); + for (HookReference hookRef : hooks) { // We do not remove unregistered services here because we are going to remove all of them at the end if (hookRef.reference.getBundle() == null) { if (missingHook == null) diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/legacy/PackageAdminImpl.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/legacy/PackageAdminImpl.java index bb6c2f254..6044e1597 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/legacy/PackageAdminImpl.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/legacy/PackageAdminImpl.java @@ -120,15 +120,16 @@ public class PackageAdminImpl implements PackageAdmin { if (allExports == null) return null; ExportedPackage result = null; - for (int i = 0; i < allExports.length; i++) { - if (name.equals(allExports[i].getName())) { + for (ExportedPackage allExport : allExports) { + if (name.equals(allExport.getName())) { if (result == null) { - result = allExports[i]; + result = allExport; } else { Version curVersion = result.getVersion(); - Version newVersion = allExports[i].getVersion(); - if (newVersion.compareTo(curVersion) >= 0) - result = allExports[i]; + Version newVersion = allExport.getVersion(); + if (newVersion.compareTo(curVersion) >= 0) { + result = allExport; + } } } } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/hookregistry/HookRegistry.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/hookregistry/HookRegistry.java index 491059664..a2c9f3969 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/hookregistry/HookRegistry.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/hookregistry/HookRegistry.java @@ -20,7 +20,6 @@ import java.net.URL; import java.util.ArrayList; import java.util.Collections; import java.util.Enumeration; -import java.util.Iterator; import java.util.List; import java.util.Properties; import org.eclipse.osgi.framework.log.FrameworkLogEntry; @@ -146,13 +145,15 @@ public final class HookRegistry { continue; boolean builtin = Boolean.valueOf(configuratorProps.getProperty(BUILTIN_HOOKS)).booleanValue(); String[] configurators = ManifestElement.getArrayFromList(hooksValue, ","); //$NON-NLS-1$ - for (int i = 0; i < configurators.length; i++) - if (!configuratorList.contains(configurators[i])) { - if (builtin) // make sure the built-in configurators are listed first (bug 170881) - configuratorList.add(curBuiltin++, configurators[i]); - else - configuratorList.add(configurators[i]); + for (String configurator : configurators) { + if (!configuratorList.contains(configurator)) { + if (builtin) { + configuratorList.add(curBuiltin++, configurator); + } else { + configuratorList.add(configurator); + } } + } } catch (IOException e) { errors.add(new FrameworkLogEntry(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, 0, "error loading: " + url.toExternalForm(), 0, e, null)); //$NON-NLS-1$ // ignore and continue to next URL @@ -172,25 +173,29 @@ public final class HookRegistry { String[] configurators = ManifestElement.getArrayFromList(container.getConfiguration().getConfiguration(HookRegistry.PROP_HOOK_CONFIGURATORS), ","); //$NON-NLS-1$ if (configurators.length > 0) { configuratorList.clear(); // clear the list, we are only going to use the configurators from the list - for (int i = 0; i < configurators.length; i++) - if (!configuratorList.contains(configurators[i])) - configuratorList.add(configurators[i]); + for (String configurator : configurators) { + if (!configuratorList.contains(configurator)) { + configuratorList.add(configurator); + } + } return; // don't do anything else } // Make sure the configurators from the include property are in the list String[] includeConfigurators = ManifestElement.getArrayFromList(container.getConfiguration().getConfiguration(HookRegistry.PROP_HOOK_CONFIGURATORS_INCLUDE), ","); //$NON-NLS-1$ - for (int i = 0; i < includeConfigurators.length; i++) - if (!configuratorList.contains(includeConfigurators[i])) - configuratorList.add(includeConfigurators[i]); + for (String includeConfigurator : includeConfigurators) { + if (!configuratorList.contains(includeConfigurator)) { + configuratorList.add(includeConfigurator); + } + } // Make sure the configurators from the exclude property are no in the list String[] excludeHooks = ManifestElement.getArrayFromList(container.getConfiguration().getConfiguration(HookRegistry.PROP_HOOK_CONFIGURATORS_EXCLUDE), ","); //$NON-NLS-1$ - for (int i = 0; i < excludeHooks.length; i++) - configuratorList.remove(excludeHooks[i]); + for (String excludeHook : excludeHooks) { + configuratorList.remove(excludeHook); + } } private void loadConfigurators(List<String> configurators, List<FrameworkLogEntry> errors) { - for (Iterator<String> iHooks = configurators.iterator(); iHooks.hasNext();) { - String hookName = iHooks.next(); + for (String hookName : configurators) { try { Class<?> clazz = Class.forName(hookName); HookConfigurator configurator = (HookConfigurator) clazz.getConstructor().newInstance(); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/hooks/DevClassLoadingHook.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/hooks/DevClassLoadingHook.java index 861a8d428..a1cfc662c 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/hooks/DevClassLoadingHook.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/hooks/DevClassLoadingHook.java @@ -37,18 +37,18 @@ public class DevClassLoadingHook extends ClassLoaderHook implements KeyedElement @Override public boolean addClassPathEntry(ArrayList<ClasspathEntry> cpEntries, String cp, ClasspathManager hostmanager, Generation sourceGeneration) { // first check that we are in devmode for this sourcedata - String[] devClassPath = !configuration.inDevelopmentMode() ? null : configuration.getDevClassPath(sourceGeneration.getRevision().getSymbolicName()); - if (devClassPath == null || devClassPath.length == 0) + String[] devClassPaths = !configuration.inDevelopmentMode() ? null : configuration.getDevClassPath(sourceGeneration.getRevision().getSymbolicName()); + if (devClassPaths == null || devClassPaths.length == 0) return false; // not in dev mode return // check that dev classpath entries have not already been added; we mark this in the first entry below if (cpEntries.size() > 0 && cpEntries.get(0).getUserObject(KEY) != null) return false; // this source has already had its dev classpath entries added. boolean result = false; - for (int i = 0; i < devClassPath.length; i++) { - if (hostmanager.addClassPathEntry(cpEntries, devClassPath[i], hostmanager, sourceGeneration)) + for (String devClassPath : devClassPaths) { + if (hostmanager.addClassPathEntry(cpEntries, devClassPath, hostmanager, sourceGeneration)) { result = true; - else { - String devCP = devClassPath[i]; + } else { + String devCP = devClassPath; boolean fromFragment = devCP.endsWith(FRAGMENT); if (!fromFragment && devCP.indexOf("..") >= 0) { //$NON-NLS-1$ // if in dev mode, try using cp as a relative path from the base bundle file @@ -91,12 +91,13 @@ public class DevClassLoadingHook extends ClassLoaderHook implements KeyedElement File file = new File(cp); if (!file.isAbsolute()) return hostGeneration; - FragmentClasspath[] fragCP = manager.getFragmentClasspaths(); - for (int i = 0; i < fragCP.length; i++) { - BundleFile fragBase = fragCP[i].getGeneration().getBundleFile(); + FragmentClasspath[] fragCPs = manager.getFragmentClasspaths(); + for (FragmentClasspath fragCP : fragCPs) { + BundleFile fragBase = fragCP.getGeneration().getBundleFile(); File fragFile = fragBase.getBaseFile(); - if (fragFile != null && file.getPath().startsWith(fragFile.getPath())) - return fragCP[i].getGeneration(); + if (fragFile != null && file.getPath().startsWith(fragFile.getPath())) { + return fragCP.getGeneration(); + } } return fromFragment ? null : hostGeneration; } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java index 0a3890b9c..a2cc76ffd 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java @@ -239,11 +239,13 @@ public class BundleLoader extends ModuleLoader { if (sources.length == 1) return sources[0]; List<SingleSourcePackage> sourceList = new ArrayList<>(sources.length); - for (int i = 0; i < sources.length; i++) { - SingleSourcePackage[] innerSources = sources[i].getSuppliers(); - for (int j = 0; j < innerSources.length; j++) - if (!sourceList.contains(innerSources[j])) - sourceList.add(innerSources[j]); + for (PackageSource source : sources) { + SingleSourcePackage[] innerSources = source.getSuppliers(); + for (SingleSourcePackage innerSource : innerSources) { + if (!sourceList.contains(innerSource)) { + sourceList.add(innerSource); + } + } } return new MultiSourcePackage(packageName, sourceList.toArray(new SingleSourcePackage[sourceList.size()])); } @@ -923,15 +925,19 @@ public class BundleLoader extends ModuleLoader { /* match against specific names */ if (dynamicImportPackages != null) - for (int i = 0; i < dynamicImportPackages.length; i++) - if (pkgname.equals(dynamicImportPackages[i])) + for (String dynamicImportPackage : dynamicImportPackages) { + if (pkgname.equals(dynamicImportPackage)) { return true; + } + } /* match against names with trailing wildcards */ if (dynamicImportPackageStems != null) - for (int i = 0; i < dynamicImportPackageStems.length; i++) - if (pkgname.startsWith(dynamicImportPackageStems[i])) + for (String dynamicImportPackageStem : dynamicImportPackageStems) { + if (pkgname.startsWith(dynamicImportPackageStem)) { return true; + } + } } return false; } @@ -1052,8 +1058,8 @@ public class BundleLoader extends ModuleLoader { stems = new ArrayList<>(size); } else { stems = new ArrayList<>(size + dynamicImportPackageStems.length); - for (int i = 0; i < dynamicImportPackageStems.length; i++) { - stems.add(dynamicImportPackageStems[i]); + for (String dynamicImportPackageStem : dynamicImportPackageStems) { + stems.add(dynamicImportPackageStem); } } @@ -1062,8 +1068,8 @@ public class BundleLoader extends ModuleLoader { names = new ArrayList<>(size); } else { names = new ArrayList<>(size + dynamicImportPackages.length); - for (int i = 0; i < dynamicImportPackages.length; i++) { - names.add(dynamicImportPackages[i]); + for (String dynamicImportPackage : dynamicImportPackages) { + names.add(dynamicImportPackage); } } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/buddy/GlobalPolicy.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/buddy/GlobalPolicy.java index c1a3eb807..15e44183b 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/buddy/GlobalPolicy.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/buddy/GlobalPolicy.java @@ -64,10 +64,10 @@ public class GlobalPolicy implements IBuddyPolicy { //get all matching resources for each package Enumeration<URL> results = null; - for (int i = 0; i < pkgs.length; i++) { + for (ExportedPackage pkg : pkgs) { try { - results = BundleLoader.compoundEnumerations(results, pkgs[i].getExportingBundle().getResources(name)); - } catch (IOException e) { + results = BundleLoader.compoundEnumerations(results, pkg.getExportingBundle().getResources(name)); + }catch (IOException e) { //ignore IO problems and try next package } } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/classpath/ClasspathManager.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/classpath/ClasspathManager.java index dc6ea5bb1..d4b950ffa 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/classpath/ClasspathManager.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/classpath/ClasspathManager.java @@ -146,25 +146,27 @@ public class ClasspathManager { * */ public void close() { - for (int i = 0; i < entries.length; i++) { - if (entries[i] != null) { + for (ClasspathEntry entry : entries) { + if (entry != null) { try { - entries[i].close(); - } catch (IOException e) { + entry.close(); + }catch (IOException e) { generation.getBundleInfo().getStorage().getAdaptor().publishContainerEvent(ContainerEvent.ERROR, generation.getRevision().getRevisions().getModule(), e); } } } FragmentClasspath[] currentFragments = getFragmentClasspaths(); - for (int i = 0; i < currentFragments.length; i++) - currentFragments[i].close(); + for (FragmentClasspath currentFragment : currentFragments) { + currentFragment.close(); + } } private ClasspathEntry[] buildClasspath(String[] cp, ClasspathManager hostloader, Generation source) { ArrayList<ClasspathEntry> result = new ArrayList<>(cp.length); // add the regular classpath entries. - for (int i = 0; i < cp.length; i++) - findClassPathEntry(result, cp[i], hostloader, source); + for (String cpEntry : cp) { + findClassPathEntry(result, cpEntry, hostloader, source); + } return result.toArray(new ClasspathEntry[result.size()]); } @@ -219,8 +221,7 @@ public class ClasspathManager { // only check for fragments if the generation is the host's generation. if (hostManager.generation == generation) { FragmentClasspath[] hostFrags = hostManager.getFragmentClasspaths(); - for (int i = 0; i < hostFrags.length; i++) { - FragmentClasspath fragCP = hostFrags[i]; + for (FragmentClasspath fragCP : hostFrags) { element = hostManager.getClasspath(cp, fragCP.getGeneration()); if (element != null) { result.add(element); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/classpath/FragmentClasspath.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/classpath/FragmentClasspath.java index 717b0e595..b640e5162 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/classpath/FragmentClasspath.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/classpath/FragmentClasspath.java @@ -54,10 +54,10 @@ public class FragmentClasspath { * */ public void close() { - for (int i = 0; i < entries.length; i++) { + for (ClasspathEntry entry : entries) { try { - entries[i].close(); - } catch (IOException e) { + entry.close(); + }catch (IOException e) { generation.getBundleInfo().getStorage().getAdaptor().publishContainerEvent(ContainerEvent.ERROR, generation.getRevision().getRevisions().getModule(), e); } } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/sources/FilteredSourcePackage.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/sources/FilteredSourcePackage.java index 18e58fa57..39d203116 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/sources/FilteredSourcePackage.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/sources/FilteredSourcePackage.java @@ -74,18 +74,21 @@ public class FilteredSourcePackage extends SingleSourcePackage { } private boolean isInList(String name, String[] list) { - for (int i = 0; i < list.length; i++) { - int len = list[i].length(); + for (String s : list) { + int len = s.length(); if (len == 0) continue; - if (list[i].charAt(0) == ALL && len == 1) + if (s.charAt(0) == ALL && len == 1) { return true; // handles "*" wild card - if (list[i].charAt(len - 1) == ALL) - if (name.startsWith(list[i].substring(0, len - 1))) + } + if (s.charAt(len - 1) == ALL) { + if (name.startsWith(s.substring(0, len - 1))) { return true; - if (name.equals(list[i])) + } + } + if (name.equals(s)) { return true; - + } } return false; } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/sources/MultiSourcePackage.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/sources/MultiSourcePackage.java index b5b4779e5..ee7559a39 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/sources/MultiSourcePackage.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/sources/MultiSourcePackage.java @@ -33,8 +33,8 @@ public class MultiSourcePackage extends PackageSource { @Override public Class<?> loadClass(String name) throws ClassNotFoundException { Class<?> result = null; - for (int i = 0; i < suppliers.length; i++) { - result = suppliers[i].loadClass(name); + for (SingleSourcePackage supplier : suppliers) { + result = supplier.loadClass(name); if (result != null) return result; } @@ -44,8 +44,8 @@ public class MultiSourcePackage extends PackageSource { @Override public URL getResource(String name) { URL result = null; - for (int i = 0; i < suppliers.length; i++) { - result = suppliers[i].getResource(name); + for (SingleSourcePackage supplier : suppliers) { + result = supplier.getResource(name); if (result != null) return result; } @@ -55,8 +55,9 @@ public class MultiSourcePackage extends PackageSource { @Override public Enumeration<URL> getResources(String name) { Enumeration<URL> results = null; - for (int i = 0; i < suppliers.length; i++) - results = BundleLoader.compoundEnumerations(results, suppliers[i].getResources(name)); + for (SingleSourcePackage supplier : suppliers) { + results = BundleLoader.compoundEnumerations(results, supplier.getResources(name)); + } return results; } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/sources/PackageSource.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/sources/PackageSource.java index c7e490319..99471fd3e 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/sources/PackageSource.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/sources/PackageSource.java @@ -74,10 +74,13 @@ public abstract class PackageSource { return false; // This will return true if the specified source has at least one // of the suppliers of this source. - for (int i = 0; i < suppliers1.length; i++) - for (int j = 0; j < suppliers2.length; j++) - if (suppliers2[j].equals(suppliers1[i])) + for (SingleSourcePackage supplier1 : suppliers1) { + for (SingleSourcePackage supplier2 : suppliers2) { + if (supplier2.equals(supplier1)) { return true; + } + } + } return false; } @@ -176,8 +179,8 @@ public abstract class PackageSource { // try the interfaces Class<?>[] interfaces = serviceClass.getInterfaces(); // note that getInterfaces never returns null - for (int i = 0; i < interfaces.length; i++) { - producerSource = getPackageSource(interfaces[i], pkgName, packageAdmin); + for (Class<?> intf : interfaces) { + producerSource = getPackageSource(intf, pkgName, packageAdmin); if (producerSource != null) return producerSource; } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EquinoxLogWriter.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EquinoxLogWriter.java index ca5bc3856..32fa2ff8d 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EquinoxLogWriter.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EquinoxLogWriter.java @@ -489,8 +489,8 @@ class EquinoxLogWriter implements SynchronousLogListener, LogFilter { FrameworkLogEntry[] children = entry.getChildren(); if (children != null) { - for (int i = 0; i < children.length; i++) { - writeLog(depth + 1, children[i]); + for (FrameworkLogEntry child : children) { + writeLog(depth + 1, child); } } } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EventAdminAdapter.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EventAdminAdapter.java index 0ed74014c..cf673436d 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EventAdminAdapter.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EventAdminAdapter.java @@ -104,9 +104,10 @@ public class EventAdminAdapter implements ServiceTrackerCustomizer<Object, Objec if (property instanceof String[]) { String[] topics = (String[]) property; - for (int i = 0; i < topics.length; i++) { - if (check.contains(topics[i])) + for (String topic : topics) { + if (check.contains(topic)) { return true; + } } } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/EquinoxSecurityManager.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/EquinoxSecurityManager.java index 1b2b333e8..0234cc8f3 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/EquinoxSecurityManager.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/EquinoxSecurityManager.java @@ -128,18 +128,21 @@ public class EquinoxSecurityManager extends SecurityManager { Map<Class<? extends Condition>, Dictionary<Object, Object>> conditionDictionaries = new HashMap<>(); for (Decision[] domainDecisions : conditionSets) { boolean grant = false; - for (int i = 0; i < domainDecisions.length; i++) { - if (domainDecisions[i] == null) + for (Decision domainDecision : domainDecisions) { + if (domainDecision == null) { break; - if ((domainDecisions[i].decision & SecurityTable.ABSTAIN) != 0) + } + if ((domainDecision.decision & SecurityTable.ABSTAIN) != 0) { continue; - if ((domainDecisions[i].decision & SecurityTable.POSTPONED) == 0) { + } + if ((domainDecision.decision & SecurityTable.POSTPONED) == 0) { // hit an immediate decision; use it - if ((domainDecisions[i].decision & SecurityTable.GRANTED) != 0) + if ((domainDecision.decision & SecurityTable.GRANTED) != 0) { grant = true; + } break; } - int decision = getPostponedDecision(domainDecisions[i], conditionDictionaries, cc); + int decision = getPostponedDecision(domainDecision, conditionDictionaries, cc); if ((decision & SecurityTable.ABSTAIN) != 0) continue; if ((decision & SecurityTable.GRANTED) != 0) @@ -160,27 +163,28 @@ public class EquinoxSecurityManager extends SecurityManager { private int getPostponedDecision(Decision decision, Map<Class<? extends Condition>, Dictionary<Object, Object>> conditionDictionaries, CheckContext cc) { Condition[] postponed = decision.postponed; - for (int i = 0; i < postponed.length; i++) { - Dictionary<Object, Object> condContext = conditionDictionaries.get(postponed[i].getClass()); + for (Condition postponedCond : postponed) { + Dictionary<Object, Object> condContext = conditionDictionaries.get(postponedCond.getClass()); if (condContext == null) { condContext = new Hashtable<>(); - conditionDictionaries.put(postponed[i].getClass(), condContext); + conditionDictionaries.put(postponedCond.getClass(), condContext); } // prevent recursion into Condition if (cc.CondClassSet == null) cc.CondClassSet = new ArrayList<>(2); - if (cc.CondClassSet.contains(postponed[i].getClass())) + if (cc.CondClassSet.contains(postponedCond.getClass())) { return SecurityTable.ABSTAIN; - cc.CondClassSet.add(postponed[i].getClass()); + } + cc.CondClassSet.add(postponedCond.getClass()); try { // must call isMutable before calling isSatisfied according to the specification - boolean mutable = postponed[i].isMutable(); - boolean isSatisfied = postponed[i].isSatisfied(new Condition[] {postponed[i]}, condContext); - decision.handleImmutable(postponed[i], isSatisfied, mutable); + boolean mutable = postponedCond.isMutable(); + boolean isSatisfied = postponedCond.isSatisfied(new Condition[]{postponedCond}, condContext); + decision.handleImmutable(postponedCond, isSatisfied, mutable); if (!isSatisfied) return SecurityTable.ABSTAIN; } finally { - cc.CondClassSet.remove(postponed[i].getClass()); + cc.CondClassSet.remove(postponedCond.getClass()); } } // call postponed conditions are satisfied return the decision diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/PermissionInfoCollection.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/PermissionInfoCollection.java index eadf1e3c7..ab5a53b36 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/PermissionInfoCollection.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/PermissionInfoCollection.java @@ -15,8 +15,15 @@ package org.eclipse.osgi.internal.permadmin; import java.io.File; import java.lang.reflect.Constructor; -import java.security.*; -import java.util.*; +import java.security.AccessController; +import java.security.AllPermission; +import java.security.Permission; +import java.security.PermissionCollection; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; import org.osgi.service.permissionadmin.PermissionInfo; public final class PermissionInfoCollection extends PermissionCollection { @@ -119,15 +126,16 @@ public final class PermissionInfoCollection extends PermissionCollection { /* * TODO: We need to cache the permission constructors to enhance performance (see bug 118813). */ - for (int i = 0; i < permInfos.length; i++) { - if (permInfos[i].getType().equals(permClassName)) { + for (PermissionInfo permInfo : permInfos) { + if (permInfo.getType().equals(permClassName)) { String args[] = new String[numArgs]; - if (numArgs > 0) - args[0] = permInfos[i].getName(); - if (numArgs > 1) - args[1] = permInfos[i].getActions(); - - if (permInfos[i].getType().equals("java.io.FilePermission")) { //$NON-NLS-1$ + if (numArgs > 0) { + args[0] = permInfo.getName(); + } + if (numArgs > 1) { + args[1] = permInfo.getActions(); + } + if (permInfo.getType().equals("java.io.FilePermission")) { //$NON-NLS-1$ // map FilePermissions for relative names to the bundle's data area if (!args[0].equals("<<ALL FILES>>")) { //$NON-NLS-1$ File file = new File(args[0]); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityAdmin.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityAdmin.java index d9e42d22d..17072314f 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityAdmin.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityAdmin.java @@ -112,11 +112,11 @@ public final class SecurityAdmin implements PermissionAdmin, ConditionalPermissi permAdminDefaults = new PermissionInfoCollection(defaultInfos); String[] locations = permissionStorage.getLocations(); if (locations != null) { - for (int i = 0; i < locations.length; i++) { - String[] encodedLocationInfos = permissionStorage.getPermissionData(locations[i]); + for (String location : locations) { + String[] encodedLocationInfos = permissionStorage.getPermissionData(location); if (encodedLocationInfos != null) { PermissionInfo[] locationInfos = getPermissionInfos(encodedLocationInfos); - permAdminTable.setPermissions(locations[i], locationInfos); + permAdminTable.setPermissions(location, locationInfos); } } } @@ -453,10 +453,12 @@ public final class SecurityAdmin implements PermissionAdmin, ConditionalPermissi permAdminCollections = permAdminTable.getCollections(); condAdminRows = condAdminTable.getRows(); } - for (int i = 0; i < permAdminCollections.length; i++) - permAdminCollections[i].clearPermissionCache(); - for (int i = 0; i < condAdminRows.length; i++) - condAdminRows[i].clearCaches(); + for (PermissionInfoCollection permAdminCollection : permAdminCollections) { + permAdminCollection.clearPermissionCache(); + } + for (SecurityRow condAdminRow : condAdminRows) { + condAdminRow.clearCaches(); + } condAdminTable.clearEvaluationCache(); } @@ -516,8 +518,8 @@ public final class SecurityAdmin implements PermissionAdmin, ConditionalPermissi private static Bundle createMockBundle(String[] signers) { Map<X509Certificate, List<X509Certificate>> signersMap = new HashMap<>(); - for (int i = 0; i < signers.length; i++) { - List<String> chain = parseDNchain(signers[i]); + for (String signer : signers) { + List<String> chain = parseDNchain(signer); List<X509Certificate> signersList = new ArrayList<>(); Principal subject = null, issuer = null; X509Certificate first = null; diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityRow.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityRow.java index 0c09613d2..c00e7728f 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityRow.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityRow.java @@ -427,10 +427,12 @@ public final class SecurityRow implements ConditionalPermissionInfo { static int getHashCode(String name, ConditionInfo[] conds, PermissionInfo[] perms, String decision) { int h = 31 * 17 + decision.hashCode(); - for (int i = 0; i < conds.length; i++) - h = 31 * h + conds[i].hashCode(); - for (int i = 0; i < perms.length; i++) - h = 31 * h + perms[i].hashCode(); + for (ConditionInfo cond : conds) { + h = 31 * h + cond.hashCode(); + } + for (PermissionInfo perm : perms) { + h = 31 * h + perm.hashCode(); + } if (name != null) h = 31 * h + name.hashCode(); return h; @@ -444,11 +446,13 @@ public final class SecurityRow implements ConditionalPermissionInfo { result.append(ConditionalPermissionInfo.ALLOW); result.append(" { "); //$NON-NLS-1$ if (conditionInfos != null) - for (int i = 0; i < conditionInfos.length; i++) - result.append(conditionInfos[i].getEncoded()).append(' '); + for (ConditionInfo conditionInfo : conditionInfos) { + result.append(conditionInfo.getEncoded()).append(' '); + } if (permissionInfos != null) - for (int i = 0; i < permissionInfos.length; i++) - result.append(permissionInfos[i].getEncoded()).append(' '); + for (PermissionInfo permissionInfo : permissionInfos) { + result.append(permissionInfo.getEncoded()).append(' '); + } result.append('}'); if (name != null) { result.append(" \""); //$NON-NLS-1$ diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityTable.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityTable.java index 7ddaadc83..34aa2a171 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityTable.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityTable.java @@ -170,9 +170,10 @@ public class SecurityTable extends PermissionCollection { } SecurityRow getRow(String name) { - for (int i = 0; i < rows.length; i++) { - if (name.equals(rows[i].getName())) - return rows[i]; + for (SecurityRow row : rows) { + if (name.equals(row.getName())) { + return row; + } } return null; } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityTableUpdate.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityTableUpdate.java index 4a45087ab..1522f8a1a 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityTableUpdate.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityTableUpdate.java @@ -29,10 +29,11 @@ public class SecurityTableUpdate implements ConditionalPermissionUpdate { this.timeStamp = timeStamp; // must make a snap shot of the security rows. this.rows = new ArrayList<>(rows.length); - for (int i = 0; i < rows.length; i++) - // Use SecurityRowSnapShot to prevent modification before commit + for (SecurityRow row : rows) { + // Use SecurityRowSnapShot to prevent modification before commit // and to throw exceptions from delete - this.rows.add(new SecurityRowSnapShot(rows[i].getName(), rows[i].internalGetConditionInfos(), rows[i].internalGetPermissionInfos(), rows[i].getAccessDecision())); + this.rows.add(new SecurityRowSnapShot(row.getName(), row.internalGetConditionInfos(), row.internalGetPermissionInfos(), row.getAccessDecision())); + } } @Override diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/DigestedInputStream.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/DigestedInputStream.java index e871bc5f9..3c39a4f90 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/DigestedInputStream.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/DigestedInputStream.java @@ -90,8 +90,9 @@ class DigestedInputStream extends FilterInputStream { return -1; int c = super.read(); if (c != -1) { - for (int i = 0; i < digests.length; i++) - digests[i].update((byte) c); + for (MessageDigest digest : digests) { + digest.update((byte) c); + } remaining--; } else { // We hit eof so set remaining to zero @@ -127,8 +128,9 @@ class DigestedInputStream extends FilterInputStream { return -1; int rc = super.read(b, off, len); if (rc != -1) { - for (int i = 0; i < digests.length; i++) - digests[i].update(b, off, rc); + for (MessageDigest digest : digests) { + digest.update(b, off, rc); + } remaining -= rc; } else { // We hit eof so set remaining to zero diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignatureBlockProcessor.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignatureBlockProcessor.java index c7cddedb9..63bf5522b 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignatureBlockProcessor.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignatureBlockProcessor.java @@ -66,8 +66,7 @@ public class SignatureBlockProcessor implements SignedContentConstants { // done processing now create a SingedContent to return SignerInfo[] allSigners = signerInfos.toArray(new SignerInfo[signerInfos.size()]); - for (Iterator<Map.Entry<String, Object>> iResults = contentMDResults.entrySet().iterator(); iResults.hasNext();) { - Map.Entry<String, Object> entry = iResults.next(); + for (Map.Entry<String, Object> entry : contentMDResults.entrySet()) { @SuppressWarnings("unchecked") List<Object>[] value = (List<Object>[]) entry.getValue(); SignerInfo[] entrySigners = value[0].toArray(new SignerInfo[value[0].size()]); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedBundleHook.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedBundleHook.java index a9f1a37a3..780605012 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedBundleHook.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedBundleHook.java @@ -184,16 +184,17 @@ public class SignedBundleHook implements ActivatorHookFactory, BundleFileWrapper public void addHooks(HookRegistry hookRegistry) { container = hookRegistry.getContainer(); hookRegistry.addActivatorHookFactory(this); - String[] support = ManifestElement.getArrayFromList(hookRegistry.getConfiguration().getConfiguration(SIGNED_CONTENT_SUPPORT, hookRegistry.getConfiguration().getConfiguration(SIGNED_BUNDLE_SUPPORT)), ","); //$NON-NLS-1$ - for (int i = 0; i < support.length; i++) { - if (SUPPORT_CERTIFICATE.equals(support[i])) + String[] supportOptions = ManifestElement.getArrayFromList(hookRegistry.getConfiguration().getConfiguration(SIGNED_CONTENT_SUPPORT, hookRegistry.getConfiguration().getConfiguration(SIGNED_BUNDLE_SUPPORT)), ","); //$NON-NLS-1$ + for (String supportOption : supportOptions) { + if (SUPPORT_CERTIFICATE.equals(supportOption)) { supportSignedBundles |= VERIFY_CERTIFICATE; - else if (SUPPORT_TRUST.equals(support[i])) + } else if (SUPPORT_TRUST.equals(supportOption)) { supportSignedBundles |= VERIFY_CERTIFICATE | VERIFY_TRUST; - else if (SUPPORT_RUNTIME.equals(support[i])) + } else if (SUPPORT_RUNTIME.equals(supportOption)) { supportSignedBundles |= VERIFY_CERTIFICATE | VERIFY_RUNTIME; - else if (SUPPORT_TRUE.equals(support[i]) || SUPPORT_ALL.equals(support[i])) + } else if (SUPPORT_TRUE.equals(supportOption) || SUPPORT_ALL.equals(supportOption)) { supportSignedBundles |= VERIFY_ALL; + } } trustEngineNameProp = hookRegistry.getConfiguration().getConfiguration(SignedContentConstants.TRUST_ENGINE); @@ -333,17 +334,17 @@ public class SignedBundleHook implements ActivatorHookFactory, BundleFileWrapper void determineTrust(SignedContentImpl trustedContent, int supportFlags) { TrustEngine[] engines = null; SignerInfo[] signers = trustedContent.getSignerInfos(); - for (int i = 0; i < signers.length; i++) { + for (SignerInfo signer : signers) { // first check if we need to find an anchor - if (signers[i].getTrustAnchor() == null) { + if (signer.getTrustAnchor() == null) { // no anchor set ask the trust engines if (engines == null) engines = getTrustEngines(); // check trust of singer certs - Certificate[] signerCerts = signers[i].getCertificateChain(); - ((SignerInfoImpl) signers[i]).setTrustAnchor(findTrustAnchor(signerCerts, engines, supportFlags)); + Certificate[] signerCerts = signer.getCertificateChain(); + ((SignerInfoImpl) signer).setTrustAnchor(findTrustAnchor(signerCerts, engines, supportFlags)); // if signer has a tsa check trust of tsa certs - SignerInfo tsaSignerInfo = trustedContent.getTSASignerInfo(signers[i]); + SignerInfo tsaSignerInfo = trustedContent.getTSASignerInfo(signer); if (tsaSignerInfo != null) { Certificate[] tsaCerts = tsaSignerInfo.getCertificateChain(); ((SignerInfoImpl) tsaSignerInfo).setTrustAnchor(findTrustAnchor(tsaCerts, engines, supportFlags)); @@ -356,17 +357,17 @@ public class SignedBundleHook implements ActivatorHookFactory, BundleFileWrapper if ((supportFlags & SignedBundleHook.VERIFY_TRUST) == 0) // we are not searching the engines; in this case we just assume the root cert is trusted return certs != null && certs.length > 0 ? certs[certs.length - 1] : null; - for (int i = 0; i < engines.length; i++) { - try { - Certificate anchor = engines[i].findTrustAnchor(certs); - if (anchor != null) - // found an anchor - return anchor; - } catch (IOException e) { - // log the exception and continue - log("TrustEngine failure: " + engines[i].getName(), FrameworkLogEntry.WARNING, e); //$NON-NLS-1$ + for (TrustEngine engine : engines) { + try { + Certificate anchor = engine.findTrustAnchor(certs); + if (anchor != null) + // found an anchor + return anchor; + } catch (IOException e) { + // log the exception and continue + log("TrustEngine failure: " + engine.getName(), FrameworkLogEntry.WARNING, e); //$NON-NLS-1$ + } } - } - return null; + return null; } } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedContentImpl.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedContentImpl.java index f224b2109..a22b2da50 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedContentImpl.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedContentImpl.java @@ -15,9 +15,19 @@ package org.eclipse.osgi.internal.signedcontent; import java.io.IOException; import java.io.InputStream; import java.security.NoSuchAlgorithmException; -import java.security.cert.*; -import java.util.*; -import org.eclipse.osgi.signedcontent.*; +import java.security.cert.Certificate; +import java.security.cert.CertificateExpiredException; +import java.security.cert.CertificateNotYetValidException; +import java.security.cert.X509Certificate; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.eclipse.osgi.signedcontent.InvalidContentException; +import org.eclipse.osgi.signedcontent.SignedContent; +import org.eclipse.osgi.signedcontent.SignedContentEntry; +import org.eclipse.osgi.signedcontent.SignerInfo; import org.eclipse.osgi.storage.bundlefile.BundleEntry; import org.eclipse.osgi.storage.bundlefile.BundleFile; import org.eclipse.osgi.util.NLS; @@ -92,13 +102,15 @@ public class SignedContentImpl implements SignedContent { if (checkedValid) return; Certificate[] certs = signer.getCertificateChain(); - for (int i = 0; i < certs.length; i++) { - if (!(certs[i] instanceof X509Certificate)) + for (Certificate cert : certs) { + if (!(cert instanceof X509Certificate)) { continue; - if (signingTime == null) - ((X509Certificate) certs[i]).checkValidity(); - else - ((X509Certificate) certs[i]).checkValidity(signingTime); + } + if (signingTime == null) { + ((X509Certificate) cert).checkValidity(); + } else { + ((X509Certificate) cert).checkValidity(signingTime); + } } checkedValid = true; } @@ -125,9 +137,11 @@ public class SignedContentImpl implements SignedContent { } private boolean containsInfo(SignerInfo signerInfo) { - for (int i = 0; i < signerInfos.length; i++) - if (signerInfo == signerInfos[i]) + for (SignerInfo si : signerInfos) { + if (signerInfo == si) { return true; + } + } return false; } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedStorageHook.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedStorageHook.java index af70b9207..4222cef06 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedStorageHook.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedStorageHook.java @@ -125,8 +125,9 @@ public class SignedStorageHook extends StorageHookFactory<List<SignerInfo>, List return; SignerInfo[] signerInfos = signedContent.getSignerInfos(); os.writeInt(signerInfos.length); - for (int i = 0; i < signerInfos.length; i++) - saveSignerInfo(signerInfos[i], os, saveContext); + for (SignerInfo signerInfo : signerInfos) { + saveSignerInfo(signerInfo, os, saveContext); + } // keyed by entry path -> {SignerInfo[] infos, byte[][] results)} Map<String, Object> contentMDResults = signedContent.getContentMDResults(); @@ -146,13 +147,13 @@ public class SignedStorageHook extends StorageHookFactory<List<SignerInfo>, List } } - for (int i = 0; i < signerInfos.length; i++) { - SignerInfo tsaInfo = signedContent.getTSASignerInfo(signerInfos[i]); + for (SignerInfo signerInfo : signerInfos) { + SignerInfo tsaInfo = signedContent.getTSASignerInfo(signerInfo); os.writeBoolean(tsaInfo != null); if (tsaInfo == null) continue; saveSignerInfo(tsaInfo, os, saveContext); - Date signingTime = signedContent.getSigningTime(signerInfos[i]); + Date signingTime = signedContent.getSigningTime(signerInfo); os.writeLong(signingTime != null ? signingTime.getTime() : Long.MIN_VALUE); } } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignerInfoImpl.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignerInfoImpl.java index d9c760965..de7de15a7 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignerInfoImpl.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignerInfoImpl.java @@ -53,8 +53,9 @@ public class SignerInfoImpl implements SignerInfo { @Override public int hashCode() { int result = mdAlgorithm.hashCode(); - for (int i = 0; i < chain.length; i++) - result += chain[i].hashCode(); + for (Certificate cert : chain) { + result += cert.hashCode(); + } // Note that we do not hash based on trustAnchor; // this changes dynamically but we need a constant hashCode for purposes of // hashing in a Set. diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/TrustEngineListener.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/TrustEngineListener.java index 91e1842d3..b3b5fc86a 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/TrustEngineListener.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/TrustEngineListener.java @@ -34,17 +34,17 @@ public class TrustEngineListener { // find any SignedContent with SignerInfos that do not have an anchor; // re-evaluate trust and check authorization for these SignedContents Bundle[] bundles = context.getBundles(); - for (int i = 0; i < bundles.length; i++) { - SignedContentImpl signedContent = getSignedContent(bundles[i]); + for (Bundle bundle : bundles) { + SignedContentImpl signedContent = getSignedContent(bundle); if (signedContent != null && signedContent.isSigned()) { // check the SignerInfos for this content SignerInfo[] infos = signedContent.getSignerInfos(); - for (int j = 0; j < infos.length; j++) { - if (infos[j].getTrustAnchor() == null) { + for (SignerInfo info : infos) { + if (info.getTrustAnchor() == null) { // one of the signers is not trusted signedBundleHook.determineTrust(signedContent, SignedBundleHook.VERIFY_TRUST); } else { - SignerInfo tsa = signedContent.getTSASignerInfo(infos[j]); + SignerInfo tsa = signedContent.getTSASignerInfo(info); if (tsa != null && tsa.getTrustAnchor() == null) // one of the tsa signers is not trusted signedBundleHook.determineTrust(signedContent, SignedBundleHook.VERIFY_TRUST); @@ -60,21 +60,21 @@ public class TrustEngineListener { Bundle[] bundles = context.getBundles(); Set<Bundle> usingAnchor = new HashSet<>(); Set<SignerInfo> untrustedSigners = new HashSet<>(); - for (int i = 0; i < bundles.length; i++) { - SignedContentImpl signedContent = getSignedContent(bundles[i]); + for (Bundle bundle : bundles) { + SignedContentImpl signedContent = getSignedContent(bundle); if (signedContent != null && signedContent.isSigned()) { // check signer infos for this content SignerInfo[] infos = signedContent.getSignerInfos(); - for (int j = 0; j < infos.length; j++) { - if (anchor.equals(infos[j].getTrustAnchor())) { + for (SignerInfo info : infos) { + if (anchor.equals(info.getTrustAnchor())) { // one of the signers uses this anchor - untrustedSigners.add(infos[j]); - usingAnchor.add(bundles[i]); + untrustedSigners.add(info); + usingAnchor.add(bundle); } - SignerInfo tsa = signedContent.getTSASignerInfo(infos[j]); + SignerInfo tsa = signedContent.getTSASignerInfo(info); if (tsa != null && anchor.equals(tsa.getTrustAnchor())) { // one of the tsa signers uses this anchor - usingAnchor.add(bundles[i]); + usingAnchor.add(bundle); untrustedSigners.add(tsa); } } @@ -84,8 +84,7 @@ public class TrustEngineListener { for (Iterator<SignerInfo> untrusted = untrustedSigners.iterator(); untrusted.hasNext();) ((SignerInfoImpl) untrusted.next()).setTrustAnchor(null); // re-establish trust - for (Iterator<Bundle> untrustedBundles = usingAnchor.iterator(); untrustedBundles.hasNext();) { - Bundle bundle = untrustedBundles.next(); + for (Bundle bundle : usingAnchor) { SignedContentImpl signedContent = getSignedContent(bundle); // found an signer using the anchor for this bundle re-evaluate trust signedBundleHook.determineTrust(signedContent, SignedBundleHook.VERIFY_TRUST); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/ContentHandlerFactoryImpl.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/ContentHandlerFactoryImpl.java index c1166cba7..3afa85e77 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/ContentHandlerFactoryImpl.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/ContentHandlerFactoryImpl.java @@ -110,19 +110,19 @@ public class ContentHandlerFactoryImpl extends MultiplexingFactory implements ja } ServiceReference<ContentHandler>[] serviceReferences = contentHandlerTracker.getServiceReferences(); if (serviceReferences != null) { - for (int i = 0; i < serviceReferences.length; i++) { - Object prop = serviceReferences[i].getProperty(URLConstants.URL_CONTENT_MIMETYPE); + for (ServiceReference<ContentHandler> serviceReference : serviceReferences) { + Object prop = serviceReference.getProperty(URLConstants.URL_CONTENT_MIMETYPE); if (prop instanceof String) prop = new String[] {(String) prop}; // TODO should this be a warning? if (!(prop instanceof String[])) { - String message = NLS.bind(Msg.URL_HANDLER_INCORRECT_TYPE, new Object[] {URLConstants.URL_CONTENT_MIMETYPE, contentHandlerClazz, serviceReferences[i].getBundle()}); + String message = NLS.bind(Msg.URL_HANDLER_INCORRECT_TYPE, new Object[]{URLConstants.URL_CONTENT_MIMETYPE, contentHandlerClazz, serviceReference.getBundle()}); container.getLogServices().log(EquinoxContainer.NAME, FrameworkLogEntry.WARNING, message, null); continue; } String[] contentHandler = (String[]) prop; - for (int j = 0; j < contentHandler.length; j++) { - if (contentHandler[j].equals(contentType)) { - proxy = new ContentHandlerProxy(contentType, serviceReferences[i], context); + for (String typename : contentHandler) { + if (typename.equals(contentType)) { + proxy = new ContentHandlerProxy(contentType, serviceReference, context); proxies.put(contentType, proxy); return (proxy); } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/ContentHandlerProxy.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/ContentHandlerProxy.java index 8b8b18bc7..0c2051d8e 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/ContentHandlerProxy.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/ContentHandlerProxy.java @@ -82,8 +82,8 @@ public class ContentHandlerProxy extends ContentHandler implements ServiceTracke return null; } String[] contentTypes = (String[]) prop; - for (int i = 0; i < contentTypes.length; i++) { - if (contentTypes[i].equals(contentType)) { + for (String candidateContentType : contentTypes) { + if (candidateContentType.equals(contentType)) { //If our contentType is registered by another service, check the service ranking and switch URLStreamHandlers if nessecary. int newServiceRanking = getRank(reference); if (newServiceRanking > ranking || contentHandlerServiceReference == null) diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/EquinoxFactoryManager.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/EquinoxFactoryManager.java index 70197bba5..01a866b06 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/EquinoxFactoryManager.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/EquinoxFactoryManager.java @@ -229,11 +229,11 @@ public class EquinoxFactoryManager { public static Field getField(Class<?> clazz, Class<?> type, boolean instance) { Field[] fields = clazz.getDeclaredFields(); - for (int i = 0; i < fields.length; i++) { - boolean isStatic = Modifier.isStatic(fields[i].getModifiers()); - if (instance != isStatic && fields[i].getType().equals(type)) { - MultiplexingFactory.setAccessible(fields[i]); - return fields[i]; + for (Field field : fields) { + boolean isStatic = Modifier.isStatic(field.getModifiers()); + if (instance != isStatic && field.getType().equals(type)) { + MultiplexingFactory.setAccessible(field); + return field; } } return null; diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/MultiplexingFactory.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/MultiplexingFactory.java index ae6084145..0d4e0b298 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/MultiplexingFactory.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/MultiplexingFactory.java @@ -154,8 +154,7 @@ public abstract class MultiplexingFactory { public Object findAuthorizedFactory(List<Class<?>> ignoredClasses) { List<Object> current = getFactories(); Class<?>[] classStack = internalSecurityManager.getClassContext(); - for (int i = 0; i < classStack.length; i++) { - Class<?> clazz = classStack[i]; + for (Class<?> clazz : classStack) { if (clazz == InternalSecurityManager.class || clazz == MultiplexingFactory.class || ignoredClasses.contains(clazz)) continue; if (hasAuthority(clazz)) diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/URLStreamHandlerFactoryImpl.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/URLStreamHandlerFactoryImpl.java index 1131d7e98..204715ffd 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/URLStreamHandlerFactoryImpl.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/URLStreamHandlerFactoryImpl.java @@ -164,19 +164,19 @@ public class URLStreamHandlerFactoryImpl extends MultiplexingFactory implements ServiceReference<URLStreamHandlerService>[] serviceReferences = handlerTracker.getServiceReferences(); if (serviceReferences == null) return null; - for (int i = 0; i < serviceReferences.length; i++) { - Object prop = serviceReferences[i].getProperty(URLConstants.URL_HANDLER_PROTOCOL); + for (ServiceReference<URLStreamHandlerService> serviceReference : serviceReferences) { + Object prop = serviceReference.getProperty(URLConstants.URL_HANDLER_PROTOCOL); if (prop instanceof String) prop = new String[] {(String) prop}; // TODO should this be a warning? if (!(prop instanceof String[])) { - String message = NLS.bind(Msg.URL_HANDLER_INCORRECT_TYPE, new Object[] {URLConstants.URL_HANDLER_PROTOCOL, URLSTREAMHANDLERCLASS, serviceReferences[i].getBundle()}); + String message = NLS.bind(Msg.URL_HANDLER_INCORRECT_TYPE, new Object[]{URLConstants.URL_HANDLER_PROTOCOL, URLSTREAMHANDLERCLASS, serviceReference.getBundle()}); container.getLogServices().log(EquinoxContainer.NAME, FrameworkLogEntry.WARNING, message, null); continue; } String[] protocols = (String[]) prop; - for (int j = 0; j < protocols.length; j++) { - if (protocols[j].equals(protocol)) { - handler = new URLStreamHandlerProxy(protocol, serviceReferences[i], context); + for (String candidateProtocol : protocols) { + if (candidateProtocol.equals(protocol)) { + handler = new URLStreamHandlerProxy(protocol, serviceReference, context); proxies.put(protocol, handler); return (handler); } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/URLStreamHandlerProxy.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/URLStreamHandlerProxy.java index f8efc54b3..7cb6567a3 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/URLStreamHandlerProxy.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/URLStreamHandlerProxy.java @@ -178,8 +178,8 @@ public class URLStreamHandlerProxy extends URLStreamHandler implements ServiceTr return null; } String[] protocols = (String[]) prop; - for (int i = 0; i < protocols.length; i++) { - if (protocols[i].equals(protocol)) { + for (String candidateProtocol : protocols) { + if (candidateProtocol.equals(protocol)) { //If our protocol is registered by another service, check the service ranking and switch URLStreamHandlers if nessecary. int newServiceRanking = getRank(reference); if (newServiceRanking > ranking || urlStreamServiceReference == null) diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/FrameworkExtensionInstaller.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/FrameworkExtensionInstaller.java index 03fea5fe2..939e9548f 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/FrameworkExtensionInstaller.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/FrameworkExtensionInstaller.java @@ -124,14 +124,15 @@ public class FrameworkExtensionInstaller { if (files == null) { return; } - for (int i = 0; i < files.length; i++) { - if (files[i] == null) - continue; + for (File file : files) { + if (file == null) { + continue; + } try { - callAddURLMethod(StorageUtil.encodeFileURL(files[i])); - } catch (InvocationTargetException | MalformedURLException e) { + callAddURLMethod(StorageUtil.encodeFileURL(file)); + }catch (InvocationTargetException | MalformedURLException e) { throw new BundleException("Error adding extension content.", e); //$NON-NLS-1$ - } + } } } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/PermissionData.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/PermissionData.java index aff8ad362..abd867c81 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/PermissionData.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/PermissionData.java @@ -174,24 +174,28 @@ public class PermissionData { String[] defaultPerms = getPermissionData(null); temp.writeInt(defaultPerms == null ? 0 : defaultPerms.length); if (defaultPerms != null) - for (int i = 0; i < defaultPerms.length; i++) - temp.writeUTF(defaultPerms[i]); + for (String defaultPerm : defaultPerms) { + temp.writeUTF(defaultPerm); + } String[] locs = getLocations(); temp.writeInt(locs == null ? 0 : locs.length); if (locs != null) - for (int i = 0; i < locs.length; i++) { - temp.writeUTF(locs[i]); - String[] perms = getPermissionData(locs[i]); + for (String loc : locs) { + temp.writeUTF(loc); + String[] perms = getPermissionData(loc); temp.writeInt(perms == null ? 0 : perms.length); - if (perms != null) - for (int j = 0; j < perms.length; j++) - temp.writeUTF(perms[j]); + if (perms != null) { + for (String perm : perms) { + temp.writeUTF(perm); + } + } } String[] condPerms = getConditionalPermissionInfos(); temp.writeInt(condPerms == null ? 0 : condPerms.length); if (condPerms != null) - for (int i = 0; i < condPerms.length; i++) - temp.writeUTF(condPerms[i]); + for (String condPerm : condPerms) { + temp.writeUTF(condPerm); + } temp.close(); out.writeInt(tempBytes.size()); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java index c6f7f3129..7c0b7d76e 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java @@ -1100,15 +1100,16 @@ public class Storage { commandProp = getConfiguration().getConfiguration(Constants.FRAMEWORK_EXECPERMISSION); if (commandProp == null) return; - String[] temp = ManifestElement.getArrayFromList(commandProp, " "); //$NON-NLS-1$ - List<String> command = new ArrayList<>(temp.length + 1); + String[] commandComponents = ManifestElement.getArrayFromList(commandProp, " "); //$NON-NLS-1$ + List<String> command = new ArrayList<>(commandComponents.length + 1); boolean foundFullPath = false; - for (int i = 0; i < temp.length; i++) { - if ("[fullpath]".equals(temp[i]) || "${abspath}".equals(temp[i])) { //$NON-NLS-1$ //$NON-NLS-2$ + for (String commandComponent : commandComponents) { + if ("[fullpath]".equals(commandComponent) || "${abspath}".equals(commandComponent)) { //$NON-NLS-1$ //$NON-NLS-2$ command.add(file.getAbsolutePath()); foundFullPath = true; - } else - command.add(temp[i]); + } else { + command.add(commandComponent); + } } if (!foundFullPath) command.add(file.getAbsolutePath()); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/StorageUtil.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/StorageUtil.java index 033c5b427..bc4f57024 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/StorageUtil.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/StorageUtil.java @@ -42,9 +42,9 @@ public class StorageUtil { String[] files = inDir.list(); if (files != null && files.length > 0) { outDir.mkdir(); - for (int i = 0; i < files.length; i++) { - File inFile = new File(inDir, files[i]); - File outFile = new File(outDir, files[i]); + for (String file : files) { + File inFile = new File(inDir, file); + File outFile = new File(outDir, file); if (inFile.isDirectory()) { copyDir(inFile, outFile); } else { |