Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHannes Wellmann2021-07-22 18:58:59 +0000
committerLars Vogel2021-07-23 12:51:26 +0000
commita539ccb597d0fb66d57786679a75fa3bbc588dd4 (patch)
tree243513e8917b9e3942fc4c4e9bb04a5d1c16c8d0
parente3bccaf7f84aadea18a0815ce72139a21a277768 (diff)
downloadrt.equinox.framework-I20210723-1800.tar.gz
rt.equinox.framework-I20210723-1800.tar.xz
rt.equinox.framework-I20210723-1800.zip
Bug 574872 - [Clean-up] Use lambda where possible (1)I20210725-1800I20210724-1800I20210723-1800
Clean up using the JDT clean-up: - Convert functional interface instances: Use lambda where possible Change-Id: I61d6fc75a675a0cda192bd97121c7598f5524f53 Signed-off-by: Hannes Wellmann <wellmann.hannes1@gmx.net> Reviewed-on: https://git.eclipse.org/r/c/equinox/rt.equinox.framework/+/183300 Tested-by: Equinox Bot <equinox-bot@eclipse.org> Reviewed-by: Lars Vogel <Lars.Vogel@vogella.com>
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainer.java70
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainerAdaptor.java9
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleDatabase.java8
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java8
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/util/SecureAction.java187
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/connect/ConnectHookConfigurator.java37
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/BundleContextImpl.java59
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/ContextFinder.java11
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxBundle.java45
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java51
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxEventPublisher.java28
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/FilterImpl.java9
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/OSGiFrameworkHooks.java28
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/legacy/PackageAdminImpl.java8
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java33
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/buddy/SystemPolicy.java9
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EventAdminLogListener.java13
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogReaderServiceFactory.java25
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/PermissionInfoCollection.java11
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceFactoryUse.java18
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceRegistry.java43
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/MultiplexingFactory.java9
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/weaving/WovenClassImpl.java20
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/FrameworkExtensionInstaller.java11
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java46
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/ZipBundleFile.java39
-rwxr-xr-xbundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/ResolverImpl.java68
-rwxr-xr-xbundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/util/OpenHashMap.java6
-rw-r--r--bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/AdaptPermission.java25
-rw-r--r--bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/AdminPermission.java25
-rw-r--r--bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/CapabilityPermission.java25
-rw-r--r--bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/PackagePermission.java25
-rw-r--r--bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/ServicePermission.java25
-rw-r--r--bundles/org.eclipse.osgi/osgi/src/org/osgi/service/condpermadmin/BundleLocationCondition.java7
34 files changed, 329 insertions, 712 deletions
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 ab7bf6fb0..4cc02eea3 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainer.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainer.java
@@ -1390,19 +1390,16 @@ public final class ModuleContainer implements DebugOptionsListener {
return;
}
getAdaptor().refreshedSystemModule();
- Thread t = new Thread(new Runnable() {
- @Override
- public void run() {
+ Thread t = new Thread(() -> {
+ try {
+ systemModule.lockStateChange(ModuleEvent.UNRESOLVED);
try {
- systemModule.lockStateChange(ModuleEvent.UNRESOLVED);
- try {
- systemModule.stop();
- } finally {
- systemModule.unlockStateChange(ModuleEvent.UNRESOLVED);
- }
- } catch (BundleException e) {
- e.printStackTrace();
+ systemModule.stop();
+ } finally {
+ systemModule.unlockStateChange(ModuleEvent.UNRESOLVED);
}
+ } catch (BundleException e) {
+ e.printStackTrace();
}
});
t.start();
@@ -1499,18 +1496,15 @@ public final class ModuleContainer implements DebugOptionsListener {
private Collection<Module> getModules(final Collection<Bundle> bundles) {
if (bundles == null)
return null;
- return AccessController.doPrivileged(new PrivilegedAction<Collection<Module>>() {
- @Override
- public Collection<Module> run() {
- Collection<Module> result = new ArrayList<>(bundles.size());
- for (Bundle bundle : bundles) {
- Module module = bundle.adapt(Module.class);
- if (module == null)
- throw new IllegalStateException("Could not adapt a bundle to a module. " + bundle); //$NON-NLS-1$
- result.add(module);
- }
- return result;
+ return AccessController.doPrivileged((PrivilegedAction<Collection<Module>>) () -> {
+ Collection<Module> result = new ArrayList<>(bundles.size());
+ for (Bundle bundle : bundles) {
+ Module module = bundle.adapt(Module.class);
+ if (module == null)
+ throw new IllegalStateException("Could not adapt a bundle to a module. " + bundle); //$NON-NLS-1$
+ result.add(module);
}
+ return result;
});
}
@@ -1829,29 +1823,21 @@ public final class ModuleContainer implements DebugOptionsListener {
if (toStart.isEmpty()) {
return;
}
- final Executor executor = inParallel ? adaptor.getStartLevelExecutor() : new Executor() {
- @Override
- public void execute(Runnable command) {
- command.run();
- }
- };
+ final Executor executor = inParallel ? adaptor.getStartLevelExecutor() : command -> command.run();
final CountDownLatch done = new CountDownLatch(toStart.size());
for (final Module module : toStart) {
- executor.execute(new Runnable() {
- @Override
- public void run() {
- try {
- if (debugStartLevel) {
- Debug.println("StartLevel: resuming bundle; " + ContainerStartLevel.this.toString(module) + "; with startLevel=" + toStartLevel); //$NON-NLS-1$ //$NON-NLS-2$
- }
- module.start(StartOptions.TRANSIENT_IF_AUTO_START, StartOptions.TRANSIENT_RESUME);
- } catch (BundleException e) {
- adaptor.publishContainerEvent(ContainerEvent.ERROR, module, e);
- } catch (IllegalStateException e) {
- // been uninstalled
- } finally {
- done.countDown();
+ executor.execute(() -> {
+ try {
+ if (debugStartLevel) {
+ Debug.println("StartLevel: resuming bundle; " + ContainerStartLevel.this.toString(module) + "; with startLevel=" + toStartLevel); //$NON-NLS-1$ //$NON-NLS-2$
}
+ module.start(StartOptions.TRANSIENT_IF_AUTO_START, StartOptions.TRANSIENT_RESUME);
+ } catch (BundleException e1) {
+ adaptor.publishContainerEvent(ContainerEvent.ERROR, module, e1);
+ } catch (IllegalStateException e2) {
+ // been uninstalled
+ } finally {
+ done.countDown();
}
});
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainerAdaptor.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainerAdaptor.java
index 5e067a82c..cf6cf6765 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2016 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
@@ -29,12 +29,7 @@ import org.osgi.framework.startlevel.FrameworkStartLevel;
* @since 3.10
*/
public abstract class ModuleContainerAdaptor {
- private static Executor defaultExecutor = new Executor() {
- @Override
- public void execute(Runnable command) {
- command.run();
- }
- };
+ private static Executor defaultExecutor = command -> command.run();
/**
* Event types that may be {@link #publishContainerEvent(ContainerEvent, Module, Throwable, FrameworkListener...) published}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleDatabase.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleDatabase.java
index 3b537f487..9356ddec1 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleDatabase.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleDatabase.java
@@ -21,7 +21,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
-import java.util.Comparator;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
@@ -575,12 +574,7 @@ public class ModuleDatabase {
if (modules.size() < 2)
return;
if (sortOptions == null || Sort.BY_ID.isContained(sortOptions) || sortOptions.length == 0) {
- Collections.sort(modules, new Comparator<Module>() {
- @Override
- public int compare(Module m1, Module m2) {
- return m1.getId().compareTo(m2.getId());
- }
- });
+ Collections.sort(modules, (m1, m2) -> m1.getId().compareTo(m2.getId()));
return;
}
// first sort by start-level
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java
index d50937c33..1ff229641 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java
@@ -1279,13 +1279,7 @@ final class ModuleResolver {
if (dynamicAttachableFrags.isEmpty()) {
return Collections.emptyMap();
}
- Collections.sort(dynamicAttachableFrags, new Comparator<ModuleRevision>() {
- @Override
- public int compare(ModuleRevision r1, ModuleRevision r2) {
- // we only care about versions here
- return -(r1.getVersion().compareTo(r2.getVersion()));
- }
- });
+ Collections.sort(dynamicAttachableFrags, (r1, r2) -> -(r1.getVersion().compareTo(r2.getVersion())));
Map<ModuleCapability, DynamicFragments> hostDynamicFragments = new HashMap<>();
// first find the hosts to dynamically attach to
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 e63b64281..62d566e6a 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
@@ -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
@@ -47,12 +47,7 @@ public class SecureAction {
private AccessControlContext controlContext;
// This ClassLoader is used in loadSystemClass if System.getClassLoader() returns null
- static final ClassLoader bootClassLoader = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
- @Override
- public ClassLoader run() {
- return new ClassLoader(Object.class.getClassLoader()) { /* boot class loader */};
- }
- });
+ static final ClassLoader bootClassLoader = AccessController.doPrivileged((PrivilegedAction<ClassLoader>) () -> new ClassLoader(Object.class.getClassLoader()) { /* boot class loader */});
/*
* Package privaet constructor a new SecureAction object.
@@ -73,12 +68,7 @@ public class SecureAction {
* @return a privileged action object that can be used to construct a SecureAction object.
*/
public static PrivilegedAction<SecureAction> createSecureAction() {
- return new PrivilegedAction<SecureAction>() {
- @Override
- public SecureAction run() {
- return new SecureAction();
- }
- };
+ return () -> new SecureAction();
}
/**
@@ -90,12 +80,7 @@ public class SecureAction {
public String getProperty(final String property) {
if (System.getSecurityManager() == null)
return System.getProperty(property);
- return AccessController.doPrivileged(new PrivilegedAction<String>() {
- @Override
- public String run() {
- return System.getProperty(property);
- }
- }, controlContext);
+ return AccessController.doPrivileged((PrivilegedAction<String>) () -> System.getProperty(property), controlContext);
}
/**
@@ -106,12 +91,7 @@ public class SecureAction {
public Properties getProperties() {
if (System.getSecurityManager() == null)
return System.getProperties();
- return AccessController.doPrivileged(new PrivilegedAction<Properties>() {
- @Override
- public Properties run() {
- return System.getProperties();
- }
- }, controlContext);
+ return AccessController.doPrivileged((PrivilegedAction<Properties>) () -> System.getProperties(), controlContext);
}
/**
@@ -125,12 +105,7 @@ public class SecureAction {
if (System.getSecurityManager() == null)
return new FileInputStream(file);
try {
- return AccessController.doPrivileged(new PrivilegedExceptionAction<FileInputStream>() {
- @Override
- public FileInputStream run() throws FileNotFoundException {
- return new FileInputStream(file);
- }
- }, controlContext);
+ return AccessController.doPrivileged((PrivilegedExceptionAction<FileInputStream>) () -> new FileInputStream(file), controlContext);
} catch (PrivilegedActionException e) {
if (e.getException() instanceof FileNotFoundException)
throw (FileNotFoundException) e.getException();
@@ -150,12 +125,7 @@ public class SecureAction {
if (System.getSecurityManager() == null)
return new FileOutputStream(file.getAbsolutePath(), append);
try {
- return AccessController.doPrivileged(new PrivilegedExceptionAction<FileOutputStream>() {
- @Override
- public FileOutputStream run() throws FileNotFoundException {
- return new FileOutputStream(file.getAbsolutePath(), append);
- }
- }, controlContext);
+ return AccessController.doPrivileged((PrivilegedExceptionAction<FileOutputStream>) () -> new FileOutputStream(file.getAbsolutePath(), append), controlContext);
} catch (PrivilegedActionException e) {
if (e.getException() instanceof FileNotFoundException)
throw (FileNotFoundException) e.getException();
@@ -172,12 +142,7 @@ public class SecureAction {
public long length(final File file) {
if (System.getSecurityManager() == null)
return file.length();
- return AccessController.doPrivileged(new PrivilegedAction<Long>() {
- @Override
- public Long run() {
- return Long.valueOf(file.length());
- }
- }, controlContext).longValue();
+ return AccessController.doPrivileged((PrivilegedAction<Long>) () -> Long.valueOf(file.length()), controlContext).longValue();
}
/**
@@ -191,12 +156,7 @@ public class SecureAction {
if (System.getSecurityManager() == null)
return file.getCanonicalPath();
try {
- return AccessController.doPrivileged(new PrivilegedExceptionAction<String>() {
- @Override
- public String run() throws IOException {
- return file.getCanonicalPath();
- }
- }, controlContext);
+ return AccessController.doPrivileged((PrivilegedExceptionAction<String>) () -> file.getCanonicalPath(), controlContext);
} catch (PrivilegedActionException e) {
if (e.getException() instanceof IOException)
throw (IOException) e.getException();
@@ -213,12 +173,7 @@ public class SecureAction {
public File getAbsoluteFile(final File file) {
if (System.getSecurityManager() == null)
return file.getAbsoluteFile();
- return AccessController.doPrivileged(new PrivilegedAction<File>() {
- @Override
- public File run() {
- return file.getAbsoluteFile();
- }
- }, controlContext);
+ return AccessController.doPrivileged((PrivilegedAction<File>) () -> file.getAbsoluteFile(), controlContext);
}
/**
@@ -231,12 +186,7 @@ public class SecureAction {
if (System.getSecurityManager() == null)
return file.getCanonicalFile();
try {
- return AccessController.doPrivileged(new PrivilegedExceptionAction<File>() {
- @Override
- public File run() throws IOException {
- return file.getCanonicalFile();
- }
- }, controlContext);
+ return AccessController.doPrivileged((PrivilegedExceptionAction<File>) () -> file.getCanonicalFile(), controlContext);
} catch (PrivilegedActionException e) {
if (e.getException() instanceof IOException)
throw (IOException) e.getException();
@@ -253,23 +203,13 @@ public class SecureAction {
public boolean exists(final File file) {
if (System.getSecurityManager() == null)
return file.exists();
- return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
- @Override
- public Boolean run() {
- return file.exists() ? Boolean.TRUE : Boolean.FALSE;
- }
- }, controlContext).booleanValue();
+ return AccessController.doPrivileged((PrivilegedAction<Boolean>) () -> file.exists() ? Boolean.TRUE : Boolean.FALSE, controlContext).booleanValue();
}
public boolean mkdirs(final File file) {
if (System.getSecurityManager() == null)
return file.mkdirs();
- return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
- @Override
- public Boolean run() {
- return file.mkdirs() ? Boolean.TRUE : Boolean.FALSE;
- }
- }, controlContext).booleanValue();
+ return AccessController.doPrivileged((PrivilegedAction<Boolean>) () -> file.mkdirs() ? Boolean.TRUE : Boolean.FALSE, controlContext).booleanValue();
}
/**
@@ -281,12 +221,7 @@ public class SecureAction {
public boolean isDirectory(final File file) {
if (System.getSecurityManager() == null)
return file.isDirectory();
- return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
- @Override
- public Boolean run() {
- return file.isDirectory() ? Boolean.TRUE : Boolean.FALSE;
- }
- }, controlContext).booleanValue();
+ return AccessController.doPrivileged((PrivilegedAction<Boolean>) () -> file.isDirectory() ? Boolean.TRUE : Boolean.FALSE, controlContext).booleanValue();
}
/**
@@ -298,12 +233,7 @@ public class SecureAction {
public long lastModified(final File file) {
if (System.getSecurityManager() == null)
return file.lastModified();
- return AccessController.doPrivileged(new PrivilegedAction<Long>() {
- @Override
- public Long run() {
- return Long.valueOf(file.lastModified());
- }
- }, controlContext).longValue();
+ return AccessController.doPrivileged((PrivilegedAction<Long>) () -> Long.valueOf(file.lastModified()), controlContext).longValue();
}
/**
@@ -315,12 +245,7 @@ public class SecureAction {
public String[] list(final File file) {
if (System.getSecurityManager() == null)
return file.list();
- return AccessController.doPrivileged(new PrivilegedAction<String[]>() {
- @Override
- public String[] run() {
- return file.list();
- }
- }, controlContext);
+ return AccessController.doPrivileged((PrivilegedAction<String[]>) () -> file.list(), controlContext);
}
/**
@@ -336,14 +261,11 @@ public class SecureAction {
if (System.getSecurityManager() == null)
return new ZipFile(file);
try {
- return AccessController.doPrivileged(new PrivilegedExceptionAction<ZipFile>() {
- @Override
- public ZipFile run() throws IOException {
- if (verify) {
- return new JarFile(file);
- }
- return new ZipFile(file);
+ return AccessController.doPrivileged((PrivilegedExceptionAction<ZipFile>) () -> {
+ if (verify) {
+ return new JarFile(file);
}
+ return new ZipFile(file);
}, controlContext);
} catch (PrivilegedActionException e) {
if (e.getException() instanceof IOException)
@@ -374,12 +296,7 @@ public class SecureAction {
if (System.getSecurityManager() == null)
return new URL(protocol, host, port, file, handler);
try {
- return AccessController.doPrivileged(new PrivilegedExceptionAction<URL>() {
- @Override
- public URL run() throws MalformedURLException {
- return new URL(protocol, host, port, file, handler);
- }
- }, controlContext);
+ return AccessController.doPrivileged((PrivilegedExceptionAction<URL>) () -> new URL(protocol, host, port, file, handler), controlContext);
} catch (PrivilegedActionException e) {
if (e.getException() instanceof MalformedURLException)
throw (MalformedURLException) e.getException();
@@ -398,12 +315,7 @@ public class SecureAction {
public Thread createThread(final Runnable target, final String name, final ClassLoader contextLoader) {
if (System.getSecurityManager() == null)
return createThread0(target, name, contextLoader);
- return AccessController.doPrivileged(new PrivilegedAction<Thread>() {
- @Override
- public Thread run() {
- return createThread0(target, name, contextLoader);
- }
- }, controlContext);
+ return AccessController.doPrivileged((PrivilegedAction<Thread>) () -> createThread0(target, name, contextLoader), controlContext);
}
Thread createThread0(Runnable target, String name, ClassLoader contextLoader) {
@@ -423,12 +335,7 @@ public class SecureAction {
public <S> S getService(final ServiceReference<S> reference, final BundleContext context) {
if (System.getSecurityManager() == null)
return context.getService(reference);
- return AccessController.doPrivileged(new PrivilegedAction<S>() {
- @Override
- public S run() {
- return context.getService(reference);
- }
- }, controlContext);
+ return AccessController.doPrivileged((PrivilegedAction<S>) () -> context.getService(reference), controlContext);
}
/**
@@ -442,12 +349,7 @@ public class SecureAction {
if (System.getSecurityManager() == null)
return Class.forName(name);
try {
- return AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>() {
- @Override
- public Class<?> run() throws Exception {
- return Class.forName(name);
- }
- }, controlContext);
+ return AccessController.doPrivileged((PrivilegedExceptionAction<Class<?>>) () -> Class.forName(name), controlContext);
} catch (PrivilegedActionException e) {
if (e.getException() instanceof ClassNotFoundException)
throw (ClassNotFoundException) e.getException();
@@ -468,12 +370,9 @@ public class SecureAction {
return (systemClassLoader != null) ? systemClassLoader.loadClass(name) : bootClassLoader.loadClass(name);
}
try {
- return AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>() {
- @Override
- public Class<?> run() throws Exception {
- ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
- return (systemClassLoader != null) ? systemClassLoader.loadClass(name) : bootClassLoader.loadClass(name);
- }
+ return AccessController.doPrivileged((PrivilegedExceptionAction<Class<?>>) () -> {
+ ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
+ return (systemClassLoader != null) ? systemClassLoader.loadClass(name) : bootClassLoader.loadClass(name);
}, controlContext);
} catch (PrivilegedActionException e) {
if (e.getException() instanceof ClassNotFoundException)
@@ -491,12 +390,9 @@ public class SecureAction {
tracker.open();
return;
}
- AccessController.doPrivileged(new PrivilegedAction<Void>() {
- @Override
- public Void run() {
- tracker.open();
- return null;
- }
+ AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
+ tracker.open();
+ return null;
}, controlContext);
}
@@ -512,12 +408,9 @@ public class SecureAction {
return;
}
try {
- AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
- @Override
- public Void run() throws BundleException {
- module.start(options);
- return null;
- }
+ AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
+ module.start(options);
+ return null;
}, controlContext);
return;
} catch (PrivilegedActionException e) {
@@ -531,23 +424,13 @@ public class SecureAction {
if (System.getSecurityManager() == null) {
return bundle.getBundleContext();
}
- return AccessController.doPrivileged(new PrivilegedAction<BundleContext>() {
- @Override
- public BundleContext run() {
- return bundle.getBundleContext();
- }
- }, controlContext);
+ return AccessController.doPrivileged((PrivilegedAction<BundleContext>) () -> bundle.getBundleContext(), controlContext);
}
public String getLocation(final Bundle bundle) {
if (System.getSecurityManager() == null) {
return bundle.getLocation();
}
- return AccessController.doPrivileged(new PrivilegedAction<String>() {
- @Override
- public String run() {
- return bundle.getLocation();
- }
- }, controlContext);
+ return AccessController.doPrivileged((PrivilegedAction<String>) () -> bundle.getLocation(), 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 a5f5a656e..aaf97974a 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
@@ -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
@@ -30,7 +30,6 @@ import org.eclipse.osgi.container.ModuleContainerAdaptor.ModuleEvent;
import org.eclipse.osgi.container.ModuleRevisionBuilder;
import org.eclipse.osgi.internal.framework.EquinoxConfiguration;
import org.eclipse.osgi.internal.framework.EquinoxContainer.ConnectModules;
-import org.eclipse.osgi.internal.hookregistry.ActivatorHookFactory;
import org.eclipse.osgi.internal.hookregistry.ClassLoaderHook;
import org.eclipse.osgi.internal.hookregistry.HookConfigurator;
import org.eclipse.osgi.internal.hookregistry.HookRegistry;
@@ -160,28 +159,24 @@ public class ConnectHookConfigurator implements HookConfigurator {
}
});
- hookRegistry.addActivatorHookFactory(new ActivatorHookFactory() {
-
- @Override
- public BundleActivator createActivator() {
- final List<BundleActivator> activators = new ArrayList<>();
- moduleConnector.newBundleActivator().ifPresent((a) -> activators.add(a));
- return new BundleActivator() {
- @Override
- public void start(BundleContext context) throws Exception {
- for (BundleActivator activator : activators) {
- activator.start(context);
- }
+ hookRegistry.addActivatorHookFactory(() -> {
+ final List<BundleActivator> activators = new ArrayList<>();
+ moduleConnector.newBundleActivator().ifPresent((a) -> activators.add(a));
+ return new BundleActivator() {
+ @Override
+ public void start(BundleContext context) throws Exception {
+ for (BundleActivator activator : activators) {
+ activator.start(context);
}
+ }
- @Override
- public void stop(BundleContext context) throws Exception {
- for (BundleActivator activator : activators) {
- activator.stop(context);
- }
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ for (BundleActivator activator : activators) {
+ activator.stop(context);
}
- };
- }
+ }
+ };
});
}
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/BundleContextImpl.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/BundleContextImpl.java
index 00f05f74f..3d358d9f0 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/BundleContextImpl.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/BundleContextImpl.java
@@ -243,12 +243,9 @@ public class BundleContextImpl implements BundleContext, EventDispatcher<Object,
if (System.getSecurityManager() == null) {
notifyFindHooksPriviledged(context, shrinkable);
} else {
- AccessController.doPrivileged(new PrivilegedAction<Void>() {
- @Override
- public Void run() {
- notifyFindHooksPriviledged(context, shrinkable);
- return null;
- }
+ AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
+ notifyFindHooksPriviledged(context, shrinkable);
+ return null;
});
}
}
@@ -803,22 +800,19 @@ public class BundleContextImpl implements BundleContext, EventDispatcher<Object,
*/
private void startActivator(final BundleActivator bundleActivator) throws BundleException {
try {
- AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
- @Override
- public Void run() throws Exception {
- if (bundleActivator != null) {
- // make sure the context class loader is set correctly
- Object previousTCCL = setContextFinder();
- /* Start the bundle synchronously */
- try {
- bundleActivator.start(BundleContextImpl.this);
- } finally {
- if (previousTCCL != Boolean.FALSE)
- Thread.currentThread().setContextClassLoader((ClassLoader) previousTCCL);
- }
+ AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
+ if (bundleActivator != null) {
+ // make sure the context class loader is set correctly
+ Object previousTCCL = setContextFinder();
+ /* Start the bundle synchronously */
+ try {
+ bundleActivator.start(BundleContextImpl.this);
+ } finally {
+ if (previousTCCL != Boolean.FALSE)
+ Thread.currentThread().setContextClassLoader((ClassLoader) previousTCCL);
}
- return null;
}
+ return null;
});
} catch (Throwable t) {
if (t instanceof PrivilegedActionException) {
@@ -860,22 +854,19 @@ public class BundleContextImpl implements BundleContext, EventDispatcher<Object,
protected void stop() throws BundleException {
try {
final BundleActivator bundleActivator = activator;
- AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
- @Override
- public Void run() throws Exception {
- if (bundleActivator != null) {
- // make sure the context class loader is set correctly
- Object previousTCCL = setContextFinder();
- try {
- /* Stop the bundle synchronously */
- bundleActivator.stop(BundleContextImpl.this);
- } finally {
- if (previousTCCL != Boolean.FALSE)
- Thread.currentThread().setContextClassLoader((ClassLoader) previousTCCL);
- }
+ AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
+ if (bundleActivator != null) {
+ // make sure the context class loader is set correctly
+ Object previousTCCL = setContextFinder();
+ try {
+ /* Stop the bundle synchronously */
+ bundleActivator.stop(BundleContextImpl.this);
+ } finally {
+ if (previousTCCL != Boolean.FALSE)
+ Thread.currentThread().setContextClassLoader((ClassLoader) previousTCCL);
}
- return null;
}
+ return null;
});
} catch (Throwable t) {
if (t instanceof PrivilegedActionException) {
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/ContextFinder.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/ContextFinder.java
index 584427a07..1cf990985 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/ContextFinder.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/ContextFinder.java
@@ -43,13 +43,10 @@ public class ContextFinder extends ClassLoader implements PrivilegedAction<List<
static ClassLoader finderClassLoader;
static Finder contextFinder;
static {
- AccessController.doPrivileged(new PrivilegedAction<Void>() {
- @Override
- public Void run() {
- finderClassLoader = ContextFinder.class.getClassLoader();
- contextFinder = new Finder();
- return null;
- }
+ AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
+ finderClassLoader = ContextFinder.class.getClassLoader();
+ contextFinder = new Finder();
+ return null;
});
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxBundle.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxBundle.java
index a10414785..fecdf7a95 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxBundle.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxBundle.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2020 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
@@ -219,14 +219,11 @@ public class EquinoxBundle implements Bundle, BundleReference {
if (Module.ACTIVE_SET.contains(getState())) {
// TODO this still has a chance of a race condition:
// multiple threads could get started if stop is called over and over
- Thread t = new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- stop();
- } catch (Throwable e) {
- SystemBundle.this.getEquinoxContainer().getLogServices().log(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, "Error stopping the framework.", e); //$NON-NLS-1$
- }
+ Thread t = new Thread((Runnable) () -> {
+ try {
+ stop();
+ } catch (Throwable e) {
+ SystemBundle.this.getEquinoxContainer().getLogServices().log(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, "Error stopping the framework.", e); //$NON-NLS-1$
}
}, "Framework stop - " + getEquinoxContainer().toString()); //$NON-NLS-1$
t.start();
@@ -243,14 +240,11 @@ public class EquinoxBundle implements Bundle, BundleReference {
lockStateChange(ModuleEvent.UPDATED);
try {
if (Module.ACTIVE_SET.contains(getState())) {
- Thread t = new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- update();
- } catch (Throwable e) {
- SystemBundle.this.getEquinoxContainer().getLogServices().log(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, "Error updating the framework.", e); //$NON-NLS-1$
- }
+ Thread t = new Thread((Runnable) () -> {
+ try {
+ update();
+ } catch (Throwable e) {
+ SystemBundle.this.getEquinoxContainer().getLogServices().log(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, "Error updating the framework.", e); //$NON-NLS-1$
}
}, "Framework update - " + getEquinoxContainer().toString()); //$NON-NLS-1$
t.start();
@@ -643,18 +637,15 @@ public class EquinoxBundle implements Bundle, BundleReference {
String reportMessage = report.getResolutionReportMessage(module.getCurrentRevision());
equinoxContainer.getEventPublisher().publishFrameworkEvent(FrameworkEvent.ERROR, this, new BundleException(reportMessage, BundleException.RESOLVE_ERROR));
}
- return AccessController.doPrivileged(new PrivilegedAction<ModuleClassLoader>() {
- @Override
- public ModuleClassLoader run() {
- ModuleWiring wiring = getModule().getCurrentRevision().getWiring();
- if (wiring != null) {
- ModuleLoader moduleLoader = wiring.getModuleLoader();
- if (moduleLoader instanceof BundleLoader) {
- return ((BundleLoader) moduleLoader).getModuleClassLoader();
- }
+ return AccessController.doPrivileged((PrivilegedAction<ModuleClassLoader>) () -> {
+ ModuleWiring wiring = getModule().getCurrentRevision().getWiring();
+ if (wiring != null) {
+ ModuleLoader moduleLoader = wiring.getModuleLoader();
+ if (moduleLoader instanceof BundleLoader) {
+ return ((BundleLoader) moduleLoader).getModuleClassLoader();
}
- return null;
}
+ return null;
});
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java
index 626ff65fd..3bf21228b 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java
@@ -125,38 +125,27 @@ public class EquinoxContainerAdaptor extends ModuleContainerAdaptor {
private Callable<Executor> createLazyExecutorCreator(final String threadName, int threadCnt, final BlockingQueue<Runnable> queue) {
// use the number of processors when configured value is <=0
final int maxThreads = threadCnt <= 0 ? Runtime.getRuntime().availableProcessors() : threadCnt;
- return new Callable<Executor>() {
- @Override
- public Executor call() throws Exception {
- if (maxThreads == 1) {
- // just do synchronous execution with current thread
- return new Executor() {
- @Override
- public void execute(Runnable command) {
- command.run();
- }
- };
- }
- // Always want to create core threads until max size
- int coreThreads = maxThreads;
- // idle timeout; make it short to get rid of threads quickly after use
- int idleTimeout = 10;
- // try to name the threads with useful name
- ThreadFactory threadFactory = new ThreadFactory() {
- @Override
- public Thread newThread(Runnable r) {
- Thread t = new Thread(r, threadName);
- t.setDaemon(true);
- return t;
- }
- };
- // use a rejection policy that simply runs the task in the current thread once the max pool size is reached
- RejectedExecutionHandler rejectHandler = new ThreadPoolExecutor.CallerRunsPolicy();
-
- ThreadPoolExecutor executor = new ThreadPoolExecutor(coreThreads, maxThreads, idleTimeout, TimeUnit.SECONDS, queue, threadFactory, rejectHandler);
- executor.allowCoreThreadTimeOut(true);
- return executor;
+ return () -> {
+ if (maxThreads == 1) {
+ // just do synchronous execution with current thread
+ return command -> command.run();
}
+ // Always want to create core threads until max size
+ int coreThreads = maxThreads;
+ // idle timeout; make it short to get rid of threads quickly after use
+ int idleTimeout = 10;
+ // try to name the threads with useful name
+ ThreadFactory threadFactory = r -> {
+ Thread t = new Thread(r, threadName);
+ t.setDaemon(true);
+ return t;
+ };
+ // use a rejection policy that simply runs the task in the current thread once the max pool size is reached
+ RejectedExecutionHandler rejectHandler = new ThreadPoolExecutor.CallerRunsPolicy();
+
+ ThreadPoolExecutor executor = new ThreadPoolExecutor(coreThreads, maxThreads, idleTimeout, TimeUnit.SECONDS, queue, threadFactory, rejectHandler);
+ executor.allowCoreThreadTimeOut(true);
+ return executor;
};
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxEventPublisher.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxEventPublisher.java
index 71b167bce..cd52303cc 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxEventPublisher.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxEventPublisher.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2020 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
@@ -137,12 +137,9 @@ public class EquinoxEventPublisher {
if (System.getSecurityManager() == null) {
publishBundleEventPrivileged(event);
} else {
- AccessController.doPrivileged(new PrivilegedAction<Void>() {
- @Override
- public Void run() {
- publishBundleEventPrivileged(event);
- return null;
- }
+ AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
+ publishBundleEventPrivileged(event);
+ return null;
});
}
}
@@ -279,12 +276,9 @@ public class EquinoxEventPublisher {
if (System.getSecurityManager() == null) {
publishFrameworkEventPrivileged(event, listeners);
} else {
- AccessController.doPrivileged(new PrivilegedAction<Void>() {
- @Override
- public Void run() {
- publishFrameworkEventPrivileged(event, listeners);
- return null;
- }
+ AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
+ publishFrameworkEventPrivileged(event, listeners);
+ return null;
});
}
}
@@ -425,13 +419,7 @@ public class EquinoxEventPublisher {
}
void flushFrameworkEvents() {
- EventDispatcher<Object, Object, CountDownLatch> dispatcher = new EventDispatcher<Object, Object, CountDownLatch>() {
- @Override
- public void dispatchEvent(Object eventListener, Object listenerObject, int eventAction, CountDownLatch flushedSignal) {
- // Signal that we have flushed all events
- flushedSignal.countDown();
- }
- };
+ EventDispatcher<Object, Object, CountDownLatch> dispatcher = (eventListener, listenerObject, eventAction, flushedSignal) -> flushedSignal.countDown();
ListenerQueue<Object, Object, CountDownLatch> queue = newListenerQueue();
queue.queueListeners(Collections.<Object, Object> singletonMap(dispatcher, dispatcher).entrySet(), dispatcher);
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/FilterImpl.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/FilterImpl.java
index 563af451a..d30701f77 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/FilterImpl.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/FilterImpl.java
@@ -1018,12 +1018,9 @@ public abstract class FilterImpl implements Filter {
private static void setAccessible(final AccessibleObject accessible) {
if (!accessible.isAccessible()) {
- AccessController.doPrivileged(new PrivilegedAction<Void>() {
- @Override
- public Void run() {
- accessible.setAccessible(true);
- return null;
- }
+ AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
+ accessible.setAccessible(true);
+ return null;
});
}
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/OSGiFrameworkHooks.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/OSGiFrameworkHooks.java
index 15adb5f96..c5c422947 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/OSGiFrameworkHooks.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/OSGiFrameworkHooks.java
@@ -100,12 +100,9 @@ class OSGiFrameworkHooks {
if (System.getSecurityManager() == null) {
notifyCollisionHooksPriviledged(operationType, target, shrinkable);
} else {
- AccessController.doPrivileged(new PrivilegedAction<Void>() {
- @Override
- public Void run() {
- notifyCollisionHooksPriviledged(operationType, target, shrinkable);
- return null;
- }
+ AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
+ notifyCollisionHooksPriviledged(operationType, target, shrinkable);
+ return null;
});
}
}
@@ -168,17 +165,14 @@ class OSGiFrameworkHooks {
}
private ServiceReferenceImpl<ResolverHookFactory>[] getHookReferences(final ServiceRegistry registry, final BundleContextImpl context) {
- return AccessController.doPrivileged(new PrivilegedAction<ServiceReferenceImpl<ResolverHookFactory>[]>() {
- @Override
- public ServiceReferenceImpl<ResolverHookFactory>[] run() {
- try {
- @SuppressWarnings("unchecked")
- ServiceReferenceImpl<ResolverHookFactory>[] result = (ServiceReferenceImpl<ResolverHookFactory>[]) registry.getServiceReferences(context, ResolverHookFactory.class.getName(), null, false);
- return result;
- } catch (InvalidSyntaxException e) {
- // cannot happen; no filter
- return null;
- }
+ return AccessController.doPrivileged((PrivilegedAction<ServiceReferenceImpl<ResolverHookFactory>[]>) () -> {
+ try {
+ @SuppressWarnings("unchecked")
+ ServiceReferenceImpl<ResolverHookFactory>[] result = (ServiceReferenceImpl<ResolverHookFactory>[]) registry.getServiceReferences(context, ResolverHookFactory.class.getName(), null, false);
+ return result;
+ } catch (InvalidSyntaxException e) {
+ // cannot happen; no filter
+ return null;
}
});
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/legacy/PackageAdminImpl.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/legacy/PackageAdminImpl.java
index b28b28dbb..4d0dfec70 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/legacy/PackageAdminImpl.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/legacy/PackageAdminImpl.java
@@ -18,7 +18,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
-import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -198,12 +197,7 @@ public class PackageAdminImpl implements PackageAdmin {
sorted.add(b);
}
}
- Collections.sort(sorted, new Comparator<Bundle>() {
- @Override
- public int compare(Bundle b1, Bundle b2) {
- return b2.getVersion().compareTo(b1.getVersion());
- }
- });
+ Collections.sort(sorted, (b1, b2) -> b2.getVersion().compareTo(b1.getVersion()));
if (sorted.isEmpty()) {
return null;
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 716f0789a..22a4ff1ca 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,12 +74,7 @@ public class BundleLoader extends ModuleLoader {
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(new PrivilegedAction<ClassContext>() {
- @Override
- public ClassContext run() {
- return new ClassContext();
- }
- });
+ public final static ClassContext CLASS_CONTEXT = AccessController.doPrivileged((PrivilegedAction<ClassContext>) () -> new ClassContext());
public final static ClassLoader FW_CLASSLOADER = getClassLoader(EquinoxContainer.class);
private static final int PRE_CLASS = 1;
@@ -266,12 +261,7 @@ public class BundleLoader extends ModuleLoader {
result = createClassLoaderPrivledged(parent, generation.getBundleInfo().getStorage().getConfiguration(), this, generation, hooks);
} else {
final ClassLoader cl = parent;
- result = AccessController.doPrivileged(new PrivilegedAction<ModuleClassLoader>() {
- @Override
- public ModuleClassLoader run() {
- return createClassLoaderPrivledged(cl, generation.getBundleInfo().getStorage().getConfiguration(), BundleLoader.this, generation, hooks);
- }
- });
+ result = AccessController.doPrivileged((PrivilegedAction<ModuleClassLoader>) () -> createClassLoaderPrivledged(cl, generation.getBundleInfo().getStorage().getConfiguration(), BundleLoader.this, generation, hooks));
}
// Synchronize on classLoaderCreatedMonitor in order to ensure hooks are called before returning.
@@ -285,15 +275,11 @@ public class BundleLoader extends ModuleLoader {
// only send to hooks if this thread wins in creating the class loader.
final ModuleClassLoader cl = result;
// protect with doPriv to avoid bubbling up permission checks that hooks may require
- AccessController.doPrivileged(new PrivilegedAction<Object>() {
- @Override
- public Object run() {
- for (ClassLoaderHook hook : hooks) {
- hook.classLoaderCreated(cl);
- }
- return null;
+ AccessController.doPrivileged((PrivilegedAction<Object>) () -> {
+ for (ClassLoaderHook hook : hooks) {
+ hook.classLoaderCreated(cl);
}
-
+ return null;
});
// finally set the class loader for use after calling hooks
classloader = classLoaderCreated;
@@ -597,12 +583,7 @@ public class BundleLoader extends ModuleLoader {
private static ClassLoader getClassLoader(final Class<?> clazz) {
if (System.getSecurityManager() == null)
return clazz.getClassLoader();
- return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
- @Override
- public ClassLoader run() {
- return clazz.getClassLoader();
- }
- });
+ return AccessController.doPrivileged((PrivilegedAction<ClassLoader>) () -> clazz.getClassLoader());
}
/**
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/buddy/SystemPolicy.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/buddy/SystemPolicy.java
index 4a5d02698..27b18f22d 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/buddy/SystemPolicy.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/buddy/SystemPolicy.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2016 IBM Corporation and others.
+ * Copyright (c) 2005, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -32,12 +32,7 @@ public class SystemPolicy implements IBuddyPolicy {
public static SystemPolicy getInstance(final byte type, final ClassLoader bootLoader) {
if (instances[type] == null) {
instances[type] = new SystemPolicy();
- instances[type].classLoader = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
- @Override
- public ClassLoader run() {
- return createClassLoader(type, bootLoader);
- }
- });
+ instances[type].classLoader = AccessController.doPrivileged((PrivilegedAction<ClassLoader>) () -> createClassLoader(type, bootLoader));
}
return instances[type];
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EventAdminLogListener.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EventAdminLogListener.java
index b196c592a..983265fc2 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EventAdminLogListener.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EventAdminLogListener.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2020 IBM Corporation
+ * Copyright (c) 2007, 2021 IBM Corporation
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -69,13 +69,10 @@ public class EventAdminLogListener implements SynchronousLogListener {
@Override
public void logged(final LogEntry entry) {
try {
- AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
- @Override
- public Void run() throws Exception {
- Object convertedEvent = convertEvent(entry);
- postEvent.invoke(eventAdmin, convertedEvent);
- return null;
- }
+ AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
+ Object convertedEvent = convertEvent(entry);
+ postEvent.invoke(eventAdmin, convertedEvent);
+ return null;
});
} catch (PrivilegedActionException e) {
Throwable cause = e.getCause();
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogReaderServiceFactory.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogReaderServiceFactory.java
index 4972ccf1f..6f8efebaa 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogReaderServiceFactory.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogReaderServiceFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2018 Cognos Incorporated, IBM Corporation and others
+ * Copyright (c) 2006, 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
@@ -60,12 +60,7 @@ public class ExtendedLogReaderServiceFactory implements ServiceFactory<ExtendedL
@SuppressWarnings("unchecked")
private static final Enumeration<LogEntry> EMPTY_ENUMERATION = Collections.enumeration(Collections.EMPTY_LIST);
- static final LogFilter NULL_LOGGER_FILTER = new LogFilter() {
- @Override
- public boolean isLoggable(Bundle b, String loggerName, int logLevel) {
- return true;
- }
- };
+ static final LogFilter NULL_LOGGER_FILTER = (b, loggerName, logLevel) -> true;
private static final LogFilter[] ALWAYS_LOG = new LogFilter[0];
@@ -151,12 +146,7 @@ public class ExtendedLogReaderServiceFactory implements ServiceFactory<ExtendedL
boolean isLoggable(final Bundle bundle, final String name, final int level) {
if (System.getSecurityManager() != null) {
- return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
- @Override
- public Boolean run() {
- return isLoggablePrivileged(bundle, name, level);
- }
- });
+ return AccessController.doPrivileged((PrivilegedAction<Boolean>) () -> isLoggablePrivileged(bundle, name, level));
}
return isLoggablePrivileged(bundle, name, level);
}
@@ -214,12 +204,9 @@ public class ExtendedLogReaderServiceFactory implements ServiceFactory<ExtendedL
void log(final Bundle bundle, final String name, final StackTraceElement stackTraceElement, final Object context, final LogLevel logLevelEnum, final int level, final String message, final ServiceReference<?> ref, final Throwable exception) {
if (System.getSecurityManager() != null) {
- AccessController.doPrivileged(new PrivilegedAction<Void>() {
- @Override
- public Void run() {
- logPrivileged(bundle, name, stackTraceElement, context, logLevelEnum, level, message, ref, exception);
- return null;
- }
+ AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
+ logPrivileged(bundle, name, stackTraceElement, context, logLevelEnum, level, message, ref, exception);
+ return null;
});
} else {
logPrivileged(bundle, name, stackTraceElement, context, logLevelEnum, level, message, ref, exception);
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/PermissionInfoCollection.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/PermissionInfoCollection.java
index 07ed021a0..34b895bcf 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/PermissionInfoCollection.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/PermissionInfoCollection.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
@@ -91,12 +91,9 @@ public final class PermissionInfoCollection extends PermissionCollection {
}
try {
final PermissionCollection targetCollection = collection;
- AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
- @Override
- public Object run() throws Exception {
- addPermissions(bundlePermissions, targetCollection, permClass);
- return null;
- }
+ AccessController.doPrivileged((PrivilegedExceptionAction<Object>) () -> {
+ addPermissions(bundlePermissions, targetCollection, permClass);
+ return null;
});
} catch (Exception e) {
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceFactoryUse.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceFactoryUse.java
index 18dff7ba1..374ee21f3 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceFactoryUse.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceFactoryUse.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2013 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
@@ -210,12 +210,7 @@ public class ServiceFactoryUse<S> extends ServiceUse<S> {
S factoryGetService() {
final S service;
try {
- service = AccessController.doPrivileged(new PrivilegedAction<S>() {
- @Override
- public S run() {
- return factory.getService(context.getBundleImpl(), registration);
- }
- });
+ service = AccessController.doPrivileged((PrivilegedAction<S>) () -> factory.getService(context.getBundleImpl(), registration));
} catch (Throwable t) {
if (debug.DEBUG_SERVICES) {
Debug.println(factory + ".getService() exception: " + t.getMessage()); //$NON-NLS-1$
@@ -259,12 +254,9 @@ public class ServiceFactoryUse<S> extends ServiceUse<S> {
/* @GuardedBy("this") */
void factoryUngetService(final S service) {
try {
- AccessController.doPrivileged(new PrivilegedAction<Void>() {
- @Override
- public Void run() {
- factory.ungetService(context.getBundleImpl(), registration, service);
- return null;
- }
+ AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
+ factory.ungetService(context.getBundleImpl(), registration, service);
+ return null;
});
} catch (Throwable t) {
if (debug.DEBUG_SERVICES) {
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceRegistry.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceRegistry.java
index 9f9f691fd..a271d3b3a 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceRegistry.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceRegistry.java
@@ -872,12 +872,9 @@ public class ServiceRegistry {
if (System.getSecurityManager() == null) {
publishServiceEventPrivileged(event);
} else {
- AccessController.doPrivileged(new PrivilegedAction<Void>() {
- @Override
- public Void run() {
- publishServiceEventPrivileged(event);
- return null;
- }
+ AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
+ publishServiceEventPrivileged(event);
+ return null;
});
}
}
@@ -1180,12 +1177,7 @@ public class ServiceRegistry {
* @return The name of the class that is not satisfied by the service object.
*/
static String checkServiceClass(final String[] clazzes, final Object serviceObject) {
- ClassLoader cl = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
- @Override
- public ClassLoader run() {
- return serviceObject.getClass().getClassLoader();
- }
- });
+ ClassLoader cl = AccessController.doPrivileged((PrivilegedAction<ClassLoader>) () -> serviceObject.getClass().getClassLoader());
for (int i = 0, len = clazzes.length; i < len; i++) {
try {
Class<?> serviceClazz = cl == null ? Class.forName(clazzes[i]) : cl.loadClass(clazzes[i]);
@@ -1238,12 +1230,9 @@ public class ServiceRegistry {
if (System.getSecurityManager() == null) {
notifyFindHooksPrivileged(context, clazz, filterstring, allservices, result);
} else {
- AccessController.doPrivileged(new PrivilegedAction<Void>() {
- @Override
- public Void run() {
- notifyFindHooksPrivileged(context, clazz, filterstring, allservices, result);
- return null;
- }
+ AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
+ notifyFindHooksPrivileged(context, clazz, filterstring, allservices, result);
+ return null;
});
}
}
@@ -1357,12 +1346,9 @@ public class ServiceRegistry {
if (System.getSecurityManager() == null) {
notifyNewListenerHookPrivileged(registration);
} else {
- AccessController.doPrivileged(new PrivilegedAction<Void>() {
- @Override
- public Void run() {
- notifyNewListenerHookPrivileged(registration);
- return null;
- }
+ AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
+ notifyNewListenerHookPrivileged(registration);
+ return null;
});
}
@@ -1405,12 +1391,9 @@ public class ServiceRegistry {
if (System.getSecurityManager() == null) {
notifyListenerHooksPrivileged(listeners, added);
} else {
- AccessController.doPrivileged(new PrivilegedAction<Void>() {
- @Override
- public Void run() {
- notifyListenerHooksPrivileged(listeners, added);
- return null;
- }
+ AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
+ notifyListenerHooksPrivileged(listeners, added);
+ return null;
});
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/MultiplexingFactory.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/MultiplexingFactory.java
index a11552620..2a1017c77 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/MultiplexingFactory.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/MultiplexingFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2016 Cognos Incorporated, IBM Corporation and others.
+ * Copyright (c) 2006, 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
@@ -232,12 +232,7 @@ public abstract class MultiplexingFactory {
private boolean isSystemClass(final Class<?> clazz) {
// we want to ignore classes from the system
- ClassLoader cl = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
- @Override
- public ClassLoader run() {
- return clazz.getClassLoader();
- }
- });
+ ClassLoader cl = AccessController.doPrivileged((PrivilegedAction<ClassLoader>) () -> clazz.getClassLoader());
return cl == null || systemLoaders.contains(cl);
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/weaving/WovenClassImpl.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/weaving/WovenClassImpl.java
index 9326e92b9..6230f70e8 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/weaving/WovenClassImpl.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/weaving/WovenClassImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2020 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
@@ -229,12 +229,9 @@ public final class WovenClassImpl implements WovenClass, HookContext<WeavingHook
registry.notifyHooksPrivileged(WovenClassListener.class, "modified", context); //$NON-NLS-1$
else {
try {
- AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
- @Override
- public Void run() {
- registry.notifyHooksPrivileged(WovenClassListener.class, "modified", context); //$NON-NLS-1$
- return null;
- }
+ AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
+ registry.notifyHooksPrivileged(WovenClassListener.class, "modified", context); //$NON-NLS-1$
+ return null;
});
} catch (PrivilegedActionException e) {
throw (RuntimeException) e.getException();
@@ -252,12 +249,9 @@ public final class WovenClassImpl implements WovenClass, HookContext<WeavingHook
registry.notifyHooksPrivileged(WeavingHook.class, "weave", this); //$NON-NLS-1$
} else {
try {
- AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
- @Override
- public Void run() {
- registry.notifyHooksPrivileged(WeavingHook.class, "weave", WovenClassImpl.this); //$NON-NLS-1$
- return null;
- }
+ AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
+ registry.notifyHooksPrivileged(WeavingHook.class, "weave", WovenClassImpl.this); //$NON-NLS-1$
+ return null;
});
} catch (PrivilegedActionException e) {
throw (RuntimeException) e.getException();
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/FrameworkExtensionInstaller.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/FrameworkExtensionInstaller.java
index fba1658fc..52a4854eb 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/FrameworkExtensionInstaller.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/FrameworkExtensionInstaller.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
@@ -116,12 +116,9 @@ public class FrameworkExtensionInstaller {
addExtensionContent0(revisions, systemModule);
} else {
try {
- AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
- @Override
- public Void run() throws BundleException {
- addExtensionContent0(revisions, systemModule);
- return null;
- }
+ AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
+ addExtensionContent0(revisions, systemModule);
+ return null;
});
} catch (PrivilegedActionException e) {
throw (BundleException) e.getCause();
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java
index 81c924a83..f7be9b57c 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java
@@ -623,12 +623,7 @@ public class Storage {
private String getUpdateLocation(final Module module) {
if (System.getSecurityManager() == null)
return getUpdateLocation0(module);
- return AccessController.doPrivileged(new PrivilegedAction<String>() {
- @Override
- public String run() {
- return getUpdateLocation0(module);
- }
- });
+ return AccessController.doPrivileged((PrivilegedAction<String>) () -> getUpdateLocation0(module));
}
String getUpdateLocation0(Module module) {
@@ -649,12 +644,7 @@ public class Storage {
return LocationHelper.getConnection(createURL(spec));
}
try {
- return AccessController.doPrivileged(new PrivilegedExceptionAction<URLConnection>() {
- @Override
- public URLConnection run() throws IOException {
- return LocationHelper.getConnection(createURL(spec));
- }
- });
+ return AccessController.doPrivileged((PrivilegedExceptionAction<URLConnection>) () -> LocationHelper.getConnection(createURL(spec)));
} catch (PrivilegedActionException e) {
if (e.getException() instanceof IOException)
throw (IOException) e.getException();
@@ -1002,12 +992,7 @@ public class Storage {
if (System.getSecurityManager() == null)
return getContentFile0(staged, contentType, bundleID, generationID);
try {
- return AccessController.doPrivileged(new PrivilegedExceptionAction<File>() {
- @Override
- public File run() throws BundleException {
- return getContentFile0(staged, contentType, bundleID, generationID);
- }
- });
+ return AccessController.doPrivileged((PrivilegedExceptionAction<File>) () -> getContentFile0(staged, contentType, bundleID, generationID));
} catch (PrivilegedActionException e) {
if (e.getException() instanceof BundleException)
throw (BundleException) e.getException();
@@ -1113,12 +1098,7 @@ public class Storage {
if (System.getSecurityManager() == null)
return stageContent0(in, sourceURL);
try {
- return AccessController.doPrivileged(new PrivilegedExceptionAction<File>() {
- @Override
- public File run() throws BundleException {
- return stageContent0(in, sourceURL);
- }
- });
+ return AccessController.doPrivileged((PrivilegedExceptionAction<File>) () -> stageContent0(in, sourceURL));
} catch (PrivilegedActionException e) {
if (e.getException() instanceof BundleException)
throw (BundleException) e.getException();
@@ -1276,12 +1256,9 @@ public class Storage {
delete0(delete);
} else {
try {
- AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
- @Override
- public Void run() throws IOException {
- delete0(delete);
- return null;
- }
+ AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
+ delete0(delete);
+ return null;
});
} catch (PrivilegedActionException e) {
if (e.getException() instanceof IOException)
@@ -1307,12 +1284,9 @@ public class Storage {
save0();
} else {
try {
- AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
- @Override
- public Void run() throws IOException {
- save0();
- return null;
- }
+ AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
+ save0();
+ return null;
});
} catch (PrivilegedActionException e) {
if (e.getException() instanceof IOException)
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/ZipBundleFile.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/ZipBundleFile.java
index 63003e118..b5ff4ff27 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/ZipBundleFile.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/ZipBundleFile.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2018 IBM Corporation and others.
+ * Copyright (c) 2005, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -102,28 +102,25 @@ public class ZipBundleFile extends CloseableBundleFile<ZipEntry> {
@Override
protected Iterable<String> getPaths() {
- return new Iterable<String>() {
- @Override
- public Iterator<String> iterator() {
- final Enumeration<? extends ZipEntry> entries = zipFile.entries();
- return new Iterator<String>() {
- @Override
- public boolean hasNext() {
- return entries.hasMoreElements();
- }
+ return () -> {
+ final Enumeration<? extends ZipEntry> entries = zipFile.entries();
+ return new Iterator<String>() {
+ @Override
+ public boolean hasNext() {
+ return entries.hasMoreElements();
+ }
- @Override
- public String next() {
- ZipEntry entry = entries.nextElement();
- return entry.getName();
- }
+ @Override
+ public String next() {
+ ZipEntry entry = entries.nextElement();
+ return entry.getName();
+ }
- @Override
- public void remove() {
- throw new UnsupportedOperationException();
- }
- };
- }
+ @Override
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ };
};
}
}
diff --git a/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/ResolverImpl.java b/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/ResolverImpl.java
index 14e6635ff..d2c02bf79 100755
--- a/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/ResolverImpl.java
+++ b/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/ResolverImpl.java
@@ -409,13 +409,7 @@ public class ResolverImpl implements Resolver
final ExecutorService executor =
System.getSecurityManager() != null ?
AccessController.doPrivileged(
- new PrivilegedAction<ExecutorService>()
- {
- public ExecutorService run()
- {
- return Executors.newFixedThreadPool(m_parallelism);
- }
- }, m_acc)
+ (PrivilegedAction<ExecutorService>) () -> Executors.newFixedThreadPool(m_parallelism), m_acc)
:
Executors.newFixedThreadPool(m_parallelism);
try
@@ -426,11 +420,9 @@ public class ResolverImpl implements Resolver
{
if (System.getSecurityManager() != null)
{
- AccessController.doPrivileged(new PrivilegedAction<Void>(){
- public Void run() {
- executor.shutdownNow();
- return null;
- }
+ AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
+ executor.shutdownNow();
+ return null;
}, m_acc);
}
else
@@ -1202,27 +1194,15 @@ public class ResolverImpl implements Resolver
{
final Packages packages = new Packages(resource);
allPackages.put(resource, packages);
- executor.execute(new Runnable()
- {
- public void run()
- {
- calculateExportedPackages(session, allCandidates, resource,
- packages.m_exportedPkgs, packages.m_substitePkgs);
- }
- });
+ executor.execute(() -> calculateExportedPackages(session, allCandidates, resource,
+ packages.m_exportedPkgs, packages.m_substitePkgs));
}
executor.await();
// Parallel compute package lists
for (final Resource resource : allWireCandidates.keySet())
{
- executor.execute(new Runnable()
- {
- public void run()
- {
- getPackages(session, allCandidates, allWireCandidates, allPackages, resource, allPackages.get(resource));
- }
- });
+ executor.execute(() -> getPackages(session, allCandidates, allWireCandidates, allPackages, resource, allPackages.get(resource)));
}
executor.await();
@@ -1247,13 +1227,7 @@ public class ResolverImpl implements Resolver
final Packages packages = entry.getValue();
if (packages.m_sources.isEmpty())
{
- executor.execute(new Runnable()
- {
- public void run()
- {
- getPackageSourcesInternal(session, allPackages, resource, packages);
- }
- });
+ executor.execute(() -> getPackageSourcesInternal(session, allPackages, resource, packages));
}
}
executor.await();
@@ -1261,13 +1235,7 @@ public class ResolverImpl implements Resolver
// Parallel compute uses
for (final Resource resource : allWireCandidates.keySet())
{
- executor.execute(new Runnable()
- {
- public void run()
- {
- computeUses(session, allWireCandidates, allPackages, resource);
- }
- });
+ executor.execute(() -> computeUses(session, allWireCandidates, allPackages, resource));
}
executor.await();
@@ -2511,18 +2479,14 @@ public class ResolverImpl implements Resolver
public void execute(final Runnable runnable)
{
- FutureTask<Void> task = new FutureTask<>(new Runnable()
- {
- public void run()
+ FutureTask<Void> task = new FutureTask<>(() -> {
+ try
{
- try
- {
- runnable.run();
- }
- catch (Throwable t)
- {
- throwable.compareAndSet(null, t);
- }
+ runnable.run();
+ }
+ catch (Throwable t)
+ {
+ throwable.compareAndSet(null, t);
}
}, (Void) null);
// must have a happens-first to add the task to awaiting
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 b27198c4d..0d8d12dc6 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,11 +631,7 @@ public class OpenHashMap<K, V> implements Serializable, Cloneable, SortedMap<K,
public Iterable<Map.Entry<K, V>> fast() {
if (fast == null) {
- fast = new Iterable<Entry<K, V>>() {
- public Iterator<Entry<K, V>> iterator() {
- return new FastEntryIterator();
- }
- };
+ fast = () -> new FastEntryIterator();
}
return fast;
diff --git a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/AdaptPermission.java b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/AdaptPermission.java
index b940a8c5c..fd002d828 100644
--- a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/AdaptPermission.java
+++ b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/AdaptPermission.java
@@ -440,21 +440,18 @@ public final class AdaptPermission extends BasicPermission {
final Map<String, Object> map = new HashMap<>(5);
map.put("adaptClass", getName());
if (bundle != null) {
- AccessController.doPrivileged(new PrivilegedAction<Void>() {
- @Override
- public Void run() {
- map.put("id", Long.valueOf(bundle.getBundleId()));
- map.put("location", bundle.getLocation());
- String name = bundle.getSymbolicName();
- if (name != null) {
- map.put("name", name);
- }
- SignerProperty signer = new SignerProperty(bundle);
- if (signer.isBundleSigned()) {
- map.put("signer", signer);
- }
- return null;
+ AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
+ map.put("id", Long.valueOf(bundle.getBundleId()));
+ map.put("location", bundle.getLocation());
+ String name = bundle.getSymbolicName();
+ if (name != null) {
+ map.put("name", name);
+ }
+ SignerProperty signer = new SignerProperty(bundle);
+ if (signer.isBundleSigned()) {
+ map.put("signer", signer);
}
+ return null;
});
}
return properties = map;
diff --git a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/AdminPermission.java b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/AdminPermission.java
index 354f476cc..e12085d70 100644
--- a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/AdminPermission.java
+++ b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/AdminPermission.java
@@ -840,21 +840,18 @@ public final class AdminPermission extends BasicPermission {
recurse.set(bundle);
try {
final Map<String, Object> map = new HashMap<>(4);
- AccessController.doPrivileged(new PrivilegedAction<Void>() {
- @Override
- public Void run() {
- map.put("id", Long.valueOf(bundle.getBundleId()));
- map.put("location", bundle.getLocation());
- String name = bundle.getSymbolicName();
- if (name != null) {
- map.put("name", name);
- }
- SignerProperty signer = new SignerProperty(bundle);
- if (signer.isBundleSigned()) {
- map.put("signer", signer);
- }
- return null;
+ AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
+ map.put("id", Long.valueOf(bundle.getBundleId()));
+ map.put("location", bundle.getLocation());
+ String name = bundle.getSymbolicName();
+ if (name != null) {
+ map.put("name", name);
+ }
+ SignerProperty signer = new SignerProperty(bundle);
+ if (signer.isBundleSigned()) {
+ map.put("signer", signer);
}
+ return null;
});
return properties = map;
} finally {
diff --git a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/CapabilityPermission.java b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/CapabilityPermission.java
index 045e9bfb4..facdb2896 100644
--- a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/CapabilityPermission.java
+++ b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/CapabilityPermission.java
@@ -504,21 +504,18 @@ public final class CapabilityPermission extends BasicPermission {
if (bundle == null) {
return properties = props;
}
- AccessController.doPrivileged(new PrivilegedAction<Void>() {
- @Override
- public Void run() {
- props.put("id", Long.valueOf(bundle.getBundleId()));
- props.put("location", bundle.getLocation());
- String name = bundle.getSymbolicName();
- if (name != null) {
- props.put("name", name);
- }
- SignerProperty signer = new SignerProperty(bundle);
- if (signer.isBundleSigned()) {
- props.put("signer", signer);
- }
- return null;
+ AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
+ props.put("id", Long.valueOf(bundle.getBundleId()));
+ props.put("location", bundle.getLocation());
+ String name = bundle.getSymbolicName();
+ if (name != null) {
+ props.put("name", name);
}
+ SignerProperty signer = new SignerProperty(bundle);
+ if (signer.isBundleSigned()) {
+ props.put("signer", signer);
+ }
+ return null;
});
return properties = new Properties(props, attributes);
}
diff --git a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/PackagePermission.java b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/PackagePermission.java
index a2329ae9b..0d6c37025 100644
--- a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/PackagePermission.java
+++ b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/PackagePermission.java
@@ -541,21 +541,18 @@ public final class PackagePermission extends BasicPermission {
final Map<String, Object> map = new HashMap<>(5);
map.put("package.name", getName());
if (bundle != null) {
- AccessController.doPrivileged(new PrivilegedAction<Void>() {
- @Override
- public Void run() {
- map.put("id", Long.valueOf(bundle.getBundleId()));
- map.put("location", bundle.getLocation());
- String name = bundle.getSymbolicName();
- if (name != null) {
- map.put("name", name);
- }
- SignerProperty signer = new SignerProperty(bundle);
- if (signer.isBundleSigned()) {
- map.put("signer", signer);
- }
- return null;
+ AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
+ map.put("id", Long.valueOf(bundle.getBundleId()));
+ map.put("location", bundle.getLocation());
+ String name = bundle.getSymbolicName();
+ if (name != null) {
+ map.put("name", name);
+ }
+ SignerProperty signer = new SignerProperty(bundle);
+ if (signer.isBundleSigned()) {
+ map.put("signer", signer);
}
+ return null;
});
}
return properties = map;
diff --git a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/ServicePermission.java b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/ServicePermission.java
index bbf1b08ff..5bb32bfe1 100644
--- a/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/ServicePermission.java
+++ b/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/ServicePermission.java
@@ -559,21 +559,18 @@ public final class ServicePermission extends BasicPermission {
final Map<String, Object> props = new HashMap<>(4);
final Bundle bundle = service.getBundle();
if (bundle != null) {
- AccessController.doPrivileged(new PrivilegedAction<Void>() {
- @Override
- public Void run() {
- props.put("id", Long.valueOf(bundle.getBundleId()));
- props.put("location", bundle.getLocation());
- String name = bundle.getSymbolicName();
- if (name != null) {
- props.put("name", name);
- }
- SignerProperty signer = new SignerProperty(bundle);
- if (signer.isBundleSigned()) {
- props.put("signer", signer);
- }
- return null;
+ AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
+ props.put("id", Long.valueOf(bundle.getBundleId()));
+ props.put("location", bundle.getLocation());
+ String name = bundle.getSymbolicName();
+ if (name != null) {
+ props.put("name", name);
}
+ SignerProperty signer = new SignerProperty(bundle);
+ if (signer.isBundleSigned()) {
+ props.put("signer", signer);
+ }
+ return null;
});
}
return properties = new Properties(props, service);
diff --git a/bundles/org.eclipse.osgi/osgi/src/org/osgi/service/condpermadmin/BundleLocationCondition.java b/bundles/org.eclipse.osgi/osgi/src/org/osgi/service/condpermadmin/BundleLocationCondition.java
index d59d86998..f46779f10 100644
--- a/bundles/org.eclipse.osgi/osgi/src/org/osgi/service/condpermadmin/BundleLocationCondition.java
+++ b/bundles/org.eclipse.osgi/osgi/src/org/osgi/service/condpermadmin/BundleLocationCondition.java
@@ -66,12 +66,7 @@ public class BundleLocationCondition {
String[] args = info.getArgs();
if (args.length != 1 && args.length != 2)
throw new IllegalArgumentException("Illegal number of args: " + args.length);
- String bundleLocation = AccessController.doPrivileged(new PrivilegedAction<String>() {
- @Override
- public String run() {
- return bundle.getLocation();
- }
- });
+ String bundleLocation = AccessController.doPrivileged((PrivilegedAction<String>) () -> bundle.getLocation());
Filter filter = null;
try {
filter = FrameworkUtil.createFilter("(location=" + escapeLocation(args[0]) + ")");

Back to the top