Merge content from HEAD (tag v20100503) to branch.
diff --git a/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/FrameworkCommandProvider.java b/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/FrameworkCommandProvider.java
index f0636f8..19d3628 100644
--- a/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/FrameworkCommandProvider.java
+++ b/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/FrameworkCommandProvider.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2003, 2009 IBM Corporation and others.
+ * Copyright (c) 2003, 2010 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -430,6 +430,8 @@
 		int stateFilter = -1;
 		if (option != null && option.equals("-s")) { //$NON-NLS-1$
 			String searchedState = intp.nextArgument();
+			if (searchedState == null)
+				searchedState = ""; //$NON-NLS-1$
 			StringTokenizer tokens = new StringTokenizer(searchedState, ","); //$NON-NLS-1$
 			while (tokens.hasMoreElements()) {
 				String desiredState = (String) tokens.nextElement();
diff --git a/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/FrameworkConsole.java b/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/FrameworkConsole.java
index 296de56..317e2bb 100644
--- a/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/FrameworkConsole.java
+++ b/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/FrameworkConsole.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2003, 2009 IBM Corporation and others.
+ * Copyright (c) 2003, 2010 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -99,7 +99,6 @@
 	 * Command output is written to the console PrintStream. The method will
 	 * loop reading commands from the console InputStream until end-of-file
 	 * is reached. This method will then return.
-	 * @throws IOException
 	 */
 	public void run() {
 		try {
diff --git a/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/framework/adaptor/ClassLoaderDelegateHook.java b/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/framework/adaptor/ClassLoaderDelegateHook.java
index 6e38cc1..e77e76d 100644
--- a/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/framework/adaptor/ClassLoaderDelegateHook.java
+++ b/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/framework/adaptor/ClassLoaderDelegateHook.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2008 IBM Corporation and others.
+ * Copyright (c) 2008, 2010 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -119,7 +119,6 @@
 	 * @param classLoader the bundle class loader
 	 * @param data the bundle data
 	 * @return the library found by this hook or null if normal delegation should continue
-	 * @throws FileNotFoundException to terminate the delegation
 	 */
 	public String postFindLibrary(String name, BundleClassLoader classLoader, BundleData data);
 }
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/console/CommandInterpreter.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/console/CommandInterpreter.java
index 213b814..4289fea 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/console/CommandInterpreter.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/console/CommandInterpreter.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2003, 2008 IBM Corporation and others.
+ * Copyright (c) 2003, 2010 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -26,18 +26,19 @@
  */
 public interface CommandInterpreter {
 	/**
-	 *	Get the next argument in the input.
-	 *	
-	 *	E.g. if the commandline is hello world, the _hello method
-	 *	will get "world" as the first argument.
+	 * Get the next argument in the input.  If no arguments are left then null is returned.
+	 *
+	 * E.g. if the commandline is hello world, the _hello method
+	 * will get "world" as the first argument.
+	 * @return the next argument or null if no arguments are left.
 	 */
 	public String nextArgument();
 
 	/**
-	 *	Execute a command line as if it came from the end user
-	 *	and return the result.
-	 *           
-	 *          Throws any exceptions generated by the command that executed.
+	 * Execute a command line as if it came from the end user
+	 * and return the result.
+	 * @param cmd The command line to execute.
+	 * @return the result of the command.
 	 */
 	public Object execute(String cmd);
 
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/Framework.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/Framework.java
index d2df7ae..aee969e 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/Framework.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/Framework.java
@@ -827,12 +827,6 @@
 	/**
 	 * Install a bundle from an InputStream.
 	 * 
-	 * <p>
-	 * This method performs all the steps listed in
-	 * {@link #installBundle(java.lang.String)}, except the bundle's content
-	 * will be read from the InputStream. The location identifier specified
-	 * will be used as the identity of the bundle.
-	 * 
 	 * @param location
 	 *            The location identifier of the bundle to install.
 	 * @param in
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/serviceregistry/ServiceRegistrationImpl.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/serviceregistry/ServiceRegistrationImpl.java
index 9b62392..69e5ea4 100755
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/serviceregistry/ServiceRegistrationImpl.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/serviceregistry/ServiceRegistrationImpl.java
@@ -614,7 +614,7 @@
 	 * We keep ServiceRegistationImpls in sorted lists such that the highest
 	 * ranked service is at element 0 for quick retrieval.
 	 * 
-	 * @param object The <code>ServiceRegistrationImpl</code> to be compared.
+	 * @param other The <code>ServiceRegistrationImpl</code> to be compared.
 	 * @return Returns a negative integer, zero, or a positive integer if this
 	 *         <code>ServiceRegistrationImpl</code> is greater than, equal to, or
 	 *         less than the specified <code>ServiceRegistrationImpl</code>.
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/serviceregistry/ServiceRegistry.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/serviceregistry/ServiceRegistry.java
index 2e75845..f45f6ce 100755
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/serviceregistry/ServiceRegistry.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/serviceregistry/ServiceRegistry.java
@@ -377,9 +377,9 @@
 	 * <p>
 	 * A bundle's use of a service is tracked by the bundle's use count of that
 	 * service. Each time a service's service object is returned by
-	 * {@link #getService(ServiceReference)} the context bundle's use count for
+	 * {@link #getService(BundleContextImpl, ServiceReferenceImpl)} the context bundle's use count for
 	 * that service is incremented by one. Each time the service is released by
-	 * {@link #ungetService(ServiceReference)} the context bundle's use count
+	 * {@link #ungetService(BundleContextImpl, ServiceReferenceImpl)} the context bundle's use count
 	 * for that service is decremented by one.
 	 * <p>
 	 * When a bundle's use count for a service drops to zero, the bundle should
@@ -428,7 +428,7 @@
 	 *         and the Java Runtime Environment supports permissions.
 	 * @throws java.lang.IllegalStateException If this BundleContext is no
 	 *         longer valid.
-	 * @see #ungetService(ServiceReference)
+	 * @see #ungetService(BundleContextImpl, ServiceReferenceImpl)
 	 * @see ServiceFactory
 	 */
 	public Object getService(BundleContextImpl context, ServiceReferenceImpl<?> reference) {
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java
index 4b0d8b7..c0ab396 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java
@@ -414,7 +414,15 @@
 		}
 		for (Iterator rejected = rejectedSingletons.iterator(); rejected.hasNext();) {
 			BundleDescription reject = (BundleDescription) rejected.next();
-			BundleDescription sameName = state.getBundle(reject.getSymbolicName(), null);
+			// need to do a bit of work to figure out which bundle got selected
+			BundleDescription[] sameNames = state.getBundles(reject.getSymbolicName());
+			BundleDescription sameName = reject;
+			for (int i = 0; i < sameNames.length; i++) {
+				if (sameNames[i] != reject && sameNames[i].isSingleton() && !rejectedSingletons.contains(sameNames[i])) {
+					sameName = sameNames[i]; // we know this one got selected
+					break;
+				}
+			}
 			state.addResolverError(reject, ResolverError.SINGLETON_SELECTION, sameName.toString(), null);
 		}
 		if (resolveOptional)
diff --git a/bundles/org.eclipse.osgi/security/src/org/eclipse/osgi/internal/signedcontent/SignedBundleHook.java b/bundles/org.eclipse.osgi/security/src/org/eclipse/osgi/internal/signedcontent/SignedBundleHook.java
index 993d9b8..5b90453 100644
--- a/bundles/org.eclipse.osgi/security/src/org/eclipse/osgi/internal/signedcontent/SignedBundleHook.java
+++ b/bundles/org.eclipse.osgi/security/src/org/eclipse/osgi/internal/signedcontent/SignedBundleHook.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2006, 2009 IBM Corporation and others.
+ * Copyright (c) 2006, 2010 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -33,6 +33,7 @@
 import org.eclipse.osgi.signedcontent.SignedContent;
 import org.eclipse.osgi.signedcontent.SignedContentFactory;
 import org.eclipse.osgi.util.ManifestElement;
+import org.eclipse.osgi.util.NLS;
 import org.osgi.framework.*;
 import org.osgi.framework.Constants;
 import org.osgi.util.tracker.ServiceTracker;
@@ -242,7 +243,19 @@
 		else
 			contentBundleFile = new ZipBundleFile(content, null);
 		SignedBundleFile result = new SignedBundleFile(null, VERIFY_ALL);
-		result.setBundleFile(contentBundleFile);
+		try {
+			result.setBundleFile(contentBundleFile);
+		} catch (InvalidKeyException e) {
+			throw (InvalidKeyException) new InvalidKeyException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content)).initCause(e);
+		} catch (SignatureException e) {
+			throw (SignatureException) new SignatureException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content)).initCause(e);
+		} catch (CertificateException e) {
+			throw (CertificateException) new CertificateException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content)).initCause(e);
+		} catch (NoSuchAlgorithmException e) {
+			throw (NoSuchAlgorithmException) new NoSuchAlgorithmException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content)).initCause(e);
+		} catch (NoSuchProviderException e) {
+			throw (NoSuchProviderException) new NoSuchProviderException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content)).initCause(e);
+		}
 		return new SignedContentFile(result.getSignedContent());
 	}
 
diff --git a/bundles/org.eclipse.osgi/security/src/org/eclipse/osgi/internal/signedcontent/SignedContentMessages.java b/bundles/org.eclipse.osgi/security/src/org/eclipse/osgi/internal/signedcontent/SignedContentMessages.java
index 6fdccd9..28cab18 100644
--- a/bundles/org.eclipse.osgi/security/src/org/eclipse/osgi/internal/signedcontent/SignedContentMessages.java
+++ b/bundles/org.eclipse.osgi/security/src/org/eclipse/osgi/internal/signedcontent/SignedContentMessages.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * Copyright (c) 2006, 2010 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -32,6 +32,8 @@
 	// Security Exceptions
 	public static String Algorithm_Not_Supported;
 
+	public static String Factory_SignedContent_Error;
+
 	public static String Default_Trust_Keystore_Load_Failed;
 	public static String Default_Trust_Read_Only;
 	public static String Default_Trust_Cert_Not_Found;
diff --git a/bundles/org.eclipse.osgi/security/src/org/eclipse/osgi/internal/signedcontent/SignedContentMessages.properties b/bundles/org.eclipse.osgi/security/src/org/eclipse/osgi/internal/signedcontent/SignedContentMessages.properties
index d0d9d98..47dace8 100644
--- a/bundles/org.eclipse.osgi/security/src/org/eclipse/osgi/internal/signedcontent/SignedContentMessages.properties
+++ b/bundles/org.eclipse.osgi/security/src/org/eclipse/osgi/internal/signedcontent/SignedContentMessages.properties
@@ -1,5 +1,5 @@
 ###############################################################################
-# Copyright (c) 2006, 2008 IBM Corporation and others.
+# Copyright (c) 2006, 2010 IBM Corporation and others.
 # All rights reserved. This program and the accompanying materials
 # are made available under the terms of the Eclipse Public License v1.0
 # which accompanies this distribution, and is available at
@@ -26,6 +26,9 @@
 # Security Exceptions
 Algorithm_Not_Supported = {0} digest algorithm is not supported!
 
+# SignedContentFactory exception
+Factory_SignedContent_Error = An error occurred while processing the signatures for the file: {0}
+
 # Default Trust Engine
 Default_Trust_Keystore_Load_Failed = Failed to load the keystore from: {0}
 Default_Trust_Read_Only=This trust engine is read only.
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/EclipseAdaptorMessages.properties b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/EclipseAdaptorMessages.properties
index ce456d5..ecb3dba 100644
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/EclipseAdaptorMessages.properties
+++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/EclipseAdaptorMessages.properties
@@ -108,7 +108,7 @@
 fileManager_notOpen = Manager is not opened.
 
 #Location messages
-location_cannotLockNIO = An error occurred while locking file \"{0}\": \"{1}\". A common reason is that the file system or Runtime Environment does not support file locking for that location. Please choose a different location, or disable file locking passing {2} as a VM argument.
+location_cannotLockNIO = An error occurred while locking file \"{0}\": \"{1}\". A common reason is that the file system or Runtime Environment does not support file locking for that location. Please choose a different location, or disable file locking by passing {2} as a VM argument.
 location_cannotLock = An error occurred while locking file \"{0}\".
 location_folderReadOnly = The folder \"{0}\" is read-only.
 location_notSet = The location has not been set.