Bug 574872 - [Clean-up] Simplify lambdas & use method references (4)

Clean up using the JDT clean-up:
- Simplify lambda expression and method reference syntax

Change-Id: Iddccb9377d4996244cf991f2f9c36f2bd0e56a71
Signed-off-by: Hannes Wellmann <wellmann.hannes1@gmx.net>
Reviewed-on: https://git.eclipse.org/r/c/equinox/rt.equinox.framework/+/183304
Tested-by: Equinox Bot <equinox-bot@eclipse.org>
Reviewed-by: Lars Vogel <Lars.Vogel@vogella.com>
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ConnectTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ConnectTests.java
index 4ca64c6..1dbf74e 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ConnectTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ConnectTests.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2019 IBM Corporation and others.
+ * Copyright (c) 2019, 2021 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -331,7 +331,7 @@
 	public void testConnectFactoryNoModules() {
 		TestCountingModuleConnector connector = new TestCountingModuleConnector();
 
-		doTestConnect(connector, Collections.emptyMap(), (f) -> {
+		doTestConnect(connector, Collections.emptyMap(), f -> {
 			try {
 				f.start();
 				f.stop();
@@ -343,7 +343,7 @@
 				sneakyThrow(t);
 			}
 		});
-		doTestConnect(connector, Collections.emptyMap(), (f) -> {
+		doTestConnect(connector, Collections.emptyMap(), f -> {
 			try {
 				f.start();
 				f.stop();
@@ -378,7 +378,7 @@
 			}
 		};
 
-		doTestConnect(activatorModuleConnector, Collections.emptyMap(), (f) -> {
+		doTestConnect(activatorModuleConnector, Collections.emptyMap(), f -> {
 			try {
 				f.start();
 				f.stop();
@@ -423,7 +423,7 @@
 			}
 		};
 
-		doTestConnect(activatorModuleConnector, Collections.emptyMap(), (f) -> {
+		doTestConnect(activatorModuleConnector, Collections.emptyMap(), f -> {
 			try {
 				f.start();
 				ServiceReference<Condition> trueCondition = trueConditionStart.get();
@@ -459,7 +459,7 @@
 		config.put("k1", "v1");
 		config.put("k2", "v2");
 
-		doTestConnect(initParamsModuleConnector, config, (f) -> {
+		doTestConnect(initParamsModuleConnector, config, f -> {
 			try {
 				f.init();
 				BundleContext bc = f.getBundleContext();
@@ -494,7 +494,7 @@
 			connector.setModule(l, withManifest ? createSimpleManifestModule(l) : createSimpleHeadersModule(l));
 		}
 
-		doTestConnect(connector, Collections.emptyMap(), (f) -> {
+		doTestConnect(connector, Collections.emptyMap(), f -> {
 			try {
 				f.init();
 				for (String l : locations) {
@@ -508,7 +508,7 @@
 			}
 		});
 
-		doTestConnect(connector, Collections.emptyMap(), (f) -> {
+		doTestConnect(connector, Collections.emptyMap(), f -> {
 			try {
 				f.init();
 				Bundle[] bundles = f.getBundleContext().getBundles();
@@ -527,7 +527,7 @@
 
 		connector.setModule("b.2", null);
 		connector.setModule("b.3", BUNDLE_EXCEPTION);
-		doTestConnect(connector, Collections.emptyMap(), (f) -> {
+		doTestConnect(connector, Collections.emptyMap(), f -> {
 			try {
 				f.init();
 				Bundle[] bundles = f.getBundleContext().getBundles();
@@ -590,7 +590,7 @@
 			connector.setModule(id.toString(), createAdvancedModule(id, provideLoader));
 		}
 
-		doTestConnect(connector, Collections.emptyMap(), (f) -> {
+		doTestConnect(connector, Collections.emptyMap(), f -> {
 			try {
 				f.start();
 				for (Integer id : ids) {
@@ -634,7 +634,7 @@
 			connector.setModule(id.toString(), m);
 		}
 
-		doTestConnect(connector, Collections.emptyMap(), (f) -> {
+		doTestConnect(connector, Collections.emptyMap(), f -> {
 			try {
 				f.start();
 				for (Integer id : ids) {
@@ -711,7 +711,7 @@
 		TestConnectModule m = createSimpleHeadersModule(NAME1);
 		connector.setModule(NAME1, m);
 
-		doTestConnect(connector, Collections.emptyMap(), (f) -> {
+		doTestConnect(connector, Collections.emptyMap(), f -> {
 			try {
 				f.start();
 				Bundle b = f.getBundleContext().installBundle(NAME1);
@@ -726,7 +726,7 @@
 
 				FrameworkWiring fwkWiring = f.adapt(FrameworkWiring.class);
 				CountDownLatch refreshDone = new CountDownLatch(1);
-				fwkWiring.refreshBundles(Collections.singletonList(b), (e) -> refreshDone.countDown());
+				fwkWiring.refreshBundles(Collections.singletonList(b), e -> refreshDone.countDown());
 				refreshDone.await();
 
 				// should still be NAME1
@@ -766,7 +766,7 @@
 		TestCountingModuleConnector connector = new TestCountingModuleConnector();
 		TestConnectModule m = withManifest ? createSimpleManifestModule(NAME1) : createSimpleHeadersModule(NAME1);
 		connector.setModule(NAME1, m);
-		doTestConnect(connector, Collections.emptyMap(), (f) -> {
+		doTestConnect(connector, Collections.emptyMap(), f -> {
 			try {
 				f.start();
 				Bundle b = f.getBundleContext().installBundle(NAME1);
@@ -803,7 +803,7 @@
 		TestCountingModuleConnector connector = new TestCountingModuleConnector();
 		TestConnectModule m = createSimpleHeadersModule(NAME);
 		connector.setModule(NAME, m);
-		doTestConnect(connector, Collections.emptyMap(), (f) -> {
+		doTestConnect(connector, Collections.emptyMap(), f -> {
 			try {
 				f.start();
 				Bundle b = f.getBundleContext().installBundle(NAME);
@@ -817,7 +817,7 @@
 		});
 
 		doTestConnect(connector, Collections.singletonMap(HookRegistry.PROP_HOOK_CONFIGURATORS_EXCLUDE,
-				"org.eclipse.equinox.weaving.hooks.WeavingHook"), (f) -> {
+				"org.eclipse.equinox.weaving.hooks.WeavingHook"), f -> {
 			try {
 				f.start();
 				Bundle b = f.getBundleContext().getBundle(NAME);
@@ -863,7 +863,7 @@
 		TestConnectModule m = createSimpleHeadersModule(NAME1);
 		connector.setModule(NAME1, m);
 
-		doTestConnect(connector, Collections.emptyMap(), (f) -> {
+		doTestConnect(connector, Collections.emptyMap(), f -> {
 			try {
 				f.start();
 				Bundle test = f.getBundleContext().installBundle(NAME1, in1);
@@ -918,7 +918,7 @@
 		TestCountingModuleConnector connector = new TestCountingModuleConnector();
 		connector.setModule("javaExport", createJavaExportModule());
 
-		doTestConnect(connector, Collections.emptyMap(), (f) -> {
+		doTestConnect(connector, Collections.emptyMap(), f -> {
 			try {
 				f.start();
 				Bundle b = f.getBundleContext().installBundle("javaExport");
@@ -926,7 +926,7 @@
 				assertTrue("No java export found.",
 						b.adapt(BundleWiring.class).getCapabilities(PackageNamespace.PACKAGE_NAMESPACE).stream()
 								.findFirst()
-								.map((c) -> "java.test.export"
+								.map(c -> "java.test.export"
 										.equals(c.getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE)))
 								.orElse(false));
 			} catch (Throwable t) {
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/ModuleContainerUsageTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/ModuleContainerUsageTest.java
index 112f557..169d91a 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/ModuleContainerUsageTest.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/ModuleContainerUsageTest.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2020 IBM Corporation and others.
+ * Copyright (c) 2020, 2021 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -186,7 +186,7 @@
 		Collection<BundleRequirement> eeBundleReqs = m.getCurrentRevision()
 				.getDeclaredRequirements(ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE);
 
-		eeBundleReqs.stream().findFirst().ifPresent((r) -> {
+		eeBundleReqs.stream().findFirst().ifPresent(r -> {
 			// notice that we depend on the available EEs
 			// to be ordered from least to greatest
 			for (BundleCapability ee : availableEEs) {
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/security/BundleToJarInputStreamTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/security/BundleToJarInputStreamTest.java
index 52ffb2f..faddec7 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/security/BundleToJarInputStreamTest.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/security/BundleToJarInputStreamTest.java
@@ -91,7 +91,7 @@
 			assertEquals("Expected manifest.", JarFile.MANIFEST_NAME, first.toUpperCase());
 			// If there are signature files, make sure they are before all other entries
 			AtomicReference<String> foundNonSignatureFile = new AtomicReference<>();
-			validpaths.forEachRemaining((s) -> {
+			validpaths.forEachRemaining(s -> {
 				if (isSignatureFile(s)) {
 					assertNull("Found non signature file before.", foundNonSignatureFile.get());
 				} else {
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainer.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainer.java
index 4cc02ee..ff86c6c 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainer.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainer.java
@@ -1823,7 +1823,7 @@
 			if (toStart.isEmpty()) {
 				return;
 			}
-			final Executor executor = inParallel ? adaptor.getStartLevelExecutor() : command -> command.run();
+			final Executor executor = inParallel ? adaptor.getStartLevelExecutor() : Runnable::run;
 			final CountDownLatch done = new CountDownLatch(toStart.size());
 			for (final Module module : toStart) {
 				executor.execute(() -> {
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainerAdaptor.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainerAdaptor.java
index cf6cf67..6d73c42 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainerAdaptor.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainerAdaptor.java
@@ -29,7 +29,7 @@
  * @since 3.10
  */
 public abstract class ModuleContainerAdaptor {
-	private static Executor defaultExecutor = command -> command.run();
+	private static Executor defaultExecutor = Runnable::run;
 
 	/**
 	 * Event types that may be {@link #publishContainerEvent(ContainerEvent, Module, Throwable, FrameworkListener...) published}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/util/SecureAction.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/util/SecureAction.java
index 62d566e..2b6113b 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/util/SecureAction.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/util/SecureAction.java
@@ -68,7 +68,7 @@
 	 * @return a privileged action object that can be used to construct a SecureAction object.
 	 */
 	public static PrivilegedAction<SecureAction> createSecureAction() {
-		return () -> new SecureAction();
+		return SecureAction::new;
 	}
 
 	/**
@@ -91,7 +91,7 @@
 	public Properties getProperties() {
 		if (System.getSecurityManager() == null)
 			return System.getProperties();
-		return AccessController.doPrivileged((PrivilegedAction<Properties>) () -> System.getProperties(), controlContext);
+		return AccessController.doPrivileged((PrivilegedAction<Properties>) System::getProperties, controlContext);
 	}
 
 	/**
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/connect/ConnectHookConfigurator.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/connect/ConnectHookConfigurator.java
index aaf9797..8d58f96 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/connect/ConnectHookConfigurator.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/connect/ConnectHookConfigurator.java
@@ -151,8 +151,7 @@
 						bundlefile = chain.getBundleFile();
 					}
 					if (bundlefile instanceof ConnectBundleFile) {
-						return ((ConnectBundleFile) bundlefile).getClassLoader().map((l) //
-						-> new DelegatingConnectClassLoader(parent, configuration, delegate, generation, l)).orElse(null);
+						return ((ConnectBundleFile) bundlefile).getClassLoader().map(l -> new DelegatingConnectClassLoader(parent, configuration, delegate, generation, l)).orElse(null);
 					}
 				}
 				return null;
@@ -161,7 +160,7 @@
 
 		hookRegistry.addActivatorHookFactory(() -> {
 			final List<BundleActivator> activators = new ArrayList<>();
-			moduleConnector.newBundleActivator().ifPresent((a) -> activators.add(a));
+			moduleConnector.newBundleActivator().ifPresent(a -> activators.add(a));
 			return new BundleActivator() {
 				@Override
 				public void start(BundleContext context) throws Exception {
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java
index 3bf2122..01abd70 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java
@@ -128,7 +128,7 @@
 		return () -> {
 			if (maxThreads == 1) {
 				// just do synchronous execution with current thread
-				return command -> command.run();
+				return Runnable::run;
 			}
 			// Always want to create core threads until max size
 			int coreThreads = maxThreads;
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java
index 22a4ff1..33ec549 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java
@@ -74,7 +74,7 @@
 	public final static String DEFAULT_PACKAGE = "."; //$NON-NLS-1$
 	public final static String JAVA_PACKAGE = "java."; //$NON-NLS-1$
 
-	public final static ClassContext CLASS_CONTEXT = AccessController.doPrivileged((PrivilegedAction<ClassContext>) () -> new ClassContext());
+	public final static ClassContext CLASS_CONTEXT = AccessController.doPrivileged((PrivilegedAction<ClassContext>) ClassContext::new);
 	public final static ClassLoader FW_CLASSLOADER = getClassLoader(EquinoxContainer.class);
 
 	private static final int PRE_CLASS = 1;
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/buddy/GlobalPolicy.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/buddy/GlobalPolicy.java
index 062cc8c..a346ee2 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/buddy/GlobalPolicy.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/buddy/GlobalPolicy.java
@@ -61,9 +61,7 @@
 	@Override
 	public URL loadResource(String name) {
 		return getExportingBundles(BundleLoader.getResourcePackageName(name)) //
-				.stream().findFirst().map(b -> {
-					return b.getResource(name);
-				}).orElse(null);
+				.stream().findFirst().map(b -> b.getResource(name)).orElse(null);
 	}
 
 	@Override
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceRegistrationImpl.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceRegistrationImpl.java
index 96d89dd..057d491 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceRegistrationImpl.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceRegistrationImpl.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2003, 2020 IBM Corporation and others.
+ * Copyright (c) 2003, 2021 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -805,7 +805,7 @@
 		S getSafeService(BundleContextImpl user, ServiceConsumer consumer) {
 			try {
 				S hook = getService(user, consumer);
-				if (hookTypes.stream().filter((hookType) -> !hookType.isInstance(hook)).findFirst().isPresent()) {
+				if (hookTypes.stream().filter(hookType -> !hookType.isInstance(hook)).findFirst().isPresent()) {
 					// the hook impl is wired to a different hook package than the framework
 					if (hook != null) {
 						systemContext.ungetService(getReference());
diff --git a/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/util/OpenHashMap.java b/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/util/OpenHashMap.java
index 0d8d12d..f781de3 100755
--- a/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/util/OpenHashMap.java
+++ b/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/util/OpenHashMap.java
@@ -631,7 +631,7 @@
 
     public Iterable<Map.Entry<K, V>> fast() {
         if (fast == null) {
-            fast = () -> new FastEntryIterator();
+            fast = FastEntryIterator::new;
         }
 
         return fast;