Revert "Bug 576024 - Multiple adapters for a adaptableType/class tuple"

This reverts commit ea28f6ab1fc5b1425b3ebf11dfca3e5c109949b4.

Reason for revert: Patch cause test failures and severe regressions.

Change-Id: Ib6e61f362c99f65fddffa24e7c22def37bad0653
Reviewed-on: https://git.eclipse.org/r/c/equinox/rt.equinox.bundles/+/186165
Tested-by: Mickael Istria <mistria@redhat.com>
Reviewed-by: Mickael Istria <mistria@redhat.com>
diff --git a/bundles/org.eclipse.equinox.common.tests/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.common.tests/META-INF/MANIFEST.MF
index 5ab8017..d233007 100644
--- a/bundles/org.eclipse.equinox.common.tests/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.common.tests/META-INF/MANIFEST.MF
@@ -3,12 +3,12 @@
 Bundle-Name: Common Eclipse Runtime Tests
 Bundle-Vendor: Eclipse.org - Equinox
 Bundle-SymbolicName: org.eclipse.equinox.common.tests;singleton:=true
-Bundle-Version: 3.15.100.qualifier
+Bundle-Version: 3.15.0.qualifier
 Automatic-Module-Name: org.eclipse.equinox.common.tests
 Bundle-RequiredExecutionEnvironment: JavaSE-11
 Bundle-ActivationPolicy: lazy
 Require-Bundle: org.junit,
- org.eclipse.equinox.common;bundle-version="3.15.100",
+ org.eclipse.equinox.common;bundle-version="3.13.0",
  org.eclipse.core.tests.harness;bundle-version="3.11.400",
  org.eclipse.equinox.registry;bundle-version="3.8.200"
 Import-Package: org.eclipse.osgi.service.localization,
diff --git a/bundles/org.eclipse.equinox.common.tests/plugin.xml b/bundles/org.eclipse.equinox.common.tests/plugin.xml
index 18bf6e8..3a998bd 100644
--- a/bundles/org.eclipse.equinox.common.tests/plugin.xml
+++ b/bundles/org.eclipse.equinox.common.tests/plugin.xml
@@ -11,20 +11,6 @@
                type="org.eclipse.equinox.common.tests.adaptable.TestAdapter">
          </adapter>
       </factory>
-      <factory
-            adaptableType="org.eclipse.equinox.common.tests.adaptable.TestAdaptable"
-            class="org.eclipse.equinox.common.tests.adaptable.NullAdapter2Factory">
-         <adapter
-               type="org.eclipse.equinox.common.tests.adaptable.TestAdapter2">
-         </adapter>
-      </factory>
-      <factory
-            adaptableType="org.eclipse.equinox.common.tests.adaptable.TestAdaptable"
-            class="org.eclipse.equinox.common.tests.adaptable.TestAdapter2Factory">
-         <adapter
-               type="org.eclipse.equinox.common.tests.adaptable.TestAdapter2">
-         </adapter>
-      </factory>
    </extension> 
    <extension-point id="factoryLoaderTest" name="factoryLoaderTest" schema="schema/factoryLoaderTest.exsd"/>
    <extension point="org.eclipse.core.runtime.adapters">
diff --git a/bundles/org.eclipse.equinox.common.tests/pom.xml b/bundles/org.eclipse.equinox.common.tests/pom.xml
index aee8c7f..185b439 100644
--- a/bundles/org.eclipse.equinox.common.tests/pom.xml
+++ b/bundles/org.eclipse.equinox.common.tests/pom.xml
@@ -19,7 +19,7 @@
   </parent>
   <groupId>org.eclipse.equinox</groupId>
   <artifactId>org.eclipse.equinox.common.tests</artifactId>
-  <version>3.15.100-SNAPSHOT</version>
+  <version>3.15.0-SNAPSHOT</version>
   <packaging>eclipse-test-plugin</packaging>
   <properties>
     <testClass>org.eclipse.equinox.common.tests.AllTests</testClass>
diff --git a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/adaptable/IAdapterManagerTest.java b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/adaptable/IAdapterManagerTest.java
index 584e60b..191ce0d 100644
--- a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/adaptable/IAdapterManagerTest.java
+++ b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/adaptable/IAdapterManagerTest.java
@@ -287,47 +287,4 @@
 			manager.unregisterAdapters(fac, Private.class);
 		}
 	}
-
-	@Test
-	public void testContinueAfterNullAdapterFactory() {
-		class PrivateAdapter {
-		}
-		class PrivateAdaptable {
-		}
-		IAdapterFactory nullAdapterFactory = new IAdapterFactory() {
-			@Override
-			public Class<?>[] getAdapterList() {
-				return new Class<?>[] { PrivateAdapter.class };
-			}
-
-			@Override
-			public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
-				return null;
-			}
-		};
-		IAdapterFactory adapterFactory = new IAdapterFactory() {
-			@Override
-			public Class<?>[] getAdapterList() {
-				return new Class<?>[] { PrivateAdapter.class };
-			}
-
-			@Override
-			public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
-				return (T) new PrivateAdapter();
-			}
-		};
-		try {
-			manager.registerAdapters(nullAdapterFactory, PrivateAdaptable.class);
-			manager.registerAdapters(adapterFactory, PrivateAdaptable.class);
-			assertNotNull(manager.getAdapter(new PrivateAdaptable(), PrivateAdapter.class));
-		} catch (Exception ex) {
-			manager.unregisterAdapters(nullAdapterFactory);
-			manager.unregisterAdapters(adapterFactory);
-		}
-	}
-
-	@Test
-	public void testMultipleAdapterFactoriesFromExtensionPoint() {
-		assertNotNull(manager.getAdapter(new TestAdaptable(), TestAdapter2.class));
-	}
 }
diff --git a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/adaptable/NullAdapter2Factory.java b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/adaptable/NullAdapter2Factory.java
deleted file mode 100644
index 671db07..0000000
--- a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/adaptable/NullAdapter2Factory.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- *  Copyright (c) 2021 Red Hat, Inc. and others.
- *
- *  This program and the accompanying materials
- *  are made available under the terms of the Eclipse Public License 2.0
- *  which accompanies this distribution, and is available at
- *  https://www.eclipse.org/legal/epl-2.0/
- *
- *  SPDX-License-Identifier: EPL-2.0
- *******************************************************************************/
-package org.eclipse.equinox.common.tests.adaptable;
-
-import org.eclipse.core.runtime.IAdapterFactory;
-
-public class NullAdapter2Factory implements IAdapterFactory {
-
-	@Override
-	public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
-		return null;
-	}
-
-	@Override
-	public Class<?>[] getAdapterList() {
-		return new Class<?>[] { TestAdaptable.class };
-	}
-
-}
diff --git a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/adaptable/TestAdapter2Factory.java b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/adaptable/TestAdapter2Factory.java
deleted file mode 100644
index 16bf5b3..0000000
--- a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/adaptable/TestAdapter2Factory.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- *  Copyright (c) 2021 Red Hat, Inc. and others.
- *
- *  This program and the accompanying materials
- *  are made available under the terms of the Eclipse Public License 2.0
- *  which accompanies this distribution, and is available at
- *  https://www.eclipse.org/legal/epl-2.0/
- *
- *  SPDX-License-Identifier: EPL-2.0
- *******************************************************************************/
-package org.eclipse.equinox.common.tests.adaptable;
-
-import org.eclipse.core.runtime.IAdapterFactory;
-
-public class TestAdapter2Factory implements IAdapterFactory {
-
-	@Override
-	public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
-		return (T) new TestAdapter2();
-	}
-
-	@Override
-	public Class<?>[] getAdapterList() {
-		return new Class<?>[] { TestAdaptable.class };
-	}
-
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/AdapterManager.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/AdapterManager.java
index 01c922e..f03be7e 100644
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/AdapterManager.java
+++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/AdapterManager.java
@@ -17,28 +17,23 @@
 package org.eclipse.core.internal.runtime;
 
 import java.util.*;
-import java.util.AbstractMap.SimpleEntry;
-import java.util.Map.Entry;
-import java.util.stream.Collectors;
 import org.eclipse.core.runtime.*;
-import org.osgi.framework.FrameworkEvent;
 
 /**
  * This class is the standard implementation of <code>IAdapterManager</code>. It provides
  * fast lookup of property values with the following semantics:
  * <ul>
- * <li>If multiple installed factories provide the same adapter, iterate until one of the factories
- * return a non-<code>null</code> value. Remaining factories won't be invoked.</li>
+ * <li>At most one factory will be invoked per property lookup
+ * <li>If multiple installed factories provide the same adapter, only the first found in
+ * the search order will be invoked.
  * <li>The search order from a class with the definition <br>
- * <code>class X extends Y implements A, B</code><br> is as follows:
- * <ul>
+ * <code>class X extends Y implements A, B</code><br> is as follows: <il>
  * <li>the target's class: X
  * <li>X's superclasses in order to <code>Object</code>
  * <li>a breadth-first traversal of each class's interfaces in the
  * order returned by <code>getInterfaces</code> (in the example, X's 
  * superinterfaces then Y's superinterfaces) </li>
  * </ul>
- * </ul>
  * 
  * @see IAdapterFactory
  * @see IAdapterManager
@@ -51,7 +46,7 @@
 	 * map wrapper class.  The inner map is not synchronized, but it is immutable
 	 * so synchronization is not necessary.
 	 */
-	private Map<String, Map<String, List<IAdapterFactory>>> adapterLookup;
+	private Map<String, Map<String, IAdapterFactory>> adapterLookup;
 
 	/**
 	 * Cache of classes for a given type name. Avoids too many loadClass calls.
@@ -81,32 +76,12 @@
 	 * the adaptable class that the factory provides adapters for. Value is a <code>List</code>
 	 * of <code>IAdapterFactory</code>.
 	 */
-	private final Map<String, List<IAdapterFactory>> factories;
+	private final HashMap<String, List<IAdapterFactory>> factories;
 
 	private final ArrayList<IAdapterManagerProvider> lazyFactoryProviders;
 
 	private static final AdapterManager singleton = new AdapterManager();
 
-	private static final Comparator<? super IAdapterFactory> ACTIVE_FIRST = new Comparator<IAdapterFactory>() {
-
-		@Override
-		public int compare(IAdapterFactory o1, IAdapterFactory o2) {
-			boolean factory1Loaded = isFactoryLoaded(o1);
-			boolean factory2Loaded = isFactoryLoaded(o2);
-			if (factory1Loaded == factory2Loaded) {
-				return 0;
-			}
-			if (factory1Loaded && !factory2Loaded) {
-				return -1;
-			}
-			if (!factory1Loaded && factory2Loaded) {
-				return +1;
-			}
-			return 0;
-		}
-
-	};
-
 	public static AdapterManager getDefault() {
 		return singleton;
 	}
@@ -119,29 +94,29 @@
 		lazyFactoryProviders = new ArrayList<>(1);
 	}
 
-	private static boolean isFactoryLoaded(IAdapterFactory adapterFactory) {
-		return (!(adapterFactory instanceof IAdapterFactoryExt)) || ((IAdapterFactoryExt) adapterFactory).loadFactory(false) != null;
-	}
-
 	/**
 	 * Given a type name, add all of the factories that respond to those types into
 	 * the given table. Each entry will be keyed by the adapter class name (supplied in
 	 * IAdapterFactory.getAdapterList).
 	 */
-	private void addFactoriesFor(String adaptableTypeName, Map<String, List<IAdapterFactory>> table) {
-		List<IAdapterFactory> factoryList = getFactories().get(adaptableTypeName);
+	private void addFactoriesFor(String typeName, Map<String, IAdapterFactory> table) {
+		List<IAdapterFactory> factoryList = getFactories().get(typeName);
 		if (factoryList == null)
 			return;
 		for (IAdapterFactory factory : factoryList) {
 			if (factory instanceof IAdapterFactoryExt) {
 				String[] adapters = ((IAdapterFactoryExt) factory).getAdapterNames();
 				for (String adapter : adapters) {
-					table.computeIfAbsent(adapter, any -> new ArrayList<>(1)).add(factory);
+					if (table.get(adapter) == null) {
+						table.put(adapter, factory);
+					}
 				}
 			} else {
 				Class<?>[] adapters = factory.getAdapterList();
 				for (Class<?> adapter : adapters) {
-					table.computeIfAbsent(adapter.getName(), any -> new ArrayList<>(1)).add(factory);
+					String adapterName = adapter.getName();
+					if (table.get(adapterName) == null)
+						table.put(adapterName, factory);
 				}
 			}
 		}
@@ -223,19 +198,23 @@
 	 * with the factory object that can perform that transformation. Returns 
 	 * a table of adapter class name to factory object.
 	 */
-	private Map<String, List<IAdapterFactory>> getFactories(Class<? extends Object> adaptable) {
+	private Map<String, IAdapterFactory> getFactories(Class<? extends Object> adaptable) {
 		//cache reference to lookup to protect against concurrent flush
-		Map<String, Map<String, List<IAdapterFactory>>> lookup = adapterLookup;
+		Map<String, Map<String, IAdapterFactory>> lookup = adapterLookup;
 		if (lookup == null)
-			adapterLookup = lookup = Collections.synchronizedMap(new HashMap<String, Map<String, List<IAdapterFactory>>>(30));
-		return lookup.computeIfAbsent(adaptable.getName(), adaptableType -> {
+			adapterLookup = lookup = Collections.synchronizedMap(new HashMap<String, Map<String, IAdapterFactory>>(30));
+		Map<String, IAdapterFactory> table = lookup.get(adaptable.getName());
+		if (table == null) {
 			// calculate adapters for the class
-			Map<String, List<IAdapterFactory>> table = new HashMap<>(4);
-			for (Class<?> cl : computeClassOrder(adaptable)) {
+			table = new HashMap<>(4);
+			Class<?>[] classes = computeClassOrder(adaptable);
+			for (Class<?> cl : classes) {
 				addFactoriesFor(cl.getName(), table);
 			}
-			return table;
-		});
+			// cache the table
+			lookup.put(adaptable.getName(), table);
+		}
+		return table;
 	}
 
 	/**
@@ -245,12 +224,19 @@
 	@Override
 	@SuppressWarnings("unchecked")
 	public <T> Class<? super T>[] computeClassOrder(Class<T> adaptable) {
+		Class<?>[] classes = null;
 		//cache reference to lookup to protect against concurrent flush
 		Map<Class<?>, Class<?>[]> lookup = classSearchOrderLookup;
-		if (lookup == null) {
+		if (lookup == null)
 			classSearchOrderLookup = lookup = Collections.synchronizedMap(new HashMap<Class<?>, Class<?>[]>());
+		else
+			classes = lookup.get(adaptable);
+		// compute class order only if it hasn't been cached before
+		if (classes == null) {
+			classes = doComputeClassOrder(adaptable);
+			lookup.put(adaptable, classes);
 		}
-		return (Class<? super T>[]) lookup.computeIfAbsent(adaptable, this::doComputeClassOrder);
+		return (Class<? super T>[]) classes;
 	}
 
 	/**
@@ -306,35 +292,25 @@
 	public <T> T getAdapter(Object adaptable, Class<T> adapterType) {
 		Assert.isNotNull(adaptable);
 		Assert.isNotNull(adapterType);
-		List<Entry<IAdapterFactory, Class<?>>> incorrectAdapters = new ArrayList<>();
-		T adapterObject = getFactories(adaptable.getClass()).getOrDefault(adapterType.getName(), Collections.emptyList()) //
-				.stream() //
-				.map(factory -> new SimpleEntry<>(factory, factory.getAdapter(adaptable, adapterType))) //
-				.filter(entry -> {
-					Object adapter = entry.getValue();
-					if (adapter == null) {
-						return false;
-					}
-					boolean res = adapterType.isInstance(adapter);
-					if (!res) {
-						IAdapterFactory factory = entry.getKey();
-						incorrectAdapters.add(new SimpleEntry<>(factory, adapter.getClass()));
-					}
-					return res;
-				}).map(Entry::getValue) //
-				.findFirst() //
-				.orElse(null);
-		if (adapterObject == null) {
-			if (!incorrectAdapters.isEmpty()) {
-				throw new AssertionFailedException(incorrectAdapters.stream().map(entry -> "Adapter factory " //$NON-NLS-1$
-						+ entry.getKey() + " returned " + entry.getValue().getName() //$NON-NLS-1$
-						+ " that is not an instance of " + adapterType.getName()).collect(Collectors.joining("\n"))); //$NON-NLS-1$ //$NON-NLS-2$
-			}
-			if (adapterType.isInstance(adaptable)) {
-				return (T) adaptable;
-			}
+		String adapterTypeName = adapterType.getName();
+		IAdapterFactory factory = getFactories(adaptable.getClass()).get(adapterTypeName);
+		T result = null;
+		if (factory != null) {
+			result = factory.getAdapter(adaptable, adapterType);
 		}
-		return adapterObject;
+		if (result == null && adapterType.isInstance(adaptable)) {
+			return (T) adaptable;
+		}
+		if (result == null || adapterType.isInstance(result)) {
+			return result;
+		}
+		// Here we have a result which does not match the expected type.
+		// Throwing an exception here allows us to identify the violating factory.
+		// If we don't do this, clients will just see CCE without any idea who
+		// supplied the wrong adapter
+		throw new AssertionFailedException("Adapter factory " //$NON-NLS-1$
+				+ factory + " returned " + result.getClass().getName() //$NON-NLS-1$
+				+ " that is not an instance of " + adapterTypeName); //$NON-NLS-1$
 	}
 
 	@Override
@@ -353,36 +329,18 @@
 	 * if no plugin activations are desired.
 	 */
 	private Object getAdapter(Object adaptable, String adapterType, boolean force) {
-		Assert.isNotNull(adaptable);
-		Assert.isNotNull(adapterType);
-		return getFactories(adaptable.getClass()).getOrDefault(adapterType, Collections.emptyList()) //
-				.stream() //
-				.sorted(ACTIVE_FIRST) // prefer factories from already active bundles to minimize activation and return earlier when possible
-				.map(factory -> force && factory instanceof IAdapterFactoryExt ? ((IAdapterFactoryExt) factory).loadFactory(true) : factory) //
-				.map(factory -> {
-					Class<?> adapterClass = classForName(factory, adapterType);
-					if (adapterClass == null) {
-						return null;
-					}
-					return new SimpleEntry<>(factory, factory.getAdapter(adaptable, adapterClass)); //
-				}).filter(Objects::nonNull) //
-				.filter(entry -> {
-					Object adapter = entry.getValue();
-					if (adapter == null) {
-						return false;
-					}
-					boolean res = adapter.getClass().getName().equals(adapterType);
-					if (!res) {
-						IAdapterFactory factory = entry.getKey();
-						Activator.getDefault().getFrameworkLog().log(new FrameworkEvent(FrameworkEvent.WARNING, Activator.getContext().getBundle(), new AssertionFailedException("Adapter factory " //$NON-NLS-1$
-								+ factory + " returned " + adapter.getClass().getName() //$NON-NLS-1$
-								+ " that is not an instance of " + adapterType))); //$NON-NLS-1$
-					}
-					return res;
-				}).map(Entry::getValue) //
-				.findFirst() //
-				.map(Object.class::cast) // casting to object seems necessary here; compiler issue?
-				.orElseGet(() -> adapterType.equals(adaptable.getClass().getName()) ? adaptable : null);
+		IAdapterFactory factory = getFactories(adaptable.getClass()).get(adapterType);
+		if (force && factory instanceof IAdapterFactoryExt)
+			factory = ((IAdapterFactoryExt) factory).loadFactory(true);
+		Object result = null;
+		if (factory != null) {
+			Class<?> clazz = classForName(factory, adapterType);
+			if (clazz != null)
+				result = factory.getAdapter(adaptable, clazz);
+		}
+		if (result == null && adaptable.getClass().getName().equals(adapterType))
+			return adaptable;
+		return result;
 	}
 
 	@Override
@@ -392,14 +350,15 @@
 
 	@Override
 	public int queryAdapter(Object adaptable, String adapterTypeName) {
-		List<IAdapterFactory> eligibleFactories = getFactories(adaptable.getClass()).get(adapterTypeName);
-		if (eligibleFactories.isEmpty()) {
+		IAdapterFactory factory = getFactories(adaptable.getClass()).get(adapterTypeName);
+		if (factory == null)
 			return NONE;
+		if (factory instanceof IAdapterFactoryExt) {
+			factory = ((IAdapterFactoryExt) factory).loadFactory(false); // don't force loading
+			if (factory == null)
+				return NOT_LOADED;
 		}
-		if (eligibleFactories.stream().anyMatch(AdapterManager::isFactoryLoaded)) {
-			return LOADED;
-		}
-		return NOT_LOADED;
+		return LOADED;
 	}
 
 	@Override
@@ -420,7 +379,12 @@
 	 * @see IAdapterManager#registerAdapters
 	 */
 	public void registerFactory(IAdapterFactory factory, String adaptableType) {
-		factories.computeIfAbsent(adaptableType, any -> new ArrayList<>(5)).add(factory);
+		List<IAdapterFactory> list = factories.get(adaptableType);
+		if (list == null) {
+			list = new ArrayList<>(5);
+			factories.put(adaptableType, list);
+		}
+		list.add(factory);
 	}
 
 	/*
@@ -467,9 +431,9 @@
 		}
 	}
 
-	public Map<String, List<IAdapterFactory>> getFactories() {
+	public HashMap<String, List<IAdapterFactory>> getFactories() {
 		synchronized (lazyFactoryProviders) {
-			while (!lazyFactoryProviders.isEmpty()) {
+			while (lazyFactoryProviders.size() > 0) {
 				IAdapterManagerProvider provider = lazyFactoryProviders.remove(0);
 				if (provider.addFactories(this))
 					flushLookup();
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/IAdapterFactoryExt.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/IAdapterFactoryExt.java
index 4002228..bfd0c7a 100644
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/IAdapterFactoryExt.java
+++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/IAdapterFactoryExt.java
@@ -27,7 +27,6 @@
 	 * @param force if <code>true</code> the plugin providing the 
 	 * factory will be loaded if necessary, otherwise no plugin activations
 	 * will occur.
-	 * @return the adapter factory, or <code>null</code>
 	 */
 	public IAdapterFactory loadFactory(boolean force);
 
diff --git a/bundles/org.eclipse.equinox.registry/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.registry/META-INF/MANIFEST.MF
index 5ada6e8..c52f44f 100644
--- a/bundles/org.eclipse.equinox.registry/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.registry/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
 Bundle-ManifestVersion: 2
 Bundle-Name: %pluginName
 Bundle-SymbolicName: org.eclipse.equinox.registry;singleton:=true
-Bundle-Version: 3.11.100.qualifier
+Bundle-Version: 3.11.0.qualifier
 Bundle-Localization: plugin
 Export-Package: org.eclipse.core.internal.adapter;x-internal:=true,
  org.eclipse.core.internal.registry;x-friends:="org.eclipse.core.runtime",
@@ -11,7 +11,7 @@
  org.eclipse.core.runtime;registry=split;version="3.7.0";mandatory:=registry,
  org.eclipse.core.runtime.dynamichelpers;version="3.4.0",
  org.eclipse.core.runtime.spi;version="3.4.0"
-Require-Bundle: org.eclipse.equinox.common;bundle-version="[3.15.100,4.0.0)"
+Require-Bundle: org.eclipse.equinox.common;bundle-version="[3.14.0,4.0.0)"
 Bundle-Vendor: %providerName
 Bundle-Activator: org.eclipse.core.internal.registry.osgi.Activator
 Import-Package: javax.xml.parsers,
diff --git a/bundles/org.eclipse.equinox.registry/pom.xml b/bundles/org.eclipse.equinox.registry/pom.xml
index e72644d..f5757b5 100644
--- a/bundles/org.eclipse.equinox.registry/pom.xml
+++ b/bundles/org.eclipse.equinox.registry/pom.xml
@@ -19,6 +19,6 @@
   </parent>
   <groupId>org.eclipse.equinox</groupId>
   <artifactId>org.eclipse.equinox.registry</artifactId>
-  <version>3.11.100-SNAPSHOT</version>
+  <version>3.11.0-SNAPSHOT</version>
   <packaging>eclipse-plugin</packaging>
 </project>
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/adapter/AdapterManagerListener.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/adapter/AdapterManagerListener.java
index d57cbe7..a540f78 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/adapter/AdapterManagerListener.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/adapter/AdapterManagerListener.java
@@ -13,6 +13,7 @@
  *******************************************************************************/
 package org.eclipse.core.internal.adapter;
 
+import java.util.Iterator;
 import java.util.List;
 import org.eclipse.core.internal.runtime.AdapterManager;
 import org.eclipse.core.internal.runtime.IAdapterManagerProvider;
@@ -84,7 +85,14 @@
 		theAdapterManager.flushLookup();
 		for (IExtension extension : extensions) {
 			for (List<IAdapterFactory> adapterFactories : theAdapterManager.getFactories().values()) {
-				adapterFactories.removeIf(factory -> factory instanceof AdapterFactoryProxy && ((AdapterFactoryProxy) factory).originatesFrom(extension));
+				for (Iterator<IAdapterFactory> it2 = (adapterFactories).iterator(); it2.hasNext();) {
+					IAdapterFactory factory = it2.next();
+					if (!(factory instanceof AdapterFactoryProxy))
+						continue;
+					if (((AdapterFactoryProxy) factory).originatesFrom(extension)) {
+						it2.remove();
+					}
+				}
 			}
 		}
 	}