Bug 574872 - [Clean-up] Use lambda where possible in tests (2)

Clean up using the JDT clean-up:
- Convert functional interface instances: Use lambda where possible

Change-Id: I3f97cc918bb332bfe33c6e6c4002f73b6214fc30
Signed-off-by: Hannes Wellmann <wellmann.hannes1@gmx.net>
Reviewed-on: https://git.eclipse.org/r/c/equinox/rt.equinox.framework/+/183301
Tested-by: Equinox Bot <equinox-bot@eclipse.org>
Reviewed-by: Lars Vogel <Lars.Vogel@vogella.com>
diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/activator.hooks.a/org/eclipse/osgi/tests/hooks/framework/activator/a/TestHookConfigurator1.java b/bundles/org.eclipse.osgi.tests/bundles_src/activator.hooks.a/org/eclipse/osgi/tests/hooks/framework/activator/a/TestHookConfigurator1.java
index 1c1057f..fb9650e 100644
--- a/bundles/org.eclipse.osgi.tests/bundles_src/activator.hooks.a/org/eclipse/osgi/tests/hooks/framework/activator/a/TestHookConfigurator1.java
+++ b/bundles/org.eclipse.osgi.tests/bundles_src/activator.hooks.a/org/eclipse/osgi/tests/hooks/framework/activator/a/TestHookConfigurator1.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2013, 2017 IBM Corporation and others.
+ * Copyright (c) 2013, 2021 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -14,7 +14,6 @@
 package org.eclipse.osgi.tests.hooks.framework.activator.a;
 
 import java.util.List;
-import org.eclipse.osgi.internal.hookregistry.ActivatorHookFactory;
 import org.eclipse.osgi.internal.hookregistry.HookConfigurator;
 import org.eclipse.osgi.internal.hookregistry.HookRegistry;
 import org.osgi.framework.BundleActivator;
@@ -25,25 +24,19 @@
 	public static volatile List<String> events;
 
 	public void addHooks(HookRegistry hookRegistry) {
-		hookRegistry.addActivatorHookFactory(new ActivatorHookFactory() {
+		hookRegistry.addActivatorHookFactory(() -> new BundleActivator() {
+			@Override
+			public void start(BundleContext context) throws Exception {
+				if (events != null) {
+					events.add("HOOK1 STARTED");
+				}
+			}
 
 			@Override
-			public BundleActivator createActivator() {
-				return new BundleActivator() {
-					@Override
-					public void start(BundleContext context) throws Exception {
-						if (events != null) {
-							events.add("HOOK1 STARTED");
-						}
-					}
-
-					@Override
-					public void stop(BundleContext context) throws Exception {
-						if (events != null) {
-							events.add("HOOK1 STOPPED");
-						}
-					}
-				};
+			public void stop(BundleContext context) throws Exception {
+				if (events != null) {
+					events.add("HOOK1 STOPPED");
+				}
 			}
 		});
 	}
diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/activator.hooks.a/org/eclipse/osgi/tests/hooks/framework/activator/a/TestHookConfigurator2.java b/bundles/org.eclipse.osgi.tests/bundles_src/activator.hooks.a/org/eclipse/osgi/tests/hooks/framework/activator/a/TestHookConfigurator2.java
index b9724a5..a02f583 100644
--- a/bundles/org.eclipse.osgi.tests/bundles_src/activator.hooks.a/org/eclipse/osgi/tests/hooks/framework/activator/a/TestHookConfigurator2.java
+++ b/bundles/org.eclipse.osgi.tests/bundles_src/activator.hooks.a/org/eclipse/osgi/tests/hooks/framework/activator/a/TestHookConfigurator2.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2013, 2017 IBM Corporation and others.
+ * Copyright (c) 2013, 2021 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -14,7 +14,6 @@
 package org.eclipse.osgi.tests.hooks.framework.activator.a;
 
 import java.util.List;
-import org.eclipse.osgi.internal.hookregistry.ActivatorHookFactory;
 import org.eclipse.osgi.internal.hookregistry.HookConfigurator;
 import org.eclipse.osgi.internal.hookregistry.HookRegistry;
 import org.osgi.framework.BundleActivator;
@@ -25,25 +24,19 @@
 
 	@Override
 	public void addHooks(HookRegistry hookRegistry) {
-		hookRegistry.addActivatorHookFactory(new ActivatorHookFactory() {
+		hookRegistry.addActivatorHookFactory(() -> new BundleActivator() {
+			@Override
+			public void start(BundleContext context) throws Exception {
+				if (events != null) {
+					events.add("HOOK2 STARTED");
+				}
+			}
 
 			@Override
-			public BundleActivator createActivator() {
-				return new BundleActivator() {
-					@Override
-					public void start(BundleContext context) throws Exception {
-						if (events != null) {
-							events.add("HOOK2 STARTED");
-						}
-					}
-
-					@Override
-					public void stop(BundleContext context) throws Exception {
-						if (events != null) {
-							events.add("HOOK2 STOPPED");
-						}
-					}
-				};
+			public void stop(BundleContext context) throws Exception {
+				if (events != null) {
+					events.add("HOOK2 STOPPED");
+				}
 			}
 		});
 
diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/activator.hooks.a/org/eclipse/osgi/tests/hooks/framework/activator/a/TestHookConfigurator3.java b/bundles/org.eclipse.osgi.tests/bundles_src/activator.hooks.a/org/eclipse/osgi/tests/hooks/framework/activator/a/TestHookConfigurator3.java
index 85e2bfe..69bd899 100644
--- a/bundles/org.eclipse.osgi.tests/bundles_src/activator.hooks.a/org/eclipse/osgi/tests/hooks/framework/activator/a/TestHookConfigurator3.java
+++ b/bundles/org.eclipse.osgi.tests/bundles_src/activator.hooks.a/org/eclipse/osgi/tests/hooks/framework/activator/a/TestHookConfigurator3.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2013, 2017 IBM Corporation and others.
+ * Copyright (c) 2013, 2021 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -14,7 +14,6 @@
 package org.eclipse.osgi.tests.hooks.framework.activator.a;
 
 import java.util.List;
-import org.eclipse.osgi.internal.hookregistry.ActivatorHookFactory;
 import org.eclipse.osgi.internal.hookregistry.HookConfigurator;
 import org.eclipse.osgi.internal.hookregistry.HookRegistry;
 import org.osgi.framework.BundleActivator;
@@ -25,25 +24,19 @@
 
 	@Override
 	public void addHooks(HookRegistry hookRegistry) {
-		hookRegistry.addActivatorHookFactory(new ActivatorHookFactory() {
+		hookRegistry.addActivatorHookFactory(() -> new BundleActivator() {
+			@Override
+			public void start(BundleContext context) throws Exception {
+				if (events != null) {
+					events.add("HOOK3 STARTED");
+				}
+			}
 
 			@Override
-			public BundleActivator createActivator() {
-				return new BundleActivator() {
-					@Override
-					public void start(BundleContext context) throws Exception {
-						if (events != null) {
-							events.add("HOOK3 STARTED");
-						}
-					}
-
-					@Override
-					public void stop(BundleContext context) throws Exception {
-						if (events != null) {
-							events.add("HOOK3 STOPPED");
-						}
-					}
-				};
+			public void stop(BundleContext context) throws Exception {
+				if (events != null) {
+					events.add("HOOK3 STOPPED");
+				}
 			}
 		});
 
diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/geturl/geturl/Activator.java b/bundles/org.eclipse.osgi.tests/bundles_src/geturl/geturl/Activator.java
index faff555..5442385 100644
--- a/bundles/org.eclipse.osgi.tests/bundles_src/geturl/geturl/Activator.java
+++ b/bundles/org.eclipse.osgi.tests/bundles_src/geturl/geturl/Activator.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2010, 2016 IBM Corporation and others.
+ * Copyright (c) 2010, 2021 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -28,30 +28,26 @@
 		final String urlSpec = (String) System.getProperties().get("test.url.spec");
 		Dictionary props = new Hashtable();
 		props.put("test.url", url);
-		context.registerService(PrivilegedAction.class, new PrivilegedAction() {
-
-			@Override
-			public Object run() {
-				try {
-					throw new RuntimeException("Expected to fail to create: " + new URL(urlSpec));
-				} catch (MalformedURLException e) {
-					// expected; the parseURL will cause this to fail
-				}
-				try {
-					new URL(url.getProtocol(), url.getHost(), url.getFile());
-				} catch (MalformedURLException e) {
-					// unexpected; the handler does not get involved and we have a multiplexor cached
-					throw new RuntimeException("Could not create URL from parts: " + url);
-				}
-				url.toExternalForm();
-
-				try {
-					url.openConnection(Proxy.NO_PROXY);
-				} catch (IOException e) {
-					// expected since our impl throws this
-				}
-				return Boolean.TRUE;
+		context.registerService(PrivilegedAction.class, () -> {
+			try {
+				throw new RuntimeException("Expected to fail to create: " + new URL(urlSpec));
+			} catch (MalformedURLException e1) {
+				// expected; the parseURL will cause this to fail
 			}
+			try {
+				new URL(url.getProtocol(), url.getHost(), url.getFile());
+			} catch (MalformedURLException e2) {
+				// unexpected; the handler does not get involved and we have a multiplexor cached
+				throw new RuntimeException("Could not create URL from parts: " + url);
+			}
+			url.toExternalForm();
+
+			try {
+				url.openConnection(Proxy.NO_PROXY);
+			} catch (IOException e3) {
+				// expected since our impl throws this
+			}
+			return Boolean.TRUE;
 		}, props);
 	}
 
diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/storage.hooks.a/org/eclipse/osgi/tests/hooks/framework/storage/a/TestHookConfigurator.java b/bundles/org.eclipse.osgi.tests/bundles_src/storage.hooks.a/org/eclipse/osgi/tests/hooks/framework/storage/a/TestHookConfigurator.java
index 684b93e..3a53f17 100644
--- a/bundles/org.eclipse.osgi.tests/bundles_src/storage.hooks.a/org/eclipse/osgi/tests/hooks/framework/storage/a/TestHookConfigurator.java
+++ b/bundles/org.eclipse.osgi.tests/bundles_src/storage.hooks.a/org/eclipse/osgi/tests/hooks/framework/storage/a/TestHookConfigurator.java
@@ -32,7 +32,6 @@
 import org.eclipse.osgi.container.ModuleContainerAdaptor.ModuleEvent;
 import org.eclipse.osgi.container.ModuleRevisionBuilder;
 import org.eclipse.osgi.container.ModuleRevisionBuilder.GenericInfo;
-import org.eclipse.osgi.internal.hookregistry.ActivatorHookFactory;
 import org.eclipse.osgi.internal.hookregistry.HookConfigurator;
 import org.eclipse.osgi.internal.hookregistry.HookRegistry;
 import org.eclipse.osgi.internal.hookregistry.StorageHookFactory;
@@ -177,21 +176,15 @@
 
 	public void addHooks(HookRegistry hookRegistry) {
 		hookRegistry.addStorageHookFactory(new TestStorageHookFactory());
-		hookRegistry.addActivatorHookFactory(new ActivatorHookFactory() {
+		hookRegistry.addActivatorHookFactory(() -> new BundleActivator() {
+			@Override
+			public void start(BundleContext context) throws Exception {
+				TestHelper.setBundle(context.getBundle(Constants.SYSTEM_BUNDLE_LOCATION));
+			}
 
 			@Override
-			public BundleActivator createActivator() {
-				return new BundleActivator() {
-					@Override
-					public void start(BundleContext context) throws Exception {
-						TestHelper.setBundle(context.getBundle(Constants.SYSTEM_BUNDLE_LOCATION));
-					}
-
-					@Override
-					public void stop(BundleContext context) throws Exception {
-						TestHelper.setBundle(null);
-					}
-				};
+			public void stop(BundleContext context) throws Exception {
+				TestHelper.setBundle(null);
 			}
 		});
 	}
diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.filter.a/test/filter/a/Activator.java b/bundles/org.eclipse.osgi.tests/bundles_src/test.filter.a/test/filter/a/Activator.java
index e661b9c..c32bb26 100644
--- a/bundles/org.eclipse.osgi.tests/bundles_src/test.filter.a/test/filter/a/Activator.java
+++ b/bundles/org.eclipse.osgi.tests/bundles_src/test.filter.a/test/filter/a/Activator.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2008 IBM Corporation and others.
+ * Copyright (c) 2008, 2021 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -22,11 +22,7 @@
 
 	public void start(BundleContext context) throws Exception {
 		final boolean[] serviceChanged = {false};
-		ServiceListener listener = new ServiceListener() {
-			public void serviceChanged(ServiceEvent event) {
-				serviceChanged[0] = true;
-			}
-		};
+		ServiceListener listener = event -> serviceChanged[0] = true;
 		context.addServiceListener(listener, "(&(objectClass=java.lang.String)(test=*))");
 		final boolean[] modifiedService = {false};
 		ServiceTracker tracker = new ServiceTracker(context, FrameworkUtil.createFilter("(&(objectClass=java.lang.String)(test=*))"), new ServiceTrackerCustomizer() {
diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/wrapper.hooks.a/org/eclipse/osgi/tests/wrapper/hooks/a/TestHookConfigurator.java b/bundles/org.eclipse.osgi.tests/bundles_src/wrapper.hooks.a/org/eclipse/osgi/tests/wrapper/hooks/a/TestHookConfigurator.java
index ad8a83f..731832b 100755
--- a/bundles/org.eclipse.osgi.tests/bundles_src/wrapper.hooks.a/org/eclipse/osgi/tests/wrapper/hooks/a/TestHookConfigurator.java
+++ b/bundles/org.eclipse.osgi.tests/bundles_src/wrapper.hooks.a/org/eclipse/osgi/tests/wrapper/hooks/a/TestHookConfigurator.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2015, 2016 IBM Corporation and others.
+ * Copyright (c) 2015, 2021 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -17,72 +17,60 @@
 import java.net.*;
 import org.eclipse.osgi.container.Module;
 import org.eclipse.osgi.internal.hookregistry.*;
-import org.eclipse.osgi.storage.BundleInfo.Generation;
 import org.eclipse.osgi.storage.bundlefile.*;
 
 public class TestHookConfigurator implements HookConfigurator {
 	public void addHooks(HookRegistry hookRegistry) {
 
-		BundleFileWrapperFactoryHook modifyContent = new BundleFileWrapperFactoryHook() {
+		BundleFileWrapperFactoryHook modifyContent = (bundleFile, generation, base) -> new BundleFileWrapper(bundleFile) {
 
 			@Override
-			public BundleFileWrapper wrapBundleFile(BundleFile bundleFile, Generation generation, boolean base) {
-				return new BundleFileWrapper(bundleFile) {
+			public BundleEntry getEntry(String path) {
+				final BundleEntry original = super.getEntry(path);
+				final byte[] content = "CUSTOM_CONTENT".getBytes();
+				if ("data/resource1".equals(path)) {
+					return new BundleEntry() {
 
-					@Override
-					public BundleEntry getEntry(String path) {
-						final BundleEntry original = super.getEntry(path);
-						final byte[] content = "CUSTOM_CONTENT".getBytes();
-						if ("data/resource1".equals(path)) {
-							return new BundleEntry() {
-
-								@Override
-								public long getTime() {
-									return original.getTime();
-								}
-
-								@Override
-								public long getSize() {
-									return content.length;
-								}
-
-								@Override
-								public String getName() {
-									return original.getName();
-								}
-
-								@Override
-								public URL getLocalURL() {
-									return original.getLocalURL();
-								}
-
-								/**
-								 * @throws IOException
-								 */
-								@Override
-								public InputStream getInputStream() throws IOException {
-									return new ByteArrayInputStream(content);
-								}
-
-								@Override
-								public URL getFileURL() {
-									return original.getFileURL();
-								}
-							};
+						@Override
+						public long getTime() {
+							return original.getTime();
 						}
-						return original;
-					}
 
-				};
+						@Override
+						public long getSize() {
+							return content.length;
+						}
+
+						@Override
+						public String getName() {
+							return original.getName();
+						}
+
+						@Override
+						public URL getLocalURL() {
+							return original.getLocalURL();
+						}
+
+						/**
+						 * @throws IOException
+						 */
+						@Override
+						public InputStream getInputStream() throws IOException {
+							return new ByteArrayInputStream(content);
+						}
+
+						@Override
+						public URL getFileURL() {
+							return original.getFileURL();
+						}
+					};
+				}
+				return original;
 			}
+
 		};
-		BundleFileWrapperFactoryHook noop = new BundleFileWrapperFactoryHook() {
-			@Override
-			public BundleFileWrapper wrapBundleFile(BundleFile bundleFile, Generation generation, boolean base) {
-				return new BundleFileWrapper(bundleFile) {
-					// Do nothing to test multiple wrappers
-				};
-			}
+		BundleFileWrapperFactoryHook noop = (bundleFile, generation, base) -> new BundleFileWrapper(bundleFile) {
+			// Do nothing to test multiple wrappers
 		};
 		// add no-op before the getResourceURL override
 		hookRegistry.addBundleFileWrapperFactoryHook(noop);
@@ -90,39 +78,33 @@
 		// add a hook that modifies content
 		hookRegistry.addBundleFileWrapperFactoryHook(modifyContent);
 
-		hookRegistry.addBundleFileWrapperFactoryHook(new BundleFileWrapperFactoryHook() {
+		hookRegistry.addBundleFileWrapperFactoryHook((bundleFile, generation, base) -> new BundleFileWrapper(bundleFile) {
+			@Override
+			public URL getResourceURL(String path, Module hostModule, int index) {
+				// just making sure the wrapper getResourceURL is never called
+				throw new RuntimeException("Should not be called");
+			}
 
 			@Override
-			public BundleFileWrapper wrapBundleFile(BundleFile bundleFile, Generation generation, boolean base) {
-				return new BundleFileWrapper(bundleFile) {
-					@Override
-					public URL getResourceURL(String path, Module hostModule, int index) {
-						// just making sure the wrapper getResourceURL is never called
-						throw new RuntimeException("Should not be called");
-					}
+			protected URL createResourceURL(BundleEntry bundleEntry, Module hostModule, int index, String path) {
+				final URL url = super.createResourceURL(bundleEntry, hostModule, index, path);
+				if (url == null) {
+					return null;
+				}
+				try {
+					return new URL("custom", "custom", 0, path, new URLStreamHandler() {
 
-					@Override
-					protected URL createResourceURL(BundleEntry bundleEntry, Module hostModule, int index, String path) {
-						final URL url = super.createResourceURL(bundleEntry, hostModule, index, path);
-						if (url == null) {
-							return null;
+						@Override
+						protected URLConnection openConnection(URL u) throws IOException {
+							// TODO Auto-generated method stub
+							return url.openConnection();
 						}
-						try {
-							return new URL("custom", "custom", 0, path, new URLStreamHandler() {
-
-								@Override
-								protected URLConnection openConnection(URL u) throws IOException {
-									// TODO Auto-generated method stub
-									return url.openConnection();
-								}
-							});
-						} catch (MalformedURLException e) {
-							throw new RuntimeException(e);
-						}
-					}
-
-				};
+					});
+				} catch (MalformedURLException e) {
+					throw new RuntimeException(e);
+				}
 			}
+
 		});
 
 		// And add no-op after
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/equinox/log/test/ExtendedLogReaderServiceTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/equinox/log/test/ExtendedLogReaderServiceTest.java
index 179e031..ce61ce4 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/equinox/log/test/ExtendedLogReaderServiceTest.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/equinox/log/test/ExtendedLogReaderServiceTest.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2012, 2015 Cognos Incorporated, IBM Corporation and others
+ * Copyright (c) 2012, 2021 Cognos Incorporated, IBM Corporation and others
  *
  * This program and the accompanying materials are made
  * available under the terms of the Eclipse Public License 2.0 which
@@ -19,17 +19,13 @@
 import org.eclipse.equinox.log.ExtendedLogEntry;
 import org.eclipse.equinox.log.ExtendedLogReaderService;
 import org.eclipse.equinox.log.ExtendedLogService;
-import org.eclipse.equinox.log.LogFilter;
 import org.eclipse.equinox.log.SynchronousLogListener;
 import org.eclipse.osgi.tests.OSGiTestsActivator;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-import org.osgi.framework.Bundle;
 import org.osgi.framework.ServiceReference;
-import org.osgi.service.log.LogEntry;
 import org.osgi.service.log.LogLevel;
-import org.osgi.service.log.LogListener;
 import org.osgi.service.log.LogService;
 import org.osgi.service.log.Logger;
 import org.osgi.service.log.admin.LoggerAdmin;
@@ -76,11 +72,7 @@
 	@Test
 	public void testaddFilteredListener() throws Exception {
 		TestListener listener = new TestListener();
-		reader.addLogListener(listener, new LogFilter() {
-			public boolean isLoggable(Bundle b, String loggerName, int logLevel) {
-				return true;
-			}
-		});
+		reader.addLogListener(listener, (b, loggerName, logLevel) -> true);
 		log.log(LogService.LOG_INFO, "info");
 		assertTrue(listener.getEntryX().getLevel() == LogService.LOG_INFO);
 	}
@@ -100,20 +92,12 @@
 	@Test
 	public void testaddFilteredListenerTwice() throws Exception {
 		TestListener listener = new TestListener();
-		reader.addLogListener(listener, new LogFilter() {
-			public boolean isLoggable(Bundle b, String loggerName, int logLevel) {
-				return false;
-			}
-		});
+		reader.addLogListener(listener, (b, loggerName, logLevel) -> false);
 
 		if (log.isLoggable(LogService.LOG_INFO))
 			fail();
 
-		reader.addLogListener(listener, new LogFilter() {
-			public boolean isLoggable(Bundle b, String loggerName, int logLevel) {
-				return true;
-			}
-		});
+		reader.addLogListener(listener, (b, loggerName, logLevel) -> true);
 		log.log(LogService.LOG_INFO, "info");
 		assertTrue(listener.getEntryX().getLevel() == LogService.LOG_INFO);
 	}
@@ -131,10 +115,8 @@
 	@Test
 	public void testBadFilter() throws Exception {
 		TestListener listener = new TestListener();
-		reader.addLogListener(listener, new LogFilter() {
-			public boolean isLoggable(Bundle b, String loggerName, int logLevel) {
-				throw new RuntimeException("Expected error for testBadFilter.");
-			}
+		reader.addLogListener(listener, (b, loggerName, logLevel) -> {
+			throw new RuntimeException("Expected error for testBadFilter.");
 		});
 
 		if (log.isLoggable(LogService.LOG_INFO))
@@ -145,11 +127,9 @@
 	public void testSynchronousLogListener() throws Exception {
 		final Thread loggerThread = Thread.currentThread();
 		called = false;
-		LogListener listener = new SynchronousLogListener() {
-			public void logged(LogEntry entry) {
-				assertTrue(Thread.currentThread() == loggerThread);
-				called = true;
-			}
+		SynchronousLogListener listener = entry -> {
+			assertTrue(Thread.currentThread() == loggerThread);
+			called = true;
 		};
 		reader.addLogListener(listener);
 		log.log(LogService.LOG_INFO, "info");
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/equinox/log/test/ExtendedLogServiceTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/equinox/log/test/ExtendedLogServiceTest.java
index 116b8c4..9d0e881 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/equinox/log/test/ExtendedLogServiceTest.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/equinox/log/test/ExtendedLogServiceTest.java
@@ -1,9 +1,9 @@
 /*******************************************************************************
-s
-s 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
+ * Copyright (c) 2007, 2021 IBM Corporation 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
@@ -21,7 +21,6 @@
 import org.eclipse.equinox.log.ExtendedLogEntry;
 import org.eclipse.equinox.log.ExtendedLogReaderService;
 import org.eclipse.equinox.log.ExtendedLogService;
-import org.eclipse.equinox.log.LogFilter;
 import org.eclipse.osgi.tests.OSGiTestsActivator;
 import org.junit.After;
 import org.junit.Before;
@@ -112,12 +111,7 @@
 
 	@Test
 	public void testNotIsLoggableWithListener() throws Exception {
-		reader.addLogListener(listener, new LogFilter() {
-
-			public boolean isLoggable(Bundle b, String loggerName, int logLevel) {
-				return false;
-			}
-		});
+		reader.addLogListener(listener, (b, loggerName, logLevel) -> false);
 		if (log.isLoggable(LogService.LOG_INFO))
 			fail();
 	}
@@ -188,13 +182,10 @@
 
 	@Test
 	public void testLoggerIsLoggableTrue() throws Exception {
-		reader.addLogListener(listener, new LogFilter() {
-
-			public boolean isLoggable(Bundle b, String loggerName, int logLevel) {
-				if (loggerName.equals("test"))
-					return true;
-				return false;
-			}
+		reader.addLogListener(listener, (b, loggerName, logLevel) -> {
+			if (loggerName.equals("test"))
+				return true;
+			return false;
 		});
 		if (!log.getLogger("test").isLoggable(LogService.LOG_INFO))
 			fail();
@@ -202,13 +193,10 @@
 
 	@Test
 	public void testLoggerNotIsLoggableWithListener() throws Exception {
-		reader.addLogListener(listener, new LogFilter() {
-
-			public boolean isLoggable(Bundle b, String loggerName, int logLevel) {
-				if (loggerName.equals("test"))
-					return false;
-				return true;
-			}
+		reader.addLogListener(listener, (b, loggerName, logLevel) -> {
+			if (loggerName.equals("test"))
+				return false;
+			return true;
 		});
 		if (log.getLogger("test").isLoggable(LogService.LOG_INFO))
 			fail();
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/equinox/log/test/LogReaderServiceTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/equinox/log/test/LogReaderServiceTest.java
index 301d7aa..c123406 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/equinox/log/test/LogReaderServiceTest.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/equinox/log/test/LogReaderServiceTest.java
@@ -1,9 +1,9 @@
 /*******************************************************************************
-s
-s 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
+ * Copyright (c) 2007, 2021 IBM Corporation 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
@@ -161,12 +161,9 @@
 		// this is just a bundle that is harmless to start/stop
 		final Bundle testBundle = installer.installBundle("test.logging.a"); //$NON-NLS-1$
 		final AtomicReference<Thread> logThread = new AtomicReference<>();
-		LogListener listener = new SynchronousLogListener() {
-			@Override
-			public void logged(LogEntry entry) {
-				if (entry.getBundle() == testBundle) {
-					logThread.compareAndSet(null, Thread.currentThread());
-				}
+		SynchronousLogListener listener = entry -> {
+			if (entry.getBundle() == testBundle) {
+				logThread.compareAndSet(null, Thread.currentThread());
 			}
 		};
 		reader.addLogListener(listener);
@@ -202,13 +199,10 @@
 		Bundle testBundle = installer.installBundle("test.logging.a"); //$NON-NLS-1$
 		final AtomicReference<LogEntry> logEntry = new AtomicReference<>();
 		final CountDownLatch countDown = new CountDownLatch(1);
-		LogListener listener = new LogListener() {
-			@Override
-			public void logged(LogEntry entry) {
-				if ((entry.getLoggerName()).startsWith("Events.Framework.")) {
-					logEntry.set(entry);
-					countDown.countDown();
-				}
+		LogListener listener = entry -> {
+			if ((entry.getLoggerName()).startsWith("Events.Framework.")) {
+				logEntry.set(entry);
+				countDown.countDown();
 			}
 		};
 		reader.addLogListener(listener);
@@ -229,13 +223,10 @@
 		final List<LogEntry> events = new CopyOnWriteArrayList<>();
 		final CountDownLatch countDown = new CountDownLatch(3);
 		final Bundle b = getContext().getBundle();
-		LogListener listener = new LogListener() {
-			@Override
-			public void logged(LogEntry entry) {
-				if (b.equals(entry.getBundle())) {
-					events.add(entry);
-					countDown.countDown();
-				}
+		LogListener listener = entry -> {
+			if (b.equals(entry.getBundle())) {
+				events.add(entry);
+				countDown.countDown();
 			}
 		};
 		reader.addLogListener(listener);
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/appadmin/ApplicationAdminTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/appadmin/ApplicationAdminTest.java
index b84b956..0eee660 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/appadmin/ApplicationAdminTest.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/appadmin/ApplicationAdminTest.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2007, 2014 IBM Corporation and others.
+ * Copyright (c) 2007, 2021 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -330,17 +330,14 @@
 		}
 		assertNotNull("app handle is null", handle); //$NON-NLS-1$
 		final ApplicationHandle destroyHandle = handle;
-		new Thread(new Runnable() {
-			@Override
-			public void run() {
-				try {
-					Thread.sleep(1000);
-					destroyHandle.destroy();
-				} catch (InterruptedException e) {
-					// nothing
-				}
-
+		new Thread(() -> {
+			try {
+				Thread.sleep(1000);
+				destroyHandle.destroy();
+			} catch (InterruptedException e) {
+				// nothing
 			}
+
 		}).start();
 		String value = null;
 		try {
@@ -588,17 +585,14 @@
 		}
 		assertNotNull("app handle is null", handle); //$NON-NLS-1$
 		final ApplicationHandle destroyHandle = handle;
-		new Thread(new Runnable() {
-			@Override
-			public void run() {
-				try {
-					Thread.sleep(1000);
-					destroyHandle.destroy();
-				} catch (InterruptedException e) {
-					// nothing
-				}
-
+		new Thread(() -> {
+			try {
+				Thread.sleep(1000);
+				destroyHandle.destroy();
+			} catch (InterruptedException e) {
+				// nothing
 			}
+
 		}).start();
 		String value = null;
 		try {
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/AbstractBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/AbstractBundleTests.java
index 0d3facb..7d2d6c2 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/AbstractBundleTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/AbstractBundleTests.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2006, 2020 IBM Corporation and others.
+ * Copyright (c) 2006, 2021 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -312,12 +312,7 @@
 		final Exception[] failureException = new BundleException[1];
 		final FrameworkEvent[] success = new FrameworkEvent[] { null };
 		final String uuid = getUUID(equinox);
-		Thread waitForUpdate = new Thread(new Runnable() {
-			@Override
-			public void run() {
-				success[0] = waitForStop(equinox, uuid, false, 10000);
-			}
-		}, "test waitForStop thread"); //$NON-NLS-1$
+		Thread waitForUpdate = new Thread((Runnable) () -> success[0] = waitForStop(equinox, uuid, false, 10000), "test waitForStop thread"); //$NON-NLS-1$
 		waitForUpdate.start();
 
 		try {
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/BundleInstallUpdateTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/BundleInstallUpdateTests.java
index 4c4a5a4..b6e0c6a 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/BundleInstallUpdateTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/BundleInstallUpdateTests.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009, 2018 IBM Corporation and others.
+ * Copyright (c) 2009, 2021 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -23,7 +23,6 @@
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLEncoder;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
@@ -267,11 +266,7 @@
 			junk = null;
 		}
 
-		CollisionHook hook = new CollisionHook() {
-			public void filterCollisions(int operationType, Bundle target, Collection collisionCandidates) {
-				collisionCandidates.clear();
-			}
-		};
+		CollisionHook hook = (operationType, target, collisionCandidates) -> collisionCandidates.clear();
 		ServiceRegistration reg = OSGiTestsActivator.getContext().registerService(CollisionHook.class, hook, null);
 		try {
 			try {
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/BundleInstaller.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/BundleInstaller.java
index fd4da8e..9d05d27 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/BundleInstaller.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/BundleInstaller.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2006, 2016 IBM Corporation and others.
+ * Copyright (c) 2006, 2021 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -64,12 +64,7 @@
 		if (System.getSecurityManager() == null)
 			return getBundleLocation0(name);
 		try {
-			return (String) AccessController.doPrivileged(new PrivilegedExceptionAction() {
-				@Override
-				public Object run() throws Exception {
-					return getBundleLocation0(name);
-				}
-			});
+			return (String) AccessController.doPrivileged((PrivilegedExceptionAction) () -> getBundleLocation0(name));
 		} catch (PrivilegedActionException e) {
 			throw (BundleException) e.getException();
 		}
@@ -169,22 +164,16 @@
 			return null;
 		PackageAdmin pa = (PackageAdmin) packageAdmin.getService();
 		final boolean[] flag = new boolean[] {false};
-		FrameworkListener listener = new FrameworkListener() {
-			public void frameworkEvent(FrameworkEvent event) {
-				if (event.getType() == FrameworkEvent.PACKAGES_REFRESHED)
-					synchronized (flag) {
-						flag[0] = true;
-						flag.notifyAll();
-					}
-			}
+		FrameworkListener listener = event -> {
+			if (event.getType() == FrameworkEvent.PACKAGES_REFRESHED)
+				synchronized (flag) {
+					flag[0] = true;
+					flag.notifyAll();
+				}
 		};
 		context.addFrameworkListener(listener);
 		final HashSet refreshed = new HashSet();
-		BundleListener refreshBundleListener = new SynchronousBundleListener() {
-			public void bundleChanged(BundleEvent event) {
-				refreshed.add(event.getBundle());
-			}
-		};
+		SynchronousBundleListener refreshBundleListener = event -> refreshed.add(event.getBundle());
 		context.addBundleListener(refreshBundleListener);
 		try {
 			pa.refreshPackages(refresh);
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java
index 0e7f0d3..e12ce56 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2006, 2020 IBM Corporation and others.
+ * Copyright (c) 2006, 2021 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -51,11 +51,9 @@
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleEvent;
 import org.osgi.framework.BundleException;
-import org.osgi.framework.BundleListener;
 import org.osgi.framework.BundleReference;
 import org.osgi.framework.Constants;
 import org.osgi.framework.FrameworkEvent;
-import org.osgi.framework.FrameworkListener;
 import org.osgi.framework.FrameworkUtil;
 import org.osgi.framework.ServiceFactory;
 import org.osgi.framework.ServiceReference;
@@ -602,15 +600,12 @@
 		final Bundle osgiE = installer.installBundle("osgi.lazystart.e"); //$NON-NLS-1$
 		assertTrue("osgi lazy start resolve", installer.resolveBundles(new Bundle[] {osgiD, osgiE})); //$NON-NLS-1$
 
-		Thread t = new Thread(new Runnable() {
-			@Override
-			public void run() {
-				try {
-					osgiD.loadClass("osgi.lazystart.d.DTest");
-				} catch (ClassNotFoundException e) {
-					// should fail here
-					throw new RuntimeException(e);
-				}
+		Thread t = new Thread((Runnable) () -> {
+			try {
+				osgiD.loadClass("osgi.lazystart.d.DTest");
+			} catch (ClassNotFoundException e) {
+				// should fail here
+				throw new RuntimeException(e);
 			}
 		}, "Starting: " + osgiD);
 		t.start();
@@ -878,16 +873,13 @@
 	public void testBug258659_01() throws Exception {
 		// install a bundle
 		Bundle osgiA = installer.installBundle("osgi.lazystart.a"); //$NON-NLS-1$
-		SynchronousBundleListener testLoadClassListener = new SynchronousBundleListener() {
-			public void bundleChanged(BundleEvent event) {
-				if (event.getType() == BundleEvent.LAZY_ACTIVATION)
-					try {
-						event.getBundle().loadClass("osgi.lazystart.a.ATest"); //$NON-NLS-1$
-					} catch (ClassNotFoundException e) {
-						simpleResults.addEvent(e);
-					}
-			}
-
+		SynchronousBundleListener testLoadClassListener = event -> {
+			if (event.getType() == BundleEvent.LAZY_ACTIVATION)
+				try {
+					event.getBundle().loadClass("osgi.lazystart.a.ATest"); //$NON-NLS-1$
+				} catch (ClassNotFoundException e) {
+					simpleResults.addEvent(e);
+				}
 		};
 		OSGiTestsActivator.getContext().addBundleListener(testLoadClassListener);
 		try {
@@ -905,16 +897,13 @@
 		// install a bundle
 		Bundle osgiA = installer.installBundle("osgi.lazystart.a"); //$NON-NLS-1$
 		osgiA.start(Bundle.START_ACTIVATION_POLICY);
-		SynchronousBundleListener testLoadClassListener = new SynchronousBundleListener() {
-			public void bundleChanged(BundleEvent event) {
-				if (event.getType() == BundleEvent.LAZY_ACTIVATION)
-					try {
-						event.getBundle().loadClass("osgi.lazystart.a.ATest"); //$NON-NLS-1$
-					} catch (ClassNotFoundException e) {
-						simpleResults.addEvent(e);
-					}
-			}
-
+		SynchronousBundleListener testLoadClassListener = event -> {
+			if (event.getType() == BundleEvent.LAZY_ACTIVATION)
+				try {
+					event.getBundle().loadClass("osgi.lazystart.a.ATest"); //$NON-NLS-1$
+				} catch (ClassNotFoundException e) {
+					simpleResults.addEvent(e);
+				}
 		};
 		OSGiTestsActivator.getContext().addBundleListener(testLoadClassListener);
 		try {
@@ -931,16 +920,13 @@
 	public void testBug258659_03() throws Exception {
 		// install a bundle
 		Bundle test = installer.installBundle("test"); //$NON-NLS-1$
-		SynchronousBundleListener testLoadClassListener = new SynchronousBundleListener() {
-			public void bundleChanged(BundleEvent event) {
-				if (event.getType() == BundleEvent.STARTED)
-					try {
-						event.getBundle().stop();
-					} catch (BundleException e) {
-						simpleResults.addEvent(e);
-					}
-			}
-
+		SynchronousBundleListener testLoadClassListener = event -> {
+			if (event.getType() == BundleEvent.STARTED)
+				try {
+					event.getBundle().stop();
+				} catch (BundleException e) {
+					simpleResults.addEvent(e);
+				}
 		};
 		OSGiTestsActivator.getContext().addBundleListener(testLoadClassListener);
 		try {
@@ -959,16 +945,13 @@
 		// install a bundle
 		Bundle test = installer.installBundle("test"); //$NON-NLS-1$
 		test.start();
-		SynchronousBundleListener testLoadClassListener = new SynchronousBundleListener() {
-			public void bundleChanged(BundleEvent event) {
-				if (event.getType() == BundleEvent.STARTED)
-					try {
-						event.getBundle().stop();
-					} catch (BundleException e) {
-						simpleResults.addEvent(e);
-					}
-			}
-
+		SynchronousBundleListener testLoadClassListener = event -> {
+			if (event.getType() == BundleEvent.STARTED)
+				try {
+					event.getBundle().stop();
+				} catch (BundleException e) {
+					simpleResults.addEvent(e);
+				}
 		};
 		// clear the results from the initial start
 		simpleResults.getResults(0);
@@ -1935,25 +1918,21 @@
 
 	public void testBug348805() {
 		final boolean[] endCalled = {false};
-		ResolverHookFactory error = new ResolverHookFactory() {
-			public ResolverHook begin(Collection triggers) {
-				return new ResolverHook() {
-					public void filterSingletonCollisions(BundleCapability singleton, Collection collisionCandidates) {
-						// Nothing
-					}
+		ResolverHookFactory error = triggers -> new ResolverHook() {
+			public void filterSingletonCollisions(BundleCapability singleton, Collection collisionCandidates) {
+				// Nothing
+			}
 
-					public void filterResolvable(Collection candidates) {
-						throw new RuntimeException("Error");
-					}
+			public void filterResolvable(Collection candidates) {
+				throw new RuntimeException("Error");
+			}
 
-					public void filterMatches(BundleRequirement requirement, Collection candidates) {
-						// Nothing
-					}
+			public void filterMatches(BundleRequirement requirement, Collection candidates) {
+				// Nothing
+			}
 
-					public void end() {
-						endCalled[0] = true;
-					}
-				};
+			public void end() {
+				endCalled[0] = true;
 			}
 		};
 		ServiceRegistration reg = OSGiTestsActivator.getContext().registerService(ResolverHookFactory.class, error, null);
@@ -1975,25 +1954,21 @@
 	}
 
 	public void testBug348806() {
-		ResolverHookFactory error = new ResolverHookFactory() {
-			public ResolverHook begin(Collection triggers) {
-				return new ResolverHook() {
-					public void filterSingletonCollisions(BundleCapability singleton, Collection collisionCandidates) {
-						// Nothing
-					}
+		ResolverHookFactory error = triggers -> new ResolverHook() {
+			public void filterSingletonCollisions(BundleCapability singleton, Collection collisionCandidates) {
+				// Nothing
+			}
 
-					public void filterResolvable(Collection candidates) {
-						// Nothing
-					}
+			public void filterResolvable(Collection candidates) {
+				// Nothing
+			}
 
-					public void filterMatches(BundleRequirement requirement, Collection candidates) {
-						// Nothing
-					}
+			public void filterMatches(BundleRequirement requirement, Collection candidates) {
+				// Nothing
+			}
 
-					public void end() {
-						throw new RuntimeException("Error");
-					}
-				};
+			public void end() {
+				throw new RuntimeException("Error");
 			}
 		};
 		ServiceRegistration reg = OSGiTestsActivator.getContext().registerService(ResolverHookFactory.class, error, null);
@@ -2015,31 +1990,25 @@
 
 	public void testBug370258_beginException() {
 		final boolean[] endCalled = {false};
-		ResolverHookFactory endHook = new ResolverHookFactory() {
-			public ResolverHook begin(Collection triggers) {
-				return new ResolverHook() {
-					public void filterSingletonCollisions(BundleCapability singleton, Collection collisionCandidates) {
-						// Nothing
-					}
-
-					public void filterResolvable(Collection candidates) {
-						throw new RuntimeException("Error");
-					}
-
-					public void filterMatches(BundleRequirement requirement, Collection candidates) {
-						// Nothing
-					}
-
-					public void end() {
-						endCalled[0] = true;
-					}
-				};
+		ResolverHookFactory endHook = triggers -> new ResolverHook() {
+			public void filterSingletonCollisions(BundleCapability singleton, Collection collisionCandidates) {
+				// Nothing
 			}
-		};
-		ResolverHookFactory error = new ResolverHookFactory() {
-			public ResolverHook begin(Collection triggers) {
+
+			public void filterResolvable(Collection candidates) {
 				throw new RuntimeException("Error");
 			}
+
+			public void filterMatches(BundleRequirement requirement, Collection candidates) {
+				// Nothing
+			}
+
+			public void end() {
+				endCalled[0] = true;
+			}
+		};
+		ResolverHookFactory error = triggers -> {
+			throw new RuntimeException("Error");
 		};
 
 		ServiceRegistration endReg = OSGiTestsActivator.getContext().registerService(ResolverHookFactory.class, endHook, null);
@@ -2064,46 +2033,38 @@
 
 	public void testBug370258_endException() {
 		final boolean[] endCalled = {false};
-		ResolverHookFactory endHook = new ResolverHookFactory() {
-			public ResolverHook begin(Collection triggers) {
-				return new ResolverHook() {
-					public void filterSingletonCollisions(BundleCapability singleton, Collection collisionCandidates) {
-						// Nothing
-					}
+		ResolverHookFactory endHook = triggers -> new ResolverHook() {
+			public void filterSingletonCollisions(BundleCapability singleton, Collection collisionCandidates) {
+				// Nothing
+			}
 
-					public void filterResolvable(Collection candidates) {
-						throw new RuntimeException("Error");
-					}
+			public void filterResolvable(Collection candidates) {
+				throw new RuntimeException("Error");
+			}
 
-					public void filterMatches(BundleRequirement requirement, Collection candidates) {
-						// Nothing
-					}
+			public void filterMatches(BundleRequirement requirement, Collection candidates) {
+				// Nothing
+			}
 
-					public void end() {
-						endCalled[0] = true;
-					}
-				};
+			public void end() {
+				endCalled[0] = true;
 			}
 		};
-		ResolverHookFactory error = new ResolverHookFactory() {
-			public ResolverHook begin(Collection triggers) {
-				return new ResolverHook() {
-					public void filterSingletonCollisions(BundleCapability singleton, Collection collisionCandidates) {
-						// Nothing
-					}
+		ResolverHookFactory error = triggers -> new ResolverHook() {
+			public void filterSingletonCollisions(BundleCapability singleton, Collection collisionCandidates) {
+				// Nothing
+			}
 
-					public void filterResolvable(Collection candidates) {
-						// Nothing
-					}
+			public void filterResolvable(Collection candidates) {
+				// Nothing
+			}
 
-					public void filterMatches(BundleRequirement requirement, Collection candidates) {
-						// Nothing
-					}
+			public void filterMatches(BundleRequirement requirement, Collection candidates) {
+				// Nothing
+			}
 
-					public void end() {
-						throw new RuntimeException("Error");
-					}
-				};
+			public void end() {
+				throw new RuntimeException("Error");
 			}
 		};
 
@@ -2183,49 +2144,38 @@
 
 		final CountDownLatch startingB = new CountDownLatch(1);
 		final CountDownLatch endedSecondThread = new CountDownLatch(1);
-		BundleListener delayB1 = new SynchronousBundleListener() {
-			@Override
-			public void bundleChanged(BundleEvent event) {
-				if (event.getBundle() == b1 && BundleEvent.STARTING == event.getType()) {
-					try {
-						startingB.countDown();
-						System.out.println(getName() + ": Delaying now ...");
-						Thread.sleep(15000);
-						System.out.println(getName() + ": Done delaying.");
-					} catch (InterruptedException e) {
-						Thread.currentThread().interrupt();
-					}
+		SynchronousBundleListener delayB1 = event -> {
+			if (event.getBundle() == b1 && BundleEvent.STARTING == event.getType()) {
+				try {
+					startingB.countDown();
+					System.out.println(getName() + ": Delaying now ...");
+					Thread.sleep(15000);
+					System.out.println(getName() + ": Done delaying.");
+				} catch (InterruptedException e) {
+					Thread.currentThread().interrupt();
 				}
 			}
 		};
 		getContext().addBundleListener(delayB1);
 		try {
-			new Thread(new Runnable() {
-
-				@Override
-				public void run() {
-					try {
-						System.out.println(getName() + ": Initial load test.");
-						a1.loadClass("test.bug490902.a.TestLoadA1").newInstance();
-					} catch (Throwable e) {
-						e.printStackTrace();
-					}
+			new Thread((Runnable) () -> {
+				try {
+					System.out.println(getName() + ": Initial load test.");
+					a1.loadClass("test.bug490902.a.TestLoadA1").newInstance();
+				} catch (Throwable e) {
+					e.printStackTrace();
 				}
 			}, "Initial load test thread.").start();
 
 			startingB.await();
-			Thread secondThread = new Thread(new Runnable() {
-
-				@Override
-				public void run() {
-					try {
-						System.out.println(getName() + ": Second load test.");
-						a1.loadClass("test.bug490902.a.TestLoadA1").newInstance();
-					} catch (Throwable e) {
-						e.printStackTrace();
-					} finally {
-						endedSecondThread.countDown();
-					}
+			Thread secondThread = new Thread((Runnable) () -> {
+				try {
+					System.out.println(getName() + ": Second load test.");
+					a1.loadClass("test.bug490902.a.TestLoadA1").newInstance();
+				} catch (Throwable e) {
+					e.printStackTrace();
+				} finally {
+					endedSecondThread.countDown();
 				}
 			}, "Second load test thread.");
 			secondThread.start();
@@ -2260,23 +2210,19 @@
 				if (!testThread.get()) {
 					return null;
 				}
-				WeavingHook hook = new WeavingHook() {
-
-					@Override
-					public void weave(WovenClass wovenClass) {
-						if (loadNewClassInWeave.get()) {
-							// Force a load of inner class
-							Runnable run = new Runnable() {
-								@Override
-								public void run() {
-									// nothing
-								}
-							};
-							run.run();
-							weavingHookClasses.add(run.getClass().getName());
-						}
-						called.add(wovenClass);
+				WeavingHook hook = wovenClass -> {
+					if (loadNewClassInWeave.get()) {
+						// Force a load of inner class (must not be a lambda)
+						Runnable run = new Runnable() {
+							@Override
+							public void run() {
+								// nothing
+							}
+						};
+						run.run();
+						weavingHookClasses.add(run.getClass().getName());
 					}
+					called.add(wovenClass);
 				};
 				weavingHookClasses.add(hook.getClass().getName());
 				return hook;
@@ -2297,7 +2243,7 @@
 			// set flag to load inner class while weaving
 			loadNewClassInWeave.set(true);
 
-			// Force a load of inner class
+			// Force a load of inner class (must not be a lambda)
 			run = new Runnable() {
 				@Override
 				public void run() {
@@ -2434,12 +2380,9 @@
 
 		// add a framework event listener to find error message about invalud class loaders
 		final BlockingQueue<FrameworkEvent> events = new LinkedBlockingQueue<>();
-		getContext().addFrameworkListener(new FrameworkListener() {
-			@Override
-			public void frameworkEvent(FrameworkEvent event) {
-				if (event.getBundle() == requirer) {
-					events.add(event);
-				}
+		getContext().addFrameworkListener(event -> {
+			if (event.getBundle() == requirer) {
+				events.add(event);
 			}
 		});
 
@@ -2556,13 +2499,9 @@
 
 	void refreshBundles(Collection<Bundle> bundles) throws InterruptedException {
 		final CountDownLatch refreshSignal = new CountDownLatch(1);
-		getContext().getBundle(Constants.SYSTEM_BUNDLE_LOCATION).adapt(FrameworkWiring.class).refreshBundles(bundles, new FrameworkListener() {
-
-			@Override
-			public void frameworkEvent(FrameworkEvent event) {
-				if (event.getType() == FrameworkEvent.PACKAGES_REFRESHED) {
-					refreshSignal.countDown();
-				}
+		getContext().getBundle(Constants.SYSTEM_BUNDLE_LOCATION).adapt(FrameworkWiring.class).refreshBundles(bundles, event -> {
+			if (event.getType() == FrameworkEvent.PACKAGES_REFRESHED) {
+				refreshSignal.countDown();
 			}
 		});
 		refreshSignal.await(30, TimeUnit.SECONDS);
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/LoggingTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/LoggingTests.java
index 4ee71f2..042f8a7 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/LoggingTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/LoggingTests.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * Copyright (c) 2010, 2021 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -375,13 +375,10 @@
 		LogServiceReference logRef = getLogService(getContext());
 
 		final List events = new ArrayList();
-		EventHandler testHandler = new EventHandler() {
-
-			public void handleEvent(Event event) {
-				synchronized (events) {
-					events.add(event);
-					events.notifyAll();
-				}
+		EventHandler testHandler = event -> {
+			synchronized (events) {
+				events.add(event);
+				events.notifyAll();
 			}
 		};
 
@@ -415,15 +412,12 @@
 		LogServiceReference logRef = getLogService(getContext());
 
 		final List events = new ArrayList();
-		EventHandler testHandler = new EventHandler() {
-
-			public void handleEvent(Event event) {
-				synchronized (events) {
-					events.add(event);
-					events.notifyAll();
-				}
-				throw new NullPointerException();
+		EventHandler testHandler = event -> {
+			synchronized (events) {
+				events.add(event);
+				events.notifyAll();
 			}
+			throw new NullPointerException();
 		};
 
 		Dictionary props = new Hashtable();
@@ -453,12 +447,7 @@
 		final Bundle testBundle = installer.installBundle("test.logging.a"); //$NON-NLS-1$
 		testBundle.start();
 		LogServiceReference logRef = getLogService(getContext());
-		ILogListener recurseLog = new ILogListener() {
-
-			public void logging(IStatus status, String plugin) {
-				Platform.getLog(testBundle).log(status);
-			}
-		};
+		ILogListener recurseLog = (status, plugin) -> Platform.getLog(testBundle).log(status);
 		Platform.addLogListener(recurseLog);
 		try {
 			logRef.fwkLog.log(new FrameworkLogEntry(getContext().getBundle().getSymbolicName(), FrameworkLogEntry.ERROR, 0, "Test message", 0, null, null));
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/PackageAdminBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/PackageAdminBundleTests.java
index c0e5820..404cd9c 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/PackageAdminBundleTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/PackageAdminBundleTests.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2007, 2013 IBM Corporation and others.
+ * Copyright (c) 2007, 2021 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -264,33 +264,27 @@
 	}
 
 	public void testUninstallWhileResolving() throws BundleException {
-		ServiceRegistration<ResolverHookFactory> resolverHookReg = getContext().registerService(ResolverHookFactory.class, new ResolverHookFactory() {
+		ServiceRegistration<ResolverHookFactory> resolverHookReg = getContext().registerService(ResolverHookFactory.class, triggers -> new ResolverHook() {
 
 			@Override
-			public ResolverHook begin(Collection<BundleRevision> triggers) {
-				return new ResolverHook() {
+			public void filterSingletonCollisions(BundleCapability singleton, Collection<BundleCapability> collisionCandidates) {
+				// Nothing
+			}
 
-					@Override
-					public void filterSingletonCollisions(BundleCapability singleton, Collection<BundleCapability> collisionCandidates) {
-						// Nothing
-					}
+			@Override
+			public void filterResolvable(Collection<BundleRevision> candidates) {
+				// prevent all resolves
+				candidates.clear();
+			}
 
-					@Override
-					public void filterResolvable(Collection<BundleRevision> candidates) {
-						// prevent all resolves
-						candidates.clear();
-					}
+			@Override
+			public void filterMatches(BundleRequirement requirement, Collection<BundleCapability> candidates) {
+				// nothing
+			}
 
-					@Override
-					public void filterMatches(BundleRequirement requirement, Collection<BundleCapability> candidates) {
-						// nothing
-					}
-
-					@Override
-					public void end() {
-						// nothing
-					}
-				};
+			@Override
+			public void end() {
+				// nothing
 			}
 		}, null);
 		try {
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/PlatformAdminBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/PlatformAdminBundleTests.java
index 7c8b016..ec82216 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/PlatformAdminBundleTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/PlatformAdminBundleTests.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2007, 2017 IBM Corporation and others.
+ * Copyright (c) 2007, 2021 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -151,14 +151,10 @@
 	public void testNativeCodeFilterWithSpecialChars() throws BundleException, InterruptedException {
 		final AtomicReference<FrameworkEvent> error = new AtomicReference<>();
 		final CountDownLatch errorCnt = new CountDownLatch(1);
-		FrameworkListener errorListener = new FrameworkListener() {
-
-			@Override
-			public void frameworkEvent(FrameworkEvent event) {
-				if (event.getType() == FrameworkEvent.ERROR) {
-					error.set(event);
-					errorCnt.countDown();
-				}
+		FrameworkListener errorListener = event -> {
+			if (event.getType() == FrameworkEvent.ERROR) {
+				error.set(event);
+				errorCnt.countDown();
 			}
 		};
 		getContext().addFrameworkListener(errorListener);
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java
index e0f6be2..23564d1 100755
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2008, 2020 IBM Corporation and others.
+ * Copyright (c) 2008, 2021 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -104,7 +104,6 @@
 import org.osgi.framework.hooks.resolver.ResolverHook;
 import org.osgi.framework.hooks.resolver.ResolverHookFactory;
 import org.osgi.framework.hooks.weaving.WeavingHook;
-import org.osgi.framework.hooks.weaving.WovenClass;
 import org.osgi.framework.launch.Framework;
 import org.osgi.framework.launch.FrameworkFactory;
 import org.osgi.framework.namespace.NativeNamespace;
@@ -1342,15 +1341,13 @@
 		long testID1 = test1.getBundleId();
 
 		final Bundle testFinal1 = test1;
-		ServiceRegistration reg = systemContext.registerService(WeavingHook.class, new WeavingHook() {
-			public void weave(WovenClass wovenClass) {
-				if (!testFinal1.equals(wovenClass.getBundleWiring().getBundle()))
-					return;
-				if (!"substitutes.x.Ax".equals(wovenClass.getClassName()))
-					return;
-				List dynamicImports = wovenClass.getDynamicImports();
-				dynamicImports.add("*");
-			}
+		ServiceRegistration reg = systemContext.registerService(WeavingHook.class, wovenClass -> {
+			if (!testFinal1.equals(wovenClass.getBundleWiring().getBundle()))
+				return;
+			if (!"substitutes.x.Ax".equals(wovenClass.getClassName()))
+				return;
+			List dynamicImports = wovenClass.getDynamicImports();
+			dynamicImports.add("*");
 		}, null);
 
 		try {
@@ -1382,15 +1379,13 @@
 		long testID2 = test2.getBundleId();
 
 		final Bundle testFinal2 = test2;
-		reg = systemContext.registerService(WeavingHook.class, new WeavingHook() {
-			public void weave(WovenClass wovenClass) {
-				if (!testFinal2.equals(wovenClass.getBundleWiring().getBundle()))
-					return;
-				if (!"exporter.importer.test.Test1".equals(wovenClass.getClassName()))
-					return;
-				List dynamicImports = wovenClass.getDynamicImports();
-				dynamicImports.add("*");
-			}
+		reg = systemContext.registerService(WeavingHook.class, wovenClass -> {
+			if (!testFinal2.equals(wovenClass.getBundleWiring().getBundle()))
+				return;
+			if (!"exporter.importer.test.Test1".equals(wovenClass.getClassName()))
+				return;
+			List dynamicImports = wovenClass.getDynamicImports();
+			dynamicImports.add("*");
 		}, null);
 
 		try {
@@ -1453,26 +1448,22 @@
 		}
 		BundleContext systemContext = equinox.getBundleContext();
 
-		systemContext.registerService(ResolverHookFactory.class, new ResolverHookFactory() {
-			public ResolverHook begin(Collection triggers) {
-				return new ResolverHook() {
-					public void filterResolvable(Collection candidates) {
-						// nothing
-					}
+		systemContext.registerService(ResolverHookFactory.class, triggers -> new ResolverHook() {
+			public void filterResolvable(Collection candidates) {
+				// nothing
+			}
 
-					public void filterSingletonCollisions(BundleCapability singleton, Collection collisionCandidates) {
-						// resolve all singletons
-						collisionCandidates.clear();
-					}
+			public void filterSingletonCollisions(BundleCapability singleton, Collection collisionCandidates) {
+				// resolve all singletons
+				collisionCandidates.clear();
+			}
 
-					public void filterMatches(BundleRequirement requirement, Collection candidates) {
-						// nothing
-					}
+			public void filterMatches(BundleRequirement requirement, Collection candidates) {
+				// nothing
+			}
 
-					public void end() {
-						// nothing
-					}
-				};
+			public void end() {
+				// nothing
 			}
 		}, null);
 
@@ -1628,42 +1619,34 @@
 		}
 
 		final Bundle testFinal1 = test1;
-		ServiceRegistration reg = systemContext.registerService(WeavingHook.class, new WeavingHook() {
-			public void weave(WovenClass wovenClass) {
-				if (!testFinal1.equals(wovenClass.getBundleWiring().getBundle()))
-					return;
-				if (!"substitutes.x.Ax".equals(wovenClass.getClassName()))
-					return;
-				List dynamicImports = wovenClass.getDynamicImports();
-				dynamicImports.add("*");
-			}
+		ServiceRegistration reg = systemContext.registerService(WeavingHook.class, wovenClass -> {
+			if (!testFinal1.equals(wovenClass.getBundleWiring().getBundle()))
+				return;
+			if (!"substitutes.x.Ax".equals(wovenClass.getClassName()))
+				return;
+			List dynamicImports = wovenClass.getDynamicImports();
+			dynamicImports.add("*");
 		}, null);
 
-		ServiceRegistration<ResolverHookFactory> resolverHookReg = systemContext.registerService(ResolverHookFactory.class, new ResolverHookFactory() {
-			@Override
-			public ResolverHook begin(Collection<BundleRevision> triggers) {
-				// just trying to delay the resolve so that we get two threads trying to apply off the same snapshot
-				try {
-					Thread.sleep(500);
-				} catch (InterruptedException e) {
-					Thread.currentThread().interrupt();
-					throw new RuntimeException(e);
-				}
-				return null;
+		ServiceRegistration<ResolverHookFactory> resolverHookReg = systemContext.registerService(ResolverHookFactory.class, triggers -> {
+			// just trying to delay the resolve so that we get two threads trying to apply off the same snapshot
+			try {
+				Thread.sleep(500);
+			} catch (InterruptedException e) {
+				Thread.currentThread().interrupt();
+				throw new RuntimeException(e);
 			}
+			return null;
 		}, null);
 
 		final Set<Throwable> errors = Collections.newSetFromMap(new ConcurrentHashMap<Throwable, Boolean>());
 		try {
-			Runnable dynamicLoadClass = new Runnable() {
-				@Override
-				public void run() {
-					try {
-						testFinal1.loadClass("substitutes.x.Ax");
-						testFinal1.loadClass("org.osgi.framework.hooks.bundle.FindHook");
-					} catch (Throwable t) {
-						errors.add(t);
-					}
+			Runnable dynamicLoadClass = () -> {
+				try {
+					testFinal1.loadClass("substitutes.x.Ax");
+					testFinal1.loadClass("org.osgi.framework.hooks.bundle.FindHook");
+				} catch (Throwable t) {
+					errors.add(t);
 				}
 			};
 			Thread t1 = new Thread(dynamicLoadClass, getName() + "-1");
@@ -1702,15 +1685,13 @@
 		Bundle chainTestA = systemContext.installBundle(installer.getBundleLocation("chain.test.a")); //$NON-NLS-1$
 		Bundle chainTestB = systemContext.installBundle(installer.getBundleLocation("chain.test.b")); //$NON-NLS-1$
 		Bundle chainTestC = systemContext.installBundle(installer.getBundleLocation("chain.test.c")); //$NON-NLS-1$
-		systemContext.registerService(WeavingHook.class, new WeavingHook() {
-			public void weave(WovenClass wovenClass) {
-				if (!chainTestD.equals(wovenClass.getBundleWiring().getBundle()))
-					return;
-				if (!"chain.test.d.DMultipleChain1".equals(wovenClass.getClassName()))
-					return;
-				List dynamicImports = wovenClass.getDynamicImports();
-				dynamicImports.add("*");
-			}
+		systemContext.registerService(WeavingHook.class, wovenClass -> {
+			if (!chainTestD.equals(wovenClass.getBundleWiring().getBundle()))
+				return;
+			if (!"chain.test.d.DMultipleChain1".equals(wovenClass.getClassName()))
+				return;
+			List dynamicImports = wovenClass.getDynamicImports();
+			dynamicImports.add("*");
 		}, null);
 
 		equinox.start();
@@ -1726,12 +1707,9 @@
 		assertEquals("D is not active.", Bundle.ACTIVE, chainTestD.getState());
 		// record STOPPING order
 		final List<Bundle> stoppingOrder = new ArrayList<>();
-		systemContext.addBundleListener(new SynchronousBundleListener() {
-			@Override
-			public void bundleChanged(BundleEvent event) {
-				if (event.getType() == BundleEvent.STOPPING) {
-					stoppingOrder.add(event.getBundle());
-				}
+		systemContext.addBundleListener((SynchronousBundleListener) event -> {
+			if (event.getType() == BundleEvent.STOPPING) {
+				stoppingOrder.add(event.getBundle());
 			}
 		});
 		stop(equinox);
@@ -2175,20 +2153,16 @@
 		final AtomicInteger stoppingEvent = new AtomicInteger();
 		final AtomicInteger stoppedEvent = new AtomicInteger();
 
-		BundleListener systemBundleListener = new SynchronousBundleListener() {
-
-			@Override
-			public void bundleChanged(BundleEvent event) {
-				if (event.getBundle().getBundleId() == 0) {
-					switch (event.getType()) {
-						case BundleEvent.STOPPING :
-							stoppingEvent.incrementAndGet();
-							break;
-						case BundleEvent.STOPPED :
-							stoppedEvent.incrementAndGet();
-						default :
-							break;
-					}
+		SynchronousBundleListener systemBundleListener = event -> {
+			if (event.getBundle().getBundleId() == 0) {
+				switch (event.getType()) {
+					case BundleEvent.STOPPING :
+						stoppingEvent.incrementAndGet();
+						break;
+					case BundleEvent.STOPPED :
+						stoppedEvent.incrementAndGet();
+					default :
+						break;
 				}
 			}
 		};
@@ -2954,13 +2928,7 @@
 			equinox.getBundleContext().addBundleListener(initialListener);
 			long startTime = System.currentTimeMillis();
 			final CountDownLatch waitForStartLevel = new CountDownLatch(1);
-			equinox.adapt(FrameworkStartLevel.class).setStartLevel(numBundles * 3, new FrameworkListener() {
-
-				@Override
-				public void frameworkEvent(FrameworkEvent event) {
-					waitForStartLevel.countDown();
-				}
-			});
+			equinox.adapt(FrameworkStartLevel.class).setStartLevel(numBundles * 3, event -> waitForStartLevel.countDown());
 			waitForStartLevel.await(20, TimeUnit.SECONDS);
 			System.out.println("Start time: " + (System.currentTimeMillis() - startTime));
 
@@ -3060,27 +3028,19 @@
 			}
 
 			final Set<Thread> startingThreads = Collections.synchronizedSet(new HashSet<Thread>());
-			equinox.getBundleContext().addBundleListener(new SynchronousBundleListener() {
-				@Override
-				public void bundleChanged(BundleEvent event) {
-					if (event.getType() == BundleEvent.STARTING) {
-						try {
-							Thread.sleep(50);
-						} catch (InterruptedException e) {
-							// nothing
-						}
-						startingThreads.add(Thread.currentThread());
+			equinox.getBundleContext().addBundleListener((SynchronousBundleListener) event -> {
+				if (event.getType() == BundleEvent.STARTING) {
+					try {
+						Thread.sleep(50);
+					} catch (InterruptedException e) {
+						// nothing
 					}
+					startingThreads.add(Thread.currentThread());
 				}
 			});
 
 			final CountDownLatch waitForStartLevel = new CountDownLatch(1);
-			equinox.adapt(FrameworkStartLevel.class).setStartLevel(5, new FrameworkListener() {
-				@Override
-				public void frameworkEvent(FrameworkEvent event) {
-					waitForStartLevel.countDown();
-				}
-			});
+			equinox.adapt(FrameworkStartLevel.class).setStartLevel(5, event -> waitForStartLevel.countDown());
 			waitForStartLevel.await(10, TimeUnit.SECONDS);
 
 			assertEquals("Did not finish start level setting.", 0, waitForStartLevel.getCount());
@@ -3146,28 +3106,20 @@
 
 			final Set<Thread> startingThreads = Collections.synchronizedSet(new HashSet<Thread>());
 			final List<Bundle> startingBundles = Collections.synchronizedList(new ArrayList<Bundle>());
-			equinox.getBundleContext().addBundleListener(new SynchronousBundleListener() {
-				@Override
-				public void bundleChanged(BundleEvent event) {
-					if (event.getType() == BundleEvent.STARTING) {
-						try {
-							Thread.sleep(100);
-						} catch (InterruptedException e) {
-							// nothing
-						}
-						startingBundles.add(event.getBundle());
-						startingThreads.add(Thread.currentThread());
+			equinox.getBundleContext().addBundleListener((SynchronousBundleListener) event -> {
+				if (event.getType() == BundleEvent.STARTING) {
+					try {
+						Thread.sleep(100);
+					} catch (InterruptedException e) {
+						// nothing
 					}
+					startingBundles.add(event.getBundle());
+					startingThreads.add(Thread.currentThread());
 				}
 			});
 
 			final CountDownLatch waitForStartLevel = new CountDownLatch(1);
-			equinox.adapt(FrameworkStartLevel.class).setStartLevel(10, new FrameworkListener() {
-				@Override
-				public void frameworkEvent(FrameworkEvent event) {
-					waitForStartLevel.countDown();
-				}
-			});
+			equinox.adapt(FrameworkStartLevel.class).setStartLevel(10, event -> waitForStartLevel.countDown());
 			waitForStartLevel.await(20, TimeUnit.SECONDS);
 
 			assertEquals("Did not finish start level setting.", 0, waitForStartLevel.getCount());
@@ -3288,16 +3240,12 @@
 		final List<Throwable> errors = new CopyOnWriteArrayList<>();
 		try {
 			for (final File testBundleFile : testBundles) {
-				executor.execute(new Runnable() {
-
-					@Override
-					public void run() {
-						try {
-							systemContext.installBundle("file:///" + testBundleFile.getAbsolutePath());
-						} catch (BundleException e) {
-							e.printStackTrace();
-							errors.add(e);
-						}
+				executor.execute(() -> {
+					try {
+						systemContext.installBundle("file:///" + testBundleFile.getAbsolutePath());
+					} catch (BundleException e) {
+						e.printStackTrace();
+						errors.add(e);
 					}
 				});
 			}
@@ -3361,14 +3309,11 @@
 		ExecutorService executor = Executors.newFixedThreadPool(10);
 		try {
 			for (int i = 0; i < 10; i++) {
-				executor.execute(new Runnable() {
-					@Override
-					public void run() {
-						List<Bundle> shuffled = new ArrayList<>(bundles);
-						Collections.shuffle(shuffled);
-						for (Bundle bundle : shuffled) {
-							bundle.getEntry("does/not/exist");
-						}
+				executor.execute(() -> {
+					List<Bundle> shuffled = new ArrayList<>(bundles);
+					Collections.shuffle(shuffled);
+					for (Bundle bundle : shuffled) {
+						bundle.getEntry("does/not/exist");
 					}
 				});
 			}
@@ -3424,34 +3369,28 @@
 		testBundle.start();
 
 		final List<FrameworkEvent> errorsAndWarnings = new CopyOnWriteArrayList<>();
-		FrameworkListener fwkListener = new FrameworkListener() {
-			@Override
-			public void frameworkEvent(FrameworkEvent event) {
-				int type = event.getType();
-				if (type == FrameworkEvent.ERROR || type == FrameworkEvent.WARNING) {
-					errorsAndWarnings.add(event);
-				}
+		FrameworkListener fwkListener = event -> {
+			int type = event.getType();
+			if (type == FrameworkEvent.ERROR || type == FrameworkEvent.WARNING) {
+				errorsAndWarnings.add(event);
 			}
 		};
 		systemContext.addFrameworkListener(fwkListener);
 
-		Runnable asyncTest = new Runnable() {
-			@Override
-			public void run() {
-				try {
-					assertNotNull("Entry not found.", testBundle.getEntry("dirA/fileA"));
-					assertNotNull("Entry not found.", testBundle.getEntry("dirA/dirB/fileB"));
-					assertNotNull("Entry not found.", testBundle.getEntry("dirA/dirC/fileC"));
-					assertNotNull("Entry not found.", testBundle.getEntry("dirA/dirC/"));
-					URL dirBURL = converter.toFileURL(testBundle.getEntry("dirA/dirB/"));
-					assertNotNull("Failed to convert to file URL", dirBURL);
-					URL dirAURL = converter.toFileURL(testBundle.getEntry("dirA/"));
-					assertNotNull("Failed to convert to file URL", dirAURL);
-					List<URL> allEntries = testBundle.adapt(BundleWiring.class).findEntries("/", "*", BundleWiring.FINDENTRIES_RECURSE);
-					assertEquals("Wrong number of entries: " + allEntries, 8, allEntries.size());
-				} catch (IOException e) {
-					throw new AssertionFailedError(e.getMessage());
-				}
+		Runnable asyncTest = () -> {
+			try {
+				assertNotNull("Entry not found.", testBundle.getEntry("dirA/fileA"));
+				assertNotNull("Entry not found.", testBundle.getEntry("dirA/dirB/fileB"));
+				assertNotNull("Entry not found.", testBundle.getEntry("dirA/dirC/fileC"));
+				assertNotNull("Entry not found.", testBundle.getEntry("dirA/dirC/"));
+				URL dirBURL = converter.toFileURL(testBundle.getEntry("dirA/dirB/"));
+				assertNotNull("Failed to convert to file URL", dirBURL);
+				URL dirAURL = converter.toFileURL(testBundle.getEntry("dirA/"));
+				assertNotNull("Failed to convert to file URL", dirAURL);
+				List<URL> allEntries = testBundle.adapt(BundleWiring.class).findEntries("/", "*", BundleWiring.FINDENTRIES_RECURSE);
+				assertEquals("Wrong number of entries: " + allEntries, 8, allEntries.size());
+			} catch (IOException e) {
+				throw new AssertionFailedError(e.getMessage());
 			}
 		};
 
@@ -3689,19 +3628,16 @@
 		final List<Exception> errors = new CopyOnWriteArrayList<>();
 		try {
 			for (final File f : testBundles) {
-				executor.execute(new Runnable() {
-					@Override
-					public void run() {
-						try {
-							String location = f.toURI().toURL().toExternalForm();
-							System.out.println("Installing: " + f.getName());
-							Bundle b = systemContext.installBundle(location);
-							b.start();
-							BundleWiring wiring = b.adapt(BundleWiring.class);
-							wiring.getClassLoader().loadClass(BundleContext.class.getName());
-						} catch (Exception e) {
-							errors.add(e);
-						}
+				executor.execute(() -> {
+					try {
+						String location = f.toURI().toURL().toExternalForm();
+						System.out.println("Installing: " + f.getName());
+						Bundle b = systemContext.installBundle(location);
+						b.start();
+						BundleWiring wiring = b.adapt(BundleWiring.class);
+						wiring.getClassLoader().loadClass(BundleContext.class.getName());
+					} catch (Exception e) {
+						errors.add(e);
 					}
 				});
 			}
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java
index 3992019..a541ace 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java
@@ -144,17 +144,14 @@
 		for (final Bundle bundle : bundles) {
 			if (bundle.getBundleId() == 0)
 				continue;
-			executor.execute(new Runnable() {
-				@Override
-				public void run() {
-					try {
-						ModuleRevisionBuilder builder = OSGiManifestBuilderFactory.createBuilder(asMap(bundle.getHeaders("")));
-						container.install(null, bundle.getLocation(), builder, null);
-					} catch (Throwable t) {
-						t.printStackTrace();
-						synchronized (installErrors) {
-							installErrors.add(t);
-						}
+			executor.execute(() -> {
+				try {
+					ModuleRevisionBuilder builder = OSGiManifestBuilderFactory.createBuilder(asMap(bundle.getHeaders("")));
+					container.install(null, bundle.getLocation(), builder, null);
+				} catch (Throwable t) {
+					t.printStackTrace();
+					synchronized (installErrors) {
+						installErrors.add(t);
 					}
 				}
 			});
@@ -522,32 +519,26 @@
 
 	@Test
 	public void testSingleton02() throws BundleException, IOException {
-		ResolverHookFactory resolverHookFactory = new ResolverHookFactory() {
+		ResolverHookFactory resolverHookFactory = triggers -> new ResolverHook() {
 
 			@Override
-			public ResolverHook begin(Collection<BundleRevision> triggers) {
-				return new ResolverHook() {
+			public void filterSingletonCollisions(BundleCapability singleton, Collection<BundleCapability> collisionCandidates) {
+				collisionCandidates.clear();
+			}
 
-					@Override
-					public void filterSingletonCollisions(BundleCapability singleton, Collection<BundleCapability> collisionCandidates) {
-						collisionCandidates.clear();
-					}
+			@Override
+			public void filterResolvable(Collection<BundleRevision> candidates) {
+				// nothing
+			}
 
-					@Override
-					public void filterResolvable(Collection<BundleRevision> candidates) {
-						// nothing
-					}
+			@Override
+			public void filterMatches(BundleRequirement requirement, Collection<BundleCapability> candidates) {
+				// nothing
+			}
 
-					@Override
-					public void filterMatches(BundleRequirement requirement, Collection<BundleCapability> candidates) {
-						// nothing
-					}
-
-					@Override
-					public void end() {
-						// nothing
-					}
-				};
+			@Override
+			public void end() {
+				// nothing
 			}
 		};
 		DummyContainerAdaptor adaptor = new DummyContainerAdaptor(new DummyCollisionHook(false), Collections.emptyMap(), resolverHookFactory);
@@ -587,32 +578,26 @@
 	@Test
 	public void testSingleton04() throws BundleException, IOException {
 		final Collection<BundleRevision> disabled = new ArrayList<>();
-		ResolverHookFactory resolverHookFactory = new ResolverHookFactory() {
+		ResolverHookFactory resolverHookFactory = triggers -> new ResolverHook() {
 
 			@Override
-			public ResolverHook begin(Collection<BundleRevision> triggers) {
-				return new ResolverHook() {
+			public void filterSingletonCollisions(BundleCapability singleton, Collection<BundleCapability> collisionCandidates) {
+				// nothing
+			}
 
-					@Override
-					public void filterSingletonCollisions(BundleCapability singleton, Collection<BundleCapability> collisionCandidates) {
-						// nothing
-					}
+			@Override
+			public void filterResolvable(Collection<BundleRevision> candidates) {
+				candidates.removeAll(disabled);
+			}
 
-					@Override
-					public void filterResolvable(Collection<BundleRevision> candidates) {
-						candidates.removeAll(disabled);
-					}
+			@Override
+			public void filterMatches(BundleRequirement requirement, Collection<BundleCapability> candidates) {
+				// nothing
+			}
 
-					@Override
-					public void filterMatches(BundleRequirement requirement, Collection<BundleCapability> candidates) {
-						// nothing
-					}
-
-					@Override
-					public void end() {
-						// nothing
-					}
-				};
+			@Override
+			public void end() {
+				// nothing
 			}
 		};
 		DummyContainerAdaptor adaptor = new DummyContainerAdaptor(new DummyCollisionHook(false), Collections.emptyMap(), resolverHookFactory);
@@ -1845,21 +1830,13 @@
 		// use sync queue to force thread creation
 		BlockingQueue<Runnable> queue = new SynchronousQueue<>();
 		// try to name the threads with useful name
-		ThreadFactory threadFactory = new ThreadFactory() {
-			@Override
-			public Thread newThread(Runnable r) {
-				Thread t = new Thread(r, "Resolver thread - UNIT TEST"); //$NON-NLS-1$
-				t.setDaemon(true);
-				return t;
-			}
+		ThreadFactory threadFactory = r -> {
+			Thread t = new Thread(r, "Resolver thread - UNIT TEST"); //$NON-NLS-1$
+			t.setDaemon(true);
+			return t;
 		};
 		// use a rejection policy that simply runs the task in the current thread once the max threads is reached
-		RejectedExecutionHandler rejectHandler = new RejectedExecutionHandler() {
-			@Override
-			public void rejectedExecution(Runnable r, ThreadPoolExecutor exe) {
-				r.run();
-			}
-		};
+		RejectedExecutionHandler rejectHandler = (r, exe) -> r.run();
 		ExecutorService executor = new ThreadPoolExecutor(coreThreads, maxThreads, idleTimeout, TimeUnit.SECONDS, queue, threadFactory, rejectHandler);
 		ScheduledExecutorService timeoutExecutor = new ScheduledThreadPoolExecutor(1);
 
@@ -2937,16 +2914,12 @@
 		try {
 			for (final Module module : modules) {
 
-				executor.execute(new Runnable() {
-
-					@Override
-					public void run() {
-						try {
-							module.start();
-						} catch (BundleException e) {
-							startErrors.offer(e);
-							e.printStackTrace();
-						}
+				executor.execute(() -> {
+					try {
+						module.start();
+					} catch (BundleException e) {
+						startErrors.offer(e);
+						e.printStackTrace();
 					}
 				});
 			}
@@ -3046,12 +3019,7 @@
 		resolverHook.container = container;
 
 		final AtomicReference<ModuleWire> dynamicWire = new AtomicReference<>();
-		Runnable runForEvents = new Runnable() {
-			@Override
-			public void run() {
-				dynamicWire.set(container.resolveDynamic("org.osgi.framework", dynamicImport.getCurrentRevision()));
-			}
-		};
+		Runnable runForEvents = () -> dynamicWire.set(container.resolveDynamic("org.osgi.framework", dynamicImport.getCurrentRevision()));
 		adaptor.setRunForEvents(runForEvents);
 		// install a bundle to resolve
 		manifest.clear();
@@ -3639,14 +3607,11 @@
 		final Module module = installDummyModule(manifest, manifest.get(Constants.BUNDLE_SYMBOLICNAME), container);
 
 		final ArrayBlockingQueue<BundleException> startExceptions = new ArrayBlockingQueue<>(2);
-		Runnable start = new Runnable() {
-			@Override
-			public void run() {
-				try {
-					module.start();
-				} catch (BundleException e) {
-					startExceptions.offer(e);
-				}
+		Runnable start = () -> {
+			try {
+				module.start();
+			} catch (BundleException e) {
+				startExceptions.offer(e);
 			}
 		};
 		Thread t1 = new Thread(start);
@@ -3662,14 +3627,11 @@
 		startError.printStackTrace();
 
 		final ArrayBlockingQueue<BundleException> stopExceptions = new ArrayBlockingQueue<>(2);
-		Runnable stop = new Runnable() {
-			@Override
-			public void run() {
-				try {
-					module.stop();
-				} catch (BundleException e) {
-					stopExceptions.offer(e);
-				}
+		Runnable stop = () -> {
+			try {
+				module.stop();
+			} catch (BundleException e) {
+				stopExceptions.offer(e);
 			}
 		};
 		Thread tStop1 = new Thread(stop);
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/hooks/framework/ClassLoaderHookTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/hooks/framework/ClassLoaderHookTests.java
index 89b6f4f..1f5ec20 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/hooks/framework/ClassLoaderHookTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/hooks/framework/ClassLoaderHookTests.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2013, 2020 IBM Corporation and others.
+ * Copyright (c) 2013, 2021 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -28,9 +28,7 @@
 import org.osgi.framework.Bundle;
 import org.osgi.framework.Constants;
 import org.osgi.framework.FrameworkEvent;
-import org.osgi.framework.FrameworkListener;
 import org.osgi.framework.hooks.weaving.WeavingHook;
-import org.osgi.framework.hooks.weaving.WovenClass;
 import org.osgi.framework.launch.Framework;
 import org.osgi.framework.namespace.PackageNamespace;
 import org.osgi.framework.wiring.BundleRevision;
@@ -120,13 +118,9 @@
 	public void testRejectTransformationFromWeavingHook() throws Exception {
 		setRejectTransformation(true);
 		initAndStartFramework();
-		framework.getBundleContext().registerService(WeavingHook.class, new WeavingHook() {
-
-			@Override
-			public void weave(WovenClass wovenClass) {
-				wovenClass.setBytes(new byte[] {'b', 'a', 'd', 'b', 'y', 't', 'e', 's'});
-				wovenClass.getDynamicImports().add("badimport");
-			}
+		framework.getBundleContext().registerService(WeavingHook.class, wovenClass -> {
+			wovenClass.setBytes(new byte[] {'b', 'a', 'd', 'b', 'y', 't', 'e', 's'});
+			wovenClass.getDynamicImports().add("badimport");
 		}, null);
 		Bundle b = installBundle();
 		b.loadClass(TEST_CLASSNAME);
@@ -183,13 +177,9 @@
 
 	private void refreshBundles(Collection<Bundle> bundles) throws InterruptedException {
 		final CountDownLatch refreshSignal = new CountDownLatch(1);
-		framework.adapt(FrameworkWiring.class).refreshBundles(bundles, new FrameworkListener() {
-
-			@Override
-			public void frameworkEvent(FrameworkEvent event) {
-				if (event.getType() == FrameworkEvent.PACKAGES_REFRESHED) {
-					refreshSignal.countDown();
-				}
+		framework.adapt(FrameworkWiring.class).refreshBundles(bundles, event -> {
+			if (event.getType() == FrameworkEvent.PACKAGES_REFRESHED) {
+				refreshSignal.countDown();
 			}
 		});
 		refreshSignal.await(30, TimeUnit.SECONDS);
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/listeners/ExceptionHandlerTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/listeners/ExceptionHandlerTests.java
index 74cff32..8115ba0 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/listeners/ExceptionHandlerTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/listeners/ExceptionHandlerTests.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2004, 2015 IBM Corporation and others.
+ * Copyright (c) 2004, 2021 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -19,7 +19,6 @@
 import org.eclipse.osgi.tests.OSGiTestsActivator;
 import org.junit.Assert;
 import org.junit.Test;
-import org.osgi.framework.BundleEvent;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.BundleListener;
 import org.osgi.framework.FrameworkEvent;
@@ -62,10 +61,8 @@
 		FrameworkEventListenerWithResult fwkListener = new FrameworkEventListenerWithResult();
 		OSGiTestsActivator.getContext().addFrameworkListener(fwkListener);
 
-		BundleListener npeGenerator = new BundleListener() {
-			public void bundleChanged(BundleEvent event) {
-				throw new NullPointerException("Generated exception");
-			}
+		BundleListener npeGenerator = event -> {
+			throw new NullPointerException("Generated exception");
 		};
 		OSGiTestsActivator.getContext().addBundleListener(npeGenerator);
 
@@ -91,10 +88,8 @@
 		FrameworkEventListenerWithResult fwkListener = new FrameworkEventListenerWithResult();
 		OSGiTestsActivator.getContext().addFrameworkListener(fwkListener);
 
-		BundleListener fatalException = new BundleListener() {
-			public void bundleChanged(BundleEvent event) {
-				throw new OutOfMemoryError("Generated exception");
-			}
+		BundleListener fatalException = event -> {
+			throw new OutOfMemoryError("Generated exception");
 		};
 		OSGiTestsActivator.getContext().addBundleListener(fatalException);
 
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resource/BasicTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resource/BasicTest.java
index 2857c0e..1670db3 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resource/BasicTest.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resource/BasicTest.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2012, 2015 IBM Corporation and others.
+ * Copyright (c) 2012, 2021 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -211,26 +211,11 @@
 	 */
 	private void assertTb2() {
 		final BundleRevision revision = tb2.adapt(BundleRevision.class);
-		assertNotIdentityCapability(new CapabilityProvider() {
-			@Override
-			public List getCapabilities(String namespace) {
-				return revision.getDeclaredCapabilities(namespace);
-			}
-		});
+		assertNotIdentityCapability(namespace -> revision.getDeclaredCapabilities(namespace));
 		final Resource resource = revision;
-		assertNotIdentityCapability(new CapabilityProvider() {
-			@Override
-			public List getCapabilities(String namespace) {
-				return resource.getCapabilities(namespace);
-			}
-		});
+		assertNotIdentityCapability(namespace -> resource.getCapabilities(namespace));
 		final BundleWiring wiring = tb2.adapt(BundleWiring.class);
-		assertNotIdentityCapability(new CapabilityProvider() {
-			@Override
-			public List getCapabilities(String namespace) {
-				return wiring.getCapabilities(namespace);
-			}
-		});
+		assertNotIdentityCapability(namespace -> wiring.getCapabilities(namespace));
 	}
 
 	/*
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resource/ResolverHookTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resource/ResolverHookTests.java
index 128fa0f..b4ee9eb 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resource/ResolverHookTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resource/ResolverHookTests.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2011, 2015 IBM Corporation and others.
+ * Copyright (c) 2011, 2021 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -36,41 +36,37 @@
 	public void testSingletonIdentity() throws Exception {
 		final RuntimeException error[] = {null};
 		final boolean called[] = {false};
-		ResolverHookFactory resolverHookFactory = new ResolverHookFactory() {
-			public ResolverHook begin(Collection triggers) {
-				return new ResolverHook() {
+		ResolverHookFactory resolverHookFactory = triggers -> new ResolverHook() {
 
-					public void filterSingletonCollisions(BundleCapability singleton, Collection collisionCandidates) {
-						if (error[0] != null)
-							return;
-						called[0] = true;
-						try {
-							assertEquals("Wrong namespace", IdentityNamespace.IDENTITY_NAMESPACE, singleton.getNamespace());
-							assertEquals("Wrong singleton directive", "true", singleton.getDirectives().get(IdentityNamespace.CAPABILITY_SINGLETON_DIRECTIVE));
-							String symbolicName = (String) singleton.getAttributes().get(IdentityNamespace.IDENTITY_NAMESPACE);
-							for (Iterator iCandidates = collisionCandidates.iterator(); iCandidates.hasNext();) {
-								BundleCapability candidate = (BundleCapability) iCandidates.next();
-								assertEquals("Wrong namespace", IdentityNamespace.IDENTITY_NAMESPACE, candidate.getNamespace());
-								assertEquals("Wrong singleton directive", "true", candidate.getDirectives().get(IdentityNamespace.CAPABILITY_SINGLETON_DIRECTIVE));
-								assertEquals("Wrong symbolic name", symbolicName, (String) candidate.getAttributes().get(IdentityNamespace.IDENTITY_NAMESPACE));
-							}
-						} catch (RuntimeException e) {
-							error[0] = e;
-						}
+			public void filterSingletonCollisions(BundleCapability singleton, Collection collisionCandidates) {
+				if (error[0] != null)
+					return;
+				called[0] = true;
+				try {
+					assertEquals("Wrong namespace", IdentityNamespace.IDENTITY_NAMESPACE, singleton.getNamespace());
+					assertEquals("Wrong singleton directive", "true", singleton.getDirectives().get(IdentityNamespace.CAPABILITY_SINGLETON_DIRECTIVE));
+					String symbolicName = (String) singleton.getAttributes().get(IdentityNamespace.IDENTITY_NAMESPACE);
+					for (Iterator iCandidates = collisionCandidates.iterator(); iCandidates.hasNext();) {
+						BundleCapability candidate = (BundleCapability) iCandidates.next();
+						assertEquals("Wrong namespace", IdentityNamespace.IDENTITY_NAMESPACE, candidate.getNamespace());
+						assertEquals("Wrong singleton directive", "true", candidate.getDirectives().get(IdentityNamespace.CAPABILITY_SINGLETON_DIRECTIVE));
+						assertEquals("Wrong symbolic name", symbolicName, (String) candidate.getAttributes().get(IdentityNamespace.IDENTITY_NAMESPACE));
 					}
+				} catch (RuntimeException e) {
+					error[0] = e;
+				}
+			}
 
-					public void filterResolvable(Collection candidates) {
-						// nothing
-					}
+			public void filterResolvable(Collection candidates) {
+				// nothing
+			}
 
-					public void filterMatches(BundleRequirement requirement, Collection candidates) {
-						// nothing
-					}
+			public void filterMatches(BundleRequirement requirement, Collection candidates) {
+				// nothing
+			}
 
-					public void end() {
-						// nothing
-					}
-				};
+			public void end() {
+				// nothing
 			}
 		};
 
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/securityadmin/SecurityManagerTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/securityadmin/SecurityManagerTests.java
index 97da257..2602ce7 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/securityadmin/SecurityManagerTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/securityadmin/SecurityManagerTests.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2008, 2020 IBM Corporation and others.
+ * Copyright (c) 2008, 2021 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -635,37 +635,31 @@
 		BundleContext systemContext = equinox.getBundleContext();
 
 		// register a no-op resolver hook to test security
-		ResolverHookFactory dummyHook = new ResolverHookFactory() {
+		ResolverHookFactory dummyHook = triggers -> new ResolverHook() {
 
 			@Override
-			public ResolverHook begin(Collection<BundleRevision> triggers) {
-				return new ResolverHook() {
-
-					@Override
-					public void filterResolvable(Collection<BundleRevision> candidates) {
-						// nothing
-					}
-
-					@Override
-					public void filterSingletonCollisions(BundleCapability singleton, Collection<BundleCapability> collisionCandidates) {
-						// nothing
-					}
-
-					@Override
-					public void filterMatches(BundleRequirement requirement, Collection<BundleCapability> candidates) {
-						// always remove candidates for dynamic import
-						if (PackageNamespace.RESOLUTION_DYNAMIC.equals(requirement.getDirectives().get(Namespace.REQUIREMENT_RESOLUTION_DIRECTIVE))) {
-							candidates.clear();
-						}
-					}
-
-					@Override
-					public void end() {
-						// nothing
-					}
-
-				};
+			public void filterResolvable(Collection<BundleRevision> candidates) {
+				// nothing
 			}
+
+			@Override
+			public void filterSingletonCollisions(BundleCapability singleton, Collection<BundleCapability> collisionCandidates) {
+				// nothing
+			}
+
+			@Override
+			public void filterMatches(BundleRequirement requirement, Collection<BundleCapability> candidates) {
+				// always remove candidates for dynamic import
+				if (PackageNamespace.RESOLUTION_DYNAMIC.equals(requirement.getDirectives().get(Namespace.REQUIREMENT_RESOLUTION_DIRECTIVE))) {
+					candidates.clear();
+				}
+			}
+
+			@Override
+			public void end() {
+				// nothing
+			}
+
 		};
 		systemContext.registerService(ResolverHookFactory.class, dummyHook, null);
 
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/serviceregistry/ServiceRegistryTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/serviceregistry/ServiceRegistryTests.java
index 0e4e0c5..49afd98 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/serviceregistry/ServiceRegistryTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/serviceregistry/ServiceRegistryTests.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2008, 2017 IBM Corporation and others.
+ * Copyright (c) 2008, 2021 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -37,29 +37,24 @@
 	public void testServiceListener01() {
 		final String testMethodName = getName();
 		// simple ServiceListener test
-		Runnable runIt = new Runnable() {
-			@Override
-			public void run() {
-				// nothing
-			}
+		Runnable runIt = () -> {
+			// nothing
 		};
 		final boolean[] results = new boolean[] {false, false, false, false};
-		ServiceListener testListener = new ServiceListener() {
-			public void serviceChanged(ServiceEvent event) {
-				switch (event.getType()) {
-					case ServiceEvent.REGISTERED :
-						results[0] = true;
-						break;
-					case ServiceEvent.MODIFIED :
-						results[1] = true;
-						break;
-					case ServiceEvent.MODIFIED_ENDMATCH :
-						results[2] = true;
-						break;
-					case ServiceEvent.UNREGISTERING :
-						results[3] = true;
-						break;
-				}
+		ServiceListener testListener = event -> {
+			switch (event.getType()) {
+				case ServiceEvent.REGISTERED :
+					results[0] = true;
+					break;
+				case ServiceEvent.MODIFIED :
+					results[1] = true;
+					break;
+				case ServiceEvent.MODIFIED_ENDMATCH :
+					results[2] = true;
+					break;
+				case ServiceEvent.UNREGISTERING :
+					results[3] = true;
+					break;
 			}
 		};
 		try {
@@ -133,29 +128,24 @@
 	public void testServiceListener02() {
 		final String testMethodName = getName();
 		// simple ServiceListener test
-		Runnable runIt = new Runnable() {
-			@Override
-			public void run() {
-				// nothing
-			}
+		Runnable runIt = () -> {
+			// nothing
 		};
 		final boolean[] results = new boolean[] {false, false, false, false};
-		ServiceListener testListener = new ServiceListener() {
-			public void serviceChanged(ServiceEvent event) {
-				switch (event.getType()) {
-					case ServiceEvent.REGISTERED :
-						results[0] = true;
-						break;
-					case ServiceEvent.MODIFIED :
-						results[1] = true;
-						break;
-					case ServiceEvent.MODIFIED_ENDMATCH :
-						results[2] = true;
-						break;
-					case ServiceEvent.UNREGISTERING :
-						results[3] = true;
-						break;
-				}
+		ServiceListener testListener = event -> {
+			switch (event.getType()) {
+				case ServiceEvent.REGISTERED :
+					results[0] = true;
+					break;
+				case ServiceEvent.MODIFIED :
+					results[1] = true;
+					break;
+				case ServiceEvent.MODIFIED_ENDMATCH :
+					results[2] = true;
+					break;
+				case ServiceEvent.UNREGISTERING :
+					results[3] = true;
+					break;
 			}
 		};
 		try {
@@ -229,29 +219,24 @@
 	public void testServiceListener03() {
 		final String testMethodName = getName();
 		// simple ServiceListener test
-		Runnable runIt = new Runnable() {
-			@Override
-			public void run() {
-				// nothing
-			}
+		Runnable runIt = () -> {
+			// nothing
 		};
 		final int[] results = new int[] {0, 0, 0, 0};
-		ServiceListener testListener = new ServiceListener() {
-			public void serviceChanged(ServiceEvent event) {
-				switch (event.getType()) {
-					case ServiceEvent.REGISTERED :
-						results[0]++;
-						break;
-					case ServiceEvent.MODIFIED :
-						results[1]++;
-						break;
-					case ServiceEvent.MODIFIED_ENDMATCH :
-						results[2]++;
-						break;
-					case ServiceEvent.UNREGISTERING :
-						results[3]++;
-						break;
-				}
+		ServiceListener testListener = event -> {
+			switch (event.getType()) {
+				case ServiceEvent.REGISTERED :
+					results[0]++;
+					break;
+				case ServiceEvent.MODIFIED :
+					results[1]++;
+					break;
+				case ServiceEvent.MODIFIED_ENDMATCH :
+					results[2]++;
+					break;
+				case ServiceEvent.UNREGISTERING :
+					results[3]++;
+					break;
 			}
 		};
 		try {
@@ -360,11 +345,8 @@
 	public void testServiceOrdering01() {
 		final String testMethodName = getName();
 		// test that getServiceReference returns the proper service
-		Runnable runIt = new Runnable() {
-			@Override
-			public void run() {
-				// nothing
-			}
+		Runnable runIt = () -> {
+			// nothing
 		};
 		Hashtable props = new Hashtable();
 		props.put("name", testMethodName); //$NON-NLS-1$
@@ -398,11 +380,8 @@
 	public void testDuplicateObjectClass() {
 		ServiceRegistration reg = null;
 		try {
-			reg = OSGiTestsActivator.getContext().registerService(new String[] {Runnable.class.getName(), Object.class.getName(), Object.class.getName()}, new Runnable() {
-				@Override
-				public void run() {
-					// nothing
-				}
+			reg = OSGiTestsActivator.getContext().registerService(new String[] {Runnable.class.getName(), Object.class.getName(), Object.class.getName()}, (Runnable) () -> {
+				// nothing
 			}, null);
 		} catch (Throwable t) {
 			fail("Failed to register service with duplicate objectClass names", t); //$NON-NLS-1$
@@ -415,11 +394,8 @@
 	public void testServiceReferenceCompare01() {
 		final String testMethodName = getName();
 		// test that getServiceReference returns the proper service
-		Runnable runIt = new Runnable() {
-			@Override
-			public void run() {
-				// nothing
-			}
+		Runnable runIt = () -> {
+			// nothing
 		};
 		Hashtable props = new Hashtable();
 		props.put("name", testMethodName); //$NON-NLS-1$
@@ -469,11 +445,8 @@
 	}
 
 	public void testModifiedRanking() {
-		Runnable runIt = new Runnable() {
-			@Override
-			public void run() {
-				// nothing
-			}
+		Runnable runIt = () -> {
+			// nothing
 		};
 		Hashtable props = new Hashtable();
 		props.put(getName(), Boolean.TRUE);
@@ -497,21 +470,13 @@
 
 	public void testInvalidRanking() {
 		final CountDownLatch warning = new CountDownLatch(1);
-		FrameworkListener warningListener = new FrameworkListener() {
-
-			@Override
-			public void frameworkEvent(FrameworkEvent event) {
-				if (FrameworkEvent.WARNING == event.getType() && OSGiTestsActivator.getContext().getBundle().equals(event.getBundle())) {
-					warning.countDown();
-				}
+		FrameworkListener warningListener = event -> {
+			if (FrameworkEvent.WARNING == event.getType() && OSGiTestsActivator.getContext().getBundle().equals(event.getBundle())) {
+				warning.countDown();
 			}
 		};
-		Runnable runIt = new Runnable() {
-
-			@Override
-			public void run() {
-				// nothing
-			}
+		Runnable runIt = () -> {
+			// nothing
 		};
 		Hashtable props = new Hashtable();
 		props.put(getName(), Boolean.TRUE);
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/serviceregistry/ServiceTrackerTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/serviceregistry/ServiceTrackerTests.java
index 0d7c3f2..9010c18 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/serviceregistry/ServiceTrackerTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/serviceregistry/ServiceTrackerTests.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2008, 2009 IBM Corporation and others.
+ * Copyright (c) 2008, 2021 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -30,11 +30,8 @@
 	public void testServiceTracker01() {
 		final String testMethodName = getName();
 		// simple ServiceTracker test
-		Runnable runIt = new Runnable() {
-			@Override
-			public void run() {
-				// nothing
-			}
+		Runnable runIt = () -> {
+			// nothing
 		};
 		Hashtable props = new Hashtable();
 		props.put(testMethodName, Boolean.TRUE);
@@ -110,11 +107,8 @@
 	public void testServiceTracker02() {
 		final String testMethodName = getName();
 		// simple ServiceTracker test
-		Runnable runIt = new Runnable() {
-			@Override
-			public void run() {
-				// nothing
-			}
+		Runnable runIt = () -> {
+			// nothing
 		};
 		Hashtable props = new Hashtable();
 		props.put(testMethodName, Boolean.FALSE);
@@ -190,11 +184,8 @@
 	public void testServiceTracker03() {
 		final String testMethodName = getName();
 		// simple ServiceTracker test
-		Runnable runIt = new Runnable() {
-			@Override
-			public void run() {
-				// nothing
-			}
+		Runnable runIt = () -> {
+			// nothing
 		};
 		Hashtable props = new Hashtable();
 		props.put(testMethodName, Boolean.TRUE);
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/BasicLocationTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/BasicLocationTests.java
index 21de7fe..45b5fea 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/BasicLocationTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/BasicLocationTests.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2004, 2014 IBM Corporation and others.
+ * Copyright (c) 2004, 2021 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -38,7 +38,6 @@
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.log.LogEntry;
-import org.osgi.service.log.LogListener;
 import org.osgi.service.log.LogReaderService;
 import org.osgi.util.tracker.ServiceTracker;
 
@@ -485,12 +484,7 @@
 		try {
 			final List<LogEntry> logEntries = new ArrayList<>();
 			LogReaderService logReaderService = getLogReaderService(equinox);
-			LogListener logListener = new SynchronousLogListener() {
-				@Override
-				public void logged(LogEntry entry) {
-					logEntries.add(entry);
-				}
-			};
+			SynchronousLogListener logListener = entry -> logEntries.add(entry);
 			logReaderService.addLogListener(logListener);
 			Map<String, Location> locations = getLocations(equinox);
 			Location userLocation = locations.get(Location.USER_FILTER);