Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Hammer2019-06-17 20:44:58 +0000
committerThomas Watson2019-07-15 13:10:24 +0000
commit20f0afb5895ee5019e3c9a1b5107456c5485694e (patch)
tree77e9c5476ae7cac3c9dc90197485f9fbabb833c2
parent5595b19ec459226e5fe38f8d39c71e1f72efab75 (diff)
downloadrt.equinox.framework-Y20190718-0450.tar.gz
rt.equinox.framework-Y20190718-0450.tar.xz
rt.equinox.framework-Y20190718-0450.zip
Replace simple uses of Iterator with a corresponding for-loop. Also add missing braces on loops as necessary. Change-Id: I97b9a58053098327f05ac48338486ed40144b987 Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de> Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
-rw-r--r--bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java85
-rw-r--r--bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/WebStartMain.java9
-rw-r--r--bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/GroupingChecker.java84
-rw-r--r--bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverBundle.java150
-rw-r--r--bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverImpl.java424
-rw-r--r--bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/VersionHashMap.java13
-rw-r--r--bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/BundleDescriptionImpl.java38
-rw-r--r--bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/ImportPackageSpecificationImpl.java24
-rw-r--r--bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/NativeCodeDescriptionImpl.java23
-rw-r--r--bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateBuilder.java181
-rw-r--r--bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateHelperImpl.java184
-rw-r--r--bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateImpl.java97
-rw-r--r--bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateObjectFactoryImpl.java11
-rw-r--r--bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateReader.java8
-rw-r--r--bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateWriter.java143
-rw-r--r--bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/UserState.java26
-rw-r--r--bundles/org.eclipse.osgi.tests/bundles_src/ext.framework.b/ext/framework/b/TestCondition.java8
-rw-r--r--bundles/org.eclipse.osgi.tests/bundles_src/security.b/security/b/Activator.java6
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/appadmin/ApplicationAdminTest.java20
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java40
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/PackageAdminBundleTests.java5
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SubstituteExportsBundleTests.java49
-rwxr-xr-xbundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java18
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/EclipseStarterConfigIniTest.java10
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/EclipseStarterConfigurationAreaTest.java10
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/MovableConfigurationAreaTest.java10
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/ReadOnlyConfigurationAreaTest.java5
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestAttributes_001.java6
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestBSN_001.java3
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestCycle_001.java16
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestCycle_002.java36
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestCycle_004.java6
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestCycle_005.java6
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestDynamic_002.java3
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestDynamic_003.java3
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestDynamic_004.java6
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestGenerated_001.java12
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestGrouping_001.java3
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestGrouping_003.java6
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestGrouping_008.java6
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestOptional_001.java3
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestOptional_002.java3
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestPropagation_001.java6
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestPropagation_003.java3
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_001.java24
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_002.java48
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_003.java40
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_004.java24
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_005.java16
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_006.java6
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_007.java6
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestVersion_001.java9
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestVersion_002.java6
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestVersion_003.java3
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/security/BaseSecurityTest.java8
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/security/KeyStoreTrustEngineTest.java27
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/security/SignedBundleTest.java171
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/serviceregistry/ServiceHookTests.java58
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/FileManagerTests.java20
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/LocationAreaSessionTest.java20
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/StreamManagerTests.java31
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/AbstractStateTest.java20
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/OSGiCapabilityTest.java28
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/StateResolverTest.java52
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/SubstitutableExportsTest.java148
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/XFriendsInternalResolverTest.java6
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/util/BidiTextProcessorTestCase.java13
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/util/LatinTextProcessorTestCase.java16
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/util/TextProcessorSessionTest.java5
-rw-r--r--bundles/org.eclipse.osgi/.settings/org.eclipse.jdt.core.prefs2
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/adaptor/EclipseStarter.java78
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java3
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/builders/OSGiManifestBuilderFactory.java56
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/util/FilePath.java4
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/ComputeNodeOrder.java24
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/debug/EclipseDebugTrace.java4
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/debug/FrameworkDebugOptions.java14
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxBundle.java12
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainer.java35
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/OSGiFrameworkHooks.java12
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/legacy/PackageAdminImpl.java13
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/hookregistry/HookRegistry.java39
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/hooks/DevClassLoadingHook.java23
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java32
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/buddy/GlobalPolicy.java6
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/classpath/ClasspathManager.java21
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/classpath/FragmentClasspath.java6
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/sources/FilteredSourcePackage.java17
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/sources/MultiSourcePackage.java13
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/sources/PackageSource.java13
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EquinoxLogWriter.java4
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EventAdminAdapter.java5
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/EquinoxSecurityManager.java34
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/PermissionInfoCollection.java28
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityAdmin.java20
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityRow.java20
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityTable.java7
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityTableUpdate.java7
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/DigestedInputStream.java10
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignatureBlockProcessor.java3
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedBundleHook.java45
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedContentImpl.java36
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedStorageHook.java11
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignerInfoImpl.java5
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/TrustEngineListener.java29
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/ContentHandlerFactoryImpl.java12
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/ContentHandlerProxy.java4
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/EquinoxFactoryManager.java10
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/MultiplexingFactory.java3
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/URLStreamHandlerFactoryImpl.java12
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/URLStreamHandlerProxy.java4
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/FrameworkExtensionInstaller.java13
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/PermissionData.java24
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java13
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/StorageUtil.java6
-rw-r--r--bundles/org.eclipse.osgi/pom.xml2
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/eventmgr/CopyOnWriteIdentityMap.java17
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/reliablefile/ReliableFile.java19
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/storagemanager/StorageManager.java51
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/ManifestElement.java4
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/NLS.java6
121 files changed, 1873 insertions, 1631 deletions
diff --git a/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java b/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java
index ee47cb76f..d013ff7c2 100644
--- a/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java
+++ b/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java
@@ -824,23 +824,22 @@ public class Main {
String[] extensions = getArrayFromList(System.getProperty(PROP_EXTENSIONS));
String parent = new File(base.getFile()).getParent();
ArrayList<String> extensionResults = new ArrayList<>(extensions.length);
- for (int i = 0; i < extensions.length; i++) {
- //Search the extension relatively to the osgi plugin
- String path = searchForBundle(extensions[i], parent);
+ for (String extension : extensions) {
+ //Search the extension relatively to the osgi plugin
+ String path = searchForBundle(extension, parent);
if (path == null) {
- log("Could not find extension: " + extensions[i]); //$NON-NLS-1$
+ log("Could not find extension: " + extension); //$NON-NLS-1$
continue;
}
- if (debug)
- System.out.println("Loading extension: " + extensions[i]); //$NON-NLS-1$
-
+ if (debug) {
+ System.out.println("Loading extension: " + extension); //$NON-NLS-1$
+ }
URL extensionURL = null;
if (installLocation.getProtocol().equals("file")) { //$NON-NLS-1$
extensionResults.add(path);
extensionURL = new File(path).toURL();
} else
extensionURL = new URL(installLocation.getProtocol(), installLocation.getHost(), installLocation.getPort(), path);
-
//Load a property file of the extension, merge its content, and in case of dev mode add the bin entries
Properties extensionProperties = null;
try {
@@ -861,12 +860,13 @@ public class Main {
qualifiedPath = "."; //$NON-NLS-1$
else
qualifiedPath = ""; //$NON-NLS-1$
- for (int j = 0; j < entries.length; j++)
- qualifiedPath += ", " + FILE_SCHEME + path + entries[j]; //$NON-NLS-1$
+ for (String entry : entries) {
+ qualifiedPath += ", " + FILE_SCHEME + path + entry; //$NON-NLS-1$
+ }
extensionProperties.put(PROP_CLASSPATH, qualifiedPath);
mergeWithSystemProperties(extensionProperties, null);
if (inDevelopmentMode) {
- String name = extensions[i];
+ String name = extension;
if (name.startsWith(REFERENCE_SCHEME)) {
// need to extract the BSN from the path
name = new File(path).getName();
@@ -912,8 +912,7 @@ public class Main {
addEntry(base, result);
return;
}
- for (int i = 0; i < baseJars.length; i++) {
- String string = baseJars[i];
+ for (String string : baseJars) {
try {
// if the string is a file: URL then *carefully* construct the
// URL. Otherwisejust try to build a URL. In either case, if we fail, use
@@ -946,8 +945,7 @@ public class Main {
if (devPathList == null)
devPathList = devClassPathProps.getProperty("*"); //$NON-NLS-1$
String[] locations = getArrayFromList(devPathList);
- for (int i = 0; i < locations.length; i++) {
- String location = locations[i];
+ for (String location : locations) {
File path = new File(location);
URL url;
if (path.isAbsolute())
@@ -995,8 +993,9 @@ public class Main {
URL[] result = getDevPath(url);
if (debug) {
System.out.println("Framework classpath:"); //$NON-NLS-1$
- for (int i = 0; i < result.length; i++)
- System.out.println(" " + result[i].toExternalForm()); //$NON-NLS-1$
+ for (URL devPath : result) {
+ System.out.println(" " + devPath.toExternalForm()); //$NON-NLS-1$
+ }
}
return result;
}
@@ -1017,9 +1016,10 @@ public class Main {
return null;
ArrayList<String> matches = new ArrayList<>(2);
- for (int i = 0; i < candidates.length; i++) {
- if (isMatchingCandidate(target, candidates[i], root))
- matches.add(candidates[i]);
+ for (String candidate : candidates) {
+ if (isMatchingCandidate(target, candidate, root)) {
+ matches.add(candidate);
+ }
}
String[] names = matches.toArray(new String[matches.size()]);
int result = findMax(target, names);
@@ -2203,15 +2203,16 @@ public class Main {
if (splashPath != null) {
String[] entries = getArrayFromList(splashPath);
ArrayList<String> path = new ArrayList<>(entries.length);
- for (int i = 0; i < entries.length; i++) {
- String entry = resolve(entries[i]);
+ for (String e : entries) {
+ String entry = resolve(e);
if (entry != null && entry.startsWith(FILE_SCHEME)) {
File entryFile = new File(entry.substring(5).replace('/', File.separatorChar));
entry = searchFor(entryFile.getName(), entryFile.getParent());
if (entry != null)
path.add(entry);
- } else
- log("Invalid splash path entry: " + entries[i]); //$NON-NLS-1$
+ } else {
+ log("Invalid splash path entry: " + e); //$NON-NLS-1$
+ }
}
// see if we can get a splash given the splash path
result = searchForSplash(path.toArray(new String[path.size()]));
@@ -2236,21 +2237,20 @@ public class Main {
locale = Locale.getDefault().toString();
String[] nlVariants = buildNLVariants(locale);
- for (int i = 0; i < nlVariants.length; i++) {
- for (int j = 0; j < searchPath.length; j++) {
- String path = searchPath[j];
+ for (String nlVariant : nlVariants) {
+ for (String path : searchPath) {
if (path.startsWith(FILE_SCHEME))
path = path.substring(5);
// do we have a JAR?
if (isJAR(path)) {
- String result = extractFromJAR(path, nlVariants[i]);
+ String result = extractFromJAR(path, nlVariant);
if (result != null)
return result;
} else {
// we have a file or a directory
if (!path.endsWith(File.separator))
path += File.separator;
- path += nlVariants[i];
+ path += nlVariant;
File result = new File(path);
if (result.exists())
return result.getAbsolutePath(); // return the first match found [20063]
@@ -2288,8 +2288,8 @@ public class Main {
if (splash.exists()) {
// if we are running with -clean then delete the cached splash file
boolean clean = false;
- for (int i = 0; i < commands.length; i++) {
- if (CLEAN.equalsIgnoreCase(commands[i])) {
+ for (String command : commands) {
+ if (CLEAN.equalsIgnoreCase(command)) {
clean = true;
splash.delete();
break;
@@ -2562,12 +2562,12 @@ public class Main {
setMultiValueProperty(PROP_COMMANDS, commands);
}
- private void setMultiValueProperty(String property, String[] value) {
- if (value != null) {
+ private void setMultiValueProperty(String property, String[] values) {
+ if (values != null) {
StringBuilder result = new StringBuilder(300);
- for (int i = 0; i < value.length; i++) {
- if (value[i] != null) {
- result.append(value[i]);
+ for (String value : values) {
+ if (value != null) {
+ result.append(value);
result.append('\n');
}
}
@@ -2671,14 +2671,15 @@ public class Main {
private boolean contains(CodeSource codeSource) {
if (codeSource == null)
return false;
- URL url = codeSource.getLocation();
- if (url == null)
+ URL location = codeSource.getLocation();
+ if (location == null)
return false;
// Check to see if this URL is in our set of URLs to give AllPermissions to.
- for (int i = 0; i < urls.length; i++) {
+ for (URL url : urls) {
// We do simple equals test here because we assume the URLs will be the same objects.
- if (urls[i] == url)
+ if (url == location) {
return true;
+ }
}
return false;
}
@@ -2703,8 +2704,8 @@ public class Main {
if (extensionPaths == null)
return super.findLibrary(name);
String libName = System.mapLibraryName(name);
- for (int i = 0; i < extensionPaths.length; i++) {
- File libFile = new File(extensionPaths[i], libName);
+ for (String extensionPath : extensionPaths) {
+ File libFile = new File(extensionPath, libName);
if (libFile.isFile())
return libFile.getAbsolutePath();
}
diff --git a/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/WebStartMain.java b/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/WebStartMain.java
index 0ac4a62d9..bacaac58a 100644
--- a/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/WebStartMain.java
+++ b/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/WebStartMain.java
@@ -310,18 +310,15 @@ public class WebStartMain extends Main {
private void buildOSGiBundleList() {
StringBuilder finalBundleList = new StringBuilder(allBundles.size() * 30);
//First go through all the bundles of the bundle
- for (Iterator<BundleInfo> iterator = bundleList.iterator(); iterator.hasNext();) {
- BundleInfo searched = iterator.next();
+ for (BundleInfo searched : bundleList) {
BundleInfo found = findBundle(searched.bsn, searched.version, true);
if (found != null)
finalBundleList.append(REFERENCE_SCHEME).append(found.location).append(searched.startData).append(',');
}
if (!Boolean.FALSE.toString().equalsIgnoreCase(System.getProperties().getProperty(PROP_WEBSTART_AUTOMATIC_INSTALLATION))) {
- for (Iterator<List<BundleInfo>> iterator = allBundles.values().iterator(); iterator.hasNext();) {
- List<BundleInfo> toAdd = iterator.next();
- for (Iterator<BundleInfo> iterator2 = toAdd.iterator(); iterator2.hasNext();) {
- BundleInfo bi = iterator2.next();
+ for (List<BundleInfo> toAdd : allBundles.values()) {
+ for (BundleInfo bi : toAdd) {
finalBundleList.append(REFERENCE_SCHEME).append(bi.location).append(',');
}
}
diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/GroupingChecker.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/GroupingChecker.java
index fa6e4c067..8988c1bf6 100644
--- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/GroupingChecker.java
+++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/GroupingChecker.java
@@ -37,8 +37,8 @@ public class GroupingChecker {
return;
// process all requires
BundleConstraint[] requires = bundle.getRequires();
- for (int j = 0; j < requires.length; j++) {
- ResolverBundle selectedSupplier = (ResolverBundle) requires[j].getSelectedSupplier();
+ for (BundleConstraint require : requires) {
+ ResolverBundle selectedSupplier = (ResolverBundle) require.getSelectedSupplier();
if (selectedSupplier != null)
isConsistentInternal(bundle, selectedSupplier, new ArrayList<ResolverBundle>(1), true, null);
}
@@ -82,18 +82,19 @@ public class GroupingChecker {
visited.add(matchingBundle);
// check that the packages exported by the matching bundle are consistent
ResolverExport[] matchingExports = matchingBundle.getExportPackages();
- for (int i = 0; i < matchingExports.length; i++) {
- ResolverExport matchingExport = matchingExports[i];
- if (matchingExports[i].getSubstitute() != null)
- matchingExport = (ResolverExport) matchingExports[i].getSubstitute();
+ for (ResolverExport matchingExport : matchingExports) {
+ if (matchingExport.getSubstitute() != null) {
+ matchingExport = (ResolverExport) matchingExport.getSubstitute();
+ }
results = isConsistentInternal(requiringBundle, matchingExport, dynamicImport, results);
}
// check that the packages from reexported bundles are consistent
BundleConstraint[] supplierRequires = matchingBundle.getRequires();
- for (int j = 0; j < supplierRequires.length; j++) {
- ResolverBundle reexported = (ResolverBundle) supplierRequires[j].getSelectedSupplier();
- if (reexported == null || !((BundleSpecification) supplierRequires[j].getVersionConstraint()).isExported())
+ for (BundleConstraint supplierRequire : supplierRequires) {
+ ResolverBundle reexported = (ResolverBundle) supplierRequire.getSelectedSupplier();
+ if (reexported == null || !((BundleSpecification) supplierRequire.getVersionConstraint()).isExported()) {
continue;
+ }
results = isConsistentInternal(requiringBundle, reexported, visited, dynamicImport, results);
}
return results;
@@ -141,8 +142,7 @@ public class GroupingChecker {
PackageRoots importingRoots = getPackageRoots(importingBundle, matchingExport.getName(), null);
Map<String, PackageRoots> importingPackages = bundles.get(importingBundle);
if (importingPackages != null)
- for (Iterator<PackageRoots> allImportingPackages = importingPackages.values().iterator(); allImportingPackages.hasNext();) {
- PackageRoots roots = allImportingPackages.next();
+ for (PackageRoots roots : importingPackages.values()) {
if (roots != importingRoots)
results = roots.isConsistentClassSpace(exportingRoots, matchingExport.getExporter(), null, results);
}
@@ -216,8 +216,8 @@ public class GroupingChecker {
List<PackageRoots> roots = new ArrayList<>(0);
// check roots from required bundles
BundleConstraint[] requires = bundle.getRequires();
- for (int i = 0; i < requires.length; i++) {
- ResolverBundle supplier = (ResolverBundle) requires[i].getSelectedSupplier();
+ for (BundleConstraint require : requires) {
+ ResolverBundle supplier = (ResolverBundle) require.getSelectedSupplier();
if (supplier == null)
continue; // no supplier, probably optional
if (supplier.getExport(packageName) != null) {
@@ -228,10 +228,11 @@ public class GroupingChecker {
} else {
// the bundle does not export the package; but it may reexport another bundle that does
BundleConstraint[] supplierRequires = supplier.getRequires();
- for (int j = 0; j < supplierRequires.length; j++) {
- ResolverBundle reexported = (ResolverBundle) supplierRequires[j].getSelectedSupplier();
- if (reexported == null || !((BundleSpecification) supplierRequires[j].getVersionConstraint()).isExported())
+ for (BundleConstraint supplierRequire : supplierRequires) {
+ ResolverBundle reexported = (ResolverBundle) supplierRequire.getSelectedSupplier();
+ if (reexported == null || !((BundleSpecification) supplierRequire.getVersionConstraint()).isExported()) {
continue;
+ }
if (reexported.getExport(packageName) != null) {
// the reexported bundle exports the package; get the package roots from it
PackageRoots reExportedRoots = getPackageRoots(reexported, packageName, visited);
@@ -259,11 +260,13 @@ public class GroupingChecker {
// in this case we cannot share the package roots object; must create one specific for this bundle
PackageRoots result = new PackageRoots(packageName);
// first merge all the roots from required bundles
- for (int i = 0; i < requiredRoots.length; i++)
- result.merge(requiredRoots[i]);
+ for (PackageRoots requiredRoot : requiredRoots) {
+ result.merge(requiredRoot);
+ }
// always add this bundles exports to the end if it exports the package
- for (int i = 0; i < exports.length; i++)
- result.addRoot(exports[i]);
+ for (ResolverExport export : exports) {
+ result.addRoot(export);
+ }
return result;
}
return roots.size() == 0 ? nullPackageRoots : roots.get(0);
@@ -299,9 +302,11 @@ public class GroupingChecker {
String exportBSN = export.getExporter().getName();
if (exportBSN != null) {
// first one wins
- for (int i = 0; i < roots.length; i++)
- if (export.getExporter() != roots[i].getExporter() && exportBSN.equals(roots[i].getExporter().getName()))
+ for (ResolverExport root : roots) {
+ if (export.getExporter() != root.getExporter() && exportBSN.equals(root.getExporter().getName())) {
return;
+ }
+ }
}
if (!contains(export, roots)) {
ResolverExport[] newRoots = new ResolverExport[roots.length + 1];
@@ -312,9 +317,11 @@ public class GroupingChecker {
}
private boolean contains(ResolverExport export, ResolverExport[] exports) {
- for (int i = 0; i < exports.length; i++)
- if (exports[i] == export)
+ for (ResolverExport e : exports) {
+ if (e == export) {
return true;
+ }
+ }
return false;
}
@@ -340,11 +347,12 @@ public class GroupingChecker {
String[] uses = root.getUsesDirective();
if (uses == null)
continue;
- for (int j = 0; j < uses.length; j++) {
- if (uses[j].equals(root.getName()))
+ for (String use : uses) {
+ if (use.equals(root.getName())) {
continue;
- PackageRoots thisUsedRoots = getPackageRoots(root.getExporter(), uses[j], null);
- PackageRoots importingUsedRoots = getPackageRoots(importingBundle, uses[j], null);
+ }
+ PackageRoots thisUsedRoots = getPackageRoots(root.getExporter(), use, null);
+ PackageRoots importingUsedRoots = getPackageRoots(importingBundle, use, null);
if (thisUsedRoots == importingUsedRoots)
continue;
if (thisUsedRoots != nullPackageRoots && importingUsedRoots != nullPackageRoots)
@@ -363,9 +371,7 @@ public class GroupingChecker {
public List<PackageRoots[]> isConsistentClassSpace(PackageRoots exportingRoots, ResolverBundle exporter, List<PackageRoots> visited, List<PackageRoots[]> results) {
if (roots == null)
return results;
- int size = roots.length;
- for (int i = 0; i < size; i++) {
- ResolverExport root = roots[i];
+ for (ResolverExport root : roots) {
String[] uses = root.getUsesDirective();
if (uses == null)
continue;
@@ -374,11 +380,12 @@ public class GroupingChecker {
if (visited.contains(this))
return results;
visited.add(this);
- for (int j = 0; j < uses.length; j++) {
- if (uses[j].equals(root.getName()) || !uses[j].equals(exportingRoots.name))
+ for (String use : uses) {
+ if (use.equals(root.getName()) || !use.equals(exportingRoots.name)) {
continue;
- PackageRoots thisUsedRoots = getPackageRoots(root.getExporter(), uses[j], null);
- PackageRoots exportingUsedRoots = getPackageRoots(exporter, uses[j], null);
+ }
+ PackageRoots thisUsedRoots = getPackageRoots(root.getExporter(), use, null);
+ PackageRoots exportingUsedRoots = getPackageRoots(exporter, use, null);
if (thisUsedRoots == exportingRoots)
return results;
if (thisUsedRoots != nullPackageRoots && exportingUsedRoots != nullPackageRoots)
@@ -410,14 +417,15 @@ public class GroupingChecker {
// TODO this is a behavioral change; before we only required 1 supplier to match; now roots must be subsets
private boolean subSet(ResolverExport[] superSet, ResolverExport[] subSet) {
- for (int i = 0; i < subSet.length; i++) {
+ for (ResolverExport subexport : subSet) {
boolean found = false;
- for (int j = 0; j < superSet.length; j++)
+ for (ResolverExport superexport : superSet) {
// compare by exporter in case the bundle exports the package multiple times
- if (subSet[i].getExporter() == superSet[j].getExporter()) {
+ if (subexport.getExporter() == superexport.getExporter()) {
found = true;
break;
}
+ }
if (!found)
return false;
}
diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverBundle.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverBundle.java
index f57bc03ee..5f66a27fe 100644
--- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverBundle.java
+++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverBundle.java
@@ -19,7 +19,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -161,23 +160,27 @@ public class ResolverBundle extends VersionSupplier implements Comparable<Resolv
void clearWires() {
ResolverImport[] allImports = getImportPackages();
- for (int i = 0; i < allImports.length; i++)
- allImports[i].clearPossibleSuppliers();
+ for (ResolverImport allImport : allImports) {
+ allImport.clearPossibleSuppliers();
+ }
if (host != null)
host.clearPossibleSuppliers();
BundleConstraint[] allRequires = getRequires();
- for (int i = 0; i < allRequires.length; i++)
- allRequires[i].clearPossibleSuppliers();
+ for (BundleConstraint allRequire : allRequires) {
+ allRequire.clearPossibleSuppliers();
+ }
GenericConstraint[] allGenericRequires = getGenericRequires();
- for (int i = 0; i < allGenericRequires.length; i++)
- allGenericRequires[i].clearPossibleSuppliers();
+ for (GenericConstraint allGenericRequire : allGenericRequires) {
+ allGenericRequire.clearPossibleSuppliers();
+ }
ResolverExport[] allExports = getExportPackages();
- for (int i = 0; i < allExports.length; i++)
- allExports[i].setSubstitute(null);
+ for (ResolverExport allExport : allExports) {
+ allExport.setSubstitute(null);
+ }
}
boolean isResolved() {
@@ -232,17 +235,20 @@ public class ResolverBundle extends VersionSupplier implements Comparable<Resolv
private ResolverExport[] getExports(boolean selected) {
ResolverExport[] results = getExportPackages();
int removedExports = 0;
- for (int i = 0; i < results.length; i++)
- if (selected ? results[i].getSubstitute() != null : results[i].getSubstitute() == null)
+ for (ResolverExport result : results) {
+ if (selected ? result.getSubstitute() != null : result.getSubstitute() == null) {
removedExports++;
+ }
+ }
if (removedExports == 0)
return results;
ResolverExport[] selectedExports = new ResolverExport[results.length - removedExports];
int index = 0;
- for (int i = 0; i < results.length; i++) {
- if (selected ? results[i].getSubstitute() != null : results[i].getSubstitute() == null)
+ for (ResolverExport result : results) {
+ if (selected ? result.getSubstitute() != null : result.getSubstitute() == null) {
continue;
- selectedExports[index] = results[i];
+ }
+ selectedExports[index] = result;
index++;
}
return selectedExports;
@@ -275,9 +281,11 @@ public class ResolverBundle extends VersionSupplier implements Comparable<Resolv
BundleConstraint getRequire(String name) {
BundleConstraint[] allRequires = getRequires();
- for (int i = 0; i < allRequires.length; i++)
- if (allRequires[i].getVersionConstraint().getName().equals(name))
- return allRequires[i];
+ for (BundleConstraint allRequire : allRequires) {
+ if (allRequire.getVersionConstraint().getName().equals(name)) {
+ return allRequire;
+ }
+ }
return null;
}
@@ -293,9 +301,9 @@ public class ResolverBundle extends VersionSupplier implements Comparable<Resolv
ResolverImport getImport(String name) {
ResolverImport[] allImports = getImportPackages();
- for (int i = 0; i < allImports.length; i++) {
- if (allImports[i].getName().equals(name)) {
- return allImports[i];
+ for (ResolverImport allImport : allImports) {
+ if (allImport.getName().equals(name)) {
+ return allImport;
}
}
return null;
@@ -323,9 +331,11 @@ public class ResolverBundle extends VersionSupplier implements Comparable<Resolv
private boolean isImported(String packageName) {
ResolverImport[] allImports = getImportPackages();
- for (int i = 0; i < allImports.length; i++)
- if (packageName.equals(allImports[i].getName()))
+ for (ResolverImport allImport : allImports) {
+ if (packageName.equals(allImport.getName())) {
return true;
+ }
+ }
return false;
}
@@ -355,10 +365,9 @@ public class ResolverBundle extends VersionSupplier implements Comparable<Resolv
fragment.setNewFragmentExports(true);
initFragments();
- // need to make sure there is not already another version of this fragment
+ // need to make sure there is not already another version of this fragment
// already attached to this host
- for (Iterator<ResolverBundle> iFragments = fragments.iterator(); iFragments.hasNext();) {
- ResolverBundle existingFragment = iFragments.next();
+ for (ResolverBundle existingFragment : fragments) {
String bsn = existingFragment.getName();
if (bsn != null && bsn.equals(fragment.getName()))
return;
@@ -370,26 +379,30 @@ public class ResolverBundle extends VersionSupplier implements Comparable<Resolv
if (newImports.length > 0) {
ArrayList<ResolverImport> hostImports = new ArrayList<>(newImports.length);
- for (int i = 0; i < newImports.length; i++)
- if (!isImported(newImports[i].getName()))
- hostImports.add(new ResolverImport(this, newImports[i]));
+ for (ImportPackageSpecification newImport : newImports) {
+ if (!isImported(newImport.getName())) {
+ hostImports.add(new ResolverImport(this, newImport));
+ }
+ }
fragmentImports.put(fragment.bundleID, hostImports);
}
if (newRequires.length > 0) {
ArrayList<BundleConstraint> hostRequires = new ArrayList<>(newRequires.length);
- for (int i = 0; i < newRequires.length; i++)
- if (!isRequired(newRequires[i].getName()))
- hostRequires.add(new BundleConstraint(this, newRequires[i]));
+ for (BundleSpecification newRequire : newRequires) {
+ if (!isRequired(newRequire.getName())) {
+ hostRequires.add(new BundleConstraint(this, newRequire));
+ }
+ }
fragmentRequires.put(fragment.bundleID, hostRequires);
}
if (newGenericRequires.length > 0) {
ArrayList<GenericConstraint> hostGenericRequires = new ArrayList<>(newGenericRequires.length);
- for (int i = 0; i < newGenericRequires.length; i++) {
+ for (GenericSpecification newGenericRequire : newGenericRequires) {
// only add namespaces that are not osgi.ee
- if (!StateImpl.OSGI_EE_NAMESPACE.equals(newGenericRequires[i].getType())) {
- hostGenericRequires.add(new GenericConstraint(this, newGenericRequires[i], resolver.isDevelopmentMode()));
+ if (!StateImpl.OSGI_EE_NAMESPACE.equals(newGenericRequire.getType())) {
+ hostGenericRequires.add(new GenericConstraint(this, newGenericRequire, resolver.isDevelopmentMode()));
}
}
if (!hostGenericRequires.isEmpty())
@@ -398,15 +411,16 @@ public class ResolverBundle extends VersionSupplier implements Comparable<Resolv
ArrayList<ResolverExport> hostExports = new ArrayList<>(newExports.length);
if (newExports.length > 0 && dynamicAttach) {
- for (int i = 0; i < newExports.length; i++) {
- ResolverExport currentExports[] = getExports(newExports[i].getName());
+ for (ExportPackageDescription newExport : newExports) {
+ ResolverExport[] currentExports = getExports(newExport.getName());
boolean foundEquivalent = false;
for (int j = 0; j < currentExports.length && !foundEquivalent; j++) {
- if (equivalentExports(currentExports[j], newExports[i]))
+ if (equivalentExports(currentExports[j], newExport)) {
foundEquivalent = true;
+ }
}
if (!foundEquivalent) {
- ExportPackageDescription hostExport = new ExportPackageDescriptionImpl(getBundleDescription(), newExports[i]);
+ ExportPackageDescription hostExport = new ExportPackageDescriptionImpl(getBundleDescription(), newExport);
hostExports.add(new ResolverExport(this, hostExport));
}
}
@@ -453,8 +467,7 @@ public class ResolverBundle extends VersionSupplier implements Comparable<Resolv
return false;
if (exactMatch && existingDirectives.size() != newDirectives.size())
return false;
- for (Iterator<Entry<String, Object>> entries = existingDirectives.entrySet().iterator(); entries.hasNext();) {
- Entry<String, Object> entry = entries.next();
+ for (Entry<String, Object> entry : existingDirectives.entrySet()) {
Object newValue = newDirectives.get(entry.getKey());
if (newValue == null || entry.getValue().getClass() != newValue.getClass())
return false;
@@ -473,20 +486,20 @@ public class ResolverBundle extends VersionSupplier implements Comparable<Resolv
// if the host is resolved then the fragment is not allowed to add new constraints;
// if the host is resolved and it already has a constraint of the same name then ensure the supplier satisfies the fragment's constraint
boolean result = false;
- for (int i = 0; i < newImports.length; i++) {
- ResolverImport hostImport = getImport(newImports[i].getName());
+ for (ImportPackageSpecification newImport : newImports) {
+ ResolverImport hostImport = getImport(newImport.getName());
ResolverExport resolvedExport = (ResolverExport) (hostImport == null ? null : hostImport.getSelectedSupplier());
- if (importPackageConflict(resolvedExport, newImports[i])) {
+ if (importPackageConflict(resolvedExport, newImport)) {
result = true;
- resolver.getState().addResolverError(fragment, ResolverError.FRAGMENT_CONFLICT, newImports[i].toString(), newImports[i]);
+ resolver.getState().addResolverError(fragment, ResolverError.FRAGMENT_CONFLICT, newImport.toString(), newImport);
}
}
- for (int i = 0; i < newRequires.length; i++) {
- BundleConstraint hostRequire = getRequire(newRequires[i].getName());
+ for (BundleSpecification newRequire : newRequires) {
+ BundleConstraint hostRequire = getRequire(newRequire.getName());
ResolverBundle resolvedRequire = (ResolverBundle) (hostRequire == null ? null : hostRequire.getSelectedSupplier());
- if ((resolvedRequire == null && isResolved()) || (resolvedRequire != null && !newRequires[i].isSatisfiedBy(resolvedRequire.getBundleDescription()))) {
+ if ((resolvedRequire == null && isResolved()) || (resolvedRequire != null && !newRequire.isSatisfiedBy(resolvedRequire.getBundleDescription()))) {
result = true;
- resolver.getState().addResolverError(fragment, ResolverError.FRAGMENT_CONFLICT, newRequires[i].toString(), newRequires[i]);
+ resolver.getState().addResolverError(fragment, ResolverError.FRAGMENT_CONFLICT, newRequire.toString(), newRequire);
}
}
// generic constraints cannot conflict;
@@ -586,9 +599,10 @@ public class ResolverBundle extends VersionSupplier implements Comparable<Resolv
}
}
ResolverExport[] results = removedExports == null ? new ResolverExport[0] : removedExports.toArray(new ResolverExport[removedExports.size()]);
- for (int i = 0; i < results.length; i++)
+ for (ResolverExport result : results) {
// TODO this is a hack; need to figure out how to indicate that a fragment export is no longer attached
- results[i].setSubstitute(results[i]);
+ result.setSubstitute(result);
+ }
resolver.getResolverExports().remove(results);
if (removedCapabilities != null)
resolver.removeGenerics(removedCapabilities.toArray(new GenericCapability[removedCapabilities.size()]));
@@ -602,31 +616,34 @@ public class ResolverBundle extends VersionSupplier implements Comparable<Resolv
constraints = remainingFragImports;
else
constraints = remainingFragRequires;
- for (int i = 0; i < constraints.length; i++)
- if (reason.getName().equals(constraints[i].getName())) {
+ for (VersionConstraint constraint : constraints) {
+ if (reason.getName().equals(constraint.getName())) {
detachFragment(remainingFragment, reason);
return true;
}
- for (int i = 0; i < oldImports.length; i++) {
- if (oldImports[i].getVersionConstraint().getBundle() != detachedFragment.getBundleDescription())
+ }
+ for (ResolverImport oldImport : oldImports) {
+ if (oldImport.getVersionConstraint().getBundle() != detachedFragment.getBundleDescription()) {
continue; // the constraint is not from the detached fragment
- for (int j = 0; j < remainingFragImports.length; j++) {
- if (oldImports[i].getName().equals(remainingFragImports[j].getName())) {
+ }
+ for (ImportPackageSpecification remainingFragImport : remainingFragImports) {
+ if (oldImport.getName().equals(remainingFragImport.getName())) {
// same constraint, must reuse the constraint object but swap out the fragment info
- additionalImports.add(oldImports[i]);
- oldImports[i].setVersionConstraint(remainingFragImports[j]);
+ additionalImports.add(oldImport);
+ oldImport.setVersionConstraint(remainingFragImport);
break;
}
}
}
- for (int i = 0; i < oldRequires.length; i++) {
- if (oldRequires[i].getVersionConstraint().getBundle() != detachedFragment.getBundleDescription())
+ for (BundleConstraint oldRequire : oldRequires) {
+ if (oldRequire.getVersionConstraint().getBundle() != detachedFragment.getBundleDescription()) {
continue; // the constraint is not from the detached fragment
- for (int j = 0; j < remainingFragRequires.length; j++) {
- if (oldRequires[i].getName().equals(remainingFragRequires[j].getName())) {
+ }
+ for (BundleSpecification remainingFragRequire : remainingFragRequires) {
+ if (oldRequire.getName().equals(remainingFragRequire.getName())) {
// same constraint, must reuse the constraint object but swap out the fragment info
- additionalRequires.add(oldRequires[i]);
- oldRequires[i].setVersionConstraint(remainingFragRequires[j]);
+ additionalRequires.add(oldRequire);
+ oldRequire.setVersionConstraint(remainingFragRequire);
break;
}
}
@@ -638,8 +655,9 @@ public class ResolverBundle extends VersionSupplier implements Comparable<Resolv
if (fragments == null)
return;
ResolverBundle[] allFragments = fragments.toArray(new ResolverBundle[fragments.size()]);
- for (int i = 0; i < allFragments.length; i++)
- detachFragment(allFragments[i], null);
+ for (ResolverBundle allFragment : allFragments) {
+ detachFragment(allFragment, null);
+ }
fragments = null;
}
diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverImpl.java
index 90e28d7f4..0ddf0183a 100644
--- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverImpl.java
+++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverImpl.java
@@ -131,18 +131,18 @@ public class ResolverImpl implements Resolver {
ArrayList<ResolverBundle> fragmentBundles = new ArrayList<>();
// Add each bundle to the resolver's internal state
- for (int i = 0; i < bundles.length; i++)
- initResolverBundle(bundles[i], fragmentBundles, false);
+ for (BundleDescription bundle : bundles) {
+ initResolverBundle(bundle, fragmentBundles, false);
+ }
// Add each removal pending bundle to the resolver's internal state
List<BundleDescription> removedBundles = removalPending.getAllValues();
for (BundleDescription removed : removedBundles)
initResolverBundle(removed, fragmentBundles, true);
// Iterate over the resolved fragments and attach them to their hosts
- for (Iterator<ResolverBundle> iter = fragmentBundles.iterator(); iter.hasNext();) {
- ResolverBundle fragment = iter.next();
+ for (ResolverBundle fragment : fragmentBundles) {
BundleDescription[] hosts = ((HostSpecification) fragment.getHost().getVersionConstraint()).getHosts();
- for (int i = 0; i < hosts.length; i++) {
- ResolverBundle host = bundleMapping.get(hosts[i]);
+ for (BundleDescription h : hosts) {
+ ResolverBundle host = bundleMapping.get(h);
if (host != null)
// Do not add fragment exports here because they would have been added by the host above.
host.attachFragment(fragment, false);
@@ -187,18 +187,19 @@ public class ResolverImpl implements Resolver {
visited.add(rb);
// Wire requires to bundles
BundleConstraint[] requires = rb.getRequires();
- for (int i = 0; i < requires.length; i++) {
- rewireRequire(requires[i], visited);
+ for (BundleConstraint require : requires) {
+ rewireRequire(require, visited);
}
// Wire imports to exports
ResolverImport[] imports = rb.getImportPackages();
- for (int i = 0; i < imports.length; i++) {
- rewireImport(imports[i], visited);
+ for (ResolverImport resolverImport : imports) {
+ rewireImport(resolverImport, visited);
}
// Wire generics
GenericConstraint[] genericRequires = rb.getGenericRequires();
- for (int i = 0; i < genericRequires.length; i++)
- rewireGeneric(genericRequires[i], visited);
+ for (GenericConstraint genericRequire : genericRequires) {
+ rewireGeneric(genericRequire, visited);
+ }
}
private void rewireGeneric(GenericConstraint constraint, List<ResolverBundle> visited) {
@@ -222,8 +223,9 @@ public class ResolverImpl implements Resolver {
}
VersionSupplier[] matchingCapabilities = constraint.getPossibleSuppliers();
if (matchingCapabilities != null)
- for (int i = 0; i < matchingCapabilities.length; i++)
- rewireBundle(matchingCapabilities[i].getResolverBundle(), visited);
+ for (VersionSupplier matchingCapability : matchingCapabilities) {
+ rewireBundle(matchingCapability.getResolverBundle(), visited);
+ }
}
private void rewireRequire(BundleConstraint req, List<ResolverBundle> visited) {
@@ -317,9 +319,11 @@ public class ResolverImpl implements Resolver {
if (nativeCode != null) {
NativeCodeDescription[] nativeCodeSuppliers = nativeCode.getPossibleSuppliers();
NativeCodeDescription highestRanked = null;
- for (int i = 0; i < nativeCodeSuppliers.length; i++)
- if (nativeCode.isSatisfiedBy(nativeCodeSuppliers[i]) && (highestRanked == null || highestRanked.compareTo(nativeCodeSuppliers[i]) < 0))
- highestRanked = nativeCodeSuppliers[i];
+ for (NativeCodeDescription nativeCodeSupplier : nativeCodeSuppliers) {
+ if (nativeCode.isSatisfiedBy(nativeCodeSupplier) && (highestRanked == null || highestRanked.compareTo(nativeCodeSupplier) < 0)) {
+ highestRanked = nativeCodeSupplier;
+ }
+ }
if (highestRanked == null) {
if (!nativeCode.isOptional()) {
state.addResolverError(bundleDesc, ResolverError.NO_NATIVECODE_MATCH, nativeCode.toString(), nativeCode);
@@ -342,10 +346,10 @@ public class ResolverImpl implements Resolver {
return false;
try {
Filter filter = FilterImpl.newInstance(platformFilter);
- for (int i = 0; i < platformProperties.length; i++) {
+ for (Dictionary<Object, Object> platformProperty : platformProperties) {
// using matchCase here in case of duplicate case invarient keys (bug 180817)
- @SuppressWarnings("rawtypes")
- Dictionary props = platformProperties[i];
+ @SuppressWarnings(value = "rawtypes")
+ Dictionary props = platformProperty;
if (filter.matchCase(props))
return true;
}
@@ -459,8 +463,8 @@ public class ResolverImpl implements Resolver {
reRefresh = addDevConstraints(reRefresh);
// Unresolve all the supplied bundles and their dependents
if (reRefresh != null)
- for (int i = 0; i < reRefresh.length; i++) {
- ResolverBundle rb = bundleMapping.get(reRefresh[i]);
+ for (BundleDescription description : reRefresh) {
+ ResolverBundle rb = bundleMapping.get(description);
if (rb != null)
unresolveBundle(rb, false);
}
@@ -588,10 +592,10 @@ public class ResolverImpl implements Resolver {
// when in develoment mode we need to reRefresh hosts of unresolved fragments that add new constraints
// and reRefresh and unresolved bundles that have dependents
Set<BundleDescription> additionalRefresh = new HashSet<>();
- ResolverBundle[] unresolved = unresolvedBundles.toArray(new ResolverBundle[unresolvedBundles.size()]);
- for (int i = 0; i < unresolved.length; i++) {
- addUnresolvedWithDependents(unresolved[i], additionalRefresh);
- addHostsFromFragmentConstraints(unresolved[i], additionalRefresh);
+ ResolverBundle[] allUnresolved = unresolvedBundles.toArray(new ResolverBundle[unresolvedBundles.size()]);
+ for (ResolverBundle unresolved : allUnresolved ) {
+ addUnresolvedWithDependents(unresolved, additionalRefresh);
+ addHostsFromFragmentConstraints(unresolved, additionalRefresh);
}
if (additionalRefresh.size() == 0)
return reRefresh; // no new bundles found to refresh
@@ -626,9 +630,9 @@ public class ResolverImpl implements Resolver {
private Collection<ResolverBundle> resolveOptionalConstraints(ResolverBundle[] bundles) {
Collection<ResolverBundle> result = new ArrayList<>();
- for (int i = 0; i < bundles.length; i++) {
- if (bundles[i] != null && resolveOptionalConstraints(bundles[i])) {
- result.add(bundles[i]);
+ for (ResolverBundle bundle : bundles) {
+ if (bundle != null && resolveOptionalConstraints(bundle)) {
+ result.add(bundle);
}
}
return result;
@@ -639,21 +643,25 @@ public class ResolverImpl implements Resolver {
BundleConstraint[] requires = bundle.getRequires();
List<ResolverBundle> cycle = new ArrayList<>();
boolean resolvedOptional = false;
- for (int i = 0; i < requires.length; i++)
- if (requires[i].isOptional() && requires[i].getSelectedSupplier() == null) {
+ for (BundleConstraint require : requires) {
+ if (require.isOptional() && require.getSelectedSupplier() == null) {
cycle.clear();
- resolveRequire(requires[i], cycle);
- if (requires[i].getSelectedSupplier() != null)
+ resolveRequire(require, cycle);
+ if (require.getSelectedSupplier() != null) {
resolvedOptional = true;
+ }
}
+ }
ResolverImport[] imports = bundle.getImportPackages();
- for (int i = 0; i < imports.length; i++)
- if (imports[i].isOptional() && imports[i].getSelectedSupplier() == null) {
+ for (ResolverImport resolverImport : imports) {
+ if (resolverImport.isOptional() && resolverImport.getSelectedSupplier() == null) {
cycle.clear();
- resolveImport(imports[i], cycle);
- if (imports[i].getSelectedSupplier() != null)
+ resolveImport(resolverImport, cycle);
+ if (resolverImport.getSelectedSupplier() != null) {
resolvedOptional = true;
+ }
}
+ }
return resolvedOptional;
}
@@ -796,17 +804,19 @@ public class ResolverImpl implements Resolver {
Arrays.sort(bundles);
// First attach all fragments to the matching hosts
Collection<String> processedFragments = new HashSet<>(bundles.length);
- for (int i = 0; i < bundles.length; i++)
- attachFragment(bundles[i], processedFragments);
+ for (ResolverBundle bundle : bundles) {
+ attachFragment(bundle, processedFragments);
+ }
// Lists of cyclic dependencies recording during resolving
List<ResolverBundle> cycle = new ArrayList<>(1); // start small
// Attempt to resolve all unresolved bundles
- for (int i = 0; i < bundles.length; i++) {
- if (DEBUG)
- ResolverImpl.log("** RESOLVING " + bundles[i] + " **"); //$NON-NLS-1$ //$NON-NLS-2$
+ for (ResolverBundle bundle : bundles) {
+ if (DEBUG) {
+ ResolverImpl.log("** RESOLVING " + bundle + " **"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
cycle.clear();
- resolveBundle(bundles[i], cycle);
+ resolveBundle(bundle, cycle);
// Check for any bundles involved in a cycle.
// if any bundles in the cycle are not resolved then we need to resolve the resolvable ones
checkCycle(cycle);
@@ -814,8 +824,9 @@ public class ResolverImpl implements Resolver {
// Resolve all fragments that are still attached to at least one host.
if (unresolvedBundles.size() > 0) {
ResolverBundle[] unresolved = unresolvedBundles.toArray(new ResolverBundle[unresolvedBundles.size()]);
- for (int i = 0; i < unresolved.length; i++)
- resolveFragment(unresolved[i]);
+ for (ResolverBundle toResolve : unresolved) {
+ resolveFragment(toResolve);
+ }
}
checkUsesConstraints(bundles, platformProperties);
checkComposites(bundles, platformProperties);
@@ -826,20 +837,21 @@ public class ResolverImpl implements Resolver {
if (helpers == null)
return;
Set<ResolverBundle> exclude = null;
- for (int i = 0; i < bundles.length; i++) {
- CompositeResolveHelper helper = helpers.getCompositeResolveHelper(bundles[i].getBundleDescription());
+ for (ResolverBundle bundle : bundles) {
+ CompositeResolveHelper helper = helpers.getCompositeResolveHelper(bundle.getBundleDescription());
if (helper == null)
continue;
- if (!bundles[i].isResolved())
+ if (!bundle.isResolved()) {
continue;
- if (!helper.giveExports(getExportsWiredTo(bundles[i], null))) {
- state.addResolverError(bundles[i].getBundleDescription(), ResolverError.DISABLED_BUNDLE, null, null);
- bundles[i].setResolvable(false);
+ }
+ if (!helper.giveExports(getExportsWiredTo(bundle, null))) {
+ state.addResolverError(bundle.getBundleDescription(), ResolverError.DISABLED_BUNDLE, null, null);
+ bundle.setResolvable(false);
// We pass false for keepFragmentsAttached because we need to redo the attachments (bug 272561)
- setBundleUnresolved(bundles[i], false, false);
+ setBundleUnresolved(bundle, false, false);
if (exclude == null)
exclude = new HashSet<>(1);
- exclude.add(bundles[i]);
+ exclude.add(bundle);
}
}
reResolveBundles(exclude, bundles, platformProperties);
@@ -880,11 +892,11 @@ public class ResolverImpl implements Resolver {
if (exclude == null || exclude.size() == 0)
return;
List<ResolverBundle> remainingUnresolved = new ArrayList<>();
- for (int i = 0; i < bundles.length; i++) {
- if (!exclude.contains(bundles[i])) {
+ for (ResolverBundle bundle : bundles) {
+ if (!exclude.contains(bundle)) {
// We pass false for keepFragmentsAttached because we need to redo the attachments (bug 272561)
- setBundleUnresolved(bundles[i], false, false);
- remainingUnresolved.add(bundles[i]);
+ setBundleUnresolved(bundle, false, false);
+ remainingUnresolved.add(bundle);
}
}
resolveBundles0(remainingUnresolved.toArray(new ResolverBundle[remainingUnresolved.size()]), platformProperties);
@@ -917,8 +929,7 @@ public class ResolverImpl implements Resolver {
printCombination(bestCombination);
}
for (int i = 0; i < bestCombination.length; i++) {
- for (int j = 0; j < multipleSuppliers[i].length; j++) {
- ResolverConstraint constraint = multipleSuppliers[i][j];
+ for (ResolverConstraint constraint : multipleSuppliers[i]) {
constraint.setSelectedSupplier(bestCombination[i]);
// sanity check to make sure we did not just get wired to our own dropped export
VersionSupplier selectedSupplier = constraint.getSelectedSupplier();
@@ -1043,8 +1054,9 @@ public class ResolverImpl implements Resolver {
multipleSuppliers[current][i].selectNextSupplier();
return true; // the current slot has a next supplier
}
- for (int i = 0; i < multipleSuppliers[current].length; i++)
- multipleSuppliers[current][i].setSelectedSupplier(0); // reset the current slot
+ for (ResolverConstraint multipleSupplier : multipleSuppliers[current]) {
+ multipleSupplier.setSelectedSupplier(0); // reset the current slot
+ }
current++; // move to the next slot
}
return false;
@@ -1064,40 +1076,39 @@ public class ResolverImpl implements Resolver {
private List<ResolverConstraint> getConflicts(ResolverBundle[] bundles, Set<String> packageConstraints, Set<String> bundleConstraints, Collection<GenericConstraint> multiRequirementWithMultiSuppliers) {
groupingChecker.clear();
List<ResolverConstraint> conflicts = null;
- for (int i = 0; i < bundles.length; i++)
- conflicts = addConflicts(bundles[i], packageConstraints, bundleConstraints, multiRequirementWithMultiSuppliers, conflicts);
+ for (ResolverBundle bundle : bundles) {
+ conflicts = addConflicts(bundle, packageConstraints, bundleConstraints, multiRequirementWithMultiSuppliers, conflicts);
+ }
return conflicts;
}
private List<ResolverConstraint> addConflicts(ResolverBundle bundle, Set<String> packageConstraints, Set<String> bundleConstraints, Collection<GenericConstraint> multiRequirementWithMultiSuppliers, List<ResolverConstraint> conflicts) {
BundleConstraint[] requires = bundle.getRequires();
- for (int i = 0; i < requires.length; i++) {
- ResolverBundle selectedSupplier = (ResolverBundle) requires[i].getSelectedSupplier();
+ for (BundleConstraint require : requires) {
+ ResolverBundle selectedSupplier = (ResolverBundle) require.getSelectedSupplier();
PackageRoots[][] conflict = selectedSupplier == null ? null : groupingChecker.isConsistent(bundle, selectedSupplier);
if (conflict != null) {
addConflictNames(conflict, packageConstraints, bundleConstraints);
-
- if (DEBUG_CONFLICTS)
- printConflict(conflict, requires[i], bundle);
-
+ if (DEBUG_CONFLICTS) {
+ printConflict(conflict, require, bundle);
+ }
if (conflicts == null)
conflicts = new ArrayList<>(1);
- conflicts.add(requires[i]);
+ conflicts.add(require);
}
}
ResolverImport[] imports = bundle.getImportPackages();
- for (int i = 0; i < imports.length; i++) {
- ResolverExport selectedSupplier = (ResolverExport) imports[i].getSelectedSupplier();
+ for (ResolverImport importConflict : imports) {
+ ResolverExport selectedSupplier = (ResolverExport) importConflict.getSelectedSupplier();
PackageRoots[][] conflict = selectedSupplier == null ? null : groupingChecker.isConsistent(bundle, selectedSupplier);
if (conflict != null) {
addConflictNames(conflict, packageConstraints, bundleConstraints);
-
- if (DEBUG_CONFLICTS)
- printConflict(conflict, imports[i], bundle);
-
+ if (DEBUG_CONFLICTS) {
+ printConflict(conflict, importConflict, bundle);
+ }
if (conflicts == null)
conflicts = new ArrayList<>(1);
- conflicts.add(imports[i]);
+ conflicts.add(importConflict);
}
}
@@ -1147,26 +1158,28 @@ public class ResolverImpl implements Resolver {
}
// records the conflict names we can use to scope down the list of multiple suppliers
- private void addConflictNames(PackageRoots[][] conflict, Set<String> packageConstraints, Set<String> bundleConstraints) {
+ private void addConflictNames(PackageRoots[][] conflicts, Set<String> packageConstraints, Set<String> bundleConstraints) {
if (packageConstraints == null || bundleConstraints == null)
return;
- for (int i = 0; i < conflict.length; i++) {
- packageConstraints.add(conflict[i][0].getName());
- packageConstraints.add(conflict[i][1].getName());
- ResolverExport[] exports0 = conflict[i][0].getRoots();
- if (exports0 != null)
- for (int j = 0; j < exports0.length; j++) {
- ResolverBundle exporter = exports0[j].getExporter();
+ for (PackageRoots[] conflict : conflicts) {
+ packageConstraints.add(conflict[0].getName());
+ packageConstraints.add(conflict[1].getName());
+ ResolverExport[] exports0 = conflict[0].getRoots();
+ if (exports0 != null) {
+ for (ResolverExport exportConflict : exports0) {
+ ResolverBundle exporter = exportConflict.getExporter();
if (exporter != null && exporter.getName() != null)
bundleConstraints.add(exporter.getName());
}
- ResolverExport[] exports1 = conflict[i][1].getRoots();
- if (exports1 != null)
- for (int j = 0; j < exports1.length; j++) {
- ResolverBundle exporter = exports1[j].getExporter();
+ }
+ ResolverExport[] exports1 = conflict[1].getRoots();
+ if (exports1 != null) {
+ for (ResolverExport exportConflict : exports1) {
+ ResolverBundle exporter = exportConflict.getExporter();
if (exporter != null && exporter.getName() != null)
bundleConstraints.add(exporter.getName());
}
+ }
}
}
@@ -1313,18 +1326,19 @@ public class ResolverImpl implements Resolver {
}
// Check that we haven't wired to any dropped exports
ResolverImport[] imports = cycleBundle.getImportPackages();
- for (int j = 0; j < imports.length; j++) {
+ for (ResolverImport resolverImport : imports) {
// check for dropped exports
- while (imports[j].getSelectedSupplier() != null) {
- ResolverExport importSupplier = (ResolverExport) imports[j].getSelectedSupplier();
- if (importSupplier.getSubstitute() != null)
- imports[j].selectNextSupplier();
- else
+ while (resolverImport.getSelectedSupplier() != null) {
+ ResolverExport importSupplier = (ResolverExport) resolverImport.getSelectedSupplier();
+ if (importSupplier.getSubstitute() != null) {
+ resolverImport.selectNextSupplier();
+ } else {
break;
+ }
}
- if (!imports[j].isDynamic() && !imports[j].isOptional() && imports[j].getSelectedSupplier() == null) {
+ if (!resolverImport.isDynamic() && !resolverImport.isOptional() && resolverImport.getSelectedSupplier() == null) {
cycleBundle.setResolvable(false);
- state.addResolverError(imports[j].getVersionConstraint().getBundle(), ResolverError.MISSING_IMPORT_PACKAGE, imports[j].getVersionConstraint().toString(), imports[j].getVersionConstraint());
+ state.addResolverError(resolverImport.getVersionConstraint().getBundle(), ResolverError.MISSING_IMPORT_PACKAGE, resolverImport.getVersionConstraint().toString(), resolverImport.getVersionConstraint());
iCycle.remove();
continue cycleLoop;
}
@@ -1394,15 +1408,17 @@ public class ResolverImpl implements Resolver {
if (!failed) {
GenericConstraint[] genericRequires = bundle.getGenericRequires();
- for (int i = 0; i < genericRequires.length; i++) {
- if (genericRequires[i].isEffective()) {
- if (!resolveGenericReq(genericRequires[i], cycle)) {
- if (DEBUG || DEBUG_GENERICS)
- ResolverImpl.log("** GENERICS " + genericRequires[i].getVersionConstraint().getName() + "[" + genericRequires[i].getBundleDescription() + "] failed to resolve"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- state.addResolverError(genericRequires[i].getVersionConstraint().getBundle(), ResolverError.MISSING_GENERIC_CAPABILITY, genericRequires[i].getVersionConstraint().toString(), genericRequires[i].getVersionConstraint());
- if (genericRequires[i].isFromFragment()) {
- if (!developmentMode) // only detach fragments when not in devmode
- bundle.detachFragment(bundleMapping.get(genericRequires[i].getVersionConstraint().getBundle()), null);
+ for (GenericConstraint genericRequire : genericRequires) {
+ if (genericRequire.isEffective()) {
+ if (!resolveGenericReq(genericRequire, cycle)) {
+ if (DEBUG || DEBUG_GENERICS) {
+ ResolverImpl.log("** GENERICS " + genericRequire.getVersionConstraint().getName() + "[" + genericRequire.getBundleDescription() + "] failed to resolve"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ state.addResolverError(genericRequire.getVersionConstraint().getBundle(), ResolverError.MISSING_GENERIC_CAPABILITY, genericRequire.getVersionConstraint().toString(), genericRequire.getVersionConstraint());
+ if (genericRequire.isFromFragment()) {
+ if (!developmentMode) { // only detach fragments when not in devmode
+ bundle.detachFragment(bundleMapping.get(genericRequire.getVersionConstraint().getBundle()), null);
+ }
continue;
}
if (!developmentMode) {
@@ -1411,8 +1427,8 @@ public class ResolverImpl implements Resolver {
break;
}
} else {
- if (StateImpl.OSGI_EE_NAMESPACE.equals(genericRequires[i].getNameSpace())) {
- VersionSupplier supplier = genericRequires[i].getSelectedSupplier();
+ if (StateImpl.OSGI_EE_NAMESPACE.equals(genericRequire.getNameSpace())) {
+ VersionSupplier supplier = genericRequire.getSelectedSupplier();
Integer ee = supplier == null ? null : (Integer) ((GenericDescription) supplier.getBaseDescription()).getAttributes().get(ExportPackageDescriptionImpl.EQUINOX_EE);
if (ee != null && ((BundleDescriptionImpl) bundle.getBaseDescription()).getEquinoxEE() < 0)
((BundleDescriptionImpl) bundle.getBundleDescription()).setEquinoxEE(ee);
@@ -1425,15 +1441,17 @@ public class ResolverImpl implements Resolver {
if (!failed) {
// Iterate thru required bundles of 'bundle' trying to find matching bundles.
BundleConstraint[] requires = bundle.getRequires();
- for (int i = 0; i < requires.length; i++) {
- if (!resolveRequire(requires[i], cycle)) {
- if (DEBUG || DEBUG_REQUIRES)
- ResolverImpl.log("** REQUIRE " + requires[i].getVersionConstraint().getName() + "[" + requires[i].getBundleDescription() + "] failed to resolve"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- state.addResolverError(requires[i].getVersionConstraint().getBundle(), ResolverError.MISSING_REQUIRE_BUNDLE, requires[i].getVersionConstraint().toString(), requires[i].getVersionConstraint());
+ for (BundleConstraint require : requires) {
+ if (!resolveRequire(require, cycle)) {
+ if (DEBUG || DEBUG_REQUIRES) {
+ ResolverImpl.log("** REQUIRE " + require.getVersionConstraint().getName() + "[" + require.getBundleDescription() + "] failed to resolve"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ state.addResolverError(require.getVersionConstraint().getBundle(), ResolverError.MISSING_REQUIRE_BUNDLE, require.getVersionConstraint().toString(), require.getVersionConstraint());
// If the require has failed to resolve and it is from a fragment, then remove the fragment from the host
- if (requires[i].isFromFragment()) {
- if (!developmentMode) // only detach fragments when not in devmode
- bundle.detachFragment(bundleMapping.get(requires[i].getVersionConstraint().getBundle()), requires[i]);
+ if (require.isFromFragment()) {
+ if (!developmentMode) { // only detach fragments when not in devmode
+ bundle.detachFragment(bundleMapping.get(require.getVersionConstraint().getBundle()), require);
+ }
continue;
}
if (!developmentMode) {
@@ -1448,16 +1466,18 @@ public class ResolverImpl implements Resolver {
if (!failed) {
// Iterate thru imports of 'bundle' trying to find matching exports.
ResolverImport[] imports = bundle.getImportPackages();
- for (int i = 0; i < imports.length; i++) {
+ for (ResolverImport resolverImport : imports) {
// Only resolve non-dynamic imports here
- if (!imports[i].isDynamic() && !resolveImport(imports[i], cycle)) {
- if (DEBUG || DEBUG_IMPORTS)
- ResolverImpl.log("** IMPORT " + imports[i].getName() + "[" + imports[i].getBundleDescription() + "] failed to resolve"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ if (!resolverImport.isDynamic() && !resolveImport(resolverImport, cycle)) {
+ if (DEBUG || DEBUG_IMPORTS) {
+ ResolverImpl.log("** IMPORT " + resolverImport.getName() + "[" + resolverImport.getBundleDescription() + "] failed to resolve"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
// If the import has failed to resolve and it is from a fragment, then remove the fragment from the host
- state.addResolverError(imports[i].getVersionConstraint().getBundle(), ResolverError.MISSING_IMPORT_PACKAGE, imports[i].getVersionConstraint().toString(), imports[i].getVersionConstraint());
- if (imports[i].isFromFragment()) {
- if (!developmentMode) // only detach fragments when not in devmode
- bundle.detachFragment(bundleMapping.get(imports[i].getVersionConstraint().getBundle()), imports[i]);
+ state.addResolverError(resolverImport.getVersionConstraint().getBundle(), ResolverError.MISSING_IMPORT_PACKAGE, resolverImport.getVersionConstraint().toString(), resolverImport.getVersionConstraint());
+ if (resolverImport.isFromFragment()) {
+ if (!developmentMode) { // only detach fragments when not in devmode
+ bundle.detachFragment(bundleMapping.get(resolverImport.getVersionConstraint().getBundle()), resolverImport);
+ }
continue;
}
if (!developmentMode) {
@@ -1498,11 +1518,12 @@ public class ResolverImpl implements Resolver {
// get all currently attached fragments and ensure that any constraints
// they have do not conflict with the constraints resolved to by the host
ResolverBundle[] fragments = bundle.getFragments();
- for (int i = 0; i < fragments.length; i++) {
- BundleDescription fragment = fragments[i].getBundleDescription();
- if (bundle.constraintsConflict(fragment, fragment.getImportPackages(), fragment.getRequiredBundles(), fragment.getGenericRequires()) && !developmentMode)
+ for (ResolverBundle resolverFragment : fragments) {
+ BundleDescription fragment = resolverFragment.getBundleDescription();
+ if (bundle.constraintsConflict(fragment, fragment.getImportPackages(), fragment.getRequiredBundles(), fragment.getGenericRequires()) && !developmentMode) {
// found some conflicts; detach the fragment
- bundle.detachFragment(fragments[i], null);
+ bundle.detachFragment(resolverFragment, null);
+ }
}
}
@@ -1712,18 +1733,22 @@ public class ResolverImpl implements Resolver {
// first add the possible supplier; this is done before resolving the supplier bundle to prevent endless cycle loops.
imp.addPossibleSupplier(export);
if (imp.getBundle() != export.getExporter()) {
- for (int j = 0; j < substitutableExps.length; j++)
- if (substitutableExps[j].getSubstitute() == null)
- substitutableExps[j].setSubstitute(export); // Import wins, drop export
+ for (ResolverExport substitutableExp : substitutableExps) {
+ if (substitutableExp.getSubstitute() == null) {
+ substitutableExp.setSubstitute(export); // Import wins, drop export
+ }
+ }
// if in dev mode then allow a constraint to resolve to an unresolved bundle
if ((originalState != ResolverBundle.RESOLVED && !resolveBundle(export.getExporter(), cycle) && !developmentMode) || export.getSubstitute() != null) {
// remove the possible supplier
imp.removePossibleSupplier(export);
// add back the exports of this package from the importer
if (imp.getSelectedSupplier() == null)
- for (int j = 0; j < substitutableExps.length; j++)
- if (substitutableExps[j].getSubstitute() == export)
- substitutableExps[j].setSubstitute(null);
+ for (ResolverExport substitutableExp : substitutableExps) {
+ if (substitutableExp.getSubstitute() == export) {
+ substitutableExp.setSubstitute(null);
+ }
+ }
continue; // Bundle hasn't resolved || export has not been selected and is unavailable
}
} else if (export.getSubstitute() != null)
@@ -1797,60 +1822,65 @@ public class ResolverImpl implements Resolver {
// Resolves the bundles in the State
private void stateResolveBundles(ResolverBundle[] resolvedBundles) {
- for (int i = 0; i < resolvedBundles.length; i++) {
- if (!resolvedBundles[i].getBundleDescription().isResolved())
- stateResolveBundle(resolvedBundles[i]);
+ for (ResolverBundle resolvedBundle : resolvedBundles) {
+ if (!resolvedBundle.getBundleDescription().isResolved()) {
+ stateResolveBundle(resolvedBundle);
+ }
}
}
private void stateResolveConstraints(ResolverBundle rb) {
ResolverImport[] imports = rb.getImportPackages();
- for (int i = 0; i < imports.length; i++) {
- ResolverExport export = (ResolverExport) imports[i].getSelectedSupplier();
+ for (ResolverImport resolverImport : imports) {
+ ResolverExport export = (ResolverExport) resolverImport.getSelectedSupplier();
BaseDescription supplier = export == null ? null : export.getExportPackageDescription();
- state.resolveConstraint(imports[i].getVersionConstraint(), supplier);
+ state.resolveConstraint(resolverImport.getVersionConstraint(), supplier);
}
BundleConstraint[] requires = rb.getRequires();
- for (int i = 0; i < requires.length; i++) {
- ResolverBundle bundle = (ResolverBundle) requires[i].getSelectedSupplier();
+ for (BundleConstraint require : requires) {
+ ResolverBundle bundle = (ResolverBundle) require.getSelectedSupplier();
BaseDescription supplier = bundle == null ? null : bundle.getBundleDescription();
- state.resolveConstraint(requires[i].getVersionConstraint(), supplier);
+ state.resolveConstraint(require.getVersionConstraint(), supplier);
}
GenericConstraint[] genericRequires = rb.getGenericRequires();
- for (int i = 0; i < genericRequires.length; i++) {
- VersionSupplier[] matchingCapabilities = genericRequires[i].getMatchingCapabilities();
- if (matchingCapabilities == null)
- state.resolveConstraint(genericRequires[i].getVersionConstraint(), null);
- else
- for (int j = 0; j < matchingCapabilities.length; j++)
- state.resolveConstraint(genericRequires[i].getVersionConstraint(), matchingCapabilities[j].getBaseDescription());
+ for (GenericConstraint genericRequire : genericRequires) {
+ VersionSupplier[] matchingCapabilities = genericRequire.getMatchingCapabilities();
+ if (matchingCapabilities == null) {
+ state.resolveConstraint(genericRequire.getVersionConstraint(), null);
+ } else {
+ for (VersionSupplier matchingCapability : matchingCapabilities) {
+ state.resolveConstraint(genericRequire.getVersionConstraint(), matchingCapability.getBaseDescription());
+ }
+ }
}
}
private void stateResolveFragConstraints(ResolverBundle rb) {
ResolverBundle host = (ResolverBundle) rb.getHost().getSelectedSupplier();
ImportPackageSpecification[] imports = rb.getBundleDescription().getImportPackages();
- for (int i = 0; i < imports.length; i++) {
- ResolverImport hostImport = host == null ? null : host.getImport(imports[i].getName());
+ for (ImportPackageSpecification importSpecification : imports) {
+ ResolverImport hostImport = host == null ? null : host.getImport(importSpecification.getName());
ResolverExport export = (ResolverExport) (hostImport == null ? null : hostImport.getSelectedSupplier());
BaseDescription supplier = export == null ? null : export.getExportPackageDescription();
- state.resolveConstraint(imports[i], supplier);
+ state.resolveConstraint(importSpecification, supplier);
}
BundleSpecification[] requires = rb.getBundleDescription().getRequiredBundles();
- for (int i = 0; i < requires.length; i++) {
- BundleConstraint hostRequire = host == null ? null : host.getRequire(requires[i].getName());
+ for (BundleSpecification require : requires) {
+ BundleConstraint hostRequire = host == null ? null : host.getRequire(require.getName());
ResolverBundle bundle = (ResolverBundle) (hostRequire == null ? null : hostRequire.getSelectedSupplier());
BaseDescription supplier = bundle == null ? null : bundle.getBundleDescription();
- state.resolveConstraint(requires[i], supplier);
+ state.resolveConstraint(require, supplier);
}
GenericConstraint[] genericRequires = rb.getGenericRequires();
- for (int i = 0; i < genericRequires.length; i++) {
- VersionSupplier[] matchingCapabilities = genericRequires[i].getMatchingCapabilities();
- if (matchingCapabilities == null)
- state.resolveConstraint(genericRequires[i].getVersionConstraint(), null);
- else
- for (int j = 0; j < matchingCapabilities.length; j++)
- state.resolveConstraint(genericRequires[i].getVersionConstraint(), matchingCapabilities[j].getBaseDescription());
+ for (GenericConstraint genericRequire : genericRequires) {
+ VersionSupplier[] matchingCapabilities = genericRequire.getMatchingCapabilities();
+ if (matchingCapabilities == null) {
+ state.resolveConstraint(genericRequire.getVersionConstraint(), null);
+ } else {
+ for (VersionSupplier matchingCapability : matchingCapabilities) {
+ state.resolveConstraint(genericRequire.getVersionConstraint(), matchingCapability.getBaseDescription());
+ }
+ }
}
}
@@ -1869,17 +1899,18 @@ public class ResolverImpl implements Resolver {
// Gather selected exports
ResolverExport[] exports = rb.getSelectedExports();
List<ExportPackageDescription> selectedExports = new ArrayList<>(exports.length);
- for (int i = 0; i < exports.length; i++) {
- if (permissionChecker.checkPackagePermission(exports[i].getExportPackageDescription()))
- selectedExports.add(exports[i].getExportPackageDescription());
+ for (ResolverExport export : exports) {
+ if (permissionChecker.checkPackagePermission(export.getExportPackageDescription())) {
+ selectedExports.add(export.getExportPackageDescription());
+ }
}
ExportPackageDescription[] selectedExportsArray = selectedExports.toArray(new ExportPackageDescription[selectedExports.size()]);
// Gather substitute exports
ResolverExport[] substituted = rb.getSubstitutedExports();
List<ExportPackageDescription> substitutedExports = new ArrayList<>(substituted.length);
- for (int i = 0; i < substituted.length; i++) {
- substitutedExports.add(substituted[i].getExportPackageDescription());
+ for (ResolverExport substitutedExport : substituted) {
+ substitutedExports.add(substitutedExport.getExportPackageDescription());
}
ExportPackageDescription[] substitutedExportsArray = substitutedExports.toArray(new ExportPackageDescription[substitutedExports.size()]);
@@ -1890,13 +1921,14 @@ public class ResolverImpl implements Resolver {
BundleConstraint[] requires = rb.getRequires();
List<BundleDescription> bundlesWiredTo = new ArrayList<>(requires.length);
List<StateWire> requireWires = new ArrayList<>(requires.length);
- for (int i = 0; i < requires.length; i++)
- if (requires[i].getSelectedSupplier() != null) {
- BundleDescription supplier = (BundleDescription) requires[i].getSelectedSupplier().getBaseDescription();
+ for (BundleConstraint require : requires) {
+ if (require.getSelectedSupplier() != null) {
+ BundleDescription supplier = (BundleDescription) require.getSelectedSupplier().getBaseDescription();
bundlesWiredTo.add(supplier);
- StateWire requireWire = newStateWire(rb.getBundleDescription(), requires[i].getVersionConstraint(), supplier, supplier);
+ StateWire requireWire = newStateWire(rb.getBundleDescription(), require.getVersionConstraint(), supplier, supplier);
requireWires.add(requireWire);
}
+ }
BundleDescription[] bundlesWiredToArray = bundlesWiredTo.toArray(new BundleDescription[bundlesWiredTo.size()]);
if (!requireWires.isEmpty())
stateWires.put(BundleRevision.BUNDLE_NAMESPACE, requireWires);
@@ -1976,13 +2008,14 @@ public class ResolverImpl implements Resolver {
ResolverImport[] imports = rb.getImportPackages();
List<ExportPackageDescription> exportsWiredTo = new ArrayList<>(imports.length);
List<StateWire> importWires = new ArrayList<>(imports.length);
- for (int i = 0; i < imports.length; i++)
- if (imports[i].getSelectedSupplier() != null) {
- ExportPackageDescription supplier = (ExportPackageDescription) imports[i].getSelectedSupplier().getBaseDescription();
+ for (ResolverImport resolverImport : imports) {
+ if (resolverImport.getSelectedSupplier() != null) {
+ ExportPackageDescription supplier = (ExportPackageDescription) resolverImport.getSelectedSupplier().getBaseDescription();
exportsWiredTo.add(supplier);
- StateWire wire = newStateWire(rb.getBundleDescription(), imports[i].getVersionConstraint(), supplier.getExporter(), supplier);
+ StateWire wire = newStateWire(rb.getBundleDescription(), resolverImport.getVersionConstraint(), supplier.getExporter(), supplier);
importWires.add(wire);
}
+ }
if (stateWires != null && !importWires.isEmpty())
stateWires.put(BundleRevision.PACKAGE_NAMESPACE, importWires);
return exportsWiredTo.toArray(new ExportPackageDescription[exportsWiredTo.size()]);
@@ -2010,12 +2043,13 @@ public class ResolverImpl implements Resolver {
ResolverImport[] resolverImports = rb.getImportPackages();
// Check through the ResolverImports of this bundle.
// If there is a matching one then pass it into resolveImport()
- for (int j = 0; j < resolverImports.length; j++) {
+ for (ResolverImport resolverImport : resolverImports) {
// Make sure it is a dynamic import
- if (!resolverImports[j].isDynamic())
+ if (!resolverImport.isDynamic()) {
continue;
+ }
// Resolve the import
- ExportPackageDescription supplier = resolveDynamicImport(resolverImports[j], requestedPackage);
+ ExportPackageDescription supplier = resolveDynamicImport(resolverImport, requestedPackage);
if (supplier != null)
return supplier;
}
@@ -2173,8 +2207,8 @@ public class ResolverImpl implements Resolver {
BundleDescription[] dependents = bundle.getBundleDescription().getDependents();
state.resolveBundle(bundle.getBundleDescription(), false, null, null, null, null, null, null, null, null);
// Unresolve dependents of 'bundle'
- for (int i = 0; i < dependents.length; i++) {
- ResolverBundle db = bundleMapping.get(dependents[i]);
+ for (BundleDescription dependent : dependents) {
+ ResolverBundle db = bundleMapping.get(dependent);
if (db == null) {
continue;
}
@@ -2255,11 +2289,11 @@ public class ResolverImpl implements Resolver {
if (requireBundles.length == 0) {
ResolverImpl.log(" (r) no requires"); //$NON-NLS-1$
} else {
- for (int i = 0; i < requireBundles.length; i++) {
- if (requireBundles[i].getSelectedSupplier() == null) {
+ for (BundleConstraint requireBundle : requireBundles) {
+ if (requireBundle.getSelectedSupplier() == null) {
ResolverImpl.log(" (r) " + rb.getBundleDescription() + " -> NULL!!!"); //$NON-NLS-1$ //$NON-NLS-2$
} else {
- ResolverImpl.log(" (r) " + rb.getBundleDescription() + " -> " + requireBundles[i].getSelectedSupplier()); //$NON-NLS-1$ //$NON-NLS-2$
+ ResolverImpl.log(" (r) " + rb.getBundleDescription() + " -> " + requireBundle.getSelectedSupplier()); //$NON-NLS-1$ //$NON-NLS-2$
}
}
}
@@ -2268,8 +2302,8 @@ public class ResolverImpl implements Resolver {
if (hostSpec != null) {
VersionSupplier[] hosts = hostSpec.getPossibleSuppliers();
if (hosts != null)
- for (int i = 0; i < hosts.length; i++) {
- ResolverImpl.log(" (h) " + rb.getBundleDescription() + " -> " + hosts[i].getBundleDescription()); //$NON-NLS-1$ //$NON-NLS-2$
+ for (VersionSupplier host : hosts) {
+ ResolverImpl.log(" (h) " + rb.getBundleDescription() + " -> " + host.getBundleDescription()); //$NON-NLS-1$ //$NON-NLS-2$
}
}
// Imports
@@ -2278,16 +2312,16 @@ public class ResolverImpl implements Resolver {
ResolverImpl.log(" (w) no imports"); //$NON-NLS-1$
continue;
}
- for (int i = 0; i < imports.length; i++) {
- if (imports[i].isDynamic() && imports[i].getSelectedSupplier() == null) {
- ResolverImpl.log(" (w) " + imports[i].getBundle() + ":" + imports[i].getName() + " -> DYNAMIC"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- } else if (imports[i].isOptional() && imports[i].getSelectedSupplier() == null) {
- ResolverImpl.log(" (w) " + imports[i].getBundle() + ":" + imports[i].getName() + " -> OPTIONAL (could not be wired)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- } else if (imports[i].getSelectedSupplier() == null) {
- ResolverImpl.log(" (w) " + imports[i].getBundle() + ":" + imports[i].getName() + " -> NULL!!!"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ for (ResolverImport resolverImport : imports) {
+ if (resolverImport.isDynamic() && resolverImport.getSelectedSupplier() == null) {
+ ResolverImpl.log(" (w) " + resolverImport.getBundle() + ":" + resolverImport.getName() + " -> DYNAMIC"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ } else if (resolverImport.isOptional() && resolverImport.getSelectedSupplier() == null) {
+ ResolverImpl.log(" (w) " + resolverImport.getBundle() + ":" + resolverImport.getName() + " -> OPTIONAL (could not be wired)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ } else if (resolverImport.getSelectedSupplier() == null) {
+ ResolverImpl.log(" (w) " + resolverImport.getBundle() + ":" + resolverImport.getName() + " -> NULL!!!"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
} else {
- ResolverImpl.log(" (w) " + imports[i].getBundle() + ":" + imports[i].getName() + " -> " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- ((ResolverExport) imports[i].getSelectedSupplier()).getExporter() + ":" + imports[i].getSelectedSupplier().getName()); //$NON-NLS-1$
+ ResolverImpl.log(" (w) " + resolverImport.getBundle() + ":" + resolverImport.getName() + " -> " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ ((ResolverExport) resolverImport.getSelectedSupplier()).getExporter() + ":" + resolverImport.getSelectedSupplier().getName()); //$NON-NLS-1$
}
}
}
diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/VersionHashMap.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/VersionHashMap.java
index 7e698e790..0bd09aa7b 100644
--- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/VersionHashMap.java
+++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/VersionHashMap.java
@@ -44,8 +44,9 @@ public class VersionHashMap<V extends VersionSupplier> extends MappedList<String
}
public void put(V[] versionSuppliers) {
- for (int i = 0; i < versionSuppliers.length; i++)
- put(versionSuppliers[i].getName(), versionSuppliers[i]);
+ for (V versionSupplier : versionSuppliers) {
+ put(versionSupplier.getName(), versionSupplier);
+ }
}
public boolean contains(V vs) {
@@ -73,15 +74,15 @@ public class VersionHashMap<V extends VersionSupplier> extends MappedList<String
}
public void remove(V[] versionSuppliers) {
- for (int i = 0; i < versionSuppliers.length; i++)
- remove(versionSuppliers[i]);
+ for (V versionSupplier : versionSuppliers) {
+ remove(versionSupplier);
+ }
}
// Once we have resolved bundles, we need to make sure that version suppliers
// from the resolved bundles are ahead of those from unresolved bundles
void reorder() {
- for (Iterator<List<V>> it = internal.values().iterator(); it.hasNext();) {
- List<V> existing = it.next();
+ for (List<V> existing : internal.values()) {
if (existing.size() > 1)
Collections.sort(existing, this);
}
diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/BundleDescriptionImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/BundleDescriptionImpl.java
index e23e41686..93053366d 100644
--- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/BundleDescriptionImpl.java
+++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/BundleDescriptionImpl.java
@@ -308,8 +308,8 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements
checkLazyData();
lazyData.exportPackages = exportPackages;
if (exportPackages != null) {
- for (int i = 0; i < exportPackages.length; i++) {
- ((ExportPackageDescriptionImpl) exportPackages[i]).setExporter(this);
+ for (ExportPackageDescription exportPackage : exportPackages) {
+ ((ExportPackageDescriptionImpl) exportPackage).setExporter(this);
}
}
}
@@ -320,10 +320,11 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements
checkLazyData();
lazyData.importPackages = importPackages;
if (importPackages != null) {
- for (int i = 0; i < importPackages.length; i++) {
- ((ImportPackageSpecificationImpl) importPackages[i]).setBundle(this);
- if (ImportPackageSpecification.RESOLUTION_DYNAMIC.equals(importPackages[i].getDirective(Constants.RESOLUTION_DIRECTIVE)))
+ for (ImportPackageSpecification importPackage : importPackages) {
+ ((ImportPackageSpecificationImpl) importPackage).setBundle(this);
+ if (ImportPackageSpecification.RESOLUTION_DYNAMIC.equals(importPackage.getDirective(Constants.RESOLUTION_DIRECTIVE))) {
stateBits |= HAS_DYNAMICIMPORT;
+ }
}
}
}
@@ -334,8 +335,8 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements
checkLazyData();
lazyData.requiredBundles = requiredBundles;
if (requiredBundles != null)
- for (int i = 0; i < requiredBundles.length; i++) {
- ((VersionConstraintImpl) requiredBundles[i]).setBundle(this);
+ for (BundleSpecification requiredBundle : requiredBundles) {
+ ((VersionConstraintImpl) requiredBundle).setBundle(this);
}
}
}
@@ -345,8 +346,9 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements
checkLazyData();
lazyData.genericCapabilities = genericCapabilities;
if (genericCapabilities != null)
- for (int i = 0; i < genericCapabilities.length; i++)
- ((GenericDescriptionImpl) genericCapabilities[i]).setSupplier(this);
+ for (GenericDescription genericCapability : genericCapabilities) {
+ ((GenericDescriptionImpl) genericCapability).setSupplier(this);
+ }
}
}
@@ -355,8 +357,9 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements
checkLazyData();
lazyData.genericRequires = genericRequires;
if (genericRequires != null)
- for (int i = 0; i < genericRequires.length; i++)
- ((VersionConstraintImpl) genericRequires[i]).setBundle(this);
+ for (GenericSpecification genericRequire : genericRequires) {
+ ((VersionConstraintImpl) genericRequire).setBundle(this);
+ }
}
}
@@ -368,8 +371,9 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements
((NativeCodeSpecificationImpl) nativeCode).setBundle(this);
NativeCodeDescription[] suppliers = nativeCode.getPossibleSuppliers();
if (suppliers != null)
- for (int i = 0; i < suppliers.length; i++)
- ((NativeCodeDescriptionImpl) suppliers[i]).setSupplier(this);
+ for (NativeCodeDescription supplier : suppliers) {
+ ((NativeCodeDescriptionImpl) supplier).setSupplier(this);
+ }
}
}
}
@@ -431,8 +435,8 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements
checkLazyData();
lazyData.selectedExports = selectedExports;
if (selectedExports != null) {
- for (int i = 0; i < selectedExports.length; i++) {
- ((ExportPackageDescriptionImpl) selectedExports[i]).setExporter(this);
+ for (ExportPackageDescription selectedExport : selectedExports) {
+ ((ExportPackageDescriptionImpl) selectedExport).setExporter(this);
}
}
}
@@ -540,8 +544,8 @@ public final class BundleDescriptionImpl extends BaseDescriptionImpl implements
return;
if (!checkDups && dependencies == null)
dependencies = new ArrayList<>(newDependencies.length);
- for (int i = 0; i < newDependencies.length; i++) {
- addDependency((BaseDescriptionImpl) newDependencies[i], checkDups);
+ for (BaseDescription newDependency : newDependencies) {
+ addDependency((BaseDescriptionImpl) newDependency, checkDups);
}
}
}
diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/ImportPackageSpecificationImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/ImportPackageSpecificationImpl.java
index adce58611..30e190832 100644
--- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/ImportPackageSpecificationImpl.java
+++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/ImportPackageSpecificationImpl.java
@@ -120,9 +120,11 @@ public class ImportPackageSpecificationImpl extends VersionConstraintImpl implem
return false;
boolean found = false;
if (friends != null && getBundle().getSymbolicName() != null)
- for (int i = 0; i < friends.length; i++)
- if (getBundle().getSymbolicName().equals(friends[i]))
+ for (String friend : friends) {
+ if (getBundle().getSymbolicName().equals(friend)) {
found = true;
+ }
+ }
if (!found)
return false;
}
@@ -149,8 +151,7 @@ public class ImportPackageSpecificationImpl extends VersionConstraintImpl implem
Map<String, ?> exportAttrs = pkgDes.getAttributes();
if (exportAttrs == null)
return false;
- for (Iterator<String> i = importAttrs.keySet().iterator(); i.hasNext();) {
- String importKey = i.next();
+ for (String importKey : importAttrs.keySet()) {
Object importValue = importAttrs.get(importKey);
Object exportValue = exportAttrs.get(importKey);
if (exportValue == null || !importValue.equals(exportValue))
@@ -170,24 +171,25 @@ public class ImportPackageSpecificationImpl extends VersionConstraintImpl implem
}
@Override
- protected boolean hasMandatoryAttributes(String[] mandatory) {
- if (mandatory != null) {
+ protected boolean hasMandatoryAttributes(String[] checkMandatory) {
+ if (checkMandatory != null) {
Map<String, ?> importAttrs = getAttributes();
- for (int i = 0; i < mandatory.length; i++) {
- if (Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE.equals(mandatory[i])) {
+ for (String mandatory : checkMandatory) {
+ if (Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE.equals(mandatory)) {
if (getBundleSymbolicName() == null)
return false;
- } else if (Constants.BUNDLE_VERSION_ATTRIBUTE.equals(mandatory[i])) {
+ } else if (Constants.BUNDLE_VERSION_ATTRIBUTE.equals(mandatory)) {
if (bundleVersionRange == null)
return false;
- } else if (Constants.PACKAGE_SPECIFICATION_VERSION.equals(mandatory[i]) || Constants.VERSION_ATTRIBUTE.equals(mandatory[i])) {
+ } else if (Constants.PACKAGE_SPECIFICATION_VERSION.equals(mandatory) || Constants.VERSION_ATTRIBUTE.equals(mandatory)) {
if (getVersionRange() == null)
return false;
} else { // arbitrary attribute
if (importAttrs == null)
return false;
- if (importAttrs.get(mandatory[i]) == null)
+ if (importAttrs.get(mandatory) == null) {
return false;
+ }
}
}
}
diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/NativeCodeDescriptionImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/NativeCodeDescriptionImpl.java
index dbc32a8a5..91f51be7b 100644
--- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/NativeCodeDescriptionImpl.java
+++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/NativeCodeDescriptionImpl.java
@@ -106,9 +106,10 @@ public class NativeCodeDescriptionImpl extends BaseDescriptionImpl implements Na
private Version getHighestVersionMatch(Version version, VersionRange[] ranges) {
Version highest = Version.emptyVersion;
- for (int i = 0; i < ranges.length; i++) {
- if (ranges[i].isIncluded(version) && highest.compareTo(ranges[i].getMinimum()) < 0)
- highest = ranges[i].getMinimum();
+ for (VersionRange range : ranges) {
+ if (range.isIncluded(version) && highest.compareTo(range.getMinimum()) < 0) {
+ highest = range.getMinimum();
+ }
}
return highest;
}
@@ -126,36 +127,36 @@ public class NativeCodeDescriptionImpl extends BaseDescriptionImpl implements Na
}
String[] procs = getProcessors();
- for (int i = 0; i < procs.length; i++) {
+ for (String proc : procs) {
sb.append("; "); //$NON-NLS-1$
sb.append(Constants.BUNDLE_NATIVECODE_PROCESSOR);
sb.append('=');
- sb.append(procs[i]);
+ sb.append(proc);
}
String[] oses = getOSNames();
- for (int i = 0; i < oses.length; i++) {
+ for (String os : oses) {
sb.append("; "); //$NON-NLS-1$
sb.append(Constants.BUNDLE_NATIVECODE_OSNAME);
sb.append('=');
- sb.append(oses[i]);
+ sb.append(os);
}
VersionRange[] osRanges = getOSVersions();
- for (int i = 0; i < osRanges.length; i++) {
+ for (VersionRange osRange : osRanges) {
sb.append("; "); //$NON-NLS-1$
sb.append(Constants.BUNDLE_NATIVECODE_OSVERSION);
sb.append("=\""); //$NON-NLS-1$
- sb.append(osRanges[i].toString());
+ sb.append(osRange.toString());
sb.append('"');
}
String[] langs = getLanguages();
- for (int i = 0; i < langs.length; i++) {
+ for (String lang : langs) {
sb.append("; "); //$NON-NLS-1$
sb.append(Constants.BUNDLE_NATIVECODE_LANGUAGE);
sb.append('=');
- sb.append(langs[i]);
+ sb.append(lang);
}
Filter f = getFilter();
diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateBuilder.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateBuilder.java
index a269baecb..b96a7ae8b 100644
--- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateBuilder.java
+++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateBuilder.java
@@ -160,17 +160,17 @@ public class StateBuilder {
List<ManifestElement> aliasList = null;
if (genericAliases.length > 0) {
aliasList = new ArrayList<>(genericRequires == null ? 0 : genericRequires.length);
- for (int i = 0; i < genericAliases.length; i++) {
- ManifestElement[] aliasReqs = ManifestElement.parseHeader(genericAliases[i][1], manifest.get(genericAliases[i][1]));
+ for (String[] genericAlias : genericAliases) {
+ ManifestElement[] aliasReqs = ManifestElement.parseHeader(genericAlias[1], manifest.get(genericAlias[1]));
if (aliasReqs == null)
continue;
- for (int j = 0; j < aliasReqs.length; j++) {
+ for (ManifestElement aliasReq : aliasReqs) {
StringBuffer strBuf = new StringBuffer();
- strBuf.append(aliasReqs[j].getValue()).append(':').append(genericAliases[i][2]);
- String filter = aliasReqs[j].getAttribute(Constants.SELECTION_FILTER_ATTRIBUTE);
+ strBuf.append(aliasReq.getValue()).append(':').append(genericAlias[2]);
+ String filter = aliasReq.getAttribute(Constants.SELECTION_FILTER_ATTRIBUTE);
if (filter != null)
strBuf.append("; ").append(Constants.SELECTION_FILTER_ATTRIBUTE).append(filter).append("=\"").append(filter).append("\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- ManifestElement[] withType = ManifestElement.parseHeader(genericAliases[i][1], strBuf.toString());
+ ManifestElement[] withType = ManifestElement.parseHeader(genericAlias[1], strBuf.toString());
aliasList.add(withType[0]);
}
}
@@ -187,18 +187,18 @@ public class StateBuilder {
List<ManifestElement> aliasList = null;
if (genericAliases.length > 0) {
aliasList = new ArrayList<>(genericCapabilities == null ? 0 : genericCapabilities.length);
- for (int i = 0; i < genericAliases.length; i++) {
- ManifestElement[] aliasCapabilities = ManifestElement.parseHeader(genericAliases[i][0], manifest.get(genericAliases[i][0]));
+ for (String[] genericAlias : genericAliases) {
+ ManifestElement[] aliasCapabilities = ManifestElement.parseHeader(genericAlias[0], manifest.get(genericAlias[0]));
if (aliasCapabilities == null)
continue;
- for (int j = 0; j < aliasCapabilities.length; j++) {
+ for (ManifestElement aliasCapability : aliasCapabilities) {
StringBuffer strBuf = new StringBuffer();
- strBuf.append(aliasCapabilities[j].getValue()).append(':').append(genericAliases[i][2]);
- for (Enumeration<String> keys = aliasCapabilities[j].getKeys(); keys != null && keys.hasMoreElements();) {
+ strBuf.append(aliasCapability.getValue()).append(':').append(genericAlias[2]);
+ for (Enumeration<String> keys = aliasCapability.getKeys(); keys != null && keys.hasMoreElements();) {
String key = keys.nextElement();
- strBuf.append("; ").append(key).append("=\"").append(aliasCapabilities[j].getAttribute(key)).append("\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ strBuf.append("; ").append(key).append("=\"").append(aliasCapability.getAttribute(key)).append("\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
- ManifestElement[] withTypes = ManifestElement.parseHeader(genericAliases[i][0], strBuf.toString());
+ ManifestElement[] withTypes = ManifestElement.parseHeader(genericAlias[0], strBuf.toString());
aliasList.add(withTypes[0]);
}
}
@@ -227,20 +227,24 @@ public class StateBuilder {
}
private static void validateHeaders(Dictionary<String, String> manifest, boolean jreBundle) 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, jreBundle);
- if (DEFINED_OSGI_VALIDATE_HEADERS[i] == Constants.DYNAMICIMPORT_PACKAGE)
- checkImportExportSyntax(DEFINED_OSGI_VALIDATE_HEADERS[i], elements, false, true, jreBundle);
- if (DEFINED_OSGI_VALIDATE_HEADERS[i] == Constants.EXPORT_PACKAGE)
- checkImportExportSyntax(DEFINED_OSGI_VALIDATE_HEADERS[i], elements, true, false, jreBundle);
- if (DEFINED_OSGI_VALIDATE_HEADERS[i] == Constants.FRAGMENT_HOST)
- checkExtensionBundle(DEFINED_OSGI_VALIDATE_HEADERS[i], elements);
- } 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, jreBundle);
+ }
+ if (definedOSGiValidateHeader == Constants.DYNAMICIMPORT_PACKAGE) {
+ checkImportExportSyntax(definedOSGiValidateHeader, elements, false, true, jreBundle);
+ }
+ if (definedOSGiValidateHeader == Constants.EXPORT_PACKAGE) {
+ checkImportExportSyntax(definedOSGiValidateHeader, elements, true, false, jreBundle);
+ }
+ if (definedOSGiValidateHeader == Constants.FRAGMENT_HOST) {
+ checkExtensionBundle(definedOSGiValidateHeader, elements);
+ }
+ } else if (definedOSGiValidateHeader == Constants.BUNDLE_SYMBOLICNAME) {
throw new BundleException(NLS.bind(StateMsg.HEADER_REQUIRED, Constants.BUNDLE_SYMBOLICNAME), BundleException.MANIFEST_ERROR);
}
}
@@ -273,12 +277,13 @@ public class StateBuilder {
if (exported.length == 0 && imported == null && dynamicImported == null)
return null;
allImports = new ArrayList<>(exported.length + (imported == null ? 0 : imported.length));
- for (int i = 0; i < exported.length; i++) {
- if (providedExports.contains(exported[i].getName()))
+ for (ExportPackageDescription exportDescription : exported) {
+ if (providedExports.contains(exportDescription.getName())) {
continue;
+ }
ImportPackageSpecificationImpl result = new ImportPackageSpecificationImpl();
- result.setName(exported[i].getName());
- result.setVersionRange(getVersionRange(exported[i].getVersion().toString()));
+ result.setName(exportDescription.getName());
+ result.setVersionRange(getVersionRange(exportDescription.getVersion().toString()));
result.setDirective(Constants.RESOLUTION_DIRECTIVE, ImportPackageSpecification.RESOLUTION_STATIC);
allImports.add(result);
}
@@ -289,27 +294,30 @@ public class StateBuilder {
// add dynamics first so they will get overriden by static imports if
// the same package is dyanamically imported and statically imported.
if (dynamicImported != null)
- for (int i = 0; i < dynamicImported.length; i++)
- addImportPackages(dynamicImported[i], allImports, manifestVersion, true);
+ for (ManifestElement dynamicImport : dynamicImported) {
+ addImportPackages(dynamicImport, allImports, manifestVersion, true);
+ }
if (imported != null)
- for (int i = 0; i < imported.length; i++)
- addImportPackages(imported[i], allImports, manifestVersion, false);
+ for (ManifestElement pkgImport : imported) {
+ addImportPackages(pkgImport, allImports, manifestVersion, false);
+ }
return allImports.toArray(new ImportPackageSpecification[allImports.size()]);
}
public static void addImportPackages(ManifestElement importPackage, List<ImportPackageSpecification> allImports, int manifestVersion, boolean dynamic) {
String[] importNames = importPackage.getValueComponents();
- for (int i = 0; i < importNames.length; i++) {
+ for (String importName : importNames) {
// do not allow for multiple imports of same package of manifest version < 2
if (manifestVersion < 2) {
Iterator<ImportPackageSpecification> iter = allImports.iterator();
- while (iter.hasNext())
- if (importNames[i].equals(iter.next().getName()))
+ while (iter.hasNext()) {
+ if (importName.equals(iter.next().getName())) {
iter.remove();
+ }
+ }
}
-
ImportPackageSpecificationImpl result = new ImportPackageSpecificationImpl();
- result.setName(importNames[i]);
+ result.setName(importName);
// set common attributes for both dynamic and static imports
String versionString = importPackage.getAttribute(Constants.VERSION_ATTRIBUTE);
if (versionString == null) // specification-version aliases to version
@@ -320,13 +328,11 @@ public class StateBuilder {
// only set the matching attributes if manifest version >= 2
if (manifestVersion >= 2)
result.setAttributes(getAttributes(importPackage, DEFINED_PACKAGE_MATCHING_ATTRS));
-
if (dynamic)
result.setDirective(Constants.RESOLUTION_DIRECTIVE, ImportPackageSpecification.RESOLUTION_DYNAMIC);
else
result.setDirective(Constants.RESOLUTION_DIRECTIVE, getResolution(importPackage.getDirective(Constants.RESOLUTION_DIRECTIVE)));
result.setArbitraryDirectives(getDirectives(importPackage, DEFINED_IMPORT_PACKAGE_DIRECTIVES));
-
allImports.add(result);
}
}
@@ -344,8 +350,9 @@ public class StateBuilder {
return null;
List<ExportPackageDescription> allExports = new ArrayList<>(numExports);
if (exported != null)
- for (int i = 0; i < exported.length; i++)
- addExportPackages(exported[i], allExports, strict);
+ for (ManifestElement packageExport : exported) {
+ addExportPackages(packageExport, allExports, strict);
+ }
if (provides != null)
addProvidePackages(provides, allExports, providedExports);
return allExports.toArray(new ExportPackageDescription[allExports.size()]);
@@ -353,12 +360,12 @@ public class StateBuilder {
static void addExportPackages(ManifestElement exportPackage, List<ExportPackageDescription> allExports, boolean strict) {
String[] exportNames = exportPackage.getValueComponents();
- for (int i = 0; i < exportNames.length; i++) {
+ for (String exportName : exportNames) {
// if we are in strict mode and the package is marked as internal, skip it.
if (strict && "true".equals(exportPackage.getDirective(StateImpl.INTERNAL_DIRECTIVE))) //$NON-NLS-1$
continue;
ExportPackageDescriptionImpl result = new ExportPackageDescriptionImpl();
- result.setName(exportNames[i]);
+ result.setName(exportName);
String versionString = exportPackage.getAttribute(Constants.VERSION_ATTRIBUTE);
if (versionString == null) // specification-version aliases to version
versionString = exportPackage.getAttribute(Constants.PACKAGE_SPECIFICATION_VERSION);
@@ -378,19 +385,20 @@ public class StateBuilder {
private static void addProvidePackages(ManifestElement[] provides, List<ExportPackageDescription> allExports, List<String> providedExports) {
ExportPackageDescription[] currentExports = allExports.toArray(new ExportPackageDescription[allExports.size()]);
- for (int i = 0; i < provides.length; i++) {
+ for (ManifestElement provide : provides) {
boolean duplicate = false;
- for (int j = 0; j < currentExports.length; j++)
- if (provides[i].getValue().equals(currentExports[j].getName())) {
+ for (ExportPackageDescription currentExport : currentExports) {
+ if (provide.getValue().equals(currentExport.getName())) {
duplicate = true;
break;
}
+ }
if (!duplicate) {
ExportPackageDescriptionImpl result = new ExportPackageDescriptionImpl();
- result.setName(provides[i].getValue());
+ result.setName(provide.getValue());
allExports.add(result);
}
- providedExports.add(provides[i].getValue());
+ providedExports.add(provide.getValue());
}
}
@@ -420,8 +428,8 @@ public class StateBuilder {
while (keys.hasMoreElements()) {
boolean definedAttr = false;
String key = keys.nextElement();
- for (int i = 0; i < definedAttrs.length; i++) {
- if (definedAttrs[i].equals(key)) {
+ for (String attr : definedAttrs) {
+ if (attr.equals(key)) {
definedAttr = true;
break;
}
@@ -670,24 +678,25 @@ public class StateBuilder {
if (equinoxRequires == null)
return null;
ArrayList<GenericSpecification> results = new ArrayList<>(equinoxRequires.length);
- for (int i = 0; i < equinoxRequires.length; i++) {
- String[] genericNames = equinoxRequires[i].getValueComponents();
- for (int j = 0; j < genericNames.length; j++) {
+ for (ManifestElement equinoxRequire : equinoxRequires) {
+ String[] genericNames = equinoxRequire.getValueComponents();
+ for (String genericName : genericNames) {
GenericSpecificationImpl spec = new GenericSpecificationImpl();
- int colonIdx = genericNames[j].indexOf(':');
+ int colonIdx = genericName.indexOf(':');
if (colonIdx > 0) {
- spec.setName(genericNames[j].substring(0, colonIdx));
- spec.setType(genericNames[j].substring(colonIdx + 1));
- } else
- spec.setName(genericNames[j]);
+ spec.setName(genericName.substring(0, colonIdx));
+ spec.setType(genericName.substring(colonIdx + 1));
+ } else {
+ spec.setName(genericName);
+ }
try {
- spec.setMatchingFilter(equinoxRequires[i].getAttribute(Constants.SELECTION_FILTER_ATTRIBUTE), true);
+ spec.setMatchingFilter(equinoxRequire.getAttribute(Constants.SELECTION_FILTER_ATTRIBUTE), true);
} catch (InvalidSyntaxException e) {
- String message = NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, GENERIC_REQUIRE, equinoxRequires[i].toString());
+ String message = NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, GENERIC_REQUIRE, equinoxRequire.toString());
throw new BundleException(message + " : " + Constants.SELECTION_FILTER_ATTRIBUTE, BundleException.MANIFEST_ERROR, e); //$NON-NLS-1$
}
- String optional = equinoxRequires[i].getAttribute(OPTIONAL_ATTR);
- String multiple = equinoxRequires[i].getAttribute(MULTIPLE_ATTR);
+ String optional = equinoxRequire.getAttribute(OPTIONAL_ATTR);
+ String multiple = equinoxRequire.getAttribute(MULTIPLE_ATTR);
int resolution = 0;
if (TRUE.equals(optional))
resolution |= GenericSpecification.RESOLUTION_OPTIONAL;
@@ -754,22 +763,22 @@ public class StateBuilder {
if (equinoxCapabilities == null)
return null;
ArrayList<GenericDescription> results = new ArrayList<>(equinoxCapabilities.length);
- for (int i = 0; i < equinoxCapabilities.length; i++) {
- String[] genericNames = equinoxCapabilities[i].getValueComponents();
- for (int j = 0; j < genericNames.length; j++) {
+ for (ManifestElement equinoxCapability : equinoxCapabilities) {
+ String[] genericNames = equinoxCapability.getValueComponents();
+ for (String genericName : genericNames) {
GenericDescriptionImpl desc = new GenericDescriptionImpl();
- String name = genericNames[j];
- int colonIdx = genericNames[j].indexOf(':');
+ String name = genericName;
+ int colonIdx = genericName.indexOf(':');
if (colonIdx > 0) {
- name = genericNames[j].substring(0, colonIdx);
- desc.setType(genericNames[j].substring(colonIdx + 1));
+ name = genericName.substring(0, colonIdx);
+ desc.setType(genericName.substring(colonIdx + 1));
if (IdentityNamespace.IDENTITY_NAMESPACE.equals(desc.getType()))
throw new BundleException("A bundle is not allowed to define a capability in the " + IdentityNamespace.IDENTITY_NAMESPACE + " name space."); //$NON-NLS-1$ //$NON-NLS-2$
}
- Map<String, Object> mapAttrs = getAttributes(equinoxCapabilities[i], new String[] {Constants.VERSION_ATTRIBUTE});
+ Map<String, Object> mapAttrs = getAttributes(equinoxCapability, new String[] {Constants.VERSION_ATTRIBUTE});
Dictionary<String, Object> attrs = mapAttrs == null ? new Hashtable<String, Object>() : new Hashtable<>(mapAttrs);
attrs.put(desc.getType(), name);
- String versionString = equinoxCapabilities[i].getAttribute(Constants.VERSION_ATTRIBUTE);
+ String versionString = equinoxCapability.getAttribute(Constants.VERSION_ATTRIBUTE);
if (versionString != null)
attrs.put(Constants.VERSION_ATTRIBUTE, Version.parseVersion(versionString));
desc.setAttributes(attrs);
@@ -837,17 +846,17 @@ public class StateBuilder {
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(StateMsg.HEADER_PACKAGE_DUPLICATES, packageNames[j]), BundleException.MANIFEST_ERROR); //$NON-NLS-1$
+ throw new BundleException(message + " : " + NLS.bind(StateMsg.HEADER_PACKAGE_DUPLICATES, packageName), BundleException.MANIFEST_ERROR); //$NON-NLS-1$
}
// check for java.*
- if (export && !jreBundle && packageNames[j].startsWith("java.")) { //$NON-NLS-1$
+ if (export && !jreBundle && 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(StateMsg.HEADER_PACKAGE_JAVA, packageNames[j]), BundleException.MANIFEST_ERROR); //$NON-NLS-1$
+ throw new BundleException(message + " : " + NLS.bind(StateMsg.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);
@@ -873,25 +882,25 @@ public class StateBuilder {
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 + " : " + StateMsg.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(StateMsg.HEADER_ATTRIBUTE_DUPLICATES, key), BundleException.MANIFEST_ERROR); //$NON-NLS-1$
}
}
diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateHelperImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateHelperImpl.java
index bb46caa5f..dcd27ff74 100644
--- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateHelperImpl.java
+++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateHelperImpl.java
@@ -41,10 +41,11 @@ public final class StateHelperImpl implements StateHelper {
return new BundleDescription[0];
Set<BundleDescription> reachable = new LinkedHashSet<>(bundles.length);
- for (int i = 0; i < bundles.length; i++) {
- if (!bundles[i].isResolved())
+ for (BundleDescription bundle : bundles) {
+ if (!bundle.isResolved()) {
continue;
- addDependentBundles(bundles[i], reachable);
+ }
+ addDependentBundles(bundle, reachable);
}
return reachable.toArray(new BundleDescription[reachable.size()]);
}
@@ -54,16 +55,18 @@ public final class StateHelperImpl implements StateHelper {
return;
reachable.add(bundle);
BundleDescription[] dependents = bundle.getDependents();
- for (int i = 0; i < dependents.length; i++)
- addDependentBundles(dependents[i], reachable);
+ for (BundleDescription dependent : dependents) {
+ addDependentBundles(dependent, reachable);
+ }
}
public BundleDescription[] getPrerequisites(BundleDescription[] bundles) {
if (bundles == null || bundles.length == 0)
return new BundleDescription[0];
Set<BundleDescription> reachable = new LinkedHashSet<>(bundles.length);
- for (int i = 0; i < bundles.length; i++)
- addPrerequisites(bundles[i], reachable);
+ for (BundleDescription bundle : bundles) {
+ addPrerequisites(bundle, reachable);
+ }
return reachable.toArray(new BundleDescription[reachable.size()]);
}
@@ -73,17 +76,17 @@ public final class StateHelperImpl implements StateHelper {
reachable.add(bundle);
List<BundleDescription> depList = ((BundleDescriptionImpl) bundle).getBundleDependencies();
BundleDescription[] dependencies = depList.toArray(new BundleDescription[depList.size()]);
- for (int i = 0; i < dependencies.length; i++)
- addPrerequisites(dependencies[i], reachable);
+ for (BundleDescription dependency : dependencies) {
+ addPrerequisites(dependency, reachable);
+ }
}
private Map<String, List<ExportPackageDescription>> getExportedPackageMap(State state) {
Map<String, List<ExportPackageDescription>> result = new HashMap<>();
BundleDescription[] bundles = state.getBundles();
- for (int i = 0; i < bundles.length; i++) {
- ExportPackageDescription[] packages = bundles[i].getExportPackages();
- for (int j = 0; j < packages.length; j++) {
- ExportPackageDescription description = packages[j];
+ for (BundleDescription bundle : bundles) {
+ ExportPackageDescription[] packages = bundle.getExportPackages();
+ for (ExportPackageDescription description : packages) {
List<ExportPackageDescription> exports = result.get(description.getName());
if (exports == null) {
exports = new ArrayList<>();
@@ -98,12 +101,12 @@ public final class StateHelperImpl implements StateHelper {
private Map<String, List<GenericDescription>> getGenericsMap(State state, boolean resolved) {
Map<String, List<GenericDescription>> result = new HashMap<>();
BundleDescription[] bundles = state.getBundles();
- for (int i = 0; i < bundles.length; i++) {
- if (resolved && !bundles[i].isResolved())
+ for (BundleDescription bundle : bundles) {
+ if (resolved && !bundle.isResolved()) {
continue; // discard unresolved bundles
- GenericDescription[] generics = bundles[i].getGenericCapabilities();
- for (int j = 0; j < generics.length; j++) {
- GenericDescription description = generics[j];
+ }
+ GenericDescription[] generics = bundle.getGenericCapabilities();
+ for (GenericDescription description : generics) {
List<GenericDescription> genericList = result.get(description.getName());
if (genericList == null) {
genericList = new ArrayList<>(1);
@@ -124,8 +127,7 @@ public final class StateHelperImpl implements StateHelper {
for (int i = 0; i < bundleList.size(); i++) {
BundleDescription description = bundleList.get(i);
VersionConstraint[] constraints = getUnsatisfiedConstraints(description, hook);
- for (int j = 0; j < constraints.length; j++) {
- VersionConstraint constraint = constraints[j];
+ for (VersionConstraint constraint : constraints) {
Collection<BaseDescription> satisfied = null;
if (constraint instanceof BundleSpecification || constraint instanceof HostSpecification) {
BundleDescription[] suppliers = state.getBundles(constraint.getName());
@@ -201,25 +203,31 @@ public final class StateHelperImpl implements StateHelper {
if (!host.isResolved() && !isBundleConstraintResolvable(host, BundleRevision.HOST_NAMESPACE, hook))
unsatisfied.add(host);
BundleSpecification[] requiredBundles = bundle.getRequiredBundles();
- for (int i = 0; i < requiredBundles.length; i++)
- if (!requiredBundles[i].isResolved() && !isBundleConstraintResolvable(requiredBundles[i], null, hook))
- unsatisfied.add(requiredBundles[i]);
+ for (BundleSpecification requiredBundle : requiredBundles) {
+ if (!requiredBundle.isResolved() && !isBundleConstraintResolvable(requiredBundle, null, hook)) {
+ unsatisfied.add(requiredBundle);
+ }
+ }
ImportPackageSpecification[] packages = bundle.getImportPackages();
- for (int i = 0; i < packages.length; i++)
- if (!packages[i].isResolved() && !isResolvable(packages[i], hook)) {
+ for (ImportPackageSpecification importSpecification : packages) {
+ if (!importSpecification.isResolved() && !isResolvable(importSpecification, hook)) {
if (bundle.isResolved()) {
// if the bundle is resolved the check if the import is option.
// Here we assume that an unresolved mandatory import must have been dropped
// in favor of an export from the same bundle (bug 338240)
- if (!ImportPackageSpecification.RESOLUTION_OPTIONAL.equals(packages[i].getDirective(Constants.RESOLUTION_DIRECTIVE)))
+ if (!ImportPackageSpecification.RESOLUTION_OPTIONAL.equals(importSpecification.getDirective(Constants.RESOLUTION_DIRECTIVE))) {
continue;
+ }
}
- unsatisfied.add(packages[i]);
+ unsatisfied.add(importSpecification);
}
+ }
GenericSpecification[] generics = bundle.getGenericRequires();
- for (int i = 0; i < generics.length; i++)
- if (!generics[i].isResolved() && !isResolvable(generics[i], hook))
- unsatisfied.add(generics[i]);
+ for (GenericSpecification generic : generics) {
+ if (!generic.isResolved() && !isResolvable(generic, hook)) {
+ unsatisfied.add(generic);
+ }
+ }
NativeCodeSpecification nativeCode = bundle.getNativeCodeSpecification();
if (nativeCode != null && !nativeCode.isResolved())
unsatisfied.add(nativeCode);
@@ -235,9 +243,11 @@ public final class StateHelperImpl implements StateHelper {
private List<BaseDescription> getPossibleCandidates(VersionConstraint constraint, BaseDescription[] descriptions, String namespace, ResolverHook hook, boolean resolved) {
List<BaseDescription> candidates = new ArrayList<>();
- for (int i = 0; i < descriptions.length; i++)
- if ((!resolved || descriptions[i].getSupplier().isResolved()) && constraint.isSatisfiedBy(descriptions[i]))
- candidates.add(descriptions[i]);
+ for (BaseDescription description : descriptions) {
+ if ((!resolved || description.getSupplier().isResolved()) && constraint.isSatisfiedBy(description)) {
+ candidates.add(description);
+ }
+ }
if (hook != null)
hook.filterMatches(constraint.getRequirement(), asArrayMap(candidates, namespace));
return candidates;
@@ -303,16 +313,18 @@ public final class StateHelperImpl implements StateHelper {
public Object[][] sortBundles(BundleDescription[] toSort) {
List<Object[]> references = new ArrayList<>(toSort.length);
- for (int i = 0; i < toSort.length; i++)
- if (toSort[i].isResolved())
- buildReferences(toSort[i], references);
+ for (BundleDescription toAddReference : toSort) {
+ if (toAddReference.isResolved()) {
+ buildReferences(toAddReference, references);
+ }
+ }
Object[][] cycles = ComputeNodeOrder.computeNodeOrder(toSort, references.toArray(new Object[references.size()][]));
if (cycles.length == 0)
return cycles;
// fix up host/fragment orders (bug 184127)
- for (int i = 0; i < cycles.length; i++) {
- for (int j = 0; j < cycles[i].length; j++) {
- BundleDescription fragment = (BundleDescription) cycles[i][j];
+ for (Object[] cycle : cycles) {
+ for (Object possibleFragment : cycle) {
+ BundleDescription fragment = (BundleDescription) possibleFragment;
if (fragment.getHost() == null)
continue;
BundleDescription host = (BundleDescription) fragment.getHost().getSupplier();
@@ -341,15 +353,17 @@ public final class StateHelperImpl implements StateHelper {
}
private void buildReferences(BundleDescription description, List<Object[]> references) {
- HostSpecification host = description.getHost();
+ HostSpecification hostSpecification = description.getHost();
// it is a fragment
- if (host != null) {
+ if (hostSpecification != null) {
// just create a dependencies for non-payload requirements (osgi.wiring.host and osgi.ee)
- if (host.getHosts() != null) {
- BundleDescription[] hosts = host.getHosts();
- for (int i = 0; i < hosts.length; i++)
- if (hosts[i] != description)
- references.add(new Object[] {description, hosts[i]});
+ if (hostSpecification.getHosts() != null) {
+ BundleDescription[] hosts = hostSpecification.getHosts();
+ for (BundleDescription host : hosts) {
+ if (host != description) {
+ references.add(new Object[]{description, host});
+ }
+ }
}
GenericDescription[] genericDependencies = description.getResolvedGenericRequires();
for (GenericDescription dependency : genericDependencies) {
@@ -373,11 +387,12 @@ public final class StateHelperImpl implements StateHelper {
if (description == reference || reference == null)
return;
BundleDescription[] fragments = reference.getFragments();
- for (int i = 0; i < fragments.length; i++) {
- if (fragments[i].isResolved()) {
- ExportPackageDescription[] exports = fragments[i].getExportPackages();
- if (exports.length > 0)
- references.add(new Object[] {description, fragments[i]});
+ for (BundleDescription fragment : fragments) {
+ if (fragment.isResolved()) {
+ ExportPackageDescription[] exports = fragment.getExportPackages();
+ if (exports.length > 0) {
+ references.add(new Object[]{description, fragment});
+ }
}
}
references.add(new Object[] {description, reference});
@@ -412,8 +427,8 @@ public final class StateHelperImpl implements StateHelper {
visited.add(bundle); // always add self to prevent recursing into self
Set<String> importNames = new HashSet<>(1);
importNames.add(imports.getName(i));
- for (int j = 0; j < requires.length; j++) {
- BundleDescription bundleSupplier = (BundleDescription) requires[j].getSupplier();
+ for (BundleSpecification require : requires) {
+ BundleDescription bundleSupplier = (BundleDescription) require.getSupplier();
if (bundleSupplier != null)
getPackages(bundleSupplier, bundle.getSymbolicName(), importList, orderedPkgList, pkgSet, visited, strict, importNames, options);
}
@@ -440,37 +455,39 @@ public final class StateHelperImpl implements StateHelper {
ExportPackageDescription[] substitutedExports = requiredBundle.getSubstitutedExports();
ExportPackageDescription[] imports = requiredBundle.getResolvedImports();
Set<String> substituteNames = null; // a temporary set used to scope packages we get from getPackages
- for (int i = 0; i < substitutedExports.length; i++) {
- if ((pkgNames == null || pkgNames.contains(substitutedExports[i].getName()))) {
- for (int j = 0; j < imports.length; j++) {
- if (substitutedExports[i].getName().equals(imports[j].getName()) && !pkgSet.contains(imports[j])) {
+ for (ExportPackageDescription substitutedExport : substitutedExports) {
+ if (pkgNames == null || pkgNames.contains(substitutedExport.getName())) {
+ for (ExportPackageDescription resolvedImport : imports) {
+ if (substitutedExport.getName().equals(resolvedImport.getName()) && !pkgSet.contains(resolvedImport)) {
if (substituteNames == null)
substituteNames = new HashSet<>(1);
else
substituteNames.clear();
// substituteNames is a set of one package containing the single substitute we are trying to get the source for
- substituteNames.add(substitutedExports[i].getName());
- getPackages(imports[j].getSupplier(), symbolicName, importList, orderedPkgList, pkgSet, new HashSet<BundleDescription>(0), strict, substituteNames, options);
+ substituteNames.add(substitutedExport.getName());
+ getPackages(resolvedImport.getSupplier(), symbolicName, importList, orderedPkgList, pkgSet, new HashSet<BundleDescription>(0), strict, substituteNames, options);
}
}
}
}
importList = substitutedExports.length == 0 ? importList : new HashSet<>(importList);
- for (int i = 0; i < substitutedExports.length; i++)
+ for (ExportPackageDescription substitutedExport : substitutedExports) {
// we add the package name to the import list to prevent required bundles from adding more sources
- importList.add(substitutedExports[i].getName());
+ importList.add(substitutedExport.getName());
+ }
ExportPackageDescription[] exports = requiredBundle.getSelectedExports();
HashSet<String> exportNames = new HashSet<>(exports.length); // set is used to improve performance of duplicate check.
- for (int i = 0; i < exports.length; i++)
- if ((pkgNames == null || pkgNames.contains(exports[i].getName())) && !isSystemExport(exports[i], options) && isFriend(symbolicName, exports[i], strict) && !importList.contains(exports[i].getName()) && !pkgSet.contains(exports[i])) {
- if (!exportNames.contains(exports[i].getName())) {
+ for (ExportPackageDescription export : exports) {
+ if ((pkgNames == null || pkgNames.contains(export.getName())) && !isSystemExport(export, options) && isFriend(symbolicName, export, strict) && !importList.contains(export.getName()) && !pkgSet.contains(export)) {
+ if (!exportNames.contains(export.getName())) {
// only add the first export
- orderedPkgList.add(exports[i]);
- pkgSet.add(exports[i]);
- exportNames.add(exports[i].getName());
+ orderedPkgList.add(export);
+ pkgSet.add(export);
+ exportNames.add(export.getName());
}
}
+ }
// now look for exports from the required bundle.
RequiresHolder requiredBundles = new RequiresHolder(requiredBundle, options);
for (int i = 0; i < requiredBundles.getSize(); i++) {
@@ -499,9 +516,11 @@ public final class StateHelperImpl implements StateHelper {
String[] friends = (String[]) export.getDirective(StateImpl.FRIENDS_DIRECTIVE);
if (friends == null)
return true; // no x-friends means it is wide open
- for (int i = 0; i < friends.length; i++)
- if (friends[i].equals(consumerBSN))
+ for (String friend : friends) {
+ if (friend.equals(consumerBSN)) {
return true; // the consumer is a friend
+ }
+ }
return false;
}
@@ -612,18 +631,17 @@ class RequiresHolder {
* Fragment bundles are also considered.
*/
private void determineRequiresVisibility(BundleDescription bundle) {
- BundleSpecification[] required = bundle.getRequiredBundles();
+ BundleSpecification[] requiredBundles = bundle.getRequiredBundles();
Set<BundleDescription> resolved = new HashSet<>();
- for (int i = 0; i < resolvedRequires.length; i++) {
- resolved.add(resolvedRequires[i]);
+ for (BundleDescription resolvedRequire : resolvedRequires) {
+ resolved.add(resolvedRequire);
}
-
// Get the visibility of all directly required bundles
- for (int i = 0; i < required.length; i++) {
- if (required[i].getSupplier() != null) {
- resolvedBundlesExported.put((BundleDescription) required[i].getSupplier(), Boolean.valueOf(required[i].isExported()));
- resolved.remove(required[i].getSupplier());
+ for (BundleSpecification required : requiredBundles) {
+ if (required.getSupplier() != null) {
+ resolvedBundlesExported.put((BundleDescription) required.getSupplier(), Boolean.valueOf(required.isExported()));
+ resolved.remove(required.getSupplier());
}
}
@@ -631,12 +649,12 @@ class RequiresHolder {
// Get the visibility of resolved required bundles, which come from fragments
if (resolved.size() > 0) {
- for (int i = 0; i < fragments.length; i++) {
- BundleSpecification[] fragmentRequiredBundles = fragments[i].getRequiredBundles();
- for (int j = 0; j < fragmentRequiredBundles.length; j++) {
- if (resolved.contains(fragmentRequiredBundles[j].getSupplier())) {
- resolvedBundlesExported.put((BundleDescription) fragmentRequiredBundles[j].getSupplier(), Boolean.valueOf(fragmentRequiredBundles[j].isExported()));
- resolved.remove(fragmentRequiredBundles[j].getSupplier());
+ for (BundleDescription fragment : fragments) {
+ BundleSpecification[] fragmentRequiredBundles = fragment.getRequiredBundles();
+ for (BundleSpecification fragmentRequiredBundle : fragmentRequiredBundles) {
+ if (resolved.contains(fragmentRequiredBundle.getSupplier())) {
+ resolvedBundlesExported.put((BundleDescription) fragmentRequiredBundle.getSupplier(), Boolean.valueOf(fragmentRequiredBundle.isExported()));
+ resolved.remove(fragmentRequiredBundle.getSupplier());
}
}
if (resolved.size() == 0) {
diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateImpl.java
index 2f79e5aea..b81df4c2c 100644
--- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateImpl.java
+++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateImpl.java
@@ -208,8 +208,8 @@ public abstract class StateImpl implements State {
NativeCodeSpecification nativeCode = description.getNativeCodeSpecification();
if (nativeCode != null) {
NativeCodeDescription[] suppliers = nativeCode.getPossibleSuppliers();
- for (int i = 0; i < suppliers.length; i++) {
- FilterImpl filter = (FilterImpl) suppliers[i].getFilter();
+ for (NativeCodeDescription supplier : suppliers) {
+ FilterImpl filter = (FilterImpl) supplier.getFilter();
if (filter != null)
addPlatformPropertyKeys(filter.getAttributes());
}
@@ -372,8 +372,7 @@ public abstract class StateImpl implements State {
return null;
BundleDescription unresolvedFound = null;
BundleDescription resolvedFound = null;
- for (int i = 0; i < allBundles.length; i++) {
- BundleDescription current = allBundles[i];
+ for (BundleDescription current : allBundles) {
BundleDescription base;
if (current.isResolved())
@@ -474,9 +473,9 @@ public abstract class StateImpl implements State {
if (hostSpec != null) {
if (hosts != null) {
hostSpec.setHosts(hosts);
- for (int i = 0; i < hosts.length; i++) {
- ((BundleDescriptionImpl) hosts[i]).addDependency(bundle, true);
- checkHostForSubstitutedExports((BundleDescriptionImpl) hosts[i], bundle);
+ for (BundleDescription host : hosts) {
+ ((BundleDescriptionImpl) host).addDependency(bundle, true);
+ checkHostForSubstitutedExports((BundleDescriptionImpl) host, bundle);
}
}
}
@@ -519,15 +518,18 @@ public abstract class StateImpl implements State {
if (nativeCode != null)
nativeCode.setSupplier(null);
ImportPackageSpecification[] imports = bundle.getImportPackages();
- for (int i = 0; i < imports.length; i++)
- ((ImportPackageSpecificationImpl) imports[i]).setSupplier(null);
+ for (ImportPackageSpecification importSpecification : imports) {
+ ((ImportPackageSpecificationImpl) importSpecification).setSupplier(null);
+ }
BundleSpecification[] requires = bundle.getRequiredBundles();
- for (int i = 0; i < requires.length; i++)
- ((BundleSpecificationImpl) requires[i]).setSupplier(null);
+ for (BundleSpecification require : requires) {
+ ((BundleSpecificationImpl) require).setSupplier(null);
+ }
GenericSpecification[] genericRequires = bundle.getGenericRequires();
if (genericRequires.length > 0)
- for (int i = 0; i < genericRequires.length; i++)
- ((GenericSpecificationImpl) genericRequires[i]).setSupplers(null);
+ for (GenericSpecification genericRequire : genericRequires) {
+ ((GenericSpecificationImpl) genericRequire).setSupplers(null);
+ }
bundle.removeDependencies();
}
@@ -620,16 +622,17 @@ public abstract class StateImpl implements State {
// merge in all removal pending bundles that are not already in the list
List<BundleDescription> result = new ArrayList<>(reResolve.length + removed.length);
Collections.addAll(result, reResolve);
- for (int i = 0; i < removed.length; i++) {
+ for (BundleDescription removedDescription : removed) {
boolean found = false;
- for (int j = 0; j < reResolve.length; j++) {
- if (removed[i] == reResolve[j]) {
+ for (BundleDescription toRefresh : reResolve) {
+ if (removedDescription == toRefresh) {
found = true;
break;
}
}
- if (!found)
- result.add(removed[i]);
+ if (!found) {
+ result.add(removedDescription);
+ }
}
return result.toArray(new BundleDescription[result.size()]);
}
@@ -640,8 +643,8 @@ public abstract class StateImpl implements State {
resolverErrors.clear();
if (resolvedBundles.isEmpty())
return;
- for (int i = 0; i < bundles.length; i++) {
- resolveBundle(bundles[i], false, null, null, null, null, null);
+ for (BundleDescription bundle : bundles) {
+ resolveBundle(bundle, false, null, null, null, null, null);
}
resolvedBundles.clear();
}
@@ -778,11 +781,12 @@ public abstract class StateImpl implements State {
if (hostSpec != null) {
BundleDescription[] hosts = hostSpec.getHosts();
if (hosts != null)
- for (int i = 0; i < hosts.length; i++)
- if (hosts[i] == host) {
+ for (BundleDescription hostCandidate : hosts) {
+ if (hostCandidate == host) {
fragments.add(bundle);
break;
}
+ }
}
}
}
@@ -921,15 +925,17 @@ public abstract class StateImpl implements State {
private void resetSystemExports() {
BundleDescription[] systemBundles = getBundles(Constants.SYSTEM_BUNDLE_SYMBOLICNAME);
- for (int idx = 0; idx < systemBundles.length; idx++) {
- BundleDescriptionImpl systemBundle = (BundleDescriptionImpl) systemBundles[idx];
- ExportPackageDescription[] exports = systemBundle.getExportPackages();
+ for (BundleDescription systemBundle : systemBundles) {
+ BundleDescriptionImpl systemBundleImpl = (BundleDescriptionImpl) systemBundle;
+ ExportPackageDescription[] exports = systemBundleImpl.getExportPackages();
List<ExportPackageDescription> newExports = new ArrayList<>(exports.length);
- for (int i = 0; i < exports.length; i++)
- if (((Integer) exports[i].getDirective(ExportPackageDescriptionImpl.EQUINOX_EE)).intValue() < 0)
- newExports.add(exports[i]);
+ for (ExportPackageDescription export : exports) {
+ if (((Integer) export.getDirective(ExportPackageDescriptionImpl.EQUINOX_EE)).intValue() < 0) {
+ newExports.add(export);
+ }
+ }
addSystemExports(newExports);
- systemBundle.setExportPackages(newExports.toArray(new ExportPackageDescription[newExports.size()]));
+ systemBundleImpl.setExportPackages(newExports.toArray(new ExportPackageDescription[newExports.size()]));
}
}
@@ -948,9 +954,9 @@ public abstract class StateImpl implements State {
return;
ExportPackageDescription[] systemExports = StateBuilder.createExportPackages(elements, null, null, false);
Integer profInx = Integer.valueOf(index);
- for (int j = 0; j < systemExports.length; j++) {
- ((ExportPackageDescriptionImpl) systemExports[j]).setDirective(ExportPackageDescriptionImpl.EQUINOX_EE, profInx);
- exports.add(systemExports[j]);
+ for (ExportPackageDescription systemExport : systemExports) {
+ ((ExportPackageDescriptionImpl) systemExport).setDirective(ExportPackageDescriptionImpl.EQUINOX_EE, profInx);
+ exports.add(systemExport);
}
}
@@ -1053,9 +1059,9 @@ public abstract class StateImpl implements State {
}
private boolean changedProps(Dictionary<Object, Object> origProps, Dictionary<Object, Object> newProps, String[] keys) {
- for (int i = 0; i < keys.length; i++) {
- Object origProp = origProps.get(keys[i]);
- Object newProp = newProps.get(keys[i]);
+ for (String key : keys) {
+ Object origProp = origProps.get(key);
+ Object newProp = newProps.get(key);
if (checkProp(origProp, newProp))
return true;
}
@@ -1203,8 +1209,9 @@ public abstract class StateImpl implements State {
}
fullyLoaded = false;
BundleDescription[] bundles = getBundles();
- for (int i = 0; i < bundles.length; i++)
- ((BundleDescriptionImpl) bundles[i]).unload();
+ for (BundleDescription bundle : bundles) {
+ ((BundleDescriptionImpl) bundle).unload();
+ }
reader.flushLazyObjectCache();
resolver.flush();
return true;
@@ -1218,9 +1225,11 @@ public abstract class StateImpl implements State {
if (systemBundles.length > 0) {
BundleDescriptionImpl systemBundle = (BundleDescriptionImpl) systemBundles[0];
ExportPackageDescription[] exports = systemBundle.getExportPackages();
- for (int i = 0; i < exports.length; i++)
- if (((Integer) exports[i].getDirective(ExportPackageDescriptionImpl.EQUINOX_EE)).intValue() >= 0)
- result.add(exports[i]);
+ for (ExportPackageDescription export : exports) {
+ if (((Integer) export.getDirective(ExportPackageDescriptionImpl.EQUINOX_EE)).intValue() >= 0) {
+ result.add(export);
+ }
+ }
}
return result.toArray(new ExportPackageDescription[result.size()]);
}
@@ -1280,9 +1289,11 @@ public abstract class StateImpl implements State {
void addPlatformPropertyKeys(String[] keys) {
synchronized (platformPropertyKeys) {
- for (int i = 0; i < keys.length; i++)
- if (!platformPropertyKeys.contains(keys[i]))
- platformPropertyKeys.add(keys[i]);
+ for (String key : keys) {
+ if (!platformPropertyKeys.contains(key)) {
+ platformPropertyKeys.add(key);
+ }
+ }
}
}
diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateObjectFactoryImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateObjectFactoryImpl.java
index b4b4e9186..5bb5123c9 100644
--- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateObjectFactoryImpl.java
+++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateObjectFactoryImpl.java
@@ -402,12 +402,13 @@ public class StateObjectFactoryImpl implements StateObjectFactory {
StateImpl newState = internalCreateState();
newState.setTimeStamp(original.getTimeStamp());
BundleDescription[] bundles = original.getBundles();
- for (int i = 0; i < bundles.length; i++) {
- BundleDescription newBundle = createBundleDescription(bundles[i]);
+ for (BundleDescription bundle : bundles) {
+ BundleDescription newBundle = createBundleDescription(bundle);
newState.basicAddBundle(newBundle);
- DisabledInfo[] infos = original.getDisabledInfos(bundles[i]);
- for (int j = 0; j < infos.length; j++)
- newState.addDisabledInfo(new DisabledInfo(infos[j].getPolicyName(), infos[j].getMessage(), newBundle));
+ DisabledInfo[] infos = original.getDisabledInfos(bundle);
+ for (DisabledInfo info : infos) {
+ newState.addDisabledInfo(new DisabledInfo(info.getPolicyName(), info.getMessage(), newBundle));
+ }
}
newState.setResolved(false);
newState.setPlatformProperties(original.getPlatformProperties());
diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateReader.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateReader.java
index 600fb6958..558afa417 100644
--- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateReader.java
+++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateReader.java
@@ -249,8 +249,9 @@ final class StateReader {
if (hostSpec != null) {
BundleDescription[] hosts = hostSpec.getHosts();
if (hosts != null) {
- for (int i = 0; i < hosts.length; i++)
- ((BundleDescriptionImpl) hosts[i]).addDependency(result, false);
+ for (BundleDescription host : hosts) {
+ ((BundleDescriptionImpl) host).addDependency(result, false);
+ }
}
}
// the rest is lazy loaded data
@@ -612,8 +613,7 @@ final class StateReader {
Map<String, Object> mapAttrs = readMap(in);
Dictionary<String, Object> attrs = new Hashtable<>();
if (mapAttrs != null) {
- for (Iterator<String> keys = mapAttrs.keySet().iterator(); keys.hasNext();) {
- String key = keys.next();
+ for (String key : mapAttrs.keySet()) {
attrs.put(key, mapAttrs.get(key));
}
}
diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateWriter.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateWriter.java
index bd185d509..1c79dea2f 100644
--- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateWriter.java
+++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateWriter.java
@@ -73,24 +73,26 @@ class StateWriter {
writePlatformProp(platformPropKeys, out);
Dictionary<Object, Object>[] propSet = state.getPlatformProperties();
out.writeInt(propSet.length);
- for (int i = 0; i < propSet.length; i++) {
- Dictionary<Object, Object> props = propSet[i];
+ for (Dictionary<Object, Object> props : propSet) {
out.writeInt(platformPropKeys.length);
- for (int j = 0; j < platformPropKeys.length; j++)
- writePlatformProp(props.get(platformPropKeys[j]), out);
+ for (String platformPropKey : platformPropKeys) {
+ writePlatformProp(props.get(platformPropKey), out);
+ }
}
BundleDescription[] bundles = state.getBundles();
StateHelperImpl.getInstance().sortBundles(bundles);
out.writeInt(bundles.length);
if (bundles.length == 0)
return;
- for (int i = 0; i < bundles.length; i++)
- writeBundleDescription(bundles[i], out, false);
+ for (BundleDescription bundle : bundles) {
+ writeBundleDescription(bundle, out, false);
+ }
out.writeBoolean(state.isResolved());
// save the lazy data offset
out.writeInt(out.size());
- for (int i = 0; i < bundles.length; i++)
- writeBundleDescriptionLazyData(bundles[i], out);
+ for (BundleDescription bundle : bundles) {
+ writeBundleDescriptionLazyData(bundle, out);
+ }
}
public void saveState(StateImpl state, File stateFile, File lazyFile) throws IOException {
@@ -104,16 +106,18 @@ class StateWriter {
StateHelperImpl.getInstance().sortBundles(bundles);
// need to prime the object table with all bundles
// this allows us to write only indexes to bundles in the lazy data
- for (int i = 0; i < bundles.length; i++) {
- addToObjectTable(bundles[i]);
- if (bundles[i].getHost() != null)
- addToObjectTable(bundles[i].getHost());
+ for (BundleDescription bundle : bundles) {
+ addToObjectTable(bundle);
+ if (bundle.getHost() != null) {
+ addToObjectTable(bundle.getHost());
+ }
}
// first write the lazy data to get the offsets and sizes to the lazy data
fosLazy = new FileOutputStream(lazyFile);
outLazy = new DataOutputStream(new BufferedOutputStream(fosLazy));
- for (int i = 0; i < bundles.length; i++)
- writeBundleDescriptionLazyData(bundles[i], outLazy);
+ for (BundleDescription bundle : bundles) {
+ writeBundleDescriptionLazyData(bundle, outLazy);
+ }
// now write the state data
fosState = new FileOutputStream(stateFile);
outState = new DataOutputStream(new BufferedOutputStream(fosState));
@@ -127,22 +131,24 @@ class StateWriter {
// write the platform property values
Dictionary<Object, Object>[] propSet = state.getPlatformProperties();
outState.writeInt(propSet.length);
- for (int i = 0; i < propSet.length; i++) {
- Dictionary<Object, Object> props = propSet[i];
+ for (Dictionary<Object, Object> props : propSet) {
outState.writeInt(platformPropKeys.length);
- for (int j = 0; j < platformPropKeys.length; j++)
- writePlatformProp(props.get(platformPropKeys[j]), outState);
+ for (String platformPropKey : platformPropKeys) {
+ writePlatformProp(props.get(platformPropKey), outState);
+ }
}
outState.writeInt(bundles.length);
- for (int i = 0; i < bundles.length; i++)
+ for (BundleDescription bundle : bundles) {
// write out each bundle with the force flag set to make sure
// the data is written at least once in the non-lazy state data
- writeBundleDescription(bundles[i], outState, true);
+ writeBundleDescription(bundle, outState, true);
+ }
// write the DisabledInfos
DisabledInfo[] infos = state.getDisabledInfos();
outState.writeInt(infos.length);
- for (int i = 0; i < infos.length; i++)
- writeDisabledInfo(infos[i], outState);
+ for (DisabledInfo info : infos) {
+ writeDisabledInfo(info, outState);
+ }
outState.writeBoolean(state.isResolved());
} finally {
if (outLazy != null) {
@@ -186,8 +192,9 @@ class StateWriter {
} else {
String[] props = (String[]) obj;
out.writeInt(props.length);
- for (int i = 0; i < props.length; i++)
- writeStringOrNull(props[i], out);
+ for (String prop : props) {
+ writeStringOrNull(prop, out);
+ }
}
}
}
@@ -242,26 +249,30 @@ class StateWriter {
ExportPackageDescription[] exports = bundle.getExportPackages();
out.writeInt(exports.length);
- for (int i = 0; i < exports.length; i++)
- writeExportPackageDesc((ExportPackageDescriptionImpl) exports[i], out);
+ for (ExportPackageDescription export : exports) {
+ writeExportPackageDesc((ExportPackageDescriptionImpl) export, out);
+ }
ImportPackageSpecification[] imports = bundle.getImportPackages();
out.writeInt(imports.length);
- for (int i = 0; i < imports.length; i++)
- writeImportPackageSpec((ImportPackageSpecificationImpl) imports[i], out);
+ for (ImportPackageSpecification importSpecification : imports) {
+ writeImportPackageSpec((ImportPackageSpecificationImpl) importSpecification, out);
+ }
BundleSpecification[] requiredBundles = bundle.getRequiredBundles();
out.writeInt(requiredBundles.length);
- for (int i = 0; i < requiredBundles.length; i++)
- writeBundleSpec((BundleSpecificationImpl) requiredBundles[i], out);
+ for (BundleSpecification requiredBundle : requiredBundles) {
+ writeBundleSpec((BundleSpecificationImpl) requiredBundle, out);
+ }
ExportPackageDescription[] selectedExports = bundle.getSelectedExports();
if (selectedExports == null) {
out.writeInt(0);
} else {
out.writeInt(selectedExports.length);
- for (int i = 0; i < selectedExports.length; i++)
- writeExportPackageDesc((ExportPackageDescriptionImpl) selectedExports[i], out);
+ for (ExportPackageDescription selectedExport : selectedExports) {
+ writeExportPackageDesc((ExportPackageDescriptionImpl) selectedExport, out);
+ }
}
ExportPackageDescription[] substitutedExports = bundle.getSubstitutedExports();
@@ -269,8 +280,9 @@ class StateWriter {
out.writeInt(0);
} else {
out.writeInt(substitutedExports.length);
- for (int i = 0; i < substitutedExports.length; i++)
- writeExportPackageDesc((ExportPackageDescriptionImpl) substitutedExports[i], out);
+ for (ExportPackageDescription substitutedExport : substitutedExports) {
+ writeExportPackageDesc((ExportPackageDescriptionImpl) substitutedExport, out);
+ }
}
ExportPackageDescription[] resolvedImports = bundle.getResolvedImports();
@@ -278,8 +290,9 @@ class StateWriter {
out.writeInt(0);
} else {
out.writeInt(resolvedImports.length);
- for (int i = 0; i < resolvedImports.length; i++)
- writeExportPackageDesc((ExportPackageDescriptionImpl) resolvedImports[i], out);
+ for (ExportPackageDescription resolvedImport : resolvedImports) {
+ writeExportPackageDesc((ExportPackageDescriptionImpl) resolvedImport, out);
+ }
}
BundleDescription[] resolvedRequires = bundle.getResolvedRequires();
@@ -287,22 +300,23 @@ class StateWriter {
out.writeInt(0);
} else {
out.writeInt(resolvedRequires.length);
- for (int i = 0; i < resolvedRequires.length; i++)
- writeBundleDescription(resolvedRequires[i], out, false);
+ for (BundleDescription resolvedRequire : resolvedRequires) {
+ writeBundleDescription(resolvedRequire, out, false);
+ }
}
String[] ees = bundle.getExecutionEnvironments();
out.writeInt(ees.length);
- for (int i = 0; i < ees.length; i++)
- writeStringOrNull(ees[i], out);
+ for (String ee : ees) {
+ writeStringOrNull(ee, out);
+ }
Map<String, Long> dynamicStamps = ((BundleDescriptionImpl) bundle).getDynamicStamps();
if (dynamicStamps == null)
out.writeInt(0);
else {
out.writeInt(dynamicStamps.size());
- for (Iterator<String> pkgs = dynamicStamps.keySet().iterator(); pkgs.hasNext();) {
- String pkg = pkgs.next();
+ for (String pkg : dynamicStamps.keySet()) {
writeStringOrNull(pkg, out);
out.writeLong(dynamicStamps.get(pkg).longValue());
}
@@ -313,8 +327,9 @@ class StateWriter {
out.writeInt(0);
else {
out.writeInt(genericCapabilities.length);
- for (int i = 0; i < genericCapabilities.length; i++)
- writeGenericDescription(genericCapabilities[i], out);
+ for (GenericDescription genericCapability : genericCapabilities) {
+ writeGenericDescription(genericCapability, out);
+ }
}
GenericSpecification[] genericRequires = bundle.getGenericRequires();
@@ -322,8 +337,9 @@ class StateWriter {
out.writeInt(0);
else {
out.writeInt(genericRequires.length);
- for (int i = 0; i < genericRequires.length; i++)
- writeGenericSpecification((GenericSpecificationImpl) genericRequires[i], out);
+ for (GenericSpecification genericRequire : genericRequires) {
+ writeGenericSpecification((GenericSpecificationImpl) genericRequire, out);
+ }
}
GenericDescription[] selectedCapabilities = bundle.getSelectedGenericCapabilities();
@@ -331,8 +347,9 @@ class StateWriter {
out.writeInt(0);
else {
out.writeInt(selectedCapabilities.length);
- for (int i = 0; i < selectedCapabilities.length; i++)
- writeGenericDescription(selectedCapabilities[i], out);
+ for (GenericDescription selectedCapability : selectedCapabilities) {
+ writeGenericDescription(selectedCapability, out);
+ }
}
GenericDescription[] resolvedCapabilities = bundle.getResolvedGenericRequires();
@@ -340,8 +357,9 @@ class StateWriter {
out.writeInt(0);
else {
out.writeInt(resolvedCapabilities.length);
- for (int i = 0; i < resolvedCapabilities.length; i++)
- writeGenericDescription(resolvedCapabilities[i], out);
+ for (GenericDescription resolvedCapability : resolvedCapabilities) {
+ writeGenericDescription(resolvedCapability, out);
+ }
}
writeNativeCode(bundle.getNativeCodeSpecification(), out);
@@ -405,8 +423,9 @@ class StateWriter {
GenericDescription[] suppliers = specification.getSuppliers();
out.writeInt(suppliers == null ? 0 : suppliers.length);
if (suppliers != null)
- for (int i = 0; i < suppliers.length; i++)
- writeGenericDescription(suppliers[i], out);
+ for (GenericDescription supplier : suppliers) {
+ writeGenericDescription(supplier, out);
+ }
out.writeInt(specification.getResolution());
writeStringOrNull(specification.getMatchingFilter(), out);
writeMap(out, specification.getAttributes());
@@ -449,16 +468,18 @@ class StateWriter {
out.writeInt(ranges == null ? 0 : ranges.length);
if (ranges == null)
return;
- for (int i = 0; i < ranges.length; i++)
- writeVersionRange(ranges[i], out);
+ for (VersionRange range : ranges) {
+ writeVersionRange(range, out);
+ }
}
private void writeStringArray(String[] strings, DataOutputStream out) throws IOException {
out.writeInt(strings == null ? 0 : strings.length);
if (strings == null)
return;
- for (int i = 0; i < strings.length; i++)
- writeStringOrNull(strings[i], out);
+ for (String string : strings) {
+ writeStringOrNull(string, out);
+ }
}
private void writeMap(DataOutputStream out, Map<String, ?> source) throws IOException {
@@ -589,8 +610,9 @@ class StateWriter {
out.writeInt(0);
} else {
out.writeInt(list.length);
- for (int i = 0; i < list.length; i++)
- writeStringOrNull(list[i], out);
+ for (String s : list) {
+ writeStringOrNull(s, out);
+ }
}
}
@@ -632,8 +654,9 @@ class StateWriter {
return;
}
out.writeInt(hosts.length);
- for (int i = 0; i < hosts.length; i++)
- writeBundleDescription(hosts[i], out, force);
+ for (BundleDescription h : hosts) {
+ writeBundleDescription(h, out, force);
+ }
writeMap(out, host.getAttributes());
writeMap(out, host.getArbitraryDirectives());
}
diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/UserState.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/UserState.java
index 3ea2d5030..988535293 100644
--- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/UserState.java
+++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/UserState.java
@@ -46,22 +46,24 @@ public class UserState extends StateImpl {
* @throws BundleException
*/
public StateDelta compare(State baseState) throws BundleException {
- BundleDescription[] current = this.getBundles();
+ BundleDescription[] currentBundles = this.getBundles();
StateDeltaImpl delta = new StateDeltaImpl(this);
// process additions and updates
- for (int i = 0; i < current.length; i++) {
- BundleDescription existing = baseState.getBundleByLocation(current[i].getLocation());
- if (existing == null)
- delta.recordBundleAdded((BundleDescriptionImpl) current[i]);
- else if (updated.contains(current[i].getLocation()))
- delta.recordBundleUpdated((BundleDescriptionImpl) current[i]);
+ for (BundleDescription current : currentBundles) {
+ BundleDescription existing = baseState.getBundleByLocation(current.getLocation());
+ if (existing == null) {
+ delta.recordBundleAdded((BundleDescriptionImpl) current);
+ } else if (updated.contains(current.getLocation())) {
+ delta.recordBundleUpdated((BundleDescriptionImpl) current);
+ }
}
// process removals
- BundleDescription[] existing = baseState.getBundles();
- for (int i = 0; i < existing.length; i++) {
- BundleDescription local = getBundleByLocation(existing[i].getLocation());
- if (local == null)
- delta.recordBundleRemoved((BundleDescriptionImpl) existing[i]);
+ BundleDescription[] existingBundles = baseState.getBundles();
+ for (BundleDescription existing : existingBundles) {
+ BundleDescription local = getBundleByLocation(existing.getLocation());
+ if (local == null) {
+ delta.recordBundleRemoved((BundleDescriptionImpl) existing);
+ }
}
return delta;
}
diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/ext.framework.b/ext/framework/b/TestCondition.java b/bundles/org.eclipse.osgi.tests/bundles_src/ext.framework.b/ext/framework/b/TestCondition.java
index 24f202b38..f114215c0 100644
--- a/bundles/org.eclipse.osgi.tests/bundles_src/ext.framework.b/ext/framework/b/TestCondition.java
+++ b/bundles/org.eclipse.osgi.tests/bundles_src/ext.framework.b/ext/framework/b/TestCondition.java
@@ -87,11 +87,11 @@ public class TestCondition implements Condition {
public boolean isSatisfied(Condition[] conditions, Dictionary context) {
if (!isPostponed())
throw new IllegalStateException("Should not call isSatisfied(Condition[] conditions, Dictionary context)"); //$NON-NLS-1$
- for (int i = 0; i < conditions.length; i++) {
- Boolean isSatisfied = (Boolean) context.get(conditions[i]);
+ for (Condition condition : conditions) {
+ Boolean isSatisfied = (Boolean) context.get(condition);
if (isSatisfied == null) {
- isSatisfied = Boolean.valueOf(conditions[i].isSatisfied());
- context.put(conditions[i], isSatisfied);
+ isSatisfied = Boolean.valueOf(condition.isSatisfied());
+ context.put(condition, isSatisfied);
}
if (!isSatisfied.booleanValue())
return false;
diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/security.b/security/b/Activator.java b/bundles/org.eclipse.osgi.tests/bundles_src/security.b/security/b/Activator.java
index 70e03d585..8b551f2d1 100644
--- a/bundles/org.eclipse.osgi.tests/bundles_src/security.b/security/b/Activator.java
+++ b/bundles/org.eclipse.osgi.tests/bundles_src/security.b/security/b/Activator.java
@@ -42,9 +42,9 @@ public class Activator implements BundleActivator {
private void doTestAction() {
Bundle[] bundles = bc.getBundles();
Bundle thisBundle = bc.getBundle();
- for (int i = 0; i < bundles.length; i++) {
- if (thisBundle.getBundleId() != bundles[i].getBundleId()) {
- checkBundle(bundles[i]);
+ for (Bundle bundle : bundles) {
+ if (thisBundle.getBundleId() != bundle.getBundleId()) {
+ checkBundle(bundle);
}
}
}
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/appadmin/ApplicationAdminTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/appadmin/ApplicationAdminTest.java
index 00420aac7..3fc7203bc 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/appadmin/ApplicationAdminTest.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/appadmin/ApplicationAdminTest.java
@@ -44,8 +44,9 @@ public class ApplicationAdminTest extends OSGiTest {
ConfigurationSessionTestSuite appAdminSessionTest = new ConfigurationSessionTestSuite(PI_OSGI_TESTS, ApplicationAdminTest.class.getName());
String[] ids = ConfigurationSessionTestSuite.MINIMAL_BUNDLE_SET;
- for (int i = 0; i < ids.length; i++)
- appAdminSessionTest.addBundle(ids[i]);
+ for (String id : ids) {
+ appAdminSessionTest.addBundle(id);
+ }
appAdminSessionTest.addBundle(PI_OSGI_UTIL);
appAdminSessionTest.addBundle(PI_OSGI_SERVICES);
appAdminSessionTest.addBundle(PI_OSGI_TESTS);
@@ -56,8 +57,9 @@ public class ApplicationAdminTest extends OSGiTest {
throw new RuntimeException(e);
}
// we add tests the hard way so we can control the order of the tests.
- for (int i = 0; i < tests.length; i++)
- appAdminSessionTest.addTest(new ApplicationAdminTest(tests[i]));
+ for (String test : tests) {
+ appAdminSessionTest.addTest(new ApplicationAdminTest(test));
+ }
suite.addTest(appAdminSessionTest);
return suite;
}
@@ -1164,8 +1166,9 @@ public class ApplicationAdminTest extends OSGiTest {
if (foundEvents.length > 0) {
StringBuilder eventsBuffer = new StringBuilder();
eventsBuffer.append("\nFound the following events: \n"); //$NON-NLS-1$
- for (int i = 0; i < foundEvents.length; i++)
- eventsBuffer.append(" handle event: ").append(foundEvents[i][0]).append(" ").append(foundEvents[i][1]).append("\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ for (Object[] foundEvent : foundEvents) {
+ eventsBuffer.append(" handle event: ").append(foundEvent[0]).append(" ").append(foundEvent[1]).append("\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
foundEventsMsg = eventsBuffer.toString();
} else {
foundEventsMsg = "\nNo events recorded"; //$NON-NLS-1$
@@ -1243,8 +1246,9 @@ public class ApplicationAdminTest extends OSGiTest {
if (foundEvents.length > 0) {
StringBuilder eventsBuffer = new StringBuilder();
eventsBuffer.append("\nFound the following events: \n"); //$NON-NLS-1$
- for (int i = 0; i < foundEvents.length; i++)
- eventsBuffer.append(" descriptor event: ").append(foundEvents[i][0]).append(" ").append(foundEvents[i][1]).append(" ").append(foundEvents[i][2]).append(" ").append(foundEvents[i][3]).append("\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ for (Object[] foundEvent : foundEvents) {
+ eventsBuffer.append(" descriptor event: ").append(foundEvent[0]).append(" ").append(foundEvent[1]).append(" ").append(foundEvent[2]).append(" ").append(foundEvent[3]).append("\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ }
foundEventsMsg = eventsBuffer.toString();
} else {
foundEventsMsg = "\nNo events recorded"; //$NON-NLS-1$
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java
index 586237f20..1b28ff4fd 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java
@@ -1028,44 +1028,44 @@ public class ClassLoadingBundleTests extends AbstractBundleTests {
urls[1] = test.getEntry("a/b/c/d"); //$NON-NLS-1$
assertNotNull("resource", urls[0]); //$NON-NLS-1$
assertNotNull("entry", urls[1]); //$NON-NLS-1$
- for (int i = 0; i < urls.length; i++) {
- URL testURL = new URL(urls[i], "g"); //$NON-NLS-1$
+ for (URL url : urls) {
+ URL testURL = new URL(url, "g"); //$NON-NLS-1$
assertEquals("g", "/a/b/c/g", testURL.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
- testURL = new URL(urls[i], "./g"); //$NON-NLS-1$
+ testURL = new URL(url, "./g"); //$NON-NLS-1$
assertEquals("./g", "/a/b/c/g", testURL.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
- testURL = new URL(urls[i], "g/"); //$NON-NLS-1$
+ testURL = new URL(url, "g/"); //$NON-NLS-1$
assertEquals("g/", "/a/b/c/g/", testURL.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
- testURL = new URL(urls[i], "/g"); //$NON-NLS-1$
+ testURL = new URL(url, "/g"); //$NON-NLS-1$
assertEquals("/g", "/g", testURL.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
- testURL = new URL(urls[i], "?y"); //$NON-NLS-1$
+ testURL = new URL(url, "?y"); //$NON-NLS-1$
assertEquals("?y", "/a/b/c/?y", testURL.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
- testURL = new URL(urls[i], "g?y"); //$NON-NLS-1$
+ testURL = new URL(url, "g?y"); //$NON-NLS-1$
assertEquals("g?y", "/a/b/c/g?y", testURL.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
- testURL = new URL(urls[i], "g#s"); //$NON-NLS-1$
+ testURL = new URL(url, "g#s"); //$NON-NLS-1$
assertEquals("g#s", "/a/b/c/g#s", testURL.getPath() + "#s"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- testURL = new URL(urls[i], "g?y#s"); //$NON-NLS-1$
+ testURL = new URL(url, "g?y#s"); //$NON-NLS-1$
assertEquals("g?y#s", "/a/b/c/g?y#s", testURL.getPath() + "#s"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- testURL = new URL(urls[i], ";x"); //$NON-NLS-1$
+ testURL = new URL(url, ";x"); //$NON-NLS-1$
assertEquals(";x", "/a/b/c/;x", testURL.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
- testURL = new URL(urls[i], "g;x"); //$NON-NLS-1$
+ testURL = new URL(url, "g;x"); //$NON-NLS-1$
assertEquals("g;x", "/a/b/c/g;x", testURL.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
- testURL = new URL(urls[i], "g;x?y#s"); //$NON-NLS-1$
+ testURL = new URL(url, "g;x?y#s"); //$NON-NLS-1$
assertEquals("g;x?y#s", "/a/b/c/g;x?y#s", testURL.getPath() + "#s"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- testURL = new URL(urls[i], "."); //$NON-NLS-1$
+ testURL = new URL(url, "."); //$NON-NLS-1$
assertEquals(".", "/a/b/c/", testURL.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
- testURL = new URL(urls[i], "./"); //$NON-NLS-1$
+ testURL = new URL(url, "./"); //$NON-NLS-1$
assertEquals("./", "/a/b/c/", testURL.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
- testURL = new URL(urls[i], ".."); //$NON-NLS-1$
+ testURL = new URL(url, ".."); //$NON-NLS-1$
assertEquals("..", "/a/b/", testURL.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
- testURL = new URL(urls[i], "../"); //$NON-NLS-1$
+ testURL = new URL(url, "../"); //$NON-NLS-1$
assertEquals("../", "/a/b/", testURL.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
- testURL = new URL(urls[i], "../g"); //$NON-NLS-1$
+ testURL = new URL(url, "../g"); //$NON-NLS-1$
assertEquals("../g", "/a/b/g", testURL.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
- testURL = new URL(urls[i], "../.."); //$NON-NLS-1$
+ testURL = new URL(url, "../.."); //$NON-NLS-1$
assertEquals("../..", "/a/", testURL.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
- testURL = new URL(urls[i], "../../"); //$NON-NLS-1$
+ testURL = new URL(url, "../../"); //$NON-NLS-1$
assertEquals("../../", "/a/", testURL.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
- testURL = new URL(urls[i], "../../g"); //$NON-NLS-1$
+ testURL = new URL(url, "../../g"); //$NON-NLS-1$
assertEquals("../../g", "/a/g", testURL.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
}
}
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/PackageAdminBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/PackageAdminBundleTests.java
index 556c7e235..c0e582016 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/PackageAdminBundleTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/PackageAdminBundleTests.java
@@ -319,8 +319,9 @@ public class PackageAdminBundleTests extends AbstractBundleTests {
private String getMessage(Throwable[] results) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
- for (int i = 0; i < results.length; i++)
- results[i].printStackTrace(pw);
+ for (Throwable result : results) {
+ result.printStackTrace(pw);
+ }
return sw.toString();
}
}
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SubstituteExportsBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SubstituteExportsBundleTests.java
index 8d56e7d6b..54796c412 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SubstituteExportsBundleTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SubstituteExportsBundleTests.java
@@ -309,11 +309,11 @@ public class SubstituteExportsBundleTests extends AbstractBundleTests {
}
String[] unexpectedClasseNames = new String[] {"substitutes.x.Jx", "substitutes.x.Lx", "substitutes.x.Nx", "substitutes.y.Jy", "substitutes.y.Ly", "substitutes.y.Ny"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
- for (int i = 0; i < unexpectedClasseNames.length; i++) {
- for (int j = 0; j < allBundles.length; j++) {
+ for (String unexpectedClasseName : unexpectedClasseNames) {
+ for (Bundle bundle : allBundles) {
try {
- Class found = allBundles[j].loadClass(unexpectedClasseNames[i]);
- fail("Found class " + found + " in bundle " + allBundles[j]); //$NON-NLS-1$//$NON-NLS-2$
+ Class found = bundle.loadClass(unexpectedClasseName);
+ fail("Found class " + found + " in bundle " + bundle); //$NON-NLS-1$//$NON-NLS-2$
} catch (ClassNotFoundException cnfe) {
// expected
}
@@ -402,11 +402,11 @@ public class SubstituteExportsBundleTests extends AbstractBundleTests {
}
String[] unexpectedClasseNames = new String[] {"substitutes.x.Ix", "substitutes.x.Kx", "substitutes.x.Mx", "substitutes.y.Iy", "substitutes.y.Ky", "substitutes.y.My"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
- for (int i = 0; i < unexpectedClasseNames.length; i++) {
- for (int j = 0; j < allBundles.length; j++) {
+ for (String unexpectedClasseName : unexpectedClasseNames) {
+ for (Bundle bundle : allBundles) {
try {
- Class found = allBundles[j].loadClass(unexpectedClasseNames[i]);
- fail("Found class " + found + " in bundle " + allBundles[j]); //$NON-NLS-1$//$NON-NLS-2$
+ Class found = bundle.loadClass(unexpectedClasseName);
+ fail("Found class " + found + " in bundle " + bundle); //$NON-NLS-1$//$NON-NLS-2$
} catch (ClassNotFoundException cnfe) {
// expected
}
@@ -472,12 +472,14 @@ public class SubstituteExportsBundleTests extends AbstractBundleTests {
private void doRefreshTest(Bundle[] allBundles, Bundle toRefresh) {
installer.resolveBundles(allBundles);
Bundle[] refreshed = installer.refreshPackages(new Bundle[] {toRefresh});
- for (int i = 0; i < allBundles.length; i++) {
+ for (Bundle allBundle : allBundles) {
boolean found = false;
- for (int j = 0; j < refreshed.length && !found; j++)
- found = allBundles[i] == refreshed[j];
- if (!found)
- fail("bundle did not get refreshed: " + allBundles[i]); //$NON-NLS-1$
+ for (int j = 0; j < refreshed.length && !found; j++) {
+ found = allBundle == refreshed[j];
+ }
+ if (!found) {
+ fail("bundle did not get refreshed: " + allBundle); //$NON-NLS-1$
+ }
}
assertEquals("Wrong number of bundles refreshed", allBundles.length, refreshed.length); //$NON-NLS-1$
}
@@ -509,9 +511,9 @@ public class SubstituteExportsBundleTests extends AbstractBundleTests {
assertEquals("Wrong number of yImporters", 3, yImporters.length); //$NON-NLS-1$
Bundle[] expectedImporters = new Bundle[] {b, c, d};
- for (int i = 0; i < expectedImporters.length; i++) {
- contains("xPackages importers does not contain", xImporters, expectedImporters[i]); //$NON-NLS-1$
- contains("yPackages importers does not contain", yImporters, expectedImporters[i]); //$NON-NLS-1$
+ for (Bundle expectedImporter : expectedImporters) {
+ contains("xPackages importers does not contain", xImporters, expectedImporter); //$NON-NLS-1$
+ contains("yPackages importers does not contain", yImporters, expectedImporter); //$NON-NLS-1$
}
}
@@ -538,27 +540,28 @@ public class SubstituteExportsBundleTests extends AbstractBundleTests {
assertEquals("yPackages wrong number", 3, yPackages.length); //$NON-NLS-1$
Bundle[] expectedExporters = new Bundle[] {iBundle, kBundle, mBundle};
- for (int i = 0; i < expectedExporters.length; i++) {
+ for (Bundle expectedExporter : expectedExporters) {
boolean found = false;
for (int j = 0; j < xPackages.length && !found; j++) {
- found = expectedExporters[i] == xPackages[j].getExportingBundle();
+ found = expectedExporter == xPackages[j].getExportingBundle();
if (found) {
Bundle[] importingBundles = xPackages[j].getImportingBundles();
Bundle[] expectedImporters = null;
String message = null;
- if (expectedExporters[i] == iBundle) {
+ if (expectedExporter == iBundle) {
expectedImporters = new Bundle[] {jBundle, mBundle, nBundle, pBundle, qBundle};
message = "iBundle "; //$NON-NLS-1$
- } else if (expectedExporters[i] == kBundle) {
+ } else if (expectedExporter == kBundle) {
expectedImporters = new Bundle[] {lBundle, mBundle, nBundle, pBundle, qBundle};
message = "kBundle "; //$NON-NLS-1$
- } else if (expectedExporters[i] == mBundle) {
+ } else if (expectedExporter == mBundle) {
expectedImporters = new Bundle[] {nBundle, pBundle, qBundle};
message = "mBundle "; //$NON-NLS-1$
}
assertEquals(message, expectedImporters.length, importingBundles.length);
- for (int k = 0; k < expectedImporters.length; k++)
- contains(message, importingBundles, expectedImporters[k]);
+ for (Bundle expectedImporter : expectedImporters) {
+ contains(message, importingBundles, expectedImporter);
+ }
}
}
}
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java
index b159cddff..ceb80c2fe 100755
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java
@@ -1133,10 +1133,10 @@ public class SystemBundleTests extends AbstractBundleTests {
} catch (IOException e) {
fail("Unexpected error creating budnles", e); //$NON-NLS-1$
}
- for (int i = 0; i < testBundles.length; i++) {
+ for (File testBundle : testBundles) {
try {
- systemContext.installBundle("reference:file:///" + testBundles[i].getAbsolutePath()); //$NON-NLS-1$
- } catch (BundleException e) {
+ systemContext.installBundle("reference:file:///" + testBundle.getAbsolutePath()); //$NON-NLS-1$
+ }catch (BundleException e) {
fail("Unexpected install error", e); //$NON-NLS-1$
}
}
@@ -1219,8 +1219,8 @@ public class SystemBundleTests extends AbstractBundleTests {
Bundle[] bundles = context.getBundles();
// get an entry from each bundle to ensure each one gets opened.
try {
- for (int i = 0; i < bundles.length; i++) {
- assertNotNull("No manifest for: " + bundles[i], bundles[i].getEntry("/META-INF/MANIFEST.MF"));
+ for (Bundle bundle : bundles) {
+ assertNotNull("No manifest for: " + bundle, bundle.getEntry("/META-INF/MANIFEST.MF"));
}
} catch (Throwable t) {
// An exception used to get thrown here when we tried to close
@@ -1587,8 +1587,8 @@ public class SystemBundleTests extends AbstractBundleTests {
Bundle[] bundles = systemContext.getBundles();
// get the headers from each bundle
try {
- for (int i = 0; i < bundles.length; i++) {
- bundles[i].getHeaders(); //$NON-NLS-1$
+ for (Bundle bundle : bundles) {
+ bundle.getHeaders(); //$NON-NLS-1$
}
} catch (Throwable t) {
// An exception used to get thrown here when we tried to close
@@ -3798,8 +3798,7 @@ public class SystemBundleTests extends AbstractBundleTests {
ExecutorService executor = Executors.newFixedThreadPool(50);
final List<Throwable> errors = new CopyOnWriteArrayList<Throwable>();
try {
- for (int i = 0; i < testBundles.length; i++) {
- final File testBundleFile = testBundles[i];
+ for (final File testBundleFile : testBundles) {
executor.execute(new Runnable() {
@Override
@@ -3812,7 +3811,6 @@ public class SystemBundleTests extends AbstractBundleTests {
}
}
});
-
}
} finally {
executor.shutdown();
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/EclipseStarterConfigIniTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/EclipseStarterConfigIniTest.java
index 806143866..eff971fd9 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/EclipseStarterConfigIniTest.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/EclipseStarterConfigIniTest.java
@@ -32,16 +32,18 @@ public class EclipseStarterConfigIniTest extends OSGiTest {
ConfigurationSessionTestSuite falseCompatBootDelegation = new ConfigurationSessionTestSuite(PI_OSGI_TESTS, EclipseStarterConfigIniTest.class.getName());
String[] ids = ConfigurationSessionTestSuite.MINIMAL_BUNDLE_SET;
- for (int i = 0; i < ids.length; i++)
- falseCompatBootDelegation.addBundle(ids[i]);
+ for (String id : ids) {
+ falseCompatBootDelegation.addBundle(id);
+ }
falseCompatBootDelegation.addBundle(PI_OSGI_TESTS);
falseCompatBootDelegation.addTest(new EclipseStarterConfigIniTest("testFalseCompatBootDelegation"));
falseCompatBootDelegation.setConfigIniValue("osgi.compatibility.bootdelegation", "false");
suite.addTest(falseCompatBootDelegation);
ConfigurationSessionTestSuite defaultCompatBootDelegation = new ConfigurationSessionTestSuite(PI_OSGI_TESTS, EclipseStarterConfigIniTest.class.getName());
- for (int i = 0; i < ids.length; i++)
- defaultCompatBootDelegation.addBundle(ids[i]);
+ for (String id : ids) {
+ defaultCompatBootDelegation.addBundle(id);
+ }
defaultCompatBootDelegation.addBundle(PI_OSGI_TESTS);
defaultCompatBootDelegation.addTest(new EclipseStarterConfigIniTest("testDefaultCompatBootDelegation"));
suite.addTest(defaultCompatBootDelegation);
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/EclipseStarterConfigurationAreaTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/EclipseStarterConfigurationAreaTest.java
index 6792fa2a1..ededca5ab 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/EclipseStarterConfigurationAreaTest.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/EclipseStarterConfigurationAreaTest.java
@@ -32,8 +32,9 @@ public class EclipseStarterConfigurationAreaTest extends OSGiTest {
ConfigurationSessionTestSuite initialization = new ConfigurationSessionTestSuite(PI_OSGI_TESTS, EclipseStarterConfigurationAreaTest.class.getName());
String[] ids = ConfigurationSessionTestSuite.MINIMAL_BUNDLE_SET;
initialization.addBundle("org.eclipse.osgi.compatibility.state");
- for (int i = 0; i < ids.length; i++)
- initialization.addBundle(ids[i]);
+ for (String id : ids) {
+ initialization.addBundle(id);
+ }
initialization.addBundle(PI_OSGI_TESTS);
// disable clean-up, we want to reuse the configuration
initialization.setCleanup(false);
@@ -45,8 +46,9 @@ public class EclipseStarterConfigurationAreaTest extends OSGiTest {
ConfigurationSessionTestSuite removeExtension = new ConfigurationSessionTestSuite(PI_OSGI_TESTS, EclipseStarterConfigurationAreaTest.class.getName());
removeExtension.setConfigurationPath(configPath);
- for (int i = 0; i < ids.length; i++)
- removeExtension.addBundle(ids[i]);
+ for (String id : ids) {
+ removeExtension.addBundle(id);
+ }
removeExtension.addBundle(PI_OSGI_TESTS);
removeExtension.addTest(new EclipseStarterConfigurationAreaTest("testRemoveExtension"));
suite.addTest(removeExtension);
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/MovableConfigurationAreaTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/MovableConfigurationAreaTest.java
index 27857fc39..0e8eb97fa 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/MovableConfigurationAreaTest.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/MovableConfigurationAreaTest.java
@@ -48,8 +48,9 @@ public class MovableConfigurationAreaTest extends OSGiTest {
ConfigurationSessionTestSuite initialization = new ConfigurationSessionTestSuite(PI_OSGI_TESTS, MovableConfigurationAreaTest.class.getName());
String[] ids = ConfigurationSessionTestSuite.MINIMAL_BUNDLE_SET;
- for (int i = 0; i < ids.length; i++)
- initialization.addBundle(ids[i]);
+ for (String id : ids) {
+ initialization.addBundle(id);
+ }
initialization.addBundle(PI_OSGI_TESTS);
initialization.setReadOnly(true);
// disable clean-up, we want to reuse the configuration
@@ -73,8 +74,9 @@ public class MovableConfigurationAreaTest extends OSGiTest {
ConfigurationSessionTestSuite afterMoving = new ConfigurationSessionTestSuite(PI_OSGI_TESTS, MovableConfigurationAreaTest.class.getName());
afterMoving.setConfigurationPath(destinationPath);
- for (int i = 0; i < ids.length; i++)
- afterMoving.addBundle(ids[i]);
+ for (String id : ids) {
+ afterMoving.addBundle(id);
+ }
afterMoving.setReadOnly(true);
// make sure we don't allow priming for the first run
afterMoving.setPrime(false);
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/ReadOnlyConfigurationAreaTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/ReadOnlyConfigurationAreaTest.java
index 44fdd6a5e..778b956f2 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/ReadOnlyConfigurationAreaTest.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/ReadOnlyConfigurationAreaTest.java
@@ -31,8 +31,9 @@ public class ReadOnlyConfigurationAreaTest extends OSGiTest {
ConfigurationSessionTestSuite suite = new ConfigurationSessionTestSuite(PI_OSGI_TESTS, ReadOnlyConfigurationAreaTest.class);
suite.setReadOnly(true);
String[] ids = ConfigurationSessionTestSuite.MINIMAL_BUNDLE_SET;
- for (int i = 0; i < ids.length; i++)
- suite.addBundle(ids[i]);
+ for (String id : ids) {
+ suite.addBundle(id);
+ }
suite.addBundle(PI_OSGI_TESTS);
return suite;
}
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestAttributes_001.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestAttributes_001.java
index ef8e43097..64059a48c 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestAttributes_001.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestAttributes_001.java
@@ -60,8 +60,7 @@ public class TestAttributes_001 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_2.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- ExportPackageDescription exp = exports[i];
+ for (ExportPackageDescription exp : exports) {
String exportPackageName = exp.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("foo")) {
@@ -75,8 +74,7 @@ public class TestAttributes_001 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_3.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- ExportPackageDescription exp = exports[i];
+ for (ExportPackageDescription exp : exports) {
String exportPackageName = exp.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("foo")) {
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestBSN_001.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestBSN_001.java
index 9ba9b825a..4057e05b2 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestBSN_001.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestBSN_001.java
@@ -53,8 +53,7 @@ public class TestBSN_001 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_1.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- ExportPackageDescription exp = exports[i];
+ for (ExportPackageDescription exp : exports) {
String exportPackageName = exp.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("foo")) {
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestCycle_001.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestCycle_001.java
index 9b0bd7537..b65a5fdd9 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestCycle_001.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestCycle_001.java
@@ -51,12 +51,12 @@ public class TestCycle_001 extends AbstractStateTest {
BundleDescription[] requires = bundle_2.getResolvedRequires();
assertNotNull("requires array is unexpectedly null", requires);
assertTrue("requires array is unexpectedly empty", requires.length > 0);
- for (int i = 0; i < requires.length; i++) {
- String requiresName = requires[i].getName();
+ for (BundleDescription require : requires) {
+ String requiresName = require.getName();
assertNotNull("package name is null", requiresName);
if (requiresName.equals("B")) {
- assertNotNull("Require [B] is not wired when it should be ", requires[i]);
- assertEquals("Require [B] is wired incorrectly ", requires[i], bundle_2);
+ assertNotNull("Require [B] is not wired when it should be ", require);
+ assertEquals("Require [B] is wired incorrectly ", require, bundle_2);
}
} // end for
} // end method
@@ -65,12 +65,12 @@ public class TestCycle_001 extends AbstractStateTest {
BundleDescription[] requires = bundle_2.getResolvedRequires();
assertNotNull("requires array is unexpectedly null", requires);
assertTrue("requires array is unexpectedly empty", requires.length > 0);
- for (int i = 0; i < requires.length; i++) {
- String requiresName = requires[i].getName();
+ for (BundleDescription require : requires) {
+ String requiresName = require.getName();
assertNotNull("package name is null", requiresName);
if (requiresName.equals("A")) {
- assertNotNull("Require [A] is not wired when it should be ", requires[i]);
- assertEquals("Require [A] is wired incorrectly ", requires[i], bundle_1);
+ assertNotNull("Require [A] is not wired when it should be ", require);
+ assertEquals("Require [A] is wired incorrectly ", require, bundle_1);
}
} // end for
} // end method
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestCycle_002.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestCycle_002.java
index 7b58fe6bc..1426390e4 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestCycle_002.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestCycle_002.java
@@ -53,15 +53,15 @@ public class TestCycle_002 extends AbstractStateTest {
BundleDescription[] requires = bundle_1.getResolvedRequires();
assertNotNull("requires array is unexpectedly null", requires);
assertTrue("requires array is unexpectedly empty", requires.length > 0);
- for (int i = 0; i < requires.length; i++) {
- String requiresName = requires[i].getName();
+ for (BundleDescription require : requires) {
+ String requiresName = require.getName();
assertNotNull("package name is null", requiresName);
if (requiresName.equals("B")) {
- assertNotNull("Require [B] is not wired when it should be ", requires[i]);
- assertEquals("Require [B] is wired incorrectly ", requires[i], bundle_2);
+ assertNotNull("Require [B] is not wired when it should be ", require);
+ assertEquals("Require [B] is wired incorrectly ", require, bundle_2);
} else if (requiresName.equals("C")) {
- assertNotNull("Require [C] is not wired when it should be ", requires[i]);
- assertEquals("Require [C] is wired incorrectly ", requires[i], bundle_3);
+ assertNotNull("Require [C] is not wired when it should be ", require);
+ assertEquals("Require [C] is wired incorrectly ", require, bundle_3);
}
} // end for
} // end method
@@ -70,15 +70,15 @@ public class TestCycle_002 extends AbstractStateTest {
BundleDescription[] requires = bundle_2.getResolvedRequires();
assertNotNull("requires array is unexpectedly null", requires);
assertTrue("requires array is unexpectedly empty", requires.length > 0);
- for (int i = 0; i < requires.length; i++) {
- String requiresName = requires[i].getName();
+ for (BundleDescription require : requires) {
+ String requiresName = require.getName();
assertNotNull("package name is null", requiresName);
if (requiresName.equals("A")) {
- assertNotNull("Require [A] is not wired when it should be ", requires[i]);
- assertEquals("Require [A] is wired incorrectly ", requires[i], bundle_1);
+ assertNotNull("Require [A] is not wired when it should be ", require);
+ assertEquals("Require [A] is wired incorrectly ", require, bundle_1);
} else if (requiresName.equals("C")) {
- assertNotNull("Require [C] is not wired when it should be ", requires[i]);
- assertEquals("Require [C] is wired incorrectly ", requires[i], bundle_3);
+ assertNotNull("Require [C] is not wired when it should be ", require);
+ assertEquals("Require [C] is wired incorrectly ", require, bundle_3);
}
} // end for
} // end method
@@ -87,15 +87,15 @@ public class TestCycle_002 extends AbstractStateTest {
BundleDescription[] requires = bundle_3.getResolvedRequires();
assertNotNull("requires array is unexpectedly null", requires);
assertTrue("requires array is unexpectedly empty", requires.length > 0);
- for (int i = 0; i < requires.length; i++) {
- String requiresName = requires[i].getName();
+ for (BundleDescription require : requires) {
+ String requiresName = require.getName();
assertNotNull("package name is null", requiresName);
if (requiresName.equals("A")) {
- assertNotNull("Require [A] is not wired when it should be ", requires[i]);
- assertEquals("Require [A] is wired incorrectly ", requires[i], bundle_1);
+ assertNotNull("Require [A] is not wired when it should be ", require);
+ assertEquals("Require [A] is wired incorrectly ", require, bundle_1);
} else if (requiresName.equals("B")) {
- assertNotNull("Require [B] is not wired when it should be ", requires[i]);
- assertEquals("Require [B] is wired incorrectly ", requires[i], bundle_2);
+ assertNotNull("Require [B] is not wired when it should be ", require);
+ assertEquals("Require [B] is wired incorrectly ", require, bundle_2);
}
} // end for
} // end method
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestCycle_004.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestCycle_004.java
index 47ff2cbd4..ebdb45b59 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestCycle_004.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestCycle_004.java
@@ -51,8 +51,7 @@ public class TestCycle_004 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_1.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- ExportPackageDescription exp = exports[i];
+ for (ExportPackageDescription exp : exports) {
String exportPackageName = exp.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("p")) {
@@ -66,8 +65,7 @@ public class TestCycle_004 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_2.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- ExportPackageDescription exp = exports[i];
+ for (ExportPackageDescription exp : exports) {
String exportPackageName = exp.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("q")) {
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestCycle_005.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestCycle_005.java
index 5b3956177..3d5e1f8b7 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestCycle_005.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestCycle_005.java
@@ -56,8 +56,7 @@ public class TestCycle_005 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_2.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- ExportPackageDescription exp = exports[i];
+ for (ExportPackageDescription exp : exports) {
String exportPackageName = exp.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("q")) {
@@ -71,8 +70,7 @@ public class TestCycle_005 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_3.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- ExportPackageDescription exp = exports[i];
+ for (ExportPackageDescription exp : exports) {
String exportPackageName = exp.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("r")) {
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestDynamic_002.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestDynamic_002.java
index bb04e25bf..842593b84 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestDynamic_002.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestDynamic_002.java
@@ -65,8 +65,7 @@ public class TestDynamic_002 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_1.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- ExportPackageDescription exp = exports[i];
+ for (ExportPackageDescription exp : exports) {
String exportPackageName = exp.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("p")) {
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestDynamic_003.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestDynamic_003.java
index eef665c25..2accc37f6 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestDynamic_003.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestDynamic_003.java
@@ -66,8 +66,7 @@ public class TestDynamic_003 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_1.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- ExportPackageDescription exp = exports[i];
+ for (ExportPackageDescription exp : exports) {
String exportPackageName = exp.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("p")) {
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestDynamic_004.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestDynamic_004.java
index aa0f65afd..a6ebf7147 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestDynamic_004.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestDynamic_004.java
@@ -68,8 +68,7 @@ public class TestDynamic_004 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_1.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- ExportPackageDescription exp = exports[i];
+ for (ExportPackageDescription exp : exports) {
String exportPackageName = exp.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("p")) {
@@ -83,8 +82,7 @@ public class TestDynamic_004 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_1.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- ExportPackageDescription exp = exports[i];
+ for (ExportPackageDescription exp : exports) {
String exportPackageName = exp.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("q")) {
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestGenerated_001.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestGenerated_001.java
index 270ca93e6..9b90fb7d5 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestGenerated_001.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestGenerated_001.java
@@ -81,8 +81,7 @@ public class TestGenerated_001 extends AbstractStateTest {
exports = bundle_3.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- ExportPackageDescription exp = exports[i];
+ for (ExportPackageDescription exp : exports) {
String exportPackageName = exp.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("a2")) {
@@ -110,8 +109,7 @@ public class TestGenerated_001 extends AbstractStateTest {
exports = bundle_6.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- ExportPackageDescription exp = exports[i];
+ for (ExportPackageDescription exp : exports) {
String exportPackageName = exp.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("a2")) {
@@ -133,8 +131,7 @@ public class TestGenerated_001 extends AbstractStateTest {
exports = bundle_7.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- ExportPackageDescription exp = exports[i];
+ for (ExportPackageDescription exp : exports) {
String exportPackageName = exp.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("a2")) {
@@ -156,8 +153,7 @@ public class TestGenerated_001 extends AbstractStateTest {
exports = bundle_8.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- ExportPackageDescription exp = exports[i];
+ for (ExportPackageDescription exp : exports) {
String exportPackageName = exp.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("a2")) {
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestGrouping_001.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestGrouping_001.java
index 8bd65a395..51a804a7d 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestGrouping_001.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestGrouping_001.java
@@ -60,8 +60,7 @@ public class TestGrouping_001 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_1.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- ExportPackageDescription exp = exports[i];
+ for (ExportPackageDescription exp : exports) {
String exportPackageName = exp.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("p")) {
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestGrouping_003.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestGrouping_003.java
index 6eeb93800..053ff320b 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestGrouping_003.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestGrouping_003.java
@@ -64,8 +64,7 @@ public class TestGrouping_003 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_1.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- ExportPackageDescription exp = exports[i];
+ for (ExportPackageDescription exp : exports) {
String exportPackageName = exp.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("r")) {
@@ -85,8 +84,7 @@ public class TestGrouping_003 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_3.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- ExportPackageDescription exp = exports[i];
+ for (ExportPackageDescription exp : exports) {
String exportPackageName = exp.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("p")) {
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestGrouping_008.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestGrouping_008.java
index 3f8f74f0f..26cf3494b 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestGrouping_008.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestGrouping_008.java
@@ -60,8 +60,7 @@ public class TestGrouping_008 extends AbstractStateTest {
BundleDescription[] requires = bundle_1.getResolvedRequires();
assertNotNull("requires array is unexpectedly null", requires);
assertTrue("requires array is unexpectedly empty", requires.length > 0);
- for (int i = 0; i < requires.length; i++) {
- BundleDescription bd = requires[i];
+ for (BundleDescription bd : requires) {
String requiresName = bd.getName();
assertNotNull("bundle name is null", requiresName);
if (requiresName.equals("B")) {
@@ -72,8 +71,7 @@ public class TestGrouping_008 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_1.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- ExportPackageDescription exp = exports[i];
+ for (ExportPackageDescription exp : exports) {
String exportPackageName = exp.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("p")) {
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestOptional_001.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestOptional_001.java
index 27aa5e361..68c1d853a 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestOptional_001.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestOptional_001.java
@@ -60,8 +60,7 @@ public class TestOptional_001 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_1.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- ExportPackageDescription exp = exports[i];
+ for (ExportPackageDescription exp : exports) {
String exportPackageName = exp.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("q")) {
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestOptional_002.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestOptional_002.java
index 8e8454891..536ced13c 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestOptional_002.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestOptional_002.java
@@ -60,8 +60,7 @@ public class TestOptional_002 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_1.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- ExportPackageDescription exp = exports[i];
+ for (ExportPackageDescription exp : exports) {
String exportPackageName = exp.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("q")) {
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestPropagation_001.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestPropagation_001.java
index c50983bce..10b24a77f 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestPropagation_001.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestPropagation_001.java
@@ -62,8 +62,7 @@ public class TestPropagation_001 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_1.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- ExportPackageDescription exp = exports[i];
+ for (ExportPackageDescription exp : exports) {
String exportPackageName = exp.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("x")) {
@@ -80,8 +79,7 @@ public class TestPropagation_001 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_2.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- ExportPackageDescription exp = exports[i];
+ for (ExportPackageDescription exp : exports) {
String exportPackageName = exp.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("x")) {
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestPropagation_003.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestPropagation_003.java
index 2cfb05a24..2c184e876 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestPropagation_003.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestPropagation_003.java
@@ -65,8 +65,7 @@ public class TestPropagation_003 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_2.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- ExportPackageDescription exp = exports[i];
+ for (ExportPackageDescription exp : exports) {
String exportPackageName = exp.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("p")) {
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_001.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_001.java
index e424729b5..86d5dd125 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_001.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_001.java
@@ -60,12 +60,12 @@ public class TestRFC79_001 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_1.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- String exportPackageName = exports[i].getName();
+ for (ExportPackageDescription export : exports) {
+ String exportPackageName = export.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("javax.servlet")) {
- assertNotNull("Package [javax.servlet] is not wired when it should be ", exports[i].getExporter());
- assertEquals("Package [javax.servlet] is wired incorrectly ", exports[i].getExporter(), bundle_2);
+ assertNotNull("Package [javax.servlet] is not wired when it should be ", export.getExporter());
+ assertEquals("Package [javax.servlet] is wired incorrectly ", export.getExporter(), bundle_2);
}
} // end for
} // end method
@@ -74,12 +74,12 @@ public class TestRFC79_001 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_2.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- String exportPackageName = exports[i].getName();
+ for (ExportPackageDescription export : exports) {
+ String exportPackageName = export.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("javax.servlet")) {
- assertNotNull("Package [javax.servlet] is not wired when it should be ", exports[i].getExporter());
- assertEquals("Package [javax.servlet] is wired incorrectly ", exports[i].getExporter(), bundle_2);
+ assertNotNull("Package [javax.servlet] is not wired when it should be ", export.getExporter());
+ assertEquals("Package [javax.servlet] is wired incorrectly ", export.getExporter(), bundle_2);
}
} // end for
} // end method
@@ -88,12 +88,12 @@ public class TestRFC79_001 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_3.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- String exportPackageName = exports[i].getName();
+ for (ExportPackageDescription export : exports) {
+ String exportPackageName = export.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("javax.servlet")) {
- assertNotNull("Package [javax.servlet] is not wired when it should be ", exports[i].getExporter());
- assertEquals("Package [javax.servlet] is wired incorrectly ", exports[i].getExporter(), bundle_2);
+ assertNotNull("Package [javax.servlet] is not wired when it should be ", export.getExporter());
+ assertEquals("Package [javax.servlet] is wired incorrectly ", export.getExporter(), bundle_2);
}
} // end for
} // end method
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_002.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_002.java
index c0809d3dd..9922c9f5a 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_002.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_002.java
@@ -64,12 +64,12 @@ public class TestRFC79_002 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_1.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- String exportPackageName = exports[i].getName();
+ for (ExportPackageDescription export : exports) {
+ String exportPackageName = export.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("javax.servlet")) {
- assertNotNull("Package [javax.servlet] is not wired when it should be ", exports[i].getExporter());
- assertEquals("Package [javax.servlet] is wired incorrectly ", exports[i].getExporter(), bundle_2);
+ assertNotNull("Package [javax.servlet] is not wired when it should be ", export.getExporter());
+ assertEquals("Package [javax.servlet] is wired incorrectly ", export.getExporter(), bundle_2);
}
} // end for
} // end method
@@ -78,12 +78,12 @@ public class TestRFC79_002 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_2.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- String exportPackageName = exports[i].getName();
+ for (ExportPackageDescription export : exports) {
+ String exportPackageName = export.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("javax.servlet")) {
- assertNotNull("Package [javax.servlet] is not wired when it should be ", exports[i].getExporter());
- assertEquals("Package [javax.servlet] is wired incorrectly ", exports[i].getExporter(), bundle_2);
+ assertNotNull("Package [javax.servlet] is not wired when it should be ", export.getExporter());
+ assertEquals("Package [javax.servlet] is wired incorrectly ", export.getExporter(), bundle_2);
}
} // end for
} // end method
@@ -92,15 +92,15 @@ public class TestRFC79_002 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_3.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- String exportPackageName = exports[i].getName();
+ for (ExportPackageDescription export : exports) {
+ String exportPackageName = export.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("org.foo.impl")) {
- assertNotNull("Package [org.foo.impl] is not wired when it should be ", exports[i].getExporter());
- assertEquals("Package [org.foo.impl] is wired incorrectly ", exports[i].getExporter(), bundle_2);
+ assertNotNull("Package [org.foo.impl] is not wired when it should be ", export.getExporter());
+ assertEquals("Package [org.foo.impl] is wired incorrectly ", export.getExporter(), bundle_2);
} else if (exportPackageName.equals("javax.servlet")) {
- assertNotNull("Package [javax.servlet] is not wired when it should be ", exports[i].getExporter());
- assertEquals("Package [javax.servlet] is wired incorrectly ", exports[i].getExporter(), bundle_2);
+ assertNotNull("Package [javax.servlet] is not wired when it should be ", export.getExporter());
+ assertEquals("Package [javax.servlet] is wired incorrectly ", export.getExporter(), bundle_2);
}
} // end for
} // end method
@@ -109,15 +109,15 @@ public class TestRFC79_002 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_4.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- String exportPackageName = exports[i].getName();
+ for (ExportPackageDescription export : exports) {
+ String exportPackageName = export.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("org.foo.impl")) {
- assertNotNull("Package [org.foo.impl] is not wired when it should be ", exports[i].getExporter());
- assertEquals("Package [org.foo.impl] is wired incorrectly ", exports[i].getExporter(), bundle_1);
+ assertNotNull("Package [org.foo.impl] is not wired when it should be ", export.getExporter());
+ assertEquals("Package [org.foo.impl] is wired incorrectly ", export.getExporter(), bundle_1);
} else if (exportPackageName.equals("javax.servlet")) {
- assertNotNull("Package [javax.servlet] is not wired when it should be ", exports[i].getExporter());
- assertEquals("Package [javax.servlet] is wired incorrectly ", exports[i].getExporter(), bundle_2);
+ assertNotNull("Package [javax.servlet] is not wired when it should be ", export.getExporter());
+ assertEquals("Package [javax.servlet] is wired incorrectly ", export.getExporter(), bundle_2);
}
} // end for
} // end method
@@ -126,12 +126,12 @@ public class TestRFC79_002 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_5.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- String exportPackageName = exports[i].getName();
+ for (ExportPackageDescription export : exports) {
+ String exportPackageName = export.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("org.foo.impl")) {
- assertNotNull("Package [org.foo.impl] is not wired when it should be ", exports[i].getExporter());
- assertEquals("Package [org.foo.impl] is wired incorrectly ", exports[i].getExporter(), bundle_2);
+ assertNotNull("Package [org.foo.impl] is not wired when it should be ", export.getExporter());
+ assertEquals("Package [org.foo.impl] is wired incorrectly ", export.getExporter(), bundle_2);
}
} // end for
} // end method
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_003.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_003.java
index 2b30381eb..bc7f55415 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_003.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_003.java
@@ -62,12 +62,12 @@ public class TestRFC79_003 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_1.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- String exportPackageName = exports[i].getName();
+ for (ExportPackageDescription export : exports) {
+ String exportPackageName = export.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("javax.servlet")) {
- assertNotNull("Package [javax.servlet] is not wired when it should be ", exports[i].getExporter());
- assertEquals("Package [javax.servlet] is wired incorrectly ", exports[i].getExporter(), bundle_2);
+ assertNotNull("Package [javax.servlet] is not wired when it should be ", export.getExporter());
+ assertEquals("Package [javax.servlet] is wired incorrectly ", export.getExporter(), bundle_2);
}
} // end for
} // end method
@@ -76,12 +76,12 @@ public class TestRFC79_003 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_2.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- String exportPackageName = exports[i].getName();
+ for (ExportPackageDescription export : exports) {
+ String exportPackageName = export.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("javax.servlet")) {
- assertNotNull("Package [javax.servlet] is not wired when it should be ", exports[i].getExporter());
- assertEquals("Package [javax.servlet] is wired incorrectly ", exports[i].getExporter(), bundle_2);
+ assertNotNull("Package [javax.servlet] is not wired when it should be ", export.getExporter());
+ assertEquals("Package [javax.servlet] is wired incorrectly ", export.getExporter(), bundle_2);
}
} // end for
} // end method
@@ -90,15 +90,15 @@ public class TestRFC79_003 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_3.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- String exportPackageName = exports[i].getName();
+ for (ExportPackageDescription export : exports) {
+ String exportPackageName = export.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("org.foo.impl")) {
- assertNotNull("Package [org.foo.impl] is not wired when it should be ", exports[i].getExporter());
- assertEquals("Package [org.foo.impl] is wired incorrectly ", exports[i].getExporter(), bundle_1);
+ assertNotNull("Package [org.foo.impl] is not wired when it should be ", export.getExporter());
+ assertEquals("Package [org.foo.impl] is wired incorrectly ", export.getExporter(), bundle_1);
} else if (exportPackageName.equals("javax.servlet")) {
- assertNotNull("Package [javax.servlet] is not wired when it should be ", exports[i].getExporter());
- assertEquals("Package [javax.servlet] is wired incorrectly ", exports[i].getExporter(), bundle_2);
+ assertNotNull("Package [javax.servlet] is not wired when it should be ", export.getExporter());
+ assertEquals("Package [javax.servlet] is wired incorrectly ", export.getExporter(), bundle_2);
}
} // end for
} // end method
@@ -107,15 +107,15 @@ public class TestRFC79_003 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_4.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- String exportPackageName = exports[i].getName();
+ for (ExportPackageDescription export : exports) {
+ String exportPackageName = export.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("org.foo.impl")) {
- assertNotNull("Package [org.foo.impl] is not wired when it should be ", exports[i].getExporter());
- assertEquals("Package [org.foo.impl] is wired incorrectly ", exports[i].getExporter(), bundle_1);
+ assertNotNull("Package [org.foo.impl] is not wired when it should be ", export.getExporter());
+ assertEquals("Package [org.foo.impl] is wired incorrectly ", export.getExporter(), bundle_1);
} else if (exportPackageName.equals("javax.servlet")) {
- assertNotNull("Package [javax.servlet] is not wired when it should be ", exports[i].getExporter());
- assertEquals("Package [javax.servlet] is wired incorrectly ", exports[i].getExporter(), bundle_2);
+ assertNotNull("Package [javax.servlet] is not wired when it should be ", export.getExporter());
+ assertEquals("Package [javax.servlet] is wired incorrectly ", export.getExporter(), bundle_2);
}
} // end for
} // end method
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_004.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_004.java
index 786bd5197..e53a8e6a4 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_004.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_004.java
@@ -62,15 +62,15 @@ public class TestRFC79_004 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_1.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- String exportPackageName = exports[i].getName();
+ for (ExportPackageDescription export : exports) {
+ String exportPackageName = export.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("org.apache.commons.logging")) {
- assertNotNull("Package [org.apache.commons.logging] is not wired when it should be ", exports[i].getExporter());
- assertEquals("Package [org.apache.commons.logging] is wired incorrectly ", exports[i].getExporter(), bundle_4);
+ assertNotNull("Package [org.apache.commons.logging] is not wired when it should be ", export.getExporter());
+ assertEquals("Package [org.apache.commons.logging] is wired incorrectly ", export.getExporter(), bundle_4);
} else if (exportPackageName.equals("org.apache.commons.io")) {
- assertNotNull("Package [org.apache.commons.io] is not wired when it should be ", exports[i].getExporter());
- assertEquals("Package [org.apache.commons.io] is wired incorrectly ", exports[i].getExporter(), bundle_4);
+ assertNotNull("Package [org.apache.commons.io] is not wired when it should be ", export.getExporter());
+ assertEquals("Package [org.apache.commons.io] is wired incorrectly ", export.getExporter(), bundle_4);
}
} // end for
} // end method
@@ -79,15 +79,15 @@ public class TestRFC79_004 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_2.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- String exportPackageName = exports[i].getName();
+ for (ExportPackageDescription export : exports) {
+ String exportPackageName = export.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("org.apache.commons.logging")) {
- assertNotNull("Package [org.apache.commons.logging] is not wired when it should be ", exports[i].getExporter());
- assertEquals("Package [org.apache.commons.logging] is wired incorrectly ", exports[i].getExporter(), bundle_3);
+ assertNotNull("Package [org.apache.commons.logging] is not wired when it should be ", export.getExporter());
+ assertEquals("Package [org.apache.commons.logging] is wired incorrectly ", export.getExporter(), bundle_3);
} else if (exportPackageName.equals("org.apache.commons.io")) {
- assertNotNull("Package [org.apache.commons.io] is not wired when it should be ", exports[i].getExporter());
- assertEquals("Package [org.apache.commons.io] is wired incorrectly ", exports[i].getExporter(), bundle_3);
+ assertNotNull("Package [org.apache.commons.io] is not wired when it should be ", export.getExporter());
+ assertEquals("Package [org.apache.commons.io] is wired incorrectly ", export.getExporter(), bundle_3);
}
} // end for
} // end method
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_005.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_005.java
index c219acda9..e8bd44a6e 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_005.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_005.java
@@ -60,12 +60,12 @@ public class TestRFC79_005 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_1.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- String exportPackageName = exports[i].getName();
+ for (ExportPackageDescription export : exports) {
+ String exportPackageName = export.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("javax.servlet")) {
- assertNotNull("Package [javax.servlet] is not wired when it should be ", exports[i].getExporter());
- assertEquals("Package [javax.servlet] is wired incorrectly ", exports[i].getExporter(), bundle_2);
+ assertNotNull("Package [javax.servlet] is not wired when it should be ", export.getExporter());
+ assertEquals("Package [javax.servlet] is wired incorrectly ", export.getExporter(), bundle_2);
}
} // end for
} // end method
@@ -74,12 +74,12 @@ public class TestRFC79_005 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_2.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- String exportPackageName = exports[i].getName();
+ for (ExportPackageDescription export : exports) {
+ String exportPackageName = export.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("javax.servlet")) {
- assertNotNull("Package [javax.servlet] is not wired when it should be ", exports[i].getExporter());
- assertEquals("Package [javax.servlet] is wired incorrectly ", exports[i].getExporter(), bundle_2);
+ assertNotNull("Package [javax.servlet] is not wired when it should be ", export.getExporter());
+ assertEquals("Package [javax.servlet] is wired incorrectly ", export.getExporter(), bundle_2);
}
} // end for
} // end method
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_006.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_006.java
index e659cf355..db803468e 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_006.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_006.java
@@ -66,8 +66,7 @@ public class TestRFC79_006 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_1.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- ExportPackageDescription exp = exports[i];
+ for (ExportPackageDescription exp : exports) {
String exportPackageName = exp.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("org.xml.sax")) {
@@ -99,8 +98,7 @@ public class TestRFC79_006 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_6.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- ExportPackageDescription exp = exports[i];
+ for (ExportPackageDescription exp : exports) {
String exportPackageName = exp.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("org.w3c.dom")) {
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_007.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_007.java
index eb46d41ca..ee34e7d41 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_007.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_007.java
@@ -64,8 +64,7 @@ public class TestRFC79_007 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_1.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- ExportPackageDescription exp = exports[i];
+ for (ExportPackageDescription exp : exports) {
String exportPackageName = exp.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("Q")) {
@@ -85,8 +84,7 @@ public class TestRFC79_007 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_4.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- ExportPackageDescription exp = exports[i];
+ for (ExportPackageDescription exp : exports) {
String exportPackageName = exp.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("R")) {
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestVersion_001.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestVersion_001.java
index 2f06153d8..bf8ca3f88 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestVersion_001.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestVersion_001.java
@@ -60,8 +60,7 @@ public class TestVersion_001 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_1.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- ExportPackageDescription exp = exports[i];
+ for (ExportPackageDescription exp : exports) {
String exportPackageName = exp.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("p")) {
@@ -75,8 +74,7 @@ public class TestVersion_001 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_2.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- ExportPackageDescription exp = exports[i];
+ for (ExportPackageDescription exp : exports) {
String exportPackageName = exp.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("p")) {
@@ -90,8 +88,7 @@ public class TestVersion_001 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_3.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- ExportPackageDescription exp = exports[i];
+ for (ExportPackageDescription exp : exports) {
String exportPackageName = exp.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("p")) {
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestVersion_002.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestVersion_002.java
index c92c84463..11f3dce8d 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestVersion_002.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestVersion_002.java
@@ -60,8 +60,7 @@ public class TestVersion_002 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_1.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- ExportPackageDescription exp = exports[i];
+ for (ExportPackageDescription exp : exports) {
String exportPackageName = exp.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("p")) {
@@ -75,8 +74,7 @@ public class TestVersion_002 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_2.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- ExportPackageDescription exp = exports[i];
+ for (ExportPackageDescription exp : exports) {
String exportPackageName = exp.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("r")) {
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestVersion_003.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestVersion_003.java
index b6ac4497b..4640d7a0e 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestVersion_003.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestVersion_003.java
@@ -60,8 +60,7 @@ public class TestVersion_003 extends AbstractStateTest {
ExportPackageDescription[] exports = bundle_1.getResolvedImports();
assertNotNull("export array is unexpectedly null", exports);
assertTrue("export array is unexpectedly empty", exports.length > 0);
- for (int i = 0; i < exports.length; i++) {
- ExportPackageDescription exp = exports[i];
+ for (ExportPackageDescription exp : exports) {
String exportPackageName = exp.getName();
assertNotNull("package name is null", exportPackageName);
if (exportPackageName.equals("p")) {
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/security/BaseSecurityTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/security/BaseSecurityTest.java
index 789c86290..a3d356d17 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/security/BaseSecurityTest.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/security/BaseSecurityTest.java
@@ -60,8 +60,8 @@ public class BaseSecurityTest extends CoreTest {
protected static void addDefaultSecurityBundles(ConfigurationSessionTestSuite suite) {
String[] ids = ConfigurationSessionTestSuite.MINIMAL_BUNDLE_SET;
- for (int i = 0; i < ids.length; i++) {
- suite.addBundle(ids[i]);
+ for (String id : ids) {
+ suite.addBundle(id);
}
suite.addBundle(BUNDLE_SECURITY_TESTS);
}
@@ -72,8 +72,8 @@ public class BaseSecurityTest extends CoreTest {
protected static Certificate[] getTestCertificateChain(String[] aliases) throws KeyStoreException {
ArrayList certs = new ArrayList(aliases.length);
- for (int i = 0; i < aliases.length; i++) {
- certs.add(getTestCertificate(aliases[i]));
+ for (String alias : aliases) {
+ certs.add(getTestCertificate(alias));
}
return (Certificate[]) certs.toArray(new Certificate[] {});
}
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/security/KeyStoreTrustEngineTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/security/KeyStoreTrustEngineTest.java
index 35828dbdd..1f3e55f34 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/security/KeyStoreTrustEngineTest.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/security/KeyStoreTrustEngineTest.java
@@ -13,14 +13,19 @@
*******************************************************************************/
package org.eclipse.osgi.tests.security;
-import java.io.*;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
import java.net.URL;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.cert.Certificate;
import java.security.cert.CertificateException;
import java.util.ArrayList;
-import junit.framework.*;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
import org.eclipse.osgi.internal.service.security.KeyStoreTrustEngine;
import org.eclipse.osgi.service.security.TrustEngine;
import org.eclipse.osgi.tests.OSGiTestsActivator;
@@ -31,8 +36,8 @@ public class KeyStoreTrustEngineTest extends TestCase {
private static String TYPE_DEFAULT = "JKS"; //$NON-NLS-1$
private static TestCase[] s_tests = {
- /* findTrustAnchor tests */
- new KeyStoreTrustEngineTest("findTrustAnchor positive test: self signed trusted", new String[] {"ca1_root"}) { //$NON-NLS-1$ //$NON-NLS-2$
+ /* findTrustAnchor tests */
+ new KeyStoreTrustEngineTest("findTrustAnchor positive test: self signed trusted", new String[] {"ca1_root"}) { //$NON-NLS-1$ //$NON-NLS-2$
public void runTest() {
testFindTrustAnchor0();
}
@@ -74,7 +79,7 @@ public class KeyStoreTrustEngineTest extends TestCase {
public void runTest() {
testAddTrustAnchor0();
}
- },/*, new KeyStoreTrustEngineTest("addTrustAnchor positive test: add with autogenerated alias", null) {
+ }, /*, new KeyStoreTrustEngineTest("addTrustAnchor positive test: add with autogenerated alias", null) {
public void runTest() {
testAddTrustAnchor1();
}
@@ -141,8 +146,8 @@ public class KeyStoreTrustEngineTest extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite("Unit tests for TrustEngine"); //$NON-NLS-1$
- for (int i = 0; i < s_tests.length; i++) {
- suite.addTest(s_tests[i]);
+ for (TestCase s_test : s_tests) {
+ suite.addTest(s_test);
}
return suite;
}
@@ -180,8 +185,8 @@ public class KeyStoreTrustEngineTest extends TestCase {
testStore = KeyStore.getInstance(TYPE_DEFAULT);
testStore.load(null, PASSWORD_DEFAULT);
if (aliases != null) {
- for (int i = 0; i < aliases.length; i++) {
- testStore.setCertificateEntry(aliases[i], getTestCertificate(aliases[i]));
+ for (String alias : aliases) {
+ testStore.setCertificateEntry(alias, getTestCertificate(alias));
}
}
testStoreFile = File.createTempFile("teststore", "jks"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -220,8 +225,8 @@ public class KeyStoreTrustEngineTest extends TestCase {
private static Certificate[] getTestCertificateChain(String[] aliases) throws KeyStoreException {
ArrayList certs = new ArrayList(aliases.length);
- for (int i = 0; i < aliases.length; i++) {
- certs.add(getTestCertificate(aliases[i]));
+ for (String alias : aliases) {
+ certs.add(getTestCertificate(alias));
}
return (Certificate[]) certs.toArray(new Certificate[] {});
}
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/security/SignedBundleTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/security/SignedBundleTest.java
index 629d4b54f..fbce8b108 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/security/SignedBundleTest.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/security/SignedBundleTest.java
@@ -20,7 +20,10 @@ import java.security.cert.X509Certificate;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.eclipse.core.tests.session.ConfigurationSessionTestSuite;
-import org.eclipse.osgi.signedcontent.*;
+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.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
@@ -162,9 +165,9 @@ public class SignedBundleTest extends BaseSecurityTest {
// verify and validate the entries
SignedContentEntry[] entries = signedContent.getSignedEntries();
assertNotNull("Entries is null", entries);
- for (int i = 0; i < entries.length; i++) {
- entries[i].verify();
- SignerInfo[] entryInfos = entries[i].getSignerInfos();
+ for (SignedContentEntry entry : entries) {
+ entry.verify();
+ SignerInfo[] entryInfos = entry.getSignerInfos();
assertNotNull("SignerInfo is null", entryInfos);
assertEquals("wrong number of entry signers", 1, entryInfos.length);
assertEquals("Entry signer does not equal content signer", infos[0], entryInfos[0]);
@@ -200,20 +203,20 @@ public class SignedBundleTest extends BaseSecurityTest {
assertNotNull("SignerInfo is null", infos);
assertEquals("wrong number of signers", 2, infos.length);
// check the signer validity
- for (int i = 0; i < infos.length; i++) {
- signedContent.checkValidity(infos[i]);
- signedContent.checkValidity(infos[i]);
+ for (SignerInfo info : infos) {
+ signedContent.checkValidity(info);
+ signedContent.checkValidity(info);
// check the signer trust
- assertTrue("Signer is not trusted: " + infos[i].getCertificateChain()[0], infos[i].isTrusted());
+ assertTrue("Signer is not trusted: " + info.getCertificateChain()[0], info.isTrusted());
// check the trust anchor
- assertNotNull("Trust anchor is null", infos[i].getTrustAnchor());
+ assertNotNull("Trust anchor is null", info.getTrustAnchor());
}
// verify and validate the entries
SignedContentEntry[] entries = signedContent.getSignedEntries();
assertNotNull("Entries is null", entries);
- for (int i = 0; i < entries.length; i++) {
- entries[i].verify();
- SignerInfo[] entryInfos = entries[i].getSignerInfos();
+ for (SignedContentEntry entry : entries) {
+ entry.verify();
+ SignerInfo[] entryInfos = entry.getSignerInfos();
assertNotNull("SignerInfo is null", entryInfos);
assertEquals("wrong number of entry signers", 2, entryInfos.length);
assertEquals("Entry signer does not equal content signer", infos[0], entryInfos[0]);
@@ -247,9 +250,9 @@ public class SignedBundleTest extends BaseSecurityTest {
assertNotNull("SignerInfo is null", infos);
assertEquals("wrong number of signers", 1, infos.length);
// check the signer validity
- for (int i = 0; i < infos.length; i++) {
+ for (SignerInfo info : infos) {
// check the signer trust
- assertTrue("Signer is trusted: " + infos[i].getCertificateChain()[0], !(infos[i].isTrusted()));
+ assertTrue("Signer is trusted: " + info.getCertificateChain()[0], !(info.isTrusted()));
}
} catch (Exception e) {
fail("Unexpected exception", e);
@@ -278,9 +281,9 @@ public class SignedBundleTest extends BaseSecurityTest {
assertNotNull("SignerInfo is null", infos);
assertEquals("wrong number of signers", 2, infos.length);
// check the signer validity
- for (int i = 0; i < infos.length; i++) {
+ for (SignerInfo info : infos) {
// check the signer trust
- assertTrue("Signer is trusted: " + infos[i].getCertificateChain()[0], !(infos[i].isTrusted()));
+ assertTrue("Signer is trusted: " + info.getCertificateChain()[0], !(info.isTrusted()));
}
} catch (Exception e) {
fail("Unexpected exception", e);
@@ -311,12 +314,10 @@ public class SignedBundleTest extends BaseSecurityTest {
assertEquals("wrong number of signers", 2, infos.length);
// make sure ca1 signer is trusted
-
// check the signer validity
- for (int i = 0; i < infos.length; i++) {
- Certificate certs[] = infos[i].getCertificateChain();
-
- if (infos[i].isTrusted()) {
+ for (SignerInfo info : infos) {
+ Certificate[] certs = info.getCertificateChain();
+ if (info.isTrusted()) {
X509Certificate x509Cert = (X509Certificate) certs[0];
assertTrue("CA1 LeafA signer is not trusted", x509Cert.getSubjectDN().getName().indexOf("CA1 LeafA") >= 0);
}
@@ -352,16 +353,18 @@ public class SignedBundleTest extends BaseSecurityTest {
SignedContentEntry[] entries = signedContent.getSignedEntries();
assertNotNull("Entries is null", entries);
- for (int i = 0; i < entries.length; i++) {
+ for (SignedContentEntry entry : entries) {
try {
- entries[i].verify();
- if ("org/eclipse/equinox/security/junit/CorruptClass.class".equals(entries[i].getName()))
- fail("Expected a corruption for: " + entries[i].getName());
+ entry.verify();
+ if ("org/eclipse/equinox/security/junit/CorruptClass.class".equals(entry.getName())) {
+ fail("Expected a corruption for: " + entry.getName());
+ }
} catch (InvalidContentException e) {
- if (!"org/eclipse/equinox/security/junit/CorruptClass.class".equals(entries[i].getName()))
- fail("Unexpected corruption in: " + entries[i].getName(), e);
+ if (!"org/eclipse/equinox/security/junit/CorruptClass.class".equals(entry.getName())) {
+ fail("Unexpected corruption in: " + entry.getName(), e);
+ }
}
- SignerInfo[] entryInfos = entries[i].getSignerInfos();
+ SignerInfo[] entryInfos = entry.getSignerInfos();
assertNotNull("SignerInfo is null", entryInfos);
assertEquals("wrong number of entry signers", 1, entryInfos.length);
assertEquals("Entry signer does not equal content signer", infos[0], entryInfos[0]);
@@ -478,9 +481,9 @@ public class SignedBundleTest extends BaseSecurityTest {
// verify and validate the entries
SignedContentEntry[] entries = signedContent.getSignedEntries();
assertNotNull("Entries is null", entries);
- for (int i = 0; i < entries.length; i++) {
- entries[i].verify();
- SignerInfo[] entryInfos = entries[i].getSignerInfos();
+ for (SignedContentEntry entry : entries) {
+ entry.verify();
+ SignerInfo[] entryInfos = entry.getSignerInfos();
assertNotNull("SignerInfo is null", entryInfos);
assertEquals("wrong number of entry signers", 1, entryInfos.length);
assertEquals("Entry signer does not equal content signer", infos[0], entryInfos[0]);
@@ -507,20 +510,20 @@ public class SignedBundleTest extends BaseSecurityTest {
assertNotNull("SignerInfo is null", infos);
assertEquals("wrong number of signers", 2, infos.length);
// check the signer validity
- for (int i = 0; i < infos.length; i++) {
- signedContent.checkValidity(infos[i]);
- signedContent.checkValidity(infos[i]);
+ for (SignerInfo info : infos) {
+ signedContent.checkValidity(info);
+ signedContent.checkValidity(info);
// check the signer trust
- assertTrue("Signer is not trusted: " + infos[i].getCertificateChain()[0], infos[i].isTrusted());
+ assertTrue("Signer is not trusted: " + info.getCertificateChain()[0], info.isTrusted());
// check the trust anchor
- assertNotNull("Trust anchor is null", infos[i].getTrustAnchor());
+ assertNotNull("Trust anchor is null", info.getTrustAnchor());
}
// verify and validate the entries
SignedContentEntry[] entries = signedContent.getSignedEntries();
assertNotNull("Entries is null", entries);
- for (int i = 0; i < entries.length; i++) {
- entries[i].verify();
- SignerInfo[] entryInfos = entries[i].getSignerInfos();
+ for (SignedContentEntry entry : entries) {
+ entry.verify();
+ SignerInfo[] entryInfos = entry.getSignerInfos();
assertNotNull("SignerInfo is null", entryInfos);
assertEquals("wrong number of entry signers", 2, entryInfos.length);
assertEquals("Entry signer does not equal content signer", infos[0], entryInfos[0]);
@@ -544,9 +547,9 @@ public class SignedBundleTest extends BaseSecurityTest {
assertNotNull("SignerInfo is null", infos);
assertEquals("wrong number of signers", 1, infos.length);
// check the signer validity
- for (int i = 0; i < infos.length; i++) {
+ for (SignerInfo info : infos) {
// check the signer trust
- assertTrue("Signer is trusted: " + infos[i].getCertificateChain()[0], !(infos[i].isTrusted()));
+ assertTrue("Signer is trusted: " + info.getCertificateChain()[0], !(info.isTrusted()));
}
} catch (Exception e) {
fail("Unexpected exception", e);
@@ -568,9 +571,9 @@ public class SignedBundleTest extends BaseSecurityTest {
assertNotNull("SignerInfo is null", infos);
assertEquals("wrong number of signers", 2, infos.length);
// check the signer validity
- for (int i = 0; i < infos.length; i++) {
+ for (SignerInfo info : infos) {
// check the signer trust
- assertTrue("Signer is trusted: " + infos[i].getCertificateChain()[0], !(infos[i].isTrusted()));
+ assertTrue("Signer is trusted: " + info.getCertificateChain()[0], !(info.isTrusted()));
}
} catch (Exception e) {
fail("Unexpected exception", e);
@@ -594,12 +597,10 @@ public class SignedBundleTest extends BaseSecurityTest {
assertEquals("wrong number of signers", 2, infos.length);
// make sure ca1 signer is trusted
-
// check the signer validity
- for (int i = 0; i < infos.length; i++) {
- Certificate certs[] = infos[i].getCertificateChain();
-
- if (infos[i].isTrusted()) {
+ for (SignerInfo info : infos) {
+ Certificate[] certs = info.getCertificateChain();
+ if (info.isTrusted()) {
X509Certificate x509Cert = (X509Certificate) certs[0];
assertTrue("CA1 LeafA signer is not trusted", x509Cert.getSubjectDN().getName().indexOf("CA1 LeafA") >= 0);
}
@@ -627,16 +628,18 @@ public class SignedBundleTest extends BaseSecurityTest {
SignedContentEntry[] entries = signedContent.getSignedEntries();
assertNotNull("Entries is null", entries);
- for (int i = 0; i < entries.length; i++) {
+ for (SignedContentEntry entry : entries) {
try {
- entries[i].verify();
- if ("org/eclipse/equinox/security/junit/CorruptClass.class".equals(entries[i].getName()))
- fail("Expected a corruption for: " + entries[i].getName());
+ entry.verify();
+ if ("org/eclipse/equinox/security/junit/CorruptClass.class".equals(entry.getName())) {
+ fail("Expected a corruption for: " + entry.getName());
+ }
} catch (InvalidContentException e) {
- if (!"org/eclipse/equinox/security/junit/CorruptClass.class".equals(entries[i].getName()))
- fail("Unexpected corruption in: " + entries[i].getName(), e);
+ if (!"org/eclipse/equinox/security/junit/CorruptClass.class".equals(entry.getName())) {
+ fail("Unexpected corruption in: " + entry.getName(), e);
+ }
}
- SignerInfo[] entryInfos = entries[i].getSignerInfos();
+ SignerInfo[] entryInfos = entry.getSignerInfos();
assertNotNull("SignerInfo is null", entryInfos);
assertEquals("wrong number of entry signers", 1, entryInfos.length);
assertEquals("Entry signer does not equal content signer", infos[0], entryInfos[0]);
@@ -693,9 +696,9 @@ public class SignedBundleTest extends BaseSecurityTest {
// verify and validate the entries
SignedContentEntry[] entries = signedContent.getSignedEntries();
assertNotNull("Entries is null", entries);
- for (int i = 0; i < entries.length; i++) {
- entries[i].verify();
- SignerInfo[] entryInfos = entries[i].getSignerInfos();
+ for (SignedContentEntry entry : entries) {
+ entry.verify();
+ SignerInfo[] entryInfos = entry.getSignerInfos();
assertNotNull("SignerInfo is null", entryInfos);
assertEquals("wrong number of entry signers", 1, entryInfos.length);
assertEquals("Entry signer does not equal content signer", infos[0], entryInfos[0]);
@@ -717,9 +720,9 @@ public class SignedBundleTest extends BaseSecurityTest {
assertFalse("Content is signed!!", signedContent.isSigned());
SignedContentEntry[] entries = signedContent.getSignedEntries();
assertNotNull("Entries is null", entries);
- for (int i = 0; i < entries.length; i++) {
- entries[i].verify();
- SignerInfo[] entryInfos = entries[i].getSignerInfos();
+ for (SignedContentEntry entry : entries) {
+ entry.verify();
+ SignerInfo[] entryInfos = entry.getSignerInfos();
assertNotNull("SignerInfo is null", entryInfos);
assertEquals("wrong number of entry signers", 0, entryInfos.length);
}
@@ -740,9 +743,9 @@ public class SignedBundleTest extends BaseSecurityTest {
SignedContentEntry[] entries = signedContent.getSignedEntries();
assertNotNull("Entries is null", entries);
assertEquals("Incorrect number of signed entries", 4, entries.length);
- for (int i = 0; i < entries.length; i++) {
- entries[i].verify();
- SignerInfo[] entryInfos = entries[i].getSignerInfos();
+ for (SignedContentEntry entry : entries) {
+ entry.verify();
+ SignerInfo[] entryInfos = entry.getSignerInfos();
assertNotNull("SignerInfo is null", entryInfos);
assertEquals("wrong number of entry signers", 1, entryInfos.length);
}
@@ -763,9 +766,9 @@ public class SignedBundleTest extends BaseSecurityTest {
SignedContentEntry[] entries = signedContent.getSignedEntries();
assertNotNull("Entries is null", entries);
assertEquals("Incorrect number of signed entries", 4, entries.length);
- for (int i = 0; i < entries.length; i++) {
- entries[i].verify();
- SignerInfo[] entryInfos = entries[i].getSignerInfos();
+ for (SignedContentEntry entry : entries) {
+ entry.verify();
+ SignerInfo[] entryInfos = entry.getSignerInfos();
assertNotNull("SignerInfo is null", entryInfos);
assertEquals("wrong number of entry signers", 1, entryInfos.length);
}
@@ -786,14 +789,14 @@ public class SignedBundleTest extends BaseSecurityTest {
SignedContentEntry[] entries = signedContent.getSignedEntries();
assertNotNull("Entries is null", entries);
assertEquals("Incorrect number of signed entries", 4, entries.length);
- for (int i = 0; i < entries.length; i++) {
+ for (SignedContentEntry entry : entries) {
try {
- entries[i].verify();
- assertFalse("Wrong entry is validated: " + entries[i].getName(), "META-INF/test/test1.file".equals(entries[i].getName()));
+ entry.verify();
+ assertFalse("Wrong entry is validated: " + entry.getName(), "META-INF/test/test1.file".equals(entry.getName()));
} catch (InvalidContentException e) {
- assertEquals("Wrong entry is corrupted", "META-INF/test/test1.file", entries[i].getName());
+ assertEquals("Wrong entry is corrupted", "META-INF/test/test1.file", entry.getName());
}
- SignerInfo[] entryInfos = entries[i].getSignerInfos();
+ SignerInfo[] entryInfos = entry.getSignerInfos();
assertNotNull("SignerInfo is null", entryInfos);
assertEquals("wrong number of entry signers", 1, entryInfos.length);
}
@@ -814,14 +817,14 @@ public class SignedBundleTest extends BaseSecurityTest {
SignedContentEntry[] entries = signedContent.getSignedEntries();
assertNotNull("Entries is null", entries);
assertEquals("Incorrect number of signed entries", 4, entries.length);
- for (int i = 0; i < entries.length; i++) {
+ for (SignedContentEntry entry : entries) {
try {
- entries[i].verify();
- assertFalse("Wrong entry is validated: " + entries[i].getName(), "META-INF/test.file".equals(entries[i].getName()));
+ entry.verify();
+ assertFalse("Wrong entry is validated: " + entry.getName(), "META-INF/test.file".equals(entry.getName()));
} catch (InvalidContentException e) {
- assertEquals("Wrong entry is corrupted", "META-INF/test.file", entries[i].getName());
+ assertEquals("Wrong entry is corrupted", "META-INF/test.file", entry.getName());
}
- SignerInfo[] entryInfos = entries[i].getSignerInfos();
+ SignerInfo[] entryInfos = entry.getSignerInfos();
assertNotNull("SignerInfo is null", entryInfos);
assertEquals("wrong number of entry signers", 1, entryInfos.length);
}
@@ -895,9 +898,9 @@ public class SignedBundleTest extends BaseSecurityTest {
// verify and validate the entries
SignedContentEntry[] entries = signedContent.getSignedEntries();
assertNotNull("Entries is null", entries);
- for (int i = 0; i < entries.length; i++) {
- entries[i].verify();
- SignerInfo[] entryInfos = entries[i].getSignerInfos();
+ for (SignedContentEntry entry : entries) {
+ entry.verify();
+ SignerInfo[] entryInfos = entry.getSignerInfos();
assertNotNull("SignerInfo is null", entryInfos);
assertEquals("wrong number of entry signers", 1, entryInfos.length);
assertEquals("Entry signer does not equal content signer", infos[0], entryInfos[0]);
@@ -947,14 +950,14 @@ public class SignedBundleTest extends BaseSecurityTest {
SignedContentEntry[] entries = signedContent.getSignedEntries();
assertNotNull("Entries is null", entries);
- for (int i = 0; i < entries.length; i++) {
+ for (SignedContentEntry entry : entries) {
try {
- entries[i].verify();
- fail("Expected a corruption for: " + entries[i].getName());
+ entry.verify();
+ fail("Expected a corruption for: " + entry.getName());
} catch (InvalidContentException e) {
// expected
}
- SignerInfo[] entryInfos = entries[i].getSignerInfos();
+ SignerInfo[] entryInfos = entry.getSignerInfos();
assertNotNull("SignerInfo is null", entryInfos);
assertEquals("wrong number of entry signers", 1, entryInfos.length);
assertEquals("Entry signer does not equal content signer", infos[0], entryInfos[0]);
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/serviceregistry/ServiceHookTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/serviceregistry/ServiceHookTests.java
index f8e3d818c..9e114a7fb 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/serviceregistry/ServiceHookTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/serviceregistry/ServiceHookTests.java
@@ -13,12 +13,28 @@
*******************************************************************************/
package org.eclipse.osgi.tests.serviceregistry;
-import java.util.*;
-import junit.framework.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import junit.framework.AssertionFailedError;
+import junit.framework.Test;
+import junit.framework.TestSuite;
import org.eclipse.osgi.tests.OSGiTestsActivator;
import org.eclipse.osgi.tests.bundles.AbstractBundleTests;
-import org.osgi.framework.*;
-import org.osgi.framework.hooks.service.*;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Filter;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.framework.hooks.service.EventHook;
+import org.osgi.framework.hooks.service.FindHook;
+import org.osgi.framework.hooks.service.ListenerHook;
public class ServiceHookTests extends AbstractBundleTests {
public static Test suite() {
@@ -49,7 +65,7 @@ public class ServiceHookTests extends AbstractBundleTests {
final int[] hookCalled = new int[] {0, 0, 0, 0, 0};
final boolean[] startTest = new boolean[] {false};
- final AssertionFailedError[] hookError = new AssertionFailedError[] {null, null, null, null};
+ final AssertionFailedError[] hookErrors = new AssertionFailedError[] {null, null, null, null};
// register find hook 1
props.put(Constants.SERVICE_DESCRIPTION, "find hook 1"); //$NON-NLS-1$
@@ -96,7 +112,7 @@ public class ServiceHookTests extends AbstractBundleTests {
fail("incorrect exception", e); //$NON-NLS-1$
}
} catch (AssertionFailedError a) {
- hookError[0] = a;
+ hookErrors[0] = a;
return;
}
}
@@ -144,7 +160,7 @@ public class ServiceHookTests extends AbstractBundleTests {
fail("incorrect exception", e); //$NON-NLS-1$
}
} catch (AssertionFailedError a) {
- hookError[1] = a;
+ hookErrors[1] = a;
return;
}
}
@@ -192,7 +208,7 @@ public class ServiceHookTests extends AbstractBundleTests {
fail("incorrect exception", e); //$NON-NLS-1$
}
} catch (AssertionFailedError a) {
- hookError[2] = a;
+ hookErrors[2] = a;
return;
}
// throw an exception from the hook to test that the next hooks are called.
@@ -245,7 +261,7 @@ public class ServiceHookTests extends AbstractBundleTests {
fail("incorrect exception", e); //$NON-NLS-1$
}
} catch (AssertionFailedError a) {
- hookError[3] = a;
+ hookErrors[3] = a;
return;
}
}
@@ -265,9 +281,9 @@ public class ServiceHookTests extends AbstractBundleTests {
assertEquals("hook 3 not called second", 3, hookCalled[2]); //$NON-NLS-1$
assertEquals("hook 4 not called third", 4, hookCalled[3]); //$NON-NLS-1$
assertEquals("hook 1 not called fourth ", 1, hookCalled[4]); //$NON-NLS-1$
- for (int i = 0; i < hookError.length; i++) {
- if (hookError[i] != null) {
- throw hookError[i];
+ for (AssertionFailedError hookError : hookErrors) {
+ if (hookError != null) {
+ throw hookError;
}
}
assertNotNull("service refs is null", refs); //$NON-NLS-1$
@@ -340,7 +356,7 @@ public class ServiceHookTests extends AbstractBundleTests {
final BundleContext testContext = OSGiTestsActivator.getContext();
final int[] hookCalled = new int[] {0, 0};
- final AssertionFailedError[] hookError = new AssertionFailedError[] {null};
+ final AssertionFailedError[] hookErrors = new AssertionFailedError[] {null};
final List events = new ArrayList();
final ServiceListener sl = new ServiceListener() {
@@ -389,7 +405,7 @@ public class ServiceHookTests extends AbstractBundleTests {
fail("incorrect exception", e); //$NON-NLS-1$
}
} catch (AssertionFailedError a) {
- hookError[0] = a;
+ hookErrors[0] = a;
return;
}
}
@@ -422,7 +438,7 @@ public class ServiceHookTests extends AbstractBundleTests {
fail("incorrect exception", e); //$NON-NLS-1$
}
} catch (AssertionFailedError a) {
- hookError[0] = a;
+ hookErrors[0] = a;
return;
}
}
@@ -443,9 +459,9 @@ public class ServiceHookTests extends AbstractBundleTests {
reg1 = testContext.registerService(Runnable.class.getName(), runIt, props);
assertEquals("all hooks not called", 1, hookCalled[0]); //$NON-NLS-1$
assertEquals("hook 1 not called first", 1, hookCalled[1]); //$NON-NLS-1$
- for (int i = 0; i < hookError.length; i++) {
- if (hookError[i] != null) {
- throw hookError[i];
+ for (AssertionFailedError hookError : hookErrors) {
+ if (hookError != null) {
+ throw hookError;
}
}
synchronized (events) {
@@ -492,9 +508,9 @@ public class ServiceHookTests extends AbstractBundleTests {
}
assertEquals("all hooks not called", 1, hookCalled[0]); //$NON-NLS-1$
assertEquals("hook 1 not called first", 1, hookCalled[1]); //$NON-NLS-1$
- for (int i = 0; i < hookError.length; i++) {
- if (hookError[i] != null) {
- throw hookError[i];
+ for (AssertionFailedError hookError : hookErrors) {
+ if (hookError != null) {
+ throw hookError;
}
}
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/FileManagerTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/FileManagerTests.java
index d6e67430d..729f1b127 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/FileManagerTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/FileManagerTests.java
@@ -13,7 +13,11 @@
*******************************************************************************/
package org.eclipse.osgi.tests.services.datalocation;
-import java.io.*;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.eclipse.core.runtime.Platform;
@@ -53,16 +57,16 @@ public class FileManagerTests extends OSGiTest {
rm(base);
}
- private void rm(File file) {
- if (file.isDirectory()) {
- File[] list = file.listFiles();
- if (list != null) {
- for (int idx = 0; idx < list.length; idx++) {
- rm(list[idx]);
+ private void rm(File folder) {
+ if (folder.isDirectory()) {
+ File[] files = folder.listFiles();
+ if (files != null) {
+ for (File file : files) {
+ rm(file);
}
}
}
- file.delete();
+ folder.delete();
}
/**
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/LocationAreaSessionTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/LocationAreaSessionTest.java
index b69453ba9..7112de0f4 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/LocationAreaSessionTest.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/LocationAreaSessionTest.java
@@ -48,8 +48,9 @@ public class LocationAreaSessionTest extends OSGiTest {
// attempt to lock same location with a session
ConfigurationSessionTestSuite sessionLock = new ConfigurationSessionTestSuite(PI_OSGI_TESTS, LocationAreaSessionTest.class.getName());
String[] ids = ConfigurationSessionTestSuite.MINIMAL_BUNDLE_SET;
- for (int i = 0; i < ids.length; i++)
- sessionLock.addBundle(ids[i]);
+ for (String id : ids) {
+ sessionLock.addBundle(id);
+ }
sessionLock.addBundle(PI_OSGI_TESTS);
try {
sessionLock.getSetup().setSystemProperty(TEST_LOCATION_DIR, testLocationLockDir);
@@ -69,8 +70,9 @@ public class LocationAreaSessionTest extends OSGiTest {
// attempt to lock the location with a session
sessionLock = new ConfigurationSessionTestSuite(PI_OSGI_TESTS, LocationAreaSessionTest.class.getName());
- for (int i = 0; i < ids.length; i++)
- sessionLock.addBundle(ids[i]);
+ for (String id : ids) {
+ sessionLock.addBundle(id);
+ }
sessionLock.addBundle(PI_OSGI_TESTS);
try {
sessionLock.getSetup().setSystemProperty(TEST_LOCATION_DIR, testLocationLockDir);
@@ -94,8 +96,9 @@ public class LocationAreaSessionTest extends OSGiTest {
// attempt to lock same location with a session
sessionLock = new ConfigurationSessionTestSuite(PI_OSGI_TESTS, LocationAreaSessionTest.class.getName());
ids = ConfigurationSessionTestSuite.MINIMAL_BUNDLE_SET;
- for (int i = 0; i < ids.length; i++)
- sessionLock.addBundle(ids[i]);
+ for (String id : ids) {
+ sessionLock.addBundle(id);
+ }
sessionLock.addBundle(PI_OSGI_TESTS);
try {
sessionLock.getSetup().setSystemProperty(TEST_LOCATION_DIR, testLocationLockDir);
@@ -117,8 +120,9 @@ public class LocationAreaSessionTest extends OSGiTest {
// attempt to lock the location with a session
sessionLock = new ConfigurationSessionTestSuite(PI_OSGI_TESTS, LocationAreaSessionTest.class.getName());
- for (int i = 0; i < ids.length; i++)
- sessionLock.addBundle(ids[i]);
+ for (String id : ids) {
+ sessionLock.addBundle(id);
+ }
sessionLock.addBundle(PI_OSGI_TESTS);
try {
sessionLock.getSetup().setSystemProperty(TEST_LOCATION_DIR, testLocationLockDir);
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/StreamManagerTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/StreamManagerTests.java
index 615b79ff8..3e2d017de 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/StreamManagerTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/StreamManagerTests.java
@@ -13,7 +13,15 @@
*******************************************************************************/
package org.eclipse.osgi.tests.services.datalocation;
-import java.io.*;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.RandomAccessFile;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.eclipse.core.runtime.Platform;
@@ -59,16 +67,16 @@ public class StreamManagerTests extends OSGiTest {
System.setProperty("osgi.useReliableFiles", reliableFile);
}
- private void rm(File file) {
- if (file.isDirectory()) {
- File[] list = file.listFiles();
- if (list != null) {
- for (int idx = 0; idx < list.length; idx++) {
- rm(list[idx]);
+ private void rm(File folder) {
+ if (folder.isDirectory()) {
+ File[] files = folder.listFiles();
+ if (files != null) {
+ for (File file : files) {
+ rm(file);
}
}
}
- file.delete();
+ folder.delete();
}
private String getInputStreamContents(InputStream is) throws IOException {
@@ -161,9 +169,10 @@ public class StreamManagerTests extends OSGiTest {
//now request only the primary file
try {
InputStream[] isSet = manager1.getInputStreamSet(new String[] {fileName});
- for (int i = 0; i < isSet.length; i++) {
- if (isSet[i] != null)
- isSet[i].close();
+ for (InputStream set : isSet) {
+ if (set != null) {
+ set.close();
+ }
}
fail("getInputStreamSet was successful");
} catch (IOException e) {
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/AbstractStateTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/AbstractStateTest.java
index 9534b6f2c..b3686144f 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/AbstractStateTest.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/AbstractStateTest.java
@@ -13,8 +13,18 @@
*******************************************************************************/
package org.eclipse.osgi.tests.services.resolver;
-import java.util.*;
-import org.eclipse.osgi.service.resolver.*;
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.StringTokenizer;
+import org.eclipse.osgi.service.resolver.BundleDescription;
+import org.eclipse.osgi.service.resolver.BundleSpecification;
+import org.eclipse.osgi.service.resolver.ExportPackageDescription;
+import org.eclipse.osgi.service.resolver.HostSpecification;
+import org.eclipse.osgi.service.resolver.ImportPackageSpecification;
+import org.eclipse.osgi.service.resolver.PlatformAdmin;
+import org.eclipse.osgi.service.resolver.State;
+import org.eclipse.osgi.service.resolver.StateObjectFactory;
+import org.eclipse.osgi.service.resolver.VersionConstraint;
import org.eclipse.osgi.tests.OSGiTest;
import org.eclipse.osgi.tests.OSGiTestsActivator;
import org.osgi.framework.BundleException;
@@ -38,9 +48,11 @@ public abstract class AbstractStateTest extends OSGiTest {
}
public void assertContains(String tag, Object[] array, Object element) {
- for (int i = 0; i < array.length; i++)
- if (array[i] == element)
+ for (Object o : array) {
+ if (o == element) {
return;
+ }
+ }
fail(tag);
}
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/OSGiCapabilityTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/OSGiCapabilityTest.java
index 3fdaaa75c..1f553df18 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/OSGiCapabilityTest.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/OSGiCapabilityTest.java
@@ -16,11 +16,20 @@ package org.eclipse.osgi.tests.services.resolver;
import java.io.File;
import java.io.IOException;
import java.net.URL;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.eclipse.osgi.framework.util.CaseInsensitiveDictionaryMap;
-import org.eclipse.osgi.service.resolver.*;
+import org.eclipse.osgi.service.resolver.BundleDescription;
+import org.eclipse.osgi.service.resolver.ExportPackageDescription;
+import org.eclipse.osgi.service.resolver.GenericDescription;
+import org.eclipse.osgi.service.resolver.State;
import org.eclipse.osgi.util.ManifestElement;
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
@@ -194,11 +203,12 @@ public class OSGiCapabilityTest extends AbstractStateTest {
assertEquals("Expected number of capabilities do not match", expectedCnt, genRequired.length);
assertEquals("Specs do not match Descs", genRequired.length, genProvided.length + (fragIdentity == null ? 0 : 1));
Collection providedCollection = new ArrayList(Arrays.asList(genProvided));
- for (int i = 0; i < genRequired.length; i++) {
- if (IdentityNamespace.IDENTITY_NAMESPACE.equals(genRequired[i].getType()) && genRequired[i].getSupplier().getHost() != null)
- assertEquals("Wrong fragment provider: " + genRequired[i], fragIdentity, genRequired[i]);
- else
- assertTrue("Wrong provider for requirement: " + genRequired[i], providedCollection.remove(genRequired[i]));
+ for (GenericDescription requiredDescription : genRequired) {
+ if (IdentityNamespace.IDENTITY_NAMESPACE.equals(requiredDescription.getType()) && requiredDescription.getSupplier().getHost() != null) {
+ assertEquals("Wrong fragment provider: " + requiredDescription, fragIdentity, requiredDescription);
+ } else {
+ assertTrue("Wrong provider for requirement: " + requiredDescription, providedCollection.remove(requiredDescription));
+ }
}
}
@@ -613,8 +623,8 @@ public class OSGiCapabilityTest extends AbstractStateTest {
GenericDescription[] required = requirer.getResolvedGenericRequires();
assertEquals("Wrong number of capabilities for bundle: " + requirer, expectedCapabilities.length, required.length);
Collection providedCollection = new ArrayList(Arrays.asList(expectedCapabilities));
- for (int i = 0; i < required.length; i++) {
- assertTrue("Wrong provider for requirement: " + required[i], providedCollection.remove(required[i]));
+ for (GenericDescription requiredDescription : required) {
+ assertTrue("Wrong provider for requirement: " + requiredDescription, providedCollection.remove(requiredDescription));
}
}
}
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/StateResolverTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/StateResolverTest.java
index 531ffd05a..5b6c147ec 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/StateResolverTest.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/StateResolverTest.java
@@ -118,8 +118,9 @@ public class StateResolverTest extends AbstractStateTest {
deltas = delta.getChanges();
assertEquals("1.0", 3, deltas.length); //$NON-NLS-1$
Map deltasMap = new HashMap();
- for (int i = 0; i < deltas.length; i++)
- deltasMap.put(Long.valueOf(deltas[i].getBundle().getBundleId()), deltas[i]);
+ for (BundleDelta bundleDelta : deltas) {
+ deltasMap.put(Long.valueOf(bundleDelta.getBundle().getBundleId()), bundleDelta);
+ }
assertNotNull("1.1", deltasMap.get(Long.valueOf(1))); //$NON-NLS-1$
assertNotNull("1.2", deltasMap.get(Long.valueOf(2))); //$NON-NLS-1$
assertNotNull("1.3", deltasMap.get(Long.valueOf(3))); //$NON-NLS-1$
@@ -144,8 +145,9 @@ public class StateResolverTest extends AbstractStateTest {
BundleDelta[] resolutions = delta.getChanges(BundleDelta.RESOLVED, false);
assertEquals("3.0", 2, resolutions.length); //$NON-NLS-1$
Map deltasMap = new HashMap();
- for (int i = 0; i < resolutions.length; i++)
- deltasMap.put(resolutions[i].getBundle().getSymbolicName(), resolutions[i]);
+ for (BundleDelta resolution : resolutions) {
+ deltasMap.put(resolution.getBundle().getSymbolicName(), resolution);
+ }
assertNotNull("3.1", deltasMap.get(b1.getSymbolicName())); //$NON-NLS-1$
assertNotNull("3.2", deltasMap.get(b2.getSymbolicName())); //$NON-NLS-1$
// TODO why do we expect unresolved deltas here when the bundle was not resolved in the first place?
@@ -179,8 +181,9 @@ public class StateResolverTest extends AbstractStateTest {
BundleDelta[] resolutions = delta.getChanges(BundleDelta.RESOLVED, false);
assertEquals("3.0", 6, resolutions.length); //$NON-NLS-1$
Map deltasMap = new HashMap();
- for (int i = 0; i < resolutions.length; i++)
- deltasMap.put(resolutions[i].getBundle().getSymbolicName(), resolutions[i]);
+ for (BundleDelta resolution : resolutions) {
+ deltasMap.put(resolution.getBundle().getSymbolicName(), resolution);
+ }
assertNotNull("3.1", deltasMap.get(b1.getSymbolicName())); //$NON-NLS-1$
assertNotNull("3.2", deltasMap.get(b2.getSymbolicName())); //$NON-NLS-1$
assertNotNull("3.3", deltasMap.get(b3.getSymbolicName())); //$NON-NLS-1$
@@ -429,8 +432,9 @@ public class StateResolverTest extends AbstractStateTest {
deltas = delta.getChanges();
assertEquals("1.0", 4, deltas.length); //$NON-NLS-1$
Map deltasMap = new HashMap();
- for (int i = 0; i < deltas.length; i++)
- deltasMap.put(Long.valueOf(deltas[i].getBundle().getBundleId()), deltas[i]);
+ for (BundleDelta bundleDelta : deltas) {
+ deltasMap.put(Long.valueOf(bundleDelta.getBundle().getBundleId()), bundleDelta);
+ }
assertNotNull("1.1", deltasMap.get(Long.valueOf(1))); //$NON-NLS-1$
assertNotNull("1.2", deltasMap.get(Long.valueOf(2))); //$NON-NLS-1$
assertNotNull("1.3", deltasMap.get(Long.valueOf(3))); //$NON-NLS-1$
@@ -503,8 +507,9 @@ public class StateResolverTest extends AbstractStateTest {
deltas = delta.getChanges();
assertEquals("1.0", 3, deltas.length); //$NON-NLS-1$
Map deltasMap = new HashMap();
- for (int i = 0; i < deltas.length; i++)
- deltasMap.put(Long.valueOf(deltas[i].getBundle().getBundleId()), deltas[i]);
+ for (BundleDelta bundleDelta : deltas) {
+ deltasMap.put(Long.valueOf(bundleDelta.getBundle().getBundleId()), bundleDelta);
+ }
assertNotNull("1.1", deltasMap.get(Long.valueOf(1))); //$NON-NLS-1$
assertNotNull("1.2", deltasMap.get(Long.valueOf(2))); //$NON-NLS-1$
assertNotNull("1.3", deltasMap.get(Long.valueOf(3))); //$NON-NLS-1$
@@ -515,8 +520,9 @@ public class StateResolverTest extends AbstractStateTest {
deltas = delta.getChanges();
assertEquals("3.0", 3, deltas.length); //$NON-NLS-1$
deltasMap = new HashMap();
- for (int i = 0; i < deltas.length; i++)
- deltasMap.put(Long.valueOf(deltas[i].getBundle().getBundleId()), deltas[i]);
+ for (BundleDelta bundleDelta : deltas) {
+ deltasMap.put(Long.valueOf(bundleDelta.getBundle().getBundleId()), bundleDelta);
+ }
assertNotNull("3.1", deltasMap.get(Long.valueOf(1))); //$NON-NLS-1$
assertNotNull("3.2", deltasMap.get(Long.valueOf(2))); //$NON-NLS-1$
assertNotNull("3.3", deltasMap.get(Long.valueOf(3))); //$NON-NLS-1$
@@ -549,8 +555,9 @@ public class StateResolverTest extends AbstractStateTest {
changes = delta.getChanges();
assertEquals("2.0", 2, changes.length); //$NON-NLS-1$
HashMap deltasMap = new HashMap();
- for (int i = 0; i < changes.length; i++)
- deltasMap.put(changes[i].getBundle(), changes[i]);
+ for (BundleDelta change : changes) {
+ deltasMap.put(change.getBundle(), change);
+ }
assertNotNull("2.1", deltasMap.get(b1)); //$NON-NLS-1$
assertNotNull("2.2", deltasMap.get(b11)); //$NON-NLS-1$
assertEquals("2.3", BundleDelta.UNRESOLVED, ((BundleDelta) deltasMap.get(b1)).getType()); //$NON-NLS-1$
@@ -3775,17 +3782,22 @@ public class StateResolverTest extends AbstractStateTest {
}
private ExportPackageDescription[] isConsistent(ExportPackageDescription[] pkgs1, ExportPackageDescription[] pkgs2) {
- for (int i = 0; i < pkgs1.length; i++)
- for (int j = 0; j < pkgs2.length; j++)
- if (pkgs1[i].getName().equals(pkgs2[j].getName()) && pkgs1[i] != pkgs2[j])
- return new ExportPackageDescription[] {pkgs1[i], pkgs2[j]};
+ for (ExportPackageDescription pkg1 : pkgs1) {
+ for (ExportPackageDescription pkg2 : pkgs2) {
+ if (pkg1.getName().equals(pkg2.getName()) && pkg1 != pkg2) {
+ return new ExportPackageDescription[]{pkg1, pkg2};
+ }
+ }
+ }
return null;
}
private boolean contains(Object[] array, Object element) {
- for (int i = 0; i < array.length; i++)
- if (array[i].equals(element))
+ for (Object o : array) {
+ if (o.equals(element)) {
return true;
+ }
+ }
return false;
}
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/SubstitutableExportsTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/SubstitutableExportsTest.java
index 2d8988ee2..f9a7c014c 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/SubstitutableExportsTest.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/SubstitutableExportsTest.java
@@ -1911,15 +1911,14 @@ public class SubstitutableExportsTest extends AbstractStateTest {
BundleDelta[] bundleDeltas = stateDelta.getChanges();
assertNotNull("bundleDeltas is null", bundleDeltas); //$NON-NLS-1$
assertEquals("bunldeDeltas wrong number", 6, bundleDeltas.length); //$NON-NLS-1$
-
- for (int i = 0; i < allBundles.length; i++) {
+ for (BundleDescription description : allBundles) {
boolean found = false;
for (int j = 0; j < bundleDeltas.length && !found; j++) {
assertEquals("unexpected delta type " + bundleDeltas[j], BundleDelta.RESOLVED, bundleDeltas[j].getType()); //$NON-NLS-1$
- found = bundleDeltas[j].getBundle() == allBundles[i];
+ found = bundleDeltas[j].getBundle() == description;
}
if (!found) {
- fail("Did not find RESOLVED BundleDelta for " + allBundles[i]); //$NON-NLS-1$
+ fail("Did not find RESOLVED BundleDelta for " + description); //$NON-NLS-1$
}
}
stateDelta = state.resolve(new BundleDescription[] {f});
@@ -1944,15 +1943,14 @@ public class SubstitutableExportsTest extends AbstractStateTest {
BundleDelta[] bundleDeltas = stateDelta.getChanges();
assertNotNull("bundleDeltas is null", bundleDeltas); //$NON-NLS-1$
assertEquals("bunldeDeltas wrong number", 6, bundleDeltas.length); //$NON-NLS-1$
-
- for (int i = 0; i < allRefreshBundles.length; i++) {
+ for (BundleDescription description : allRefreshBundles) {
boolean found = false;
for (int j = 0; j < bundleDeltas.length && !found; j++) {
assertEquals("unexpected delta type " + bundleDeltas[j], BundleDelta.RESOLVED, bundleDeltas[j].getType()); //$NON-NLS-1$
- found = bundleDeltas[j].getBundle() == allRefreshBundles[i];
+ found = bundleDeltas[j].getBundle() == description;
}
if (!found) {
- fail("Did not find RESOLVED BundleDelta for " + allRefreshBundles[i]); //$NON-NLS-1$
+ fail("Did not find RESOLVED BundleDelta for " + description); //$NON-NLS-1$
}
}
stateDelta = state.resolve(new BundleDescription[] {f});
@@ -1983,15 +1981,14 @@ public class SubstitutableExportsTest extends AbstractStateTest {
BundleDelta[] bundleDeltas = stateDelta.getChanges();
assertNotNull("bundleDeltas is null", bundleDeltas); //$NON-NLS-1$
assertEquals("bunldeDeltas wrong number", 8, bundleDeltas.length); //$NON-NLS-1$
-
- for (int i = 0; i < allRefreshBundles.length; i++) {
+ for (BundleDescription description : allRefreshBundles) {
boolean found = false;
for (int j = 0; j < bundleDeltas.length && !found; j++) {
assertEquals("unexpected delta type " + bundleDeltas[j], BundleDelta.RESOLVED, bundleDeltas[j].getType()); //$NON-NLS-1$
- found = bundleDeltas[j].getBundle() == allRefreshBundles[i];
+ found = bundleDeltas[j].getBundle() == description;
}
if (!found) {
- fail("Did not find RESOLVED BundleDelta for " + allRefreshBundles[i]); //$NON-NLS-1$
+ fail("Did not find RESOLVED BundleDelta for " + description); //$NON-NLS-1$
}
}
stateDelta = state.resolve(new BundleDescription[] {f});
@@ -2003,15 +2000,14 @@ public class SubstitutableExportsTest extends AbstractStateTest {
bundleDeltas = stateDelta.getChanges();
assertNotNull("bundleDeltas is null", bundleDeltas); //$NON-NLS-1$
assertEquals("bunldeDeltas wrong number", 8, bundleDeltas.length); //$NON-NLS-1$
-
- for (int i = 0; i < allRefreshBundles.length; i++) {
+ for (BundleDescription description : allRefreshBundles) {
boolean found = false;
for (int j = 0; j < bundleDeltas.length && !found; j++) {
assertEquals("unexpected delta type " + bundleDeltas[j], BundleDelta.RESOLVED, bundleDeltas[j].getType()); //$NON-NLS-1$
- found = bundleDeltas[j].getBundle() == allRefreshBundles[i];
+ found = bundleDeltas[j].getBundle() == description;
}
if (!found) {
- fail("Did not find RESOLVED BundleDelta for " + allRefreshBundles[i]); //$NON-NLS-1$
+ fail("Did not find RESOLVED BundleDelta for " + description); //$NON-NLS-1$
}
}
}
@@ -2035,15 +2031,14 @@ public class SubstitutableExportsTest extends AbstractStateTest {
BundleDelta[] bundleDeltas = stateDelta.getChanges();
assertNotNull("bundleDeltas is null", bundleDeltas); //$NON-NLS-1$
assertEquals("bunldeDeltas wrong number", 9, bundleDeltas.length); //$NON-NLS-1$
-
- for (int i = 0; i < allBundles.length; i++) {
+ for (BundleDescription description : allBundles) {
boolean found = false;
for (int j = 0; j < bundleDeltas.length && !found; j++) {
assertEquals("unexpected delta type " + bundleDeltas[j], BundleDelta.RESOLVED, bundleDeltas[j].getType()); //$NON-NLS-1$
- found = bundleDeltas[j].getBundle() == allBundles[i];
+ found = bundleDeltas[j].getBundle() == description;
}
if (!found) {
- fail("Did not find RESOLVED BundleDelta for " + allBundles[i]); //$NON-NLS-1$
+ fail("Did not find RESOLVED BundleDelta for " + description); //$NON-NLS-1$
}
}
stateDelta = state.resolve(new BundleDescription[] {f});
@@ -2056,15 +2051,14 @@ public class SubstitutableExportsTest extends AbstractStateTest {
BundleDescription[] expectedRefresh = new BundleDescription[] {c, cFrag, f};
assertNotNull("bundleDeltas is null", bundleDeltas); //$NON-NLS-1$
assertEquals("bunldeDeltas wrong number", 3, bundleDeltas.length); //$NON-NLS-1$
-
- for (int i = 0; i < expectedRefresh.length; i++) {
+ for (BundleDescription description : expectedRefresh) {
boolean found = false;
for (int j = 0; j < bundleDeltas.length && !found; j++) {
assertEquals("unexpected delta type " + bundleDeltas[j], BundleDelta.RESOLVED, bundleDeltas[j].getType()); //$NON-NLS-1$
- found = bundleDeltas[j].getBundle() == expectedRefresh[i];
+ found = bundleDeltas[j].getBundle() == description;
}
if (!found) {
- fail("Did not find RESOLVED BundleDelta for " + expectedRefresh[i]); //$NON-NLS-1$
+ fail("Did not find RESOLVED BundleDelta for " + description); //$NON-NLS-1$
}
}
}
@@ -2090,15 +2084,14 @@ public class SubstitutableExportsTest extends AbstractStateTest {
BundleDelta[] bundleDeltas = stateDelta.getChanges();
assertNotNull("bundleDeltas is null", bundleDeltas); //$NON-NLS-1$
assertEquals("bunldeDeltas wrong number", allRefreshBundles.length, bundleDeltas.length); //$NON-NLS-1$
-
- for (int i = 0; i < allRefreshBundles.length; i++) {
+ for (BundleDescription description : allRefreshBundles) {
boolean found = false;
for (int j = 0; j < bundleDeltas.length && !found; j++) {
assertEquals("unexpected delta type " + bundleDeltas[j], BundleDelta.RESOLVED, bundleDeltas[j].getType()); //$NON-NLS-1$
- found = bundleDeltas[j].getBundle() == allRefreshBundles[i];
+ found = bundleDeltas[j].getBundle() == description;
}
if (!found) {
- fail("Did not find RESOLVED BundleDelta for " + allRefreshBundles[i]); //$NON-NLS-1$
+ fail("Did not find RESOLVED BundleDelta for " + description); //$NON-NLS-1$
}
}
stateDelta = state.resolve(new BundleDescription[] {f});
@@ -2116,15 +2109,14 @@ public class SubstitutableExportsTest extends AbstractStateTest {
BundleDescription[] expectedRefresh = new BundleDescription[] {c, cFrag, f};
assertNotNull("bundleDeltas is null", bundleDeltas); //$NON-NLS-1$
assertEquals("bunldeDeltas wrong number", 3, bundleDeltas.length); //$NON-NLS-1$
-
- for (int i = 0; i < expectedRefresh.length; i++) {
+ for (BundleDescription description : expectedRefresh) {
boolean found = false;
for (int j = 0; j < bundleDeltas.length && !found; j++) {
assertEquals("unexpected delta type " + bundleDeltas[j], BundleDelta.RESOLVED, bundleDeltas[j].getType()); //$NON-NLS-1$
- found = bundleDeltas[j].getBundle() == expectedRefresh[i];
+ found = bundleDeltas[j].getBundle() == description;
}
if (!found) {
- fail("Did not find RESOLVED BundleDelta for " + expectedRefresh[i]); //$NON-NLS-1$
+ fail("Did not find RESOLVED BundleDelta for " + description); //$NON-NLS-1$
}
}
}
@@ -2151,15 +2143,14 @@ public class SubstitutableExportsTest extends AbstractStateTest {
BundleDelta[] bundleDeltas = stateDelta.getChanges();
assertNotNull("bundleDeltas is null", bundleDeltas); //$NON-NLS-1$
assertEquals("bunldeDeltas wrong number", allRefreshBundles.length, bundleDeltas.length); //$NON-NLS-1$
-
- for (int j = 0; j < allRefreshBundles.length; j++) {
+ for (BundleDescription description : allRefreshBundles) {
boolean found = false;
for (int k = 0; k < bundleDeltas.length && !found; k++) {
assertEquals("unexpected delta type " + bundleDeltas[k], BundleDelta.RESOLVED, bundleDeltas[k].getType()); //$NON-NLS-1$
- found = bundleDeltas[k].getBundle() == allRefreshBundles[j];
+ found = bundleDeltas[k].getBundle() == description;
}
if (!found) {
- fail("Did not find RESOLVED BundleDelta for " + allRefreshBundles[j]); //$NON-NLS-1$
+ fail("Did not find RESOLVED BundleDelta for " + description); //$NON-NLS-1$
}
}
stateDelta = state.resolve(new BundleDescription[] {f});
@@ -2171,15 +2162,14 @@ public class SubstitutableExportsTest extends AbstractStateTest {
bundleDeltas = stateDelta.getChanges();
assertNotNull("bundleDeltas is null", bundleDeltas); //$NON-NLS-1$
assertEquals("bunldeDeltas wrong number", allRefreshBundles.length, bundleDeltas.length); //$NON-NLS-1$
-
- for (int j = 0; j < allRefreshBundles.length; j++) {
+ for (BundleDescription description : allRefreshBundles) {
boolean found = false;
for (int k = 0; k < bundleDeltas.length && !found; k++) {
assertEquals("unexpected delta type " + bundleDeltas[k], BundleDelta.RESOLVED, bundleDeltas[k].getType()); //$NON-NLS-1$
- found = bundleDeltas[k].getBundle() == allRefreshBundles[j];
+ found = bundleDeltas[k].getBundle() == description;
}
if (!found) {
- fail("Did not find RESOLVED BundleDelta for " + allRefreshBundles[j]); //$NON-NLS-1$
+ fail("Did not find RESOLVED BundleDelta for " + description); //$NON-NLS-1$
}
}
}
@@ -2202,15 +2192,14 @@ public class SubstitutableExportsTest extends AbstractStateTest {
BundleDelta[] bundleDeltas = stateDelta.getChanges();
assertNotNull("bundleDeltas is null", bundleDeltas); //$NON-NLS-1$
assertEquals("bunldeDeltas wrong number", allBundles.length, bundleDeltas.length); //$NON-NLS-1$
-
- for (int j = 0; j < allBundles.length; j++) {
+ for (BundleDescription description : allBundles) {
boolean found = false;
for (int k = 0; k < bundleDeltas.length && !found; k++) {
assertEquals("unexpected delta type " + bundleDeltas[k], BundleDelta.RESOLVED, bundleDeltas[k].getType()); //$NON-NLS-1$
- found = bundleDeltas[k].getBundle() == allBundles[j];
+ found = bundleDeltas[k].getBundle() == description;
}
if (!found) {
- fail("Did not find RESOLVED BundleDelta for " + allBundles[j]); //$NON-NLS-1$
+ fail("Did not find RESOLVED BundleDelta for " + description); //$NON-NLS-1$
}
}
@@ -2219,15 +2208,14 @@ public class SubstitutableExportsTest extends AbstractStateTest {
BundleDescription[] expectedRefresh = new BundleDescription[] {f, i};
assertNotNull("bundleDeltas is null", bundleDeltas); //$NON-NLS-1$
assertEquals("bunldeDeltas wrong number", expectedRefresh.length, bundleDeltas.length); //$NON-NLS-1$
-
- for (int j = 0; j < expectedRefresh.length; j++) {
+ for (BundleDescription description : expectedRefresh) {
boolean found = false;
for (int k = 0; k < bundleDeltas.length && !found; k++) {
assertEquals("unexpected delta type " + bundleDeltas[k], BundleDelta.RESOLVED, bundleDeltas[k].getType()); //$NON-NLS-1$
- found = bundleDeltas[k].getBundle() == expectedRefresh[j];
+ found = bundleDeltas[k].getBundle() == description;
}
if (!found) {
- fail("Did not find RESOLVED BundleDelta for " + expectedRefresh[j]); //$NON-NLS-1$
+ fail("Did not find RESOLVED BundleDelta for " + description); //$NON-NLS-1$
}
}
stateDelta = state.resolve(new BundleDescription[] {i});
@@ -2256,15 +2244,14 @@ public class SubstitutableExportsTest extends AbstractStateTest {
BundleDelta[] bundleDeltas = stateDelta.getChanges();
assertNotNull("bundleDeltas is null", bundleDeltas); //$NON-NLS-1$
assertEquals("bunldeDeltas wrong number", allRefreshBundles.length, bundleDeltas.length); //$NON-NLS-1$
-
- for (int l = 0; l < allRefreshBundles.length; l++) {
+ for (BundleDescription description : allRefreshBundles) {
boolean found = false;
for (int m = 0; m < bundleDeltas.length && !found; m++) {
assertEquals("unexpected delta type " + bundleDeltas[m], BundleDelta.RESOLVED, bundleDeltas[m].getType()); //$NON-NLS-1$
- found = bundleDeltas[m].getBundle() == allRefreshBundles[l];
+ found = bundleDeltas[m].getBundle() == description;
}
if (!found) {
- fail("Did not find RESOLVED BundleDelta for " + allRefreshBundles[l]); //$NON-NLS-1$
+ fail("Did not find RESOLVED BundleDelta for " + description); //$NON-NLS-1$
}
}
@@ -2273,15 +2260,14 @@ public class SubstitutableExportsTest extends AbstractStateTest {
BundleDescription[] expectedRefresh = new BundleDescription[] {f, i};
assertNotNull("bundleDeltas is null", bundleDeltas); //$NON-NLS-1$
assertEquals("bunldeDeltas wrong number", expectedRefresh.length, bundleDeltas.length); //$NON-NLS-1$
-
- for (int l = 0; l < expectedRefresh.length; l++) {
+ for (BundleDescription description : expectedRefresh) {
boolean found = false;
for (int m = 0; m < bundleDeltas.length && !found; m++) {
assertEquals("unexpected delta type " + bundleDeltas[m], BundleDelta.RESOLVED, bundleDeltas[m].getType()); //$NON-NLS-1$
- found = bundleDeltas[m].getBundle() == expectedRefresh[l];
+ found = bundleDeltas[m].getBundle() == description;
}
if (!found) {
- fail("Did not find RESOLVED BundleDelta for " + expectedRefresh[l]); //$NON-NLS-1$
+ fail("Did not find RESOLVED BundleDelta for " + description); //$NON-NLS-1$
}
}
stateDelta = state.resolve(new BundleDescription[] {i});
@@ -2314,15 +2300,14 @@ public class SubstitutableExportsTest extends AbstractStateTest {
BundleDelta[] bundleDeltas = stateDelta.getChanges();
assertNotNull("bundleDeltas is null", bundleDeltas); //$NON-NLS-1$
assertEquals("bunldeDeltas wrong number", allRefreshBundles.length, bundleDeltas.length); //$NON-NLS-1$
-
- for (int k = 0; k < allRefreshBundles.length; k++) {
+ for (BundleDescription description : allRefreshBundles) {
boolean found = false;
for (int l = 0; l < bundleDeltas.length && !found; l++) {
assertEquals("unexpected delta type " + bundleDeltas[l], BundleDelta.RESOLVED, bundleDeltas[l].getType()); //$NON-NLS-1$
- found = bundleDeltas[l].getBundle() == allRefreshBundles[k];
+ found = bundleDeltas[l].getBundle() == description;
}
if (!found) {
- fail("Did not find RESOLVED BundleDelta for " + allRefreshBundles[k]); //$NON-NLS-1$
+ fail("Did not find RESOLVED BundleDelta for " + description); //$NON-NLS-1$
}
}
stateDelta = state.resolve(new BundleDescription[] {i});
@@ -2334,15 +2319,14 @@ public class SubstitutableExportsTest extends AbstractStateTest {
bundleDeltas = stateDelta.getChanges();
assertNotNull("bundleDeltas is null", bundleDeltas); //$NON-NLS-1$
assertEquals("bunldeDeltas wrong number", allRefreshBundles.length, bundleDeltas.length); //$NON-NLS-1$
-
- for (int k = 0; k < allRefreshBundles.length; k++) {
+ for (BundleDescription description : allRefreshBundles) {
boolean found = false;
for (int l = 0; l < bundleDeltas.length && !found; l++) {
assertEquals("unexpected delta type " + bundleDeltas[l], BundleDelta.RESOLVED, bundleDeltas[l].getType()); //$NON-NLS-1$
- found = bundleDeltas[l].getBundle() == allRefreshBundles[k];
+ found = bundleDeltas[l].getBundle() == description;
}
if (!found) {
- fail("Did not find RESOLVED BundleDelta for " + allRefreshBundles[k]); //$NON-NLS-1$
+ fail("Did not find RESOLVED BundleDelta for " + description); //$NON-NLS-1$
}
}
}
@@ -2604,13 +2588,13 @@ public class SubstitutableExportsTest extends AbstractStateTest {
ExportPackageDescription[] expected = new ExportPackageDescription[aExported.length + dExported.length];
System.arraycopy(aExported, 0, expected, 0, aExported.length);
System.arraycopy(dExported, 0, expected, aExported.length, dExported.length);
- for (int index = 0; index < expected.length; index++) {
- assertContains("eVisible not correct", eVisible, expected[index]); //$NON-NLS-1$
- assertContains("fVisible not correct", fVisible, expected[index]); //$NON-NLS-1$
- assertContains("gVisible not correct", gVisible, expected[index]); //$NON-NLS-1$
- assertContains("hVisible not correct", hVisible, expected[index]); //$NON-NLS-1$
- assertContains("iVisible not correct", iVisible, expected[index]); //$NON-NLS-1$
- assertContains("jVisible not correct", jVisible, expected[index]); //$NON-NLS-1$
+ for (ExportPackageDescription exportDescription : expected) {
+ assertContains("eVisible not correct", eVisible, exportDescription); //$NON-NLS-1$
+ assertContains("fVisible not correct", fVisible, exportDescription); //$NON-NLS-1$
+ assertContains("gVisible not correct", gVisible, exportDescription); //$NON-NLS-1$
+ assertContains("hVisible not correct", hVisible, exportDescription); //$NON-NLS-1$
+ assertContains("iVisible not correct", iVisible, exportDescription); //$NON-NLS-1$
+ assertContains("jVisible not correct", jVisible, exportDescription); //$NON-NLS-1$
}
}
@@ -2709,19 +2693,19 @@ public class SubstitutableExportsTest extends AbstractStateTest {
System.arraycopy(aExported, 0, efExpected, 0, aExported.length);
System.arraycopy(dExported, 0, efExpected, aExported.length, dExported.length);
efExpected[aExported.length + dExported.length] = l.getSelectedExports()[1];
- for (int index = 0; index < efExpected.length; index++) {
- assertContains("eVisible not correct", eVisible, efExpected[index]); //$NON-NLS-1$
- assertContains("fVisible not correct", fVisible, efExpected[index]); //$NON-NLS-1$
+ for (ExportPackageDescription efExport : efExpected) {
+ assertContains("eVisible not correct", eVisible, efExport); //$NON-NLS-1$
+ assertContains("fVisible not correct", fVisible, efExport); //$NON-NLS-1$
}
ExportPackageDescription[] ghijExpected = new ExportPackageDescription[aExported.length + dExported.length];
System.arraycopy(aExported, 0, ghijExpected, 0, aExported.length);
System.arraycopy(dExported, 0, ghijExpected, aExported.length, dExported.length);
- for (int index = 0; index < ghijExpected.length; index++) {
- assertContains("gVisible not correct", gVisible, ghijExpected[index]); //$NON-NLS-1$
- assertContains("hVisible not correct", hVisible, ghijExpected[index]); //$NON-NLS-1$
- assertContains("iVisible not correct", iVisible, ghijExpected[index]); //$NON-NLS-1$
- assertContains("jVisible not correct", jVisible, ghijExpected[index]); //$NON-NLS-1$
+ for (ExportPackageDescription ghijExport : ghijExpected) {
+ assertContains("gVisible not correct", gVisible, ghijExport); //$NON-NLS-1$
+ assertContains("hVisible not correct", hVisible, ghijExport); //$NON-NLS-1$
+ assertContains("iVisible not correct", iVisible, ghijExport); //$NON-NLS-1$
+ assertContains("jVisible not correct", jVisible, ghijExport); //$NON-NLS-1$
}
ExportPackageDescription[] lExported = l.getSelectedExports();
@@ -2729,9 +2713,9 @@ public class SubstitutableExportsTest extends AbstractStateTest {
System.arraycopy(aExported, 0, mnExpected, 0, aExported.length);
System.arraycopy(dExported, 0, mnExpected, aExported.length, dExported.length);
System.arraycopy(lExported, 0, mnExpected, aExported.length + dExported.length, lExported.length);
- for (int index = 0; index < mnExpected.length; index++) {
- assertContains("mVisible not correct", mVisible, mnExpected[index]); //$NON-NLS-1$
- assertContains("nVisible not correct", nVisible, mnExpected[index]); //$NON-NLS-1$
+ for (ExportPackageDescription mnExport : mnExpected) {
+ assertContains("mVisible not correct", mVisible, mnExport); //$NON-NLS-1$
+ assertContains("nVisible not correct", nVisible, mnExport); //$NON-NLS-1$
}
}
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/XFriendsInternalResolverTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/XFriendsInternalResolverTest.java
index 045f01e9d..6fcc03acd 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/XFriendsInternalResolverTest.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/XFriendsInternalResolverTest.java
@@ -370,9 +370,11 @@ public class XFriendsInternalResolverTest extends AbstractStateTest {
}
private boolean contains(Object[] array, Object element) {
- for (int i = 0; i < array.length; i++)
- if (array[i].equals(element))
+ for (Object o : array) {
+ if (o.equals(element)) {
return true;
+ }
+ }
return false;
}
}
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/util/BidiTextProcessorTestCase.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/util/BidiTextProcessorTestCase.java
index 97fb2f4ea..07dfac7fd 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/util/BidiTextProcessorTestCase.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/util/BidiTextProcessorTestCase.java
@@ -174,17 +174,16 @@ public class BidiTextProcessorTestCase extends TextProcessorTestCase {
public void testOtherStringsDeprocess() {
int testNum = 1;
- for (int i = 0; i < TEST_STAR_PATHS.length; i++) {
- String result = TextProcessor.process(TEST_STAR_PATHS[i], "*.");
+ for (String testStarPath : TEST_STAR_PATHS) {
+ String result = TextProcessor.process(testStarPath, "*.");
String resultDP = TextProcessor.deprocess(result);
- verifyBidiResult("Deprocess other (star) string" + testNum, resultDP, TEST_STAR_PATHS[i]);
+ verifyBidiResult("Deprocess other (star) string" + testNum, resultDP, testStarPath);
testNum++;
}
-
- for (int i = 0; i < TEST_EQUALS_PATHS.length; i++) {
- String result = TextProcessor.process(TEST_EQUALS_PATHS[i], "=");
+ for (String testEqualsPath : TEST_EQUALS_PATHS) {
+ String result = TextProcessor.process(testEqualsPath, "=");
String resultDP = TextProcessor.deprocess(result);
- verifyBidiResult("Deprocess other (equals) string" + testNum, resultDP, TEST_EQUALS_PATHS[i]);
+ verifyBidiResult("Deprocess other (equals) string" + testNum, resultDP, testEqualsPath);
testNum++;
}
}
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/util/LatinTextProcessorTestCase.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/util/LatinTextProcessorTestCase.java
index e3df4a885..2e9caca5c 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/util/LatinTextProcessorTestCase.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/util/LatinTextProcessorTestCase.java
@@ -27,20 +27,20 @@ public class LatinTextProcessorTestCase extends TextProcessorTestCase {
int size = TEST_DEFAULT_PATHS.length + TEST_STAR_PATHS.length + TEST_EQUALS_PATHS.length + TEST_ADDITIONAL_STRINGS.length;
ALL_PATHS = new String[size];
int idx = 0;
- for (int i = 0; i < TEST_DEFAULT_PATHS.length; i++) {
- ALL_PATHS[idx] = TEST_DEFAULT_PATHS[i];
+ for (String testDefaultPath : TEST_DEFAULT_PATHS) {
+ ALL_PATHS[idx] = testDefaultPath;
idx++;
}
- for (int i = 0; i < TEST_STAR_PATHS.length; i++) {
- ALL_PATHS[idx] = TEST_STAR_PATHS[i];
+ for (String testStartPath : TEST_STAR_PATHS) {
+ ALL_PATHS[idx] = testStartPath;
idx++;
}
- for (int i = 0; i < TEST_EQUALS_PATHS.length; i++) {
- ALL_PATHS[idx] = TEST_EQUALS_PATHS[i];
+ for (String testEqualsPath : TEST_EQUALS_PATHS) {
+ ALL_PATHS[idx] = testEqualsPath;
idx++;
}
- for (int i = 0; i < TEST_ADDITIONAL_STRINGS.length; i++) {
- ALL_PATHS[idx] = TEST_ADDITIONAL_STRINGS[i];
+ for (String testAdditionalString : TEST_ADDITIONAL_STRINGS) {
+ ALL_PATHS[idx] = testAdditionalString;
idx++;
}
}
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/util/TextProcessorSessionTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/util/TextProcessorSessionTest.java
index bb07b9a71..93fc182f3 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/util/TextProcessorSessionTest.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/util/TextProcessorSessionTest.java
@@ -30,8 +30,9 @@ public class TextProcessorSessionTest extends ConfigurationSessionTestSuite {
super(pluginId, clazz);
lang = language;
String[] ids = ConfigurationSessionTestSuite.MINIMAL_BUNDLE_SET;
- for (int i = 0; i < ids.length; i++)
- addBundle(ids[i]);
+ for (String id : ids) {
+ addBundle(id);
+ }
addBundle(OSGiTest.PI_OSGI_TESTS);
}
diff --git a/bundles/org.eclipse.osgi/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.osgi/.settings/org.eclipse.jdt.core.prefs
index 15d2ec557..770503dc3 100644
--- a/bundles/org.eclipse.osgi/.settings/org.eclipse.jdt.core.prefs
+++ b/bundles/org.eclipse.osgi/.settings/org.eclipse.jdt.core.prefs
@@ -69,7 +69,7 @@ org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=error
org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
org.eclipse.jdt.core.compiler.problem.nullReference=warning
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 {
diff --git a/bundles/org.eclipse.osgi/pom.xml b/bundles/org.eclipse.osgi/pom.xml
index dffff72d5..c0def9f01 100644
--- a/bundles/org.eclipse.osgi/pom.xml
+++ b/bundles/org.eclipse.osgi/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
-->
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/eventmgr/CopyOnWriteIdentityMap.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/eventmgr/CopyOnWriteIdentityMap.java
index f58ab624e..4625925a0 100644
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/eventmgr/CopyOnWriteIdentityMap.java
+++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/eventmgr/CopyOnWriteIdentityMap.java
@@ -291,10 +291,9 @@ public class CopyOnWriteIdentityMap<K, V> implements Map<K, V> {
throw new IllegalArgumentException();
}
- Entry<K, V>[] e = entries();
- for (int i = 0; i < e.length; i++) {
- if (e[i].key == key) {
- return e[i].value;
+ for (Entry<K, V> entry : entries()) {
+ if (entry.key == key) {
+ return entry.value;
}
}
return null;
@@ -314,9 +313,8 @@ public class CopyOnWriteIdentityMap<K, V> implements Map<K, V> {
throw new IllegalArgumentException();
}
- Entry<K, V>[] e = entries();
- for (int i = 0; i < e.length; i++) {
- if (e[i].key == key) {
+ for (Entry<K, V> entry : entries()) {
+ if (entry.key == key) {
return true;
}
}
@@ -332,9 +330,8 @@ public class CopyOnWriteIdentityMap<K, V> implements Map<K, V> {
*/
@Override
public boolean containsValue(Object value) {
- Entry<K, V>[] e = entries();
- for (int i = 0; i < e.length; i++) {
- if (e[i].value == value) {
+ for (Entry<K, V> entry : entries()) {
+ if (entry.value == value) {
return true;
}
}
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/reliablefile/ReliableFile.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/reliablefile/ReliableFile.java
index 5a8123834..ca2b71651 100644
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/reliablefile/ReliableFile.java
+++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/reliablefile/ReliableFile.java
@@ -199,12 +199,12 @@ public class ReliableFile {
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 candidateFile : files) {
+ if (candidateFile.startsWith(prefix)) {
try {
- int id = Integer.parseInt(files[i].substring(prefixLen));
+ int id = Integer.parseInt(candidateFile.substring(prefixLen));
list.add(Integer.valueOf(id));
- } catch (NumberFormatException e) {/*ignore*/
+ }catch (NumberFormatException e) {/*ignore*/
}
}
}
@@ -543,12 +543,12 @@ public class ReliableFile {
String[] files = parent.list();
if (files == null)
return false;
- for (int i = 0; i < files.length; i++) {
- if (files[i].startsWith(prefix)) {
+ for (String candidateFile : files) {
+ if (candidateFile.startsWith(prefix)) {
try {
- Integer.parseInt(files[i].substring(prefixLen));
+ Integer.parseInt(candidateFile.substring(prefixLen));
return true;
- } catch (NumberFormatException e) {/*ignore*/
+ }catch (NumberFormatException e) {/*ignore*/
}
}
}
@@ -642,8 +642,7 @@ public class ReliableFile {
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.osgi/supplement/src/org/eclipse/osgi/storagemanager/StorageManager.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/storagemanager/StorageManager.java
index c792c3155..2cadd889b 100644
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/storagemanager/StorageManager.java
+++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/storagemanager/StorageManager.java
@@ -22,7 +22,6 @@ import java.io.OutputStream;
import java.io.SyncFailedException;
import java.util.Collection;
import java.util.Enumeration;
-import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
@@ -270,14 +269,15 @@ public final class StorageManager {
if (files != null) {
String name = managedFile + '.';
int len = name.length();
- for (int i = 0; i < files.length; i++) {
- if (!files[i].startsWith(name))
+ for (String file : files) {
+ if (!file.startsWith(name)) {
continue;
+ }
try {
- int generation = Integer.parseInt(files[i].substring(len));
+ int generation = Integer.parseInt(file.substring(len));
if (generation > oldestGeneration)
oldestGeneration = generation;
- } catch (NumberFormatException e) {
+ }catch (NumberFormatException e) {
continue;
}
}
@@ -620,13 +620,13 @@ public final class StorageManager {
//Iterate through the temp files and delete them all, except the one representing this storage manager.
String[] files = managerRoot.list();
if (files != null) {
- for (int i = 0; i < files.length; i++) {
- if (files[i].endsWith(".instance") && (instanceFile == null || !files[i].equalsIgnoreCase(instanceFile.getName()))) { //$NON-NLS-1$
- Locker tmpLocker = LocationHelper.createLocker(new File(managerRoot, files[i]), lockMode, false);
+ for (String file : files) {
+ if (file.endsWith(".instance") && (instanceFile == null || !file.equalsIgnoreCase(instanceFile.getName()))) { //$NON-NLS-1$
+ Locker tmpLocker = LocationHelper.createLocker(new File(managerRoot, file), lockMode, false);
if (tmpLocker.lock()) {
//If I can lock it is a file that has been left behind by a crash
tmpLocker.release();
- new File(managerRoot, files[i]).delete();
+ new File(managerRoot, file).delete();
} else {
tmpLocker.release();
return; //The file is still being locked by somebody else
@@ -638,8 +638,7 @@ public final class StorageManager {
//If we are here it is because we are the last instance running. After locking the table and getting its latest content, remove all the backup files and change the table
updateTable();
Collection<Map.Entry<Object, Object>> managedFiles = table.entrySet();
- for (Iterator<Map.Entry<Object, Object>> iter = managedFiles.iterator(); iter.hasNext();) {
- Map.Entry<Object, Object> fileEntry = iter.next();
+ for (Map.Entry<Object, Object> fileEntry : managedFiles) {
String fileName = (String) fileEntry.getKey();
Entry info = (Entry) fileEntry.getValue();
if (info.getFileType() == FILETYPE_RELIABLEFILE) {
@@ -654,9 +653,9 @@ public final class StorageManager {
if (tempCleanup) {
files = base.list();
if (files != null) {
- for (int i = 0; i < files.length; i++) {
- if (files[i].endsWith(ReliableFile.tmpExt)) {
- new File(base, files[i]).delete();
+ for (String file : files) {
+ if (file.endsWith(ReliableFile.tmpExt)) {
+ new File(base, file).delete();
}
}
}
@@ -672,9 +671,10 @@ public final class StorageManager {
String[] files = base.list();
if (files == null)
return;
- for (int i = 0; i < files.length; i++) {
- if (files[i].startsWith(fileName + '.') && !files[i].equals(notToDelete))
- new File(base, files[i]).delete();
+ for (String file : files) {
+ if (file.startsWith(fileName + '.') && !file.equals(notToDelete)) {
+ new File(base, file).delete();
+ }
}
}
@@ -849,13 +849,13 @@ public final class StorageManager {
* @see #getOutputStreamSet(String[])
*/
void abortOutputStream(ManagedOutputStream out) {
- ManagedOutputStream[] set = out.getStreamSet();
- if (set == null) {
- set = new ManagedOutputStream[] {out};
+ ManagedOutputStream[] streamset = out.getStreamSet();
+ if (streamset == null) {
+ streamset = new ManagedOutputStream[] {out};
}
- synchronized (set) {
- for (int idx = 0; idx < set.length; idx++) {
- out = set[idx];
+ synchronized (streamset) {
+ for (ManagedOutputStream stream : streamset) {
+ out = stream;
if (out.getOutputFile() == null) {
// this is a ReliableFileOutpuStream
ReliableFileOutputStream rfos = (ReliableFileOutputStream) out.getOutputStream();
@@ -921,9 +921,10 @@ public final class StorageManager {
if (streamSet != null) {
synchronized (streamSet) {
//check all the streams to see if there are any left open....
- for (int idx = 0; idx < streamSet.length; idx++) {
- if (streamSet[idx].getState() == ManagedOutputStream.ST_OPEN)
+ for (ManagedOutputStream stream : streamSet) {
+ if (stream.getState() == ManagedOutputStream.ST_OPEN) {
return; //done
+ }
}
//all streams are closed, we need to update storage manager
String[] targets = new String[streamSet.length];
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/ManifestElement.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/ManifestElement.java
index 7a47f0bdd..76833c7ee 100644
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/ManifestElement.java
+++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/ManifestElement.java
@@ -608,11 +608,11 @@ public class ManifestElement {
private void addValues(boolean directive, String key, String[] values, StringBuffer result) {
if (values == null)
return;
- for (int i = 0; i < values.length; i++) {
+ for (String value : values) {
result.append(';').append(key);
if (directive)
result.append(':');
- result.append("=\"").append(values[i]).append('\"'); //$NON-NLS-1$
+ result.append("=\"").append(value).append('\"'); //$NON-NLS-1$
}
}
}
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/NLS.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/NLS.java
index f438b7409..7d64991d1 100644
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/NLS.java
+++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/NLS.java
@@ -327,16 +327,16 @@ public abstract class NLS {
// the MessagesProperties.put method will mark assigned fields
// to prevent them from being assigned twice
final String[] variants = buildVariants(bundleName);
- for (int i = 0; i < variants.length; i++) {
+ for (String variant : variants) {
// loader==null if we're launched off the Java boot classpath
- final InputStream input = loader == null ? ClassLoader.getSystemResourceAsStream(variants[i]) : loader.getResourceAsStream(variants[i]);
+ final InputStream input = loader == null ? ClassLoader.getSystemResourceAsStream(variant) : loader.getResourceAsStream(variant);
if (input == null)
continue;
try {
final MessagesProperties properties = new MessagesProperties(fields, bundleName, isAccessible);
properties.load(input);
} catch (IOException e) {
- log(SEVERITY_ERROR, "Error loading " + variants[i], e); //$NON-NLS-1$
+ log(SEVERITY_ERROR, "Error loading " + variant, e); //$NON-NLS-1$
} finally {
if (input != null)
try {

Back to the top