Bug 578701 - Lambdas in core framework classes lead to performance
degradation

Change-Id: I7fc9d468abea7963b83dd4dfa37f5374e2f8b429
Signed-off-by: Jared Anderson <jhanders@us.ibm.com>
Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
Reviewed-on: https://git.eclipse.org/r/c/equinox/rt.equinox.framework/+/190725
Tested-by: Equinox Bot <equinox-bot@eclipse.org>
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainer.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainer.java
index 9320a7f..951661b 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainer.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainer.java
@@ -1390,16 +1390,19 @@
 			return;
 		}
 		getAdaptor().refreshedSystemModule();
-		Thread t = new Thread(() -> {
-			try {
-				systemModule.lockStateChange(ModuleEvent.UNRESOLVED);
+		Thread t = new Thread(new Runnable() {
+			@Override
+			public void run() {
 				try {
-					systemModule.stop();
-				} finally {
-					systemModule.unlockStateChange(ModuleEvent.UNRESOLVED);
+					systemModule.lockStateChange(ModuleEvent.UNRESOLVED);
+					try {
+						systemModule.stop();
+					} finally {
+						systemModule.unlockStateChange(ModuleEvent.UNRESOLVED);
+					}
+				} catch (BundleException e) {
+					e.printStackTrace();
 				}
-			} catch (BundleException e) {
-				e.printStackTrace();
 			}
 		});
 		t.start();
@@ -1496,15 +1499,18 @@
 		private Collection<Module> getModules(final Collection<Bundle> bundles) {
 			if (bundles == null)
 				return null;
-			return AccessController.doPrivileged((PrivilegedAction<Collection<Module>>) () -> {
-				Collection<Module> result = new ArrayList<>(bundles.size());
-				for (Bundle bundle : bundles) {
-					Module module = bundle.adapt(Module.class);
-					if (module == null)
-						throw new IllegalStateException("Could not adapt a bundle to a module. " + bundle); //$NON-NLS-1$
-					result.add(module);
+			return AccessController.doPrivileged(new PrivilegedAction<Collection<Module>>() {
+				@Override
+				public Collection<Module> run() {
+					Collection<Module> result = new ArrayList<>(bundles.size());
+					for (Bundle bundle : bundles) {
+						Module module = bundle.adapt(Module.class);
+						if (module == null)
+							throw new IllegalStateException("Could not adapt a bundle to a module. " + bundle); //$NON-NLS-1$
+						result.add(module);
+					}
+					return result;
 				}
-				return result;
 			});
 		}
 
@@ -1823,21 +1829,29 @@
 			if (toStart.isEmpty()) {
 				return;
 			}
-			final Executor executor = inParallel ? adaptor.getStartLevelExecutor() : Runnable::run;
+			final Executor executor = inParallel ? adaptor.getStartLevelExecutor() : new Executor() {
+				@Override
+				public void execute(Runnable command) {
+					command.run();
+				}
+			};
 			final CountDownLatch done = new CountDownLatch(toStart.size());
 			for (final Module module : toStart) {
-				executor.execute(() -> {
-					try {
-						if (debugStartLevel) {
-							Debug.println("StartLevel: resuming bundle; " + ContainerStartLevel.this.toString(module) + "; with startLevel=" + toStartLevel); //$NON-NLS-1$ //$NON-NLS-2$
+				executor.execute(new Runnable() {
+					@Override
+					public void run() {
+						try {
+							if (debugStartLevel) {
+								Debug.println("StartLevel: resuming bundle; " + ContainerStartLevel.this.toString(module) + "; with startLevel=" + toStartLevel); //$NON-NLS-1$ //$NON-NLS-2$
+							}
+							module.start(StartOptions.TRANSIENT_IF_AUTO_START, StartOptions.TRANSIENT_RESUME);
+						} catch (BundleException e) {
+							adaptor.publishContainerEvent(ContainerEvent.ERROR, module, e);
+						} catch (IllegalStateException e) {
+							// been uninstalled
+						} finally {
+							done.countDown();
 						}
-						module.start(StartOptions.TRANSIENT_IF_AUTO_START, StartOptions.TRANSIENT_RESUME);
-					} catch (BundleException e1) {
-						adaptor.publishContainerEvent(ContainerEvent.ERROR, module, e1);
-					} catch (IllegalStateException e2) {
-						// been uninstalled
-					} finally {
-						done.countDown();
 					}
 				});
 
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainerAdaptor.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainerAdaptor.java
index 6d73c42..2a53609 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainerAdaptor.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainerAdaptor.java
@@ -29,7 +29,12 @@
  * @since 3.10
  */
 public abstract class ModuleContainerAdaptor {
-	private static Executor defaultExecutor = Runnable::run;
+	private static Executor defaultExecutor = new Executor() {
+		@Override
+		public void execute(Runnable command) {
+			command.run();
+		}
+	};
 
 	/**
 	 * Event types that may be {@link #publishContainerEvent(ContainerEvent, Module, Throwable, FrameworkListener...) published}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleDatabase.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleDatabase.java
index 77f8e09..e952151 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleDatabase.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleDatabase.java
@@ -33,6 +33,7 @@
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
+import java.util.function.BiFunction;
 import org.eclipse.osgi.container.Module.Settings;
 import org.eclipse.osgi.container.Module.State;
 import org.eclipse.osgi.container.ModuleContainerAdaptor.ContainerEvent;
@@ -501,8 +502,12 @@
 		readLock();
 		try {
 			Map<ModuleRevision, ModuleWiring> clonedWirings = new HashMap<>(wirings);
-			clonedWirings.replaceAll((r, w) -> new ModuleWiring(r, w.getCapabilities(), w.getRequirements(),
-					w.getProvidedWires(), w.getRequiredWires(), w.getSubstitutedNames()));
+			clonedWirings.replaceAll(new BiFunction<ModuleRevision, ModuleWiring, ModuleWiring>() {
+				public ModuleWiring apply(ModuleRevision r, ModuleWiring w) {
+					return new ModuleWiring(r, w.getCapabilities(), w.getRequirements(), w.getProvidedWires(),
+							w.getRequiredWires(), w.getSubstitutedNames());
+				}
+			});
 			return clonedWirings;
 		} finally {
 			readUnlock();
@@ -595,7 +600,12 @@
 		if (modules.size() < 2)
 			return;
 		if (sortOptions == null || Sort.BY_ID.isContained(sortOptions) || sortOptions.length == 0) {
-			Collections.sort(modules, Comparator.comparing(Module::getId));
+			Collections.sort(modules, new Comparator<Module>() {
+				@Override
+				public int compare(Module m1, Module m2) {
+					return m1.getId().compareTo(m2.getId());
+				}
+			});
 			return;
 		}
 		// first sort by start-level
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRevision.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRevision.java
index f057fa7..462075c 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRevision.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRevision.java
@@ -19,6 +19,7 @@
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
+import java.util.function.Function;
 import org.eclipse.osgi.container.ModuleRevisionBuilder.GenericInfo;
 import org.eclipse.osgi.container.namespaces.EquinoxModuleDataNamespace;
 import org.eclipse.osgi.internal.container.InternalUtils;
@@ -57,10 +58,12 @@
 	}
 
 	private NamespaceList<ModuleCapability> createCapabilities(NamespaceList.Builder<GenericInfo> capabilityInfos) {
-		return capabilityInfos.transformIntoCopy(i -> {
-			Map<String, String> directives = i.mutable ? copyUnmodifiableMap(i.directives) : i.directives;
-			Map<String, Object> attributes = i.mutable ? copyUnmodifiableMap(i.attributes) : i.attributes;
-			return new ModuleCapability(i.namespace, directives, attributes, this);
+		return capabilityInfos.transformIntoCopy(new Function<GenericInfo, ModuleCapability>()  {
+			public ModuleCapability apply(GenericInfo i) {
+				Map<String, String> directives = i.mutable ? copyUnmodifiableMap(i.directives) : i.directives;
+				Map<String, Object> attributes = i.mutable ? copyUnmodifiableMap(i.attributes) : i.attributes;
+				return new ModuleCapability(i.namespace, directives, attributes, ModuleRevision.this);
+			}
 		}, NamespaceList.CAPABILITY).build();
 	}
 
@@ -77,8 +80,11 @@
 	}
 
 	private NamespaceList<ModuleRequirement> createRequirements(NamespaceList.Builder<GenericInfo> infos) {
-		return infos.transformIntoCopy(i -> new ModuleRequirement(i.namespace, i.directives, i.attributes, this),
-				NamespaceList.REQUIREMENT).build();
+		return infos.transformIntoCopy(new Function<GenericInfo, ModuleRequirement>()  {
+			public ModuleRequirement apply(GenericInfo i) {
+				return new ModuleRequirement(i.namespace, i.directives, i.attributes, ModuleRevision.this);
+			}
+		}, NamespaceList.REQUIREMENT).build();
 	}
 
 	@Override
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRevisionBuilder.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRevisionBuilder.java
index a0cf9ed..2c54939 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRevisionBuilder.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRevisionBuilder.java
@@ -19,6 +19,7 @@
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
+import java.util.function.Function;
 import org.eclipse.osgi.internal.container.NamespaceList;
 import org.eclipse.osgi.internal.container.NamespaceList.Builder;
 import org.eclipse.osgi.internal.framework.FilterImpl;
@@ -50,6 +51,11 @@
 	 * Provides information about a capability or requirement
 	 */
 	public static class GenericInfo {
+		final static Function<GenericInfo, String> GETNAMESPACE = new Function<GenericInfo, String>() {
+			public String apply(GenericInfo info) {
+				return info.getNamespace();
+			}
+		};
 		final String namespace;
 		final Map<String, String> directives;
 		final Map<String, Object> attributes;
@@ -90,8 +96,8 @@
 	private String symbolicName = null;
 	private Version version = Version.emptyVersion;
 	private int types = 0;
-	private final NamespaceList.Builder<GenericInfo> capabilityInfos = Builder.create(GenericInfo::getNamespace);
-	private final NamespaceList.Builder<GenericInfo> requirementInfos = Builder.create(GenericInfo::getNamespace);
+	private final NamespaceList.Builder<GenericInfo> capabilityInfos = Builder.create(GenericInfo.GETNAMESPACE);
+	private final NamespaceList.Builder<GenericInfo> requirementInfos = Builder.create(GenericInfo.GETNAMESPACE);
 	private long id = -1;
 
 	/**
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/util/SecureAction.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/util/SecureAction.java
index bdd3f2a..255f3a9 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/util/SecureAction.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/util/SecureAction.java
@@ -46,9 +46,17 @@
 	// make sure we use the correct controlContext;
 	private AccessControlContext controlContext;
 
-	// This ClassLoader is used in loadSystemClass if System.getClassLoader() returns null
-	static final ClassLoader bootClassLoader = AccessController.doPrivileged((PrivilegedAction<ClassLoader>)
-			() -> new ClassLoader(Object.class.getClassLoader()) { /* boot class loader */});
+        // uses initialization-on-demand holder idiom to do fast lazy loading
+	private static class BootClassLoaderHolder {
+		// This ClassLoader is used in loadSystemClass if System.getClassLoader() returns null
+		static final ClassLoader bootClassLoader = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+			@Override
+			public ClassLoader run() {
+				return new ClassLoader(Object.class.getClassLoader()) { /* boot class loader */};
+			}
+		});
+
+        }
 
 	/*
 	 * Package privaet constructor a new SecureAction object.
@@ -69,7 +77,12 @@
 	 * @return a privileged action object that can be used to construct a SecureAction object.
 	 */
 	public static PrivilegedAction<SecureAction> createSecureAction() {
-		return SecureAction::new;
+		return new PrivilegedAction<SecureAction>() {
+			@Override
+			public SecureAction run() {
+				return new SecureAction();
+			}
+		};
 	}
 
 	/**
@@ -81,7 +94,12 @@
 	public String getProperty(final String property) {
 		if (System.getSecurityManager() == null)
 			return System.getProperty(property);
-		return doPrivileged(() -> System.getProperty(property), controlContext);
+		return AccessController.doPrivileged(new PrivilegedAction<String>() {
+			@Override
+			public String run() {
+				return System.getProperty(property);
+			}
+		}, controlContext);
 	}
 
 	/**
@@ -92,7 +110,12 @@
 	public Properties getProperties() {
 		if (System.getSecurityManager() == null)
 			return System.getProperties();
-		return doPrivileged(System::getProperties, controlContext);
+		return AccessController.doPrivileged(new PrivilegedAction<Properties>() {
+			@Override
+			public Properties run() {
+				return System.getProperties();
+			}
+		}, controlContext);
 	}
 
 	/**
@@ -106,7 +129,12 @@
 		if (System.getSecurityManager() == null)
 			return new FileInputStream(file);
 		try {
-			return doPrivilegedWithException(() -> new FileInputStream(file), controlContext);
+			return AccessController.doPrivileged(new PrivilegedExceptionAction<FileInputStream>() {
+				@Override
+				public FileInputStream run() throws FileNotFoundException {
+					return new FileInputStream(file);
+				}
+			}, controlContext);
 		} catch (PrivilegedActionException e) {
 			if (e.getException() instanceof FileNotFoundException)
 				throw (FileNotFoundException) e.getException();
@@ -126,7 +154,12 @@
 		if (System.getSecurityManager() == null)
 			return new FileOutputStream(file.getAbsolutePath(), append);
 		try {
-			return doPrivilegedWithException(() -> new FileOutputStream(file.getAbsolutePath(), append), controlContext);
+			return AccessController.doPrivileged(new PrivilegedExceptionAction<FileOutputStream>() {
+				@Override
+				public FileOutputStream run() throws FileNotFoundException {
+					return new FileOutputStream(file.getAbsolutePath(), append);
+				}
+			}, controlContext);
 		} catch (PrivilegedActionException e) {
 			if (e.getException() instanceof FileNotFoundException)
 				throw (FileNotFoundException) e.getException();
@@ -143,7 +176,12 @@
 	public long length(final File file) {
 		if (System.getSecurityManager() == null)
 			return file.length();
-		return doPrivileged(file::length, controlContext);
+		return AccessController.doPrivileged(new PrivilegedAction<Long>() {
+			@Override
+			public Long run() {
+				return Long.valueOf(file.length());
+			}
+		}, controlContext).longValue();
 	}
 
 	/**
@@ -157,7 +195,12 @@
 		if (System.getSecurityManager() == null)
 			return file.getCanonicalPath();
 		try {
-			return doPrivilegedWithException(file::getCanonicalPath, controlContext);
+			return AccessController.doPrivileged(new PrivilegedExceptionAction<String>() {
+				@Override
+				public String run() throws IOException {
+					return file.getCanonicalPath();
+				}
+			}, controlContext);
 		} catch (PrivilegedActionException e) {
 			if (e.getException() instanceof IOException)
 				throw (IOException) e.getException();
@@ -174,7 +217,12 @@
 	public File getAbsoluteFile(final File file) {
 		if (System.getSecurityManager() == null)
 			return file.getAbsoluteFile();
-		return doPrivileged(file::getAbsoluteFile, controlContext);
+		return AccessController.doPrivileged(new PrivilegedAction<File>() {
+			@Override
+			public File run() {
+				return file.getAbsoluteFile();
+			}
+		}, controlContext);
 	}
 
 
@@ -188,7 +236,12 @@
 		if (System.getSecurityManager() == null)
 			return file.getCanonicalFile();
 		try {
-			return doPrivilegedWithException(file::getCanonicalFile, controlContext);
+			return AccessController.doPrivileged(new PrivilegedExceptionAction<File>() {
+				@Override
+				public File run() throws IOException {
+					return file.getCanonicalFile();
+				}
+			}, controlContext);
 		} catch (PrivilegedActionException e) {
 			if (e.getException() instanceof IOException)
 				throw (IOException) e.getException();
@@ -205,13 +258,23 @@
 	public boolean exists(final File file) {
 		if (System.getSecurityManager() == null)
 			return file.exists();
-		return doPrivileged(file::exists, controlContext);
+		return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
+			@Override
+			public Boolean run() {
+				return file.exists() ? Boolean.TRUE : Boolean.FALSE;
+			}
+		}, controlContext).booleanValue();
 	}
 
 	public boolean mkdirs(final File file) {
 		if (System.getSecurityManager() == null)
 			return file.mkdirs();
-		return doPrivileged(file::mkdirs, controlContext);
+		return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
+			@Override
+			public Boolean run() {
+				return file.mkdirs() ? Boolean.TRUE : Boolean.FALSE;
+			}
+		}, controlContext).booleanValue();
 	}
 
 	/**
@@ -223,7 +286,12 @@
 	public boolean isDirectory(final File file) {
 		if (System.getSecurityManager() == null)
 			return file.isDirectory();
-		return doPrivileged(file::isDirectory, controlContext);
+		return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
+			@Override
+			public Boolean run() {
+				return file.isDirectory() ? Boolean.TRUE : Boolean.FALSE;
+			}
+		}, controlContext).booleanValue();
 	}
 
 	/**
@@ -235,7 +303,12 @@
 	public long lastModified(final File file) {
 		if (System.getSecurityManager() == null)
 			return file.lastModified();
-		return doPrivileged(file::lastModified, controlContext);
+		return AccessController.doPrivileged(new PrivilegedAction<Long>() {
+			@Override
+			public Long run() {
+				return Long.valueOf(file.lastModified());
+			}
+		}, controlContext).longValue();
 	}
 
 	/**
@@ -247,7 +320,12 @@
 	public String[] list(final File file) {
 		if (System.getSecurityManager() == null)
 			return file.list();
-		return doPrivileged(file::list, controlContext);
+		return AccessController.doPrivileged(new PrivilegedAction<String[]>() {
+			@Override
+			public String[] run() {
+				return file.list();
+			}
+		}, controlContext);
 	}
 
 	/**
@@ -263,7 +341,12 @@
 			if (System.getSecurityManager() == null)
 				return new ZipFile(file);
 			try {
-				return doPrivilegedWithException(() -> verify ? new JarFile(file) : new ZipFile(file), controlContext);
+				return AccessController.doPrivileged(new PrivilegedExceptionAction<ZipFile>() {
+					@Override
+					public ZipFile run() throws IOException {
+						return verify ? new JarFile(file) : new ZipFile(file);
+					}
+				}, controlContext);
 			} catch (PrivilegedActionException e) {
 				if (e.getException() instanceof IOException)
 					throw (IOException) e.getException();
@@ -293,7 +376,12 @@
 		if (System.getSecurityManager() == null)
 			return new URL(protocol, host, port, file, handler);
 		try {
-			return doPrivilegedWithException(() -> new URL(protocol, host, port, file, handler), controlContext);
+			return AccessController.doPrivileged(new PrivilegedExceptionAction<URL>() {
+				@Override
+				public URL run() throws MalformedURLException {
+					return new URL(protocol, host, port, file, handler);
+				}
+			}, controlContext);
 		} catch (PrivilegedActionException e) {
 			if (e.getException() instanceof MalformedURLException)
 				throw (MalformedURLException) e.getException();
@@ -312,7 +400,12 @@
 	public Thread createThread(final Runnable target, final String name, final ClassLoader contextLoader) {
 		if (System.getSecurityManager() == null)
 			return createThread0(target, name, contextLoader);
-		return doPrivileged(() -> createThread0(target, name, contextLoader), controlContext);
+		return AccessController.doPrivileged(new PrivilegedAction<Thread>() {
+			@Override
+			public Thread run() {
+				return createThread0(target, name, contextLoader);
+			}
+		}, controlContext);
 	}
 
 	Thread createThread0(Runnable target, String name, ClassLoader contextLoader) {
@@ -332,7 +425,12 @@
 	public <S> S getService(final ServiceReference<S> reference, final BundleContext context) {
 		if (System.getSecurityManager() == null)
 			return context.getService(reference);
-		return doPrivileged(() -> context.getService(reference), controlContext);
+		return AccessController.doPrivileged(new PrivilegedAction<S>() {
+			@Override
+			public S run() {
+				return context.getService(reference);
+			}
+		}, controlContext);
 	}
 
 	/**
@@ -346,7 +444,12 @@
 		if (System.getSecurityManager() == null)
 			return Class.forName(name);
 		try {
-			return doPrivilegedWithException(() -> Class.forName(name), controlContext);
+			return AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>() {
+				@Override
+				public Class<?> run() throws Exception {
+					return Class.forName(name);
+				}
+			}, controlContext);
 		} catch (PrivilegedActionException e) {
 			if (e.getException() instanceof ClassNotFoundException)
 				throw (ClassNotFoundException) e.getException();
@@ -364,12 +467,15 @@
 	public Class<?> loadSystemClass(final String name) throws ClassNotFoundException {
 		if (System.getSecurityManager() == null) {
 			ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
-			return (systemClassLoader != null) ? systemClassLoader.loadClass(name) : bootClassLoader.loadClass(name);
+			return (systemClassLoader != null) ? systemClassLoader.loadClass(name) : BootClassLoaderHolder.bootClassLoader.loadClass(name);
 		}
 		try {
-			return doPrivilegedWithException(() -> {
-				ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
-				return (systemClassLoader != null) ? systemClassLoader.loadClass(name) : bootClassLoader.loadClass(name);
+			return AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>() {
+				@Override
+				public Class<?> run() throws Exception {
+					ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
+					return (systemClassLoader != null) ? systemClassLoader.loadClass(name) : BootClassLoaderHolder.bootClassLoader.loadClass(name);
+				}
 			}, controlContext);
 		} catch (PrivilegedActionException e) {
 			if (e.getException() instanceof ClassNotFoundException)
@@ -387,9 +493,12 @@
 			tracker.open();
 			return;
 		}
-		doPrivileged(() -> {
-			tracker.open();
-			return null;
+		AccessController.doPrivileged(new PrivilegedAction<Void>() {
+			@Override
+			public Void run() {
+				tracker.open();
+				return null;
+			}
 		}, controlContext);
 	}
 
@@ -405,9 +514,12 @@
 			return;
 		}
 		try {
-			doPrivilegedWithException(() -> {
-				module.start(options);
-				return null;
+			AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
+				@Override
+				public Void run() throws BundleException {
+					module.start(options);
+					return null;
+				}
 			}, controlContext);
 		} catch (PrivilegedActionException e) {
 			if (e.getException() instanceof BundleException)
@@ -420,22 +532,23 @@
 		if (System.getSecurityManager() == null) {
 			return bundle.getBundleContext();
 		}
-		return doPrivileged(bundle::getBundleContext, controlContext);
+		return AccessController.doPrivileged(new PrivilegedAction<BundleContext>() {
+			@Override
+			public BundleContext run() {
+				return bundle.getBundleContext();
+			}
+		}, controlContext);
 	}
 
 	public String getLocation(final Bundle bundle) {
 		if (System.getSecurityManager() == null) {
 			return bundle.getLocation();
 		}
-		return doPrivileged(bundle::getLocation, controlContext);
-	}
-
-	private static <T> T doPrivileged(PrivilegedAction<T> action, AccessControlContext context) {
-		return AccessController.doPrivileged(action, context);
-	}
-
-	private static <T> T doPrivilegedWithException(PrivilegedExceptionAction<T> action, AccessControlContext context)
-			throws PrivilegedActionException {
-		return AccessController.doPrivileged(action, context);
+		return AccessController.doPrivileged(new PrivilegedAction<String>() {
+			@Override
+			public String run() {
+				return bundle.getLocation();
+			}
+		}, controlContext);
 	}
 }
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/NamespaceList.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/NamespaceList.java
index e23ef3f..4813c1c 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/NamespaceList.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/NamespaceList.java
@@ -23,6 +23,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.NoSuchElementException;
+import java.util.function.BiFunction;
 import java.util.function.BiPredicate;
 import java.util.function.Function;
 import java.util.function.Predicate;
@@ -45,9 +46,21 @@
  */
 public class NamespaceList<E> {
 
-	public final static Function<ModuleWire, String> WIRE = wire -> wire.getCapability().getNamespace();
-	public final static Function<ModuleCapability, String> CAPABILITY = ModuleCapability::getNamespace;
-	public final static Function<ModuleRequirement, String> REQUIREMENT = ModuleRequirement::getNamespace;
+	public final static Function<ModuleWire, String> WIRE = new Function<ModuleWire, String>() { 
+		public String apply(ModuleWire wire) {
+			return wire.getCapability().getNamespace();
+		}
+	};
+	public final static Function<ModuleCapability, String> CAPABILITY = new Function<ModuleCapability, String>() {
+		public String apply(ModuleCapability capability) {
+			return capability.getNamespace();
+		}
+	};
+	public final static Function<ModuleRequirement, String> REQUIREMENT = new Function<ModuleRequirement, String>() {
+		public String apply(ModuleRequirement requirement) {
+			return requirement.getNamespace();
+		}
+	};
 
 	/**
 	 * Returns an empty NamespaceList.
@@ -216,7 +229,9 @@
 		public List<E> getNamespaceElements(String namespace) {
 			if (namespace == null) {
 				List<E> list = new ArrayList<>(size);
-				namespaceElements.values().forEach(list::addAll);
+				for (List<E> es : namespaceElements.values()) {
+					list.addAll(es);
+				}
 				return Collections.unmodifiableList(list);
 			}
 			List<E> namespaceList = namespaceElements.get(namespace);
@@ -243,11 +258,14 @@
 		public <R> Builder<R> transformIntoCopy(Function<E, R> transformation, Function<R, String> newGetNamespace) {
 			Builder<R> transformedBuilder = new Builder<>(newGetNamespace, this.namespaceElements.size());
 			transformedBuilder.size = this.size;
-			this.namespaceElements.forEach((n, es) -> {
+                        for (Map.Entry<String, List<E>> entry : namespaceElements.entrySet()) {
+				List<E> es = entry.getValue();
 				List<R> transformedElements = new ArrayList<>(es.size());
-				es.forEach(e -> transformedElements.add(transformation.apply(e)));
-				transformedBuilder.namespaceElements.put(n, transformedElements);
-			});
+				for (E e : es) {
+					transformedElements.add(transformation.apply(e));
+				}
+				transformedBuilder.namespaceElements.put(entry.getKey(), transformedElements);
+			}
 			return transformedBuilder;
 		}
 
@@ -306,15 +324,20 @@
 		}
 
 		private boolean addAll(Map<String, List<E>> perNamespaceElements) {
-			perNamespaceElements.forEach((n, es) -> {
-				getNamespaceList(n).addAll(es);
+			for (Map.Entry<String, List<E>> entry : perNamespaceElements.entrySet()) {
+				List<E> es = entry.getValue();
+				getNamespaceList(entry.getKey()).addAll(es);
 				this.size += es.size();
-			});
+			}
 			return true;
 		}
 
 		private List<E> getNamespaceList(String namespace) {
-			return namespaceElements.computeIfAbsent(namespace, n -> new ArrayList<>());
+			return namespaceElements.computeIfAbsent(namespace, new Function<String, List<E>>() {
+				public List<E> apply(String n) {
+					return new ArrayList<>();
+				}
+			});
 		}
 
 		/**
@@ -370,15 +393,21 @@
 			}
 			prepareModification();
 
-			list.namespaces().forEach((namespace, elementsToAdd) -> {
+			for (Map.Entry<String, List<E>> entry : list.namespaces().entrySet()) {
+				String namespace = entry.getKey();
 				if (namespaceFilter.test(namespace)) {
 					List<E> targetList = getNamespaceList(namespace);
+					List<E> elementsToAdd = entry.getValue();
 					for (E toAdd : elementsToAdd) {
 						if (elementFilter.test(toAdd)) {
 							if (insertionMatcher == null) {
 								targetList.add(toAdd);
 							} else {
-								addAfterLastMatch(toAdd, targetList, e -> insertionMatcher.test(toAdd, e));
+								addAfterLastMatch(toAdd, targetList, new Predicate<E>() {
+									public boolean test(E e) {
+										return insertionMatcher.test(toAdd, e);
+									}
+								});
 							}
 							this.size++;
 						}
@@ -387,7 +416,7 @@
 						namespaceElements.remove(namespace);
 					}
 				}
-			});
+			}
 		}
 
 		private void addAfterLastMatch(E e, List<E> list, Predicate<E> matcher) {
@@ -420,11 +449,13 @@
 		}
 
 		private void removeNamespaceElement(String namespace, E element) {
-			namespaceElements.computeIfPresent(namespace, (n, es) -> {
-				if (es.remove(element)) {
-					this.size--;
+			namespaceElements.computeIfPresent(namespace, new BiFunction<String, List<E>, List<E>>() {
+				public List<E> apply (String n, List<E> es) {
+					if (es.remove(element)) {
+						Builder.this.size--;
+					}
+					return es.isEmpty() ? null : es;
 				}
-				return es.isEmpty() ? null : es;
 			});
 		}
 
@@ -452,12 +483,14 @@
 		public void removeNamespaceIf(Predicate<String> filter) {
 			prepareModification();
 
-			namespaceElements.entrySet().removeIf(e -> {
-				if (filter.test(e.getKey())) {
-					this.size -= e.getValue().size();
-					return true;
+			namespaceElements.entrySet().removeIf(new Predicate<Map.Entry<String, List<E>>>() {
+				public boolean test(Map.Entry<String, List<E>> e) {
+					if (filter.test(e.getKey())) {
+						Builder.this.size -= e.getValue().size();
+						return true;
+					}
+					return false;
 				}
-				return false;
 			});
 		}
 
@@ -466,7 +499,11 @@
 			prepareModification();
 
 			int s = size;
-			namespaceElements.values().removeIf(es -> removeElementsIf(es, filter) == null);
+			namespaceElements.values().removeIf(new Predicate<List<E>>() {
+				public boolean test(List<E> es) {
+					return removeElementsIf(es, filter) == null;
+				}
+			});
 			return size < s;
 		}
 
@@ -480,7 +517,11 @@
 		public void removeElementsOfNamespaceIf(String namespace, Predicate<? super E> filter) {
 			prepareModification();
 
-			namespaceElements.computeIfPresent(namespace, (n, es) -> removeElementsIf(es, filter));
+			namespaceElements.computeIfPresent(namespace, new BiFunction<String, List<E>, List<E>>() {
+				public List<E> apply(String n, List<E> es) {
+					return removeElementsIf(es, filter);
+				}
+			});
 		}
 
 		private List<E> removeElementsIf(List<E> list, Predicate<? super E> filter) {
@@ -509,14 +550,18 @@
 			}
 			if (lastBuildElements == null) {
 				lastBuildElements = new ArrayList<>(size);
-				namespaceElements.values().forEach(lastBuildElements::addAll);
+				for (List<E> es : namespaceElements.values()) {
+					lastBuildElements.addAll(es);
+				}
 				lastBuildElements = Collections.unmodifiableList(lastBuildElements);
 
 				int[] start = new int[] { 0 };
-				namespaceElements.replaceAll((n, es) -> {
-					int from = start[0];
-					int to = start[0] += es.size();
-					return lastBuildElements.subList(from, to);
+				namespaceElements.replaceAll(new BiFunction<String, List<E>, List<E>>() {
+					public List<E> apply(String n, List<E> es) {
+						int from = start[0];
+						int to = start[0] += es.size();
+						return lastBuildElements.subList(from, to);
+					}
 				});
 			}
 			return new NamespaceList<>(getNamespace, namespaceElements, lastBuildElements);
@@ -527,7 +572,11 @@
 				// this builder was build before. Create a copy of the Map and their
 				// namespace-lists for subsequent modification
 				namespaceElements = new LinkedHashMap<>(namespaceElements);
-				namespaceElements.replaceAll((n, es) -> new ArrayList<>(es));
+				namespaceElements.replaceAll(new BiFunction<String, List<E>, List<E>>() {
+					public List<E> apply(String n, List<E> es) {
+						return new ArrayList<>(es);
+					}
+				});
 				lastBuildElements = null;
 			}
 		}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/BundleContextImpl.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/BundleContextImpl.java
index bb3a3dc..0ba9db7 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/BundleContextImpl.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/BundleContextImpl.java
@@ -243,9 +243,12 @@
 		if (System.getSecurityManager() == null) {
 			notifyFindHooksPriviledged(context, shrinkable);
 		} else {
-			AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
-				notifyFindHooksPriviledged(context, shrinkable);
-				return null;
+			AccessController.doPrivileged(new PrivilegedAction<Void>() {
+				@Override
+				public Void run() {
+					notifyFindHooksPriviledged(context, shrinkable);
+					return null;
+				}
 			});
 		}
 	}
@@ -799,19 +802,22 @@
 	 */
 	private void startActivator(final BundleActivator bundleActivator) throws BundleException {
 		try {
-			AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
-				if (bundleActivator != null) {
-					// make sure the context class loader is set correctly
-					Object previousTCCL = setContextFinder();
-					/* Start the bundle synchronously */
-					try {
-						bundleActivator.start(BundleContextImpl.this);
-					} finally {
-						if (previousTCCL != Boolean.FALSE)
-							Thread.currentThread().setContextClassLoader((ClassLoader) previousTCCL);
+			AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
+				@Override
+				public Void run() throws Exception {
+					if (bundleActivator != null) {
+						// make sure the context class loader is set correctly
+						Object previousTCCL = setContextFinder();
+						/* Start the bundle synchronously */
+						try {
+							bundleActivator.start(BundleContextImpl.this);
+						} finally {
+							if (previousTCCL != Boolean.FALSE)
+								Thread.currentThread().setContextClassLoader((ClassLoader) previousTCCL);
+						}
 					}
+					return null;
 				}
-				return null;
 			});
 		} catch (Throwable t) {
 			if (t instanceof PrivilegedActionException) {
@@ -853,19 +859,22 @@
 	protected void stop() throws BundleException {
 		try {
 			final BundleActivator bundleActivator = activator;
-			AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
-				if (bundleActivator != null) {
-					// make sure the context class loader is set correctly
-					Object previousTCCL = setContextFinder();
-					try {
-						/* Stop the bundle synchronously */
-						bundleActivator.stop(BundleContextImpl.this);
-					} finally {
-						if (previousTCCL != Boolean.FALSE)
-							Thread.currentThread().setContextClassLoader((ClassLoader) previousTCCL);
+			AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
+				@Override
+				public Void run() throws Exception {
+					if (bundleActivator != null) {
+						// make sure the context class loader is set correctly
+						Object previousTCCL = setContextFinder();
+						try {
+							/* Stop the bundle synchronously */
+							bundleActivator.stop(BundleContextImpl.this);
+						} finally {
+							if (previousTCCL != Boolean.FALSE)
+								Thread.currentThread().setContextClassLoader((ClassLoader) previousTCCL);
+						}
 					}
+					return null;
 				}
-				return null;
 			});
 		} catch (Throwable t) {
 			if (t instanceof PrivilegedActionException) {
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/ContextFinder.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/ContextFinder.java
index 29b05e3..c0f5347 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/ContextFinder.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/ContextFinder.java
@@ -43,10 +43,13 @@
 	static ClassLoader finderClassLoader;
 	static Finder contextFinder;
 	static {
-		AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
-			finderClassLoader = ContextFinder.class.getClassLoader();
-			contextFinder = new Finder();
-			return null;
+		AccessController.doPrivileged(new PrivilegedAction<Void>() {
+			@Override
+			public Void run() {
+				finderClassLoader = ContextFinder.class.getClassLoader();
+				contextFinder = new Finder();
+				return null;
+			}
 		});
 	}
 
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 189cfe8..5eb8022 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
@@ -219,11 +219,14 @@
 					if (Module.ACTIVE_SET.contains(getState())) {
 						// TODO this still has a chance of a race condition:
 						// multiple threads could get started if stop is called over and over
-						Thread t = new Thread(() -> {
-							try {
-								stop();
-							} catch (Throwable e) {
-								SystemBundle.this.getEquinoxContainer().getLogServices().log(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, "Error stopping the framework.", e); //$NON-NLS-1$
+						Thread t = new Thread(new Runnable() {
+							@Override
+							public void run() {
+								try {
+									stop();
+								} catch (Throwable e) {
+									SystemBundle.this.getEquinoxContainer().getLogServices().log(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, "Error stopping the framework.", e); //$NON-NLS-1$
+								}
 							}
 						}, "Framework stop - " + getEquinoxContainer().toString()); //$NON-NLS-1$
 						t.start();
@@ -240,11 +243,14 @@
 				lockStateChange(ModuleEvent.UPDATED);
 				try {
 					if (Module.ACTIVE_SET.contains(getState())) {
-						Thread t = new Thread(() -> {
-							try {
-								update();
-							} catch (Throwable e) {
-								SystemBundle.this.getEquinoxContainer().getLogServices().log(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, "Error updating the framework.", e); //$NON-NLS-1$
+						Thread t = new Thread(new Runnable() {
+							@Override
+							public void run() {
+								try {
+									update();
+								} catch (Throwable e) {
+									SystemBundle.this.getEquinoxContainer().getLogServices().log(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, "Error updating the framework.", e); //$NON-NLS-1$
+								}
 							}
 						}, "Framework update - " + getEquinoxContainer().toString()); //$NON-NLS-1$
 						t.start();
@@ -637,15 +643,18 @@
 			String reportMessage = report.getResolutionReportMessage(module.getCurrentRevision());
 			equinoxContainer.getEventPublisher().publishFrameworkEvent(FrameworkEvent.ERROR, this, new BundleException(reportMessage, BundleException.RESOLVE_ERROR));
 		}
-		return AccessController.doPrivileged((PrivilegedAction<ModuleClassLoader>) () -> {
-			ModuleWiring wiring = getModule().getCurrentRevision().getWiring();
-			if (wiring != null) {
-				ModuleLoader moduleLoader = wiring.getModuleLoader();
-				if (moduleLoader instanceof BundleLoader) {
-					return ((BundleLoader) moduleLoader).getModuleClassLoader();
+		return AccessController.doPrivileged(new PrivilegedAction<ModuleClassLoader>() {
+			@Override
+			public ModuleClassLoader run() {
+				ModuleWiring wiring = getModule().getCurrentRevision().getWiring();
+				if (wiring != null) {
+					ModuleLoader moduleLoader = wiring.getModuleLoader();
+					if (moduleLoader instanceof BundleLoader) {
+						return ((BundleLoader) moduleLoader).getModuleClassLoader();
+					}
 				}
+				return null;
 			}
-			return null;
 		});
 	}
 
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java
index 01abd70..b00ab1e 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java
@@ -125,27 +125,38 @@
 	private Callable<Executor> createLazyExecutorCreator(final String threadName, int threadCnt, final BlockingQueue<Runnable> queue) {
 		// use the number of processors when configured value is <=0
 		final int maxThreads = threadCnt <= 0 ? Runtime.getRuntime().availableProcessors() : threadCnt;
-		return () -> {
-			if (maxThreads == 1) {
-				// just do synchronous execution with current thread
-				return Runnable::run;
-			}
-			// Always want to create core threads until max size
-			int coreThreads = maxThreads;
-			// idle timeout; make it short to get rid of threads quickly after use
-			int idleTimeout = 10;
-			// try to name the threads with useful name
-			ThreadFactory threadFactory = r -> {
-				Thread t = new Thread(r, threadName);
-				t.setDaemon(true);
-				return t;
-			};
-			// use a rejection policy that simply runs the task in the current thread once the max pool size is reached
-			RejectedExecutionHandler rejectHandler = new ThreadPoolExecutor.CallerRunsPolicy();
+		return new Callable<Executor>() {
+			@Override
+			public Executor call() throws Exception {
+				if (maxThreads == 1) {
+					// just do synchronous execution with current thread
+					return new Executor() {
+						@Override
+						public void execute(Runnable command) {
+							command.run();
+						}
+					};
+				}
+				// Always want to create core threads until max size
+				int coreThreads = maxThreads;
+				// idle timeout; make it short to get rid of threads quickly after use
+				int idleTimeout = 10;
+				// try to name the threads with useful name
+				ThreadFactory threadFactory = new ThreadFactory() {
+					@Override
+					public Thread newThread(Runnable r) {
+						Thread t = new Thread(r, threadName);
+						t.setDaemon(true);
+						return t;
+					}
+				};
+				// use a rejection policy that simply runs the task in the current thread once the max pool size is reached
+				RejectedExecutionHandler rejectHandler = new ThreadPoolExecutor.CallerRunsPolicy();
 
-			ThreadPoolExecutor executor = new ThreadPoolExecutor(coreThreads, maxThreads, idleTimeout, TimeUnit.SECONDS, queue, threadFactory, rejectHandler);
-			executor.allowCoreThreadTimeOut(true);
-			return executor;
+				ThreadPoolExecutor executor = new ThreadPoolExecutor(coreThreads, maxThreads, idleTimeout, TimeUnit.SECONDS, queue, threadFactory, rejectHandler);
+				executor.allowCoreThreadTimeOut(true);
+				return executor;
+			}
 		};
 	}
 
@@ -403,4 +414,4 @@
 		Generation generation = (Generation) revisionInfo;
 		return generation.adaptModuleRevisionBuilder(operation, origin, builder);
 	}
-}
\ No newline at end of file
+}
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 9414400..606432d 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
@@ -74,7 +74,12 @@
 	public final static String DEFAULT_PACKAGE = "."; //$NON-NLS-1$
 	public final static String JAVA_PACKAGE = "java."; //$NON-NLS-1$
 
-	public final static ClassContext CLASS_CONTEXT = AccessController.doPrivileged((PrivilegedAction<ClassContext>) ClassContext::new);
+	public final static ClassContext CLASS_CONTEXT = AccessController.doPrivileged(new PrivilegedAction<ClassContext>() {
+		@Override
+		public ClassContext run() {
+			return new ClassContext();
+		}
+	});
 	public final static ClassLoader FW_CLASSLOADER = getClassLoader(EquinoxContainer.class);
 
 	private static final int PRE_CLASS = 1;
@@ -257,8 +262,12 @@
 			result = createClassLoaderPrivledged(parent, generation.getBundleInfo().getStorage().getConfiguration(), this, generation, hooks);
 		} else {
 			final ClassLoader cl = parent;
-			result = AccessController.doPrivileged((PrivilegedAction<ModuleClassLoader>)
-					() -> createClassLoaderPrivledged(cl, generation.getBundleInfo().getStorage().getConfiguration(), BundleLoader.this, generation, hooks));
+			result = AccessController.doPrivileged(new PrivilegedAction<ModuleClassLoader>() {
+				@Override
+				public ModuleClassLoader run() {
+					return createClassLoaderPrivledged(cl, generation.getBundleInfo().getStorage().getConfiguration(), BundleLoader.this, generation, hooks);
+				}
+			});
 		}
 
 		// Synchronize on classLoaderCreatedMonitor in order to ensure hooks are called before returning.
@@ -272,11 +281,15 @@
 				// only send to hooks if this thread wins in creating the class loader.
 				final ModuleClassLoader cl = result;
 				// protect with doPriv to avoid bubbling up permission checks that hooks may require
-				AccessController.doPrivileged((PrivilegedAction<Object>) () -> {
-					for (ClassLoaderHook hook : hooks) {
-						hook.classLoaderCreated(cl);
+				AccessController.doPrivileged(new PrivilegedAction<Object>() {
+					@Override
+					public Object run() {
+						for (ClassLoaderHook hook : hooks) {
+							hook.classLoaderCreated(cl);
+						}
+						return null;
 					}
-					return null;
+
 				});
 				// finally set the class loader for use after calling hooks
 				classloader = classLoaderCreated;
@@ -601,7 +614,12 @@
 	private static ClassLoader getClassLoader(final Class<?> clazz) {
 		if (System.getSecurityManager() == null)
 			return clazz.getClassLoader();
-		return AccessController.doPrivileged((PrivilegedAction<ClassLoader>) clazz::getClassLoader);
+		return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+			@Override
+			public ClassLoader run() {
+				return clazz.getClassLoader();
+			}
+		});
 	}
 
 	/**
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogReaderServiceFactory.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogReaderServiceFactory.java
index b8aa9d2..bb2e6a9 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogReaderServiceFactory.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogReaderServiceFactory.java
@@ -57,7 +57,12 @@
 		}
 	}
 
-	static final LogFilter NULL_LOGGER_FILTER = (b, loggerName, logLevel) -> true;
+	static final LogFilter NULL_LOGGER_FILTER = new LogFilter() {
+		@Override
+		public boolean isLoggable(Bundle b, String loggerName, int logLevel) {
+			return true;
+		}
+	};
 
 	private static final LogFilter[] ALWAYS_LOG = new LogFilter[0];
 
@@ -143,7 +148,12 @@
 
 	boolean isLoggable(final Bundle bundle, final String name, final int level) {
 		if (System.getSecurityManager() != null) {
-			return AccessController.doPrivileged((PrivilegedAction<Boolean>) () -> isLoggablePrivileged(bundle, name, level));
+			return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
+				@Override
+				public Boolean run() {
+					return isLoggablePrivileged(bundle, name, level);
+				}
+			});
 		}
 		return isLoggablePrivileged(bundle, name, level);
 	}
@@ -201,9 +211,12 @@
 
 	void log(final Bundle bundle, final String name, final StackTraceElement stackTraceElement, final Object context, final LogLevel logLevelEnum, final int level, final String message, final ServiceReference<?> ref, final Throwable exception) {
 		if (System.getSecurityManager() != null) {
-			AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
-				logPrivileged(bundle, name, stackTraceElement, context, logLevelEnum, level, message, ref, exception);
-				return null;
+			AccessController.doPrivileged(new PrivilegedAction<Void>() {
+				@Override
+				public Void run() {
+					logPrivileged(bundle, name, stackTraceElement, context, logLevelEnum, level, message, ref, exception);
+					return null;
+				}
 			});
 		} else {
 			logPrivileged(bundle, name, stackTraceElement, context, logLevelEnum, level, message, ref, exception);
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceFactoryUse.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceFactoryUse.java
index eb441de..4d39c2a 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceFactoryUse.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceFactoryUse.java
@@ -214,7 +214,12 @@
 	S factoryGetService() {
 		final S service;
 		try {
-			service = AccessController.doPrivileged((PrivilegedAction<S>) () -> factory.getService(context.getBundleImpl(), registration));
+			service = AccessController.doPrivileged(new PrivilegedAction<S>() {
+				@Override
+				public S run() {
+					return factory.getService(context.getBundleImpl(), registration);
+				}
+			});
 		} catch (Throwable t) {
 			if (debug.DEBUG_SERVICES) {
 				Debug.println(factory + ".getService() exception: " + t.getMessage()); //$NON-NLS-1$
@@ -262,9 +267,12 @@
 	/* @GuardedBy("this") */
 	void factoryUngetService(final S service) {
 		try {
-			AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
-				factory.ungetService(context.getBundleImpl(), registration, service);
-				return null;
+			AccessController.doPrivileged(new PrivilegedAction<Void>() {
+				@Override
+				public Void run() {
+					factory.ungetService(context.getBundleImpl(), registration, service);
+					return null;
+				}
 			});
 		} catch (Throwable t) {
 			if (debug.DEBUG_SERVICES) {
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceRegistry.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceRegistry.java
index 4a75b45..176c281 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceRegistry.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceRegistry.java
@@ -872,9 +872,12 @@
 		if (System.getSecurityManager() == null) {
 			publishServiceEventPrivileged(event);
 		} else {
-			AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
-				publishServiceEventPrivileged(event);
-				return null;
+			AccessController.doPrivileged(new PrivilegedAction<Void>() {
+				@Override
+				public Void run() {
+					publishServiceEventPrivileged(event);
+					return null;
+				}
 			});
 		}
 	}
@@ -1177,7 +1180,12 @@
 	 * @return The name of the class that is not satisfied by the service object.
 	 */
 	static String checkServiceClass(final String[] clazzes, final Object serviceObject) {
-		ClassLoader cl = AccessController.doPrivileged((PrivilegedAction<ClassLoader>) () -> serviceObject.getClass().getClassLoader());
+		ClassLoader cl = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+			@Override
+			public ClassLoader run() {
+				return serviceObject.getClass().getClassLoader();
+			}
+		});
 		for (int i = 0, len = clazzes.length; i < len; i++) {
 			try {
 				Class<?> serviceClazz = cl == null ? Class.forName(clazzes[i]) : cl.loadClass(clazzes[i]);
@@ -1230,9 +1238,12 @@
 		if (System.getSecurityManager() == null) {
 			notifyFindHooksPrivileged(context, clazz, filterstring, allservices, result);
 		} else {
-			AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
-				notifyFindHooksPrivileged(context, clazz, filterstring, allservices, result);
-				return null;
+			AccessController.doPrivileged(new PrivilegedAction<Void>() {
+				@Override
+				public Void run() {
+					notifyFindHooksPrivileged(context, clazz, filterstring, allservices, result);
+					return null;
+				}
 			});
 		}
 	}
@@ -1342,9 +1353,12 @@
 		if (System.getSecurityManager() == null) {
 			notifyNewListenerHookPrivileged(registration);
 		} else {
-			AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
-				notifyNewListenerHookPrivileged(registration);
-				return null;
+			AccessController.doPrivileged(new PrivilegedAction<Void>() {
+				@Override
+				public Void run() {
+					notifyNewListenerHookPrivileged(registration);
+					return null;
+				}
 			});
 		}
 
@@ -1387,9 +1401,12 @@
 		if (System.getSecurityManager() == null) {
 			notifyListenerHooksPrivileged(listeners, added);
 		} else {
-			AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
-				notifyListenerHooksPrivileged(listeners, added);
-				return null;
+			AccessController.doPrivileged(new PrivilegedAction<Void>() {
+				@Override
+				public Void run() {
+					notifyListenerHooksPrivileged(listeners, added);
+					return null;
+				}
 			});
 		}
 
diff --git a/bundles/org.eclipse.osgi/supplement/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi/supplement/META-INF/MANIFEST.MF
index 547a773..a4fd218 100644
--- a/bundles/org.eclipse.osgi/supplement/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.osgi/supplement/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
 Bundle-ManifestVersion: 2
 Bundle-Name: %pluginName
 Bundle-SymbolicName: org.eclipse.equinox.supplement
-Bundle-Version: 1.10.300.qualifier
+Bundle-Version: 1.10.400.qualifier
 Bundle-Vendor: %providerName
 Bundle-Localization: plugin
 Export-Package: org.eclipse.equinox.log;version="1.1",
diff --git a/bundles/org.eclipse.osgi/supplement/pom.xml b/bundles/org.eclipse.osgi/supplement/pom.xml
index bed7265..88a61a7 100644
--- a/bundles/org.eclipse.osgi/supplement/pom.xml
+++ b/bundles/org.eclipse.osgi/supplement/pom.xml
@@ -21,7 +21,7 @@
 
   <groupId>org.eclipse.equinox</groupId>
   <artifactId>org.eclipse.equinox.supplement</artifactId>
-  <version>1.10.300-SNAPSHOT</version>
+  <version>1.10.400-SNAPSHOT</version>
   <packaging>eclipse-plugin</packaging>
 
 </project>
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/eventmgr/EventManager.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/eventmgr/EventManager.java
index 1d5286d..31078d3 100644
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/eventmgr/EventManager.java
+++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/eventmgr/EventManager.java
@@ -195,7 +195,13 @@
 		}
 		if (thread == null) {
 			/* if there is no thread, then create a new one */
-			thread = AccessController.doPrivileged((PrivilegedAction<EventThread<K, V, E>>) () -> new EventThread<>(threadGroup, threadName));
+			thread = AccessController.doPrivileged(new PrivilegedAction<EventThread<K, V, E>>() {
+				@Override
+				public EventThread<K, V, E> run() {
+					EventThread<K, V, E> t = new EventThread<>(threadGroup, threadName);
+					return t;
+				}
+			});
 			/* start the new thread */
 			thread.start();
 		}
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 94f3458..7a8b89e 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
@@ -64,7 +64,12 @@
 	private static String[] nlSuffixes;
 	private static final String PROP_WARNINGS = "osgi.nls.warnings"; //$NON-NLS-1$
 	private static final String IGNORE = "ignore"; //$NON-NLS-1$
-	private static final boolean ignoreWarnings = AccessController.doPrivileged((PrivilegedAction<Boolean>) () -> IGNORE.equals(System.getProperty(PROP_WARNINGS)));
+	private static final boolean ignoreWarnings = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
+		@Override
+		public Boolean run() {
+			return IGNORE.equals(System.getProperty(PROP_WARNINGS));
+		}
+	});
 
 	/*
 	 * NOTE do not change the name of this field; it is set by the Framework using reflection
@@ -147,9 +152,12 @@
 			load(baseName, clazz);
 			return;
 		}
-		AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
-			load(baseName, clazz);
-			return null;
+		AccessController.doPrivileged(new PrivilegedAction<Void>() {
+			@Override
+			public Void run() {
+				load(baseName, clazz);
+				return null;
+			}
 		});
 	}