Bug 117530 - equinox.registry should have its own InvalidRegistryObjectException
diff --git a/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentType.java b/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentType.java
index ac7139f..4ec9af0 100644
--- a/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentType.java
+++ b/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentType.java
@@ -17,6 +17,7 @@
 import org.eclipse.core.runtime.content.*;
 import org.eclipse.core.runtime.preferences.IScopeContext;
 import org.eclipse.equinox.registry.IConfigurationElement;
+import org.eclipse.equinox.registry.InvalidRegistryObjectException;
 import org.eclipse.osgi.util.NLS;
 import org.osgi.service.prefs.BackingStoreException;
 import org.osgi.service.prefs.Preferences;
diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/registry/eclipse/LegacyConfigurationElementHandle.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/registry/eclipse/LegacyConfigurationElementHandle.java
index 061a135..fc33878 100644
--- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/registry/eclipse/LegacyConfigurationElementHandle.java
+++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/registry/eclipse/LegacyConfigurationElementHandle.java
@@ -44,16 +44,28 @@
 		target = element;
 	}
 
-	public String getAttribute(String propertyName) {
-		return target.getAttribute(propertyName);
+	public String getAttribute(String propertyName) throws InvalidRegistryObjectException {
+		try {
+			return target.getAttribute(propertyName);
+		} catch (org.eclipse.equinox.registry.InvalidRegistryObjectException e) {
+			throw LegacyRegistryConverter.convert(e);
+		}
 	}
 
-	public String[] getAttributeNames() {
-		return target.getAttributeNames();
+	public String[] getAttributeNames() throws InvalidRegistryObjectException {
+		try {
+			return target.getAttributeNames();
+		} catch (org.eclipse.equinox.registry.InvalidRegistryObjectException e) {
+			throw LegacyRegistryConverter.convert(e);
+		}
 	}
 
-	public IConfigurationElement[] getChildren() {
-		return LegacyRegistryConverter.convert(target.getChildren());
+	public IConfigurationElement[] getChildren() throws InvalidRegistryObjectException {
+		try {
+			return LegacyRegistryConverter.convert(target.getChildren());
+		} catch (org.eclipse.equinox.registry.InvalidRegistryObjectException e) {
+			throw LegacyRegistryConverter.convert(e);
+		}
 	}
 
 	public Object createExecutableExtension(String propertyName) throws CoreException {
@@ -61,44 +73,76 @@
 
 	}
 
-	public String getAttributeAsIs(String name) {
-		return target.getAttributeAsIs(name);
+	public String getAttributeAsIs(String name) throws InvalidRegistryObjectException {
+		try {
+			return target.getAttributeAsIs(name);
+		} catch (org.eclipse.equinox.registry.InvalidRegistryObjectException e) {
+			throw LegacyRegistryConverter.convert(e);
+		}
 	}
 
-	public IConfigurationElement[] getChildren(String name) {
-		return LegacyRegistryConverter.convert(target.getChildren(name));
+	public IConfigurationElement[] getChildren(String name) throws InvalidRegistryObjectException {
+		try {
+			return LegacyRegistryConverter.convert(target.getChildren(name));
+		} catch (org.eclipse.equinox.registry.InvalidRegistryObjectException e) {
+			throw LegacyRegistryConverter.convert(e);
+		}
 	}
 
-	public IExtension getDeclaringExtension() {
-		return LegacyRegistryConverter.convert(target.getDeclaringExtension());
+	public IExtension getDeclaringExtension() throws InvalidRegistryObjectException {
+		try {
+			return LegacyRegistryConverter.convert(target.getDeclaringExtension());
+		} catch (org.eclipse.equinox.registry.InvalidRegistryObjectException e) {
+			throw LegacyRegistryConverter.convert(e);
+		}
 	}
 
-	public String getName() {
-		return target.getName();
+	public String getName() throws InvalidRegistryObjectException {
+		try {
+			return target.getName();
+		} catch (org.eclipse.equinox.registry.InvalidRegistryObjectException e) {
+			throw LegacyRegistryConverter.convert(e);
+		}
 	}
 
-	public Object getParent() {
-		Object internalResult = target.getParent();
-		if (internalResult instanceof org.eclipse.equinox.registry.IConfigurationElement)
-			return LegacyRegistryConverter.convert((org.eclipse.equinox.registry.IConfigurationElement)internalResult);
-		else if (internalResult instanceof org.eclipse.equinox.registry.IExtensionPoint)
-			return LegacyRegistryConverter.convert((org.eclipse.equinox.registry.IExtensionPoint)internalResult);
-		else if (internalResult instanceof org.eclipse.equinox.registry.IExtension)
-			return LegacyRegistryConverter.convert((org.eclipse.equinox.registry.IExtension)internalResult);
-		else 
-			return internalResult;
+	public Object getParent() throws InvalidRegistryObjectException {
+		try {
+			Object internalResult = target.getParent();
+			if (internalResult instanceof org.eclipse.equinox.registry.IConfigurationElement)
+				return LegacyRegistryConverter.convert((org.eclipse.equinox.registry.IConfigurationElement)internalResult);
+			else if (internalResult instanceof org.eclipse.equinox.registry.IExtensionPoint)
+				return LegacyRegistryConverter.convert((org.eclipse.equinox.registry.IExtensionPoint)internalResult);
+			else if (internalResult instanceof org.eclipse.equinox.registry.IExtension)
+				return LegacyRegistryConverter.convert((org.eclipse.equinox.registry.IExtension)internalResult);
+			else 
+				return internalResult;
+		} catch (org.eclipse.equinox.registry.InvalidRegistryObjectException e) {
+			throw LegacyRegistryConverter.convert(e);
+		}
 	}
 
-	public String getValue() {
-		return target.getValue();
+	public String getValue() throws InvalidRegistryObjectException {
+		try {
+			return target.getValue();
+		} catch (org.eclipse.equinox.registry.InvalidRegistryObjectException e) {
+			throw LegacyRegistryConverter.convert(e);
+		}
 	}
 
-	public String getValueAsIs() {
-		return target.getValueAsIs();
+	public String getValueAsIs() throws InvalidRegistryObjectException {
+		try {
+			return target.getValueAsIs();
+		} catch (org.eclipse.equinox.registry.InvalidRegistryObjectException e) {
+			throw LegacyRegistryConverter.convert(e);
+		}
 	}
 
-	public String getNamespace() {
-		return target.getNamespace();
+	public String getNamespace() throws InvalidRegistryObjectException {
+		try {
+			return target.getNamespace();
+		} catch (org.eclipse.equinox.registry.InvalidRegistryObjectException e) {
+			throw LegacyRegistryConverter.convert(e);
+		}
 	}
 
 	public boolean isValid() {
diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/registry/eclipse/LegacyExtensionHandle.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/registry/eclipse/LegacyExtensionHandle.java
index 811782e..056c607 100644
--- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/registry/eclipse/LegacyExtensionHandle.java
+++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/registry/eclipse/LegacyExtensionHandle.java
@@ -46,28 +46,52 @@
 		target = extension;
 	}
 
-	public String getNamespace() {
-		return target.getNamespace();
+	public String getNamespace() throws InvalidRegistryObjectException {
+		try {
+			return target.getNamespace();
+		} catch (org.eclipse.equinox.registry.InvalidRegistryObjectException e) {
+			throw LegacyRegistryConverter.convert(e);
+		}
 	}
 
-	public String getExtensionPointUniqueIdentifier() {
-		return target.getExtensionPointUniqueIdentifier();
+	public String getExtensionPointUniqueIdentifier() throws InvalidRegistryObjectException {
+		try {
+			return target.getExtensionPointUniqueIdentifier();
+		} catch (org.eclipse.equinox.registry.InvalidRegistryObjectException e) {
+			throw LegacyRegistryConverter.convert(e);
+		}
 	}
 
-	public String getLabel() {
-		return target.getLabel();
+	public String getLabel() throws InvalidRegistryObjectException {
+		try {
+			return target.getLabel();
+		} catch (org.eclipse.equinox.registry.InvalidRegistryObjectException e) {
+			throw LegacyRegistryConverter.convert(e);
+		}
 	}
 
-	public String getSimpleIdentifier() {
-		return target.getSimpleIdentifier();
+	public String getSimpleIdentifier() throws InvalidRegistryObjectException {
+		try {
+			return target.getSimpleIdentifier();
+		} catch (org.eclipse.equinox.registry.InvalidRegistryObjectException e) {
+			throw LegacyRegistryConverter.convert(e);
+		}
 	}
 
-	public String getUniqueIdentifier() {
-		return target.getUniqueIdentifier();
+	public String getUniqueIdentifier() throws InvalidRegistryObjectException {
+		try {
+			return target.getUniqueIdentifier();
+		} catch (org.eclipse.equinox.registry.InvalidRegistryObjectException e) {
+			throw LegacyRegistryConverter.convert(e);
+		}
 	}
 
-	public IConfigurationElement[] getConfigurationElements() {
-		return LegacyRegistryConverter.convert(target.getConfigurationElements());
+	public IConfigurationElement[] getConfigurationElements() throws InvalidRegistryObjectException {
+		try {
+			return LegacyRegistryConverter.convert(target.getConfigurationElements());
+		} catch (org.eclipse.equinox.registry.InvalidRegistryObjectException e) {
+			throw LegacyRegistryConverter.convert(e);
+		}
 	}
 
 	public boolean isValid() {
@@ -85,7 +109,7 @@
 	/**
 	 * @deprecated
 	 */
-	public org.eclipse.core.runtime.IPluginDescriptor getDeclaringPluginDescriptor() {
+	public org.eclipse.core.runtime.IPluginDescriptor getDeclaringPluginDescriptor() throws InvalidRegistryObjectException {
 		String namespace = getNamespace();
 		org.eclipse.core.runtime.IPluginDescriptor result = org.eclipse.core.internal.runtime.CompatibilityHelper.getPluginDescriptor(namespace);
 		if (result == null) {
diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/registry/eclipse/LegacyExtensionPointHandle.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/registry/eclipse/LegacyExtensionPointHandle.java
index 732ce3b..cdad6db 100644
--- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/registry/eclipse/LegacyExtensionPointHandle.java
+++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/registry/eclipse/LegacyExtensionPointHandle.java
@@ -43,36 +43,68 @@
 		target = extensionPoint;
 	}
 
-	public IExtension[] getExtensions() {
-		return LegacyRegistryConverter.convert(target.getExtensions());
+	public IExtension[] getExtensions() throws InvalidRegistryObjectException {
+		try {
+			return LegacyRegistryConverter.convert(target.getExtensions());
+		} catch (org.eclipse.equinox.registry.InvalidRegistryObjectException e) {
+			throw LegacyRegistryConverter.convert(e);
+		}
 	}
 
-	public String getNamespace() {
-		return target.getNamespace();
+	public String getNamespace() throws InvalidRegistryObjectException {
+		try {
+			return target.getNamespace();
+		} catch (org.eclipse.equinox.registry.InvalidRegistryObjectException e) {
+			throw LegacyRegistryConverter.convert(e);
+		}
 	}
 
-	public IExtension getExtension(String extensionId) {
-		return LegacyRegistryConverter.convert(target.getExtension(extensionId));
+	public IExtension getExtension(String extensionId) throws InvalidRegistryObjectException {
+		try {
+			return LegacyRegistryConverter.convert(target.getExtension(extensionId));
+		} catch (org.eclipse.equinox.registry.InvalidRegistryObjectException e) {
+			throw LegacyRegistryConverter.convert(e);
+		}
 	}
 
-	public IConfigurationElement[] getConfigurationElements() {
-		return LegacyRegistryConverter.convert(target.getConfigurationElements());
+	public IConfigurationElement[] getConfigurationElements() throws InvalidRegistryObjectException {
+		try {
+			return LegacyRegistryConverter.convert(target.getConfigurationElements());
+		} catch (org.eclipse.equinox.registry.InvalidRegistryObjectException e) {
+			throw LegacyRegistryConverter.convert(e);
+		}
 	}
 
-	public String getLabel() {
-		return target.getLabel();
+	public String getLabel() throws InvalidRegistryObjectException {
+		try {
+			return target.getLabel();
+		} catch (org.eclipse.equinox.registry.InvalidRegistryObjectException e) {
+			throw LegacyRegistryConverter.convert(e);
+		}
 	}
 
-	public String getSchemaReference() {
-		return target.getSchemaReference();
+	public String getSchemaReference() throws InvalidRegistryObjectException {
+		try {
+			return target.getSchemaReference();
+		} catch (org.eclipse.equinox.registry.InvalidRegistryObjectException e) {
+			throw LegacyRegistryConverter.convert(e);
+		}
 	}
 
-	public String getSimpleIdentifier() {
-		return target.getSimpleIdentifier();
+	public String getSimpleIdentifier() throws InvalidRegistryObjectException {
+		try {
+			return target.getSimpleIdentifier();
+		} catch (org.eclipse.equinox.registry.InvalidRegistryObjectException e) {
+			throw LegacyRegistryConverter.convert(e);
+		}
 	}
 
-	public String getUniqueIdentifier() {
-		return target.getUniqueIdentifier();
+	public String getUniqueIdentifier() throws InvalidRegistryObjectException {
+		try {
+			return target.getUniqueIdentifier();
+		} catch (org.eclipse.equinox.registry.InvalidRegistryObjectException e) {
+			throw LegacyRegistryConverter.convert(e);
+		}
 	}
 
 	public boolean isValid() {
diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/InvalidRegistryObjectException.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/InvalidRegistryObjectException.java
new file mode 100644
index 0000000..5b627a2
--- /dev/null
+++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/InvalidRegistryObjectException.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.core.runtime;
+
+/** 
+ * An unchecked exception indicating that an attempt to access
+ * an extension registry object that is no longer valid.
+ * <p>
+ * This exception is thrown by methods on extension registry
+ * objects. It is not intended to be instantiated or
+ * subclassed by clients.
+ * </p>
+ * 
+ * @since 3.1
+ */
+public class InvalidRegistryObjectException extends RuntimeException {
+	/*
+	 * Declare a stable serialVersionUID.
+	 */
+	private static final long serialVersionUID = 1L;
+
+	private static final String MESSAGE = "Invalid registry object"; //$NON-NLS-1$
+
+	/**
+	 * Creates a new exception instance with null as its detail message.
+	 */
+	public InvalidRegistryObjectException() {
+		super(MESSAGE);
+	}
+}
diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/LegacyRegistryConverter.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/LegacyRegistryConverter.java
index ad34e92..8350d02 100644
--- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/LegacyRegistryConverter.java
+++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/LegacyRegistryConverter.java
@@ -153,4 +153,15 @@
 			result[i] = convert(equinoxDeltas[i]);
 		return result;
 	}
+
+	/**
+	 * Converts the given Equinox registry exception to an equivalent legacy runtime exception.
+	 * @param exception the exception in the Equinox registry format
+	 * @return the exception converted to the legacy registry format
+	 */
+	public final static InvalidRegistryObjectException convert(org.eclipse.equinox.registry.InvalidRegistryObjectException exception) {
+		InvalidRegistryObjectException wrappedException = new InvalidRegistryObjectException();
+		wrappedException.setStackTrace(exception.getStackTrace());
+		return wrappedException;
+	}
 }