Skip to content

Commit

Permalink
Perform clean code of bundles/org.eclipse.osgi
Browse files Browse the repository at this point in the history
  • Loading branch information
eclipse-equinox-bot committed Jan 30, 2025
1 parent 59b8eea commit 657162c
Show file tree
Hide file tree
Showing 90 changed files with 515 additions and 238 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,7 @@ final Map<ModuleRevision, ModuleWiring> getWiringsClone() {
try {
Map<ModuleRevision, ModuleWiring> clonedWirings = new HashMap<>(wirings);
clonedWirings.replaceAll(new BiFunction<ModuleRevision, ModuleWiring, ModuleWiring>() {
@Override
public ModuleWiring apply(ModuleRevision r, ModuleWiring w) {
return new ModuleWiring(r, w.getCapabilities(), w.getRequirements(), w.getProvidedWires(),
w.getRequiredWires(), w.getSubstitutedNames());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ public Type getType() {
private final Map<Resource, List<Entry>> entries;
private final ResolutionException resolutionException;
private final Map<Resource, List<Wire>> resolutionResult;
private int totalPerm;
private int processedPerm;
private int usesPerm;
private int subPerm;
private int importPerm;
private final int totalPerm;
private final int processedPerm;
private final int usesPerm;
private final int subPerm;
private final int importPerm;

ModuleResolutionReport(Map<Resource, List<Wire>> resolutionResult, Map<Resource, List<Entry>> entries,
ResolutionException cause, int totalPerm, int processedPerm, int usesPerm, int subPerm, int importPerm) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,10 +507,12 @@ public void logUsesConstraintViolation(Resource resource, ResolutionError error)
}
}

@Override
public void logRequirement(String message, Requirement requirement) {
debug(String.format(message, ModuleContainer.toString(requirement)));
}

@Override
public void logCapability(String message, Capability requirement) {
debug(String.format(message, ModuleContainer.toString(requirement)));
}
Expand Down Expand Up @@ -643,8 +645,8 @@ public void logProcessPermutation(PermutationType type) {
private volatile boolean currentlyResolvingMandatory = false;
private final Set<Resource> transitivelyResolveFailures = new LinkedHashSet<>();
private final Set<Resource> failedToResolve = new HashSet<>();
private AtomicBoolean scheduleTimeout = new AtomicBoolean(true);
private AtomicReference<ScheduledFuture<?>> timoutFuture = new AtomicReference<>();
private final AtomicBoolean scheduleTimeout = new AtomicBoolean(true);
private final AtomicReference<ScheduledFuture<?>> timoutFuture = new AtomicReference<>();
/*
* Used to generate the UNRESOLVED_PROVIDER resolution report entries.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public final class ModuleRevision implements BundleRevision {

private NamespaceList<ModuleCapability> createCapabilities(NamespaceList.Builder<GenericInfo> capabilityInfos) {
return capabilityInfos.transformIntoCopy(new Function<GenericInfo, ModuleCapability>() {
@Override
public ModuleCapability apply(GenericInfo i) {
Map<String, String> directives = i.mutable ? copyUnmodifiableMap(i.directives) : i.directives;
Map<String, Object> attributes = i.mutable ? copyUnmodifiableMap(i.attributes) : i.attributes;
Expand All @@ -82,6 +83,7 @@ private <K, V> Map<K, V> copyUnmodifiableMap(Map<K, V> map) {

private NamespaceList<ModuleRequirement> createRequirements(NamespaceList.Builder<GenericInfo> infos) {
return infos.transformIntoCopy(new Function<GenericInfo, ModuleRequirement>() {
@Override
public ModuleRequirement apply(GenericInfo i) {
return new ModuleRequirement(i.namespace, i.directives, i.attributes, ModuleRevision.this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public final class ModuleRevisionBuilder {
*/
public static class GenericInfo {
final static Function<GenericInfo, String> GETNAMESPACE = new Function<GenericInfo, String>() {
@Override
public String apply(GenericInfo info) {
return info.getNamespace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public class EquinoxModuleDataNamespace extends Namespace {
*
* @deprecated use {@link #LAZYSTART_HEADER}
*/
@Deprecated
public static final String AUTOSTART_HEADER = "Eclipse-AutoStart"; //$NON-NLS-1$

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public static Headers<String, String> parseManifest(InputStream in) throws Bundl
}

private static class ArrayEnumeration<E> implements Enumeration<E> {
private E[] array;
private final E[] array;
int cur = 0;

public ArrayEnumeration(E[] array, int size) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
*/
public class SecureAction {
// make sure we use the correct controlContext;
private AccessControlContext controlContext;
private final AccessControlContext controlContext;

// uses initialization-on-demand holder idiom to do fast lazy loading
private static class BootClassLoaderHolder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public int read() throws IOException {
throw new IOException();
}

@Override
public File getContent() {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,14 @@ public Vertex(Object id) {
*
* Element type: <code>Vertex</code>
*/
private List<Vertex> vertexList = new ArrayList<>(100);
private final List<Vertex> vertexList = new ArrayList<>(100);

/**
* Map from id to vertex.
*
* Key type: <code>Object</code>; value type: <code>Vertex</code>
*/
private Map<Object, Vertex> vertexMap = new HashMap<>(100);
private final Map<Object, Vertex> vertexMap = new HashMap<>(100);

/**
* DFS visit time. Non-negative.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,19 @@
public class NamespaceList<E> {

public final static Function<ModuleWire, String> WIRE = new Function<ModuleWire, String>() {
@Override
public String apply(ModuleWire wire) {
return wire.getCapability().getNamespace();
}
};
public final static Function<ModuleCapability, String> CAPABILITY = new Function<ModuleCapability, String>() {
@Override
public String apply(ModuleCapability capability) {
return capability.getNamespace();
}
};
public final static Function<ModuleRequirement, String> REQUIREMENT = new Function<ModuleRequirement, String>() {
@Override
public String apply(ModuleRequirement requirement) {
return requirement.getNamespace();
}
Expand Down Expand Up @@ -188,6 +191,7 @@ public boolean hasNext() {
return inner.hasNext();
}

@Override
public E next() {
if (!hasNext()) {
throw new NoSuchElementException();
Expand Down Expand Up @@ -333,6 +337,7 @@ private boolean addAll(Map<String, List<E>> perNamespaceElements) {

private List<E> getNamespaceList(String namespace) {
return namespaceElements.computeIfAbsent(namespace, new Function<String, List<E>>() {
@Override
public List<E> apply(String n) {
return new ArrayList<>();
}
Expand Down Expand Up @@ -402,6 +407,7 @@ public void addAllFilteredAfterLastMatch(NamespaceList<E> list, Predicate<? supe
targetList.add(toAdd);
} else {
addAfterLastMatch(toAdd, targetList, new Predicate<E>() {
@Override
public boolean test(E e) {
return insertionMatcher.test(toAdd, e);
}
Expand Down Expand Up @@ -448,6 +454,7 @@ public boolean remove(Object o) {

private void removeNamespaceElement(String namespace, E element) {
namespaceElements.computeIfPresent(namespace, new BiFunction<String, List<E>, List<E>>() {
@Override
public List<E> apply(String n, List<E> es) {
if (es.remove(element)) {
Builder.this.size--;
Expand Down Expand Up @@ -482,6 +489,7 @@ public void removeNamespaceIf(Predicate<String> filter) {
prepareModification();

namespaceElements.entrySet().removeIf(new Predicate<Map.Entry<String, List<E>>>() {
@Override
public boolean test(Map.Entry<String, List<E>> e) {
if (filter.test(e.getKey())) {
Builder.this.size -= e.getValue().size();
Expand All @@ -498,6 +506,7 @@ public boolean removeIf(Predicate<? super E> filter) {

int s = size;
namespaceElements.values().removeIf(new Predicate<List<E>>() {
@Override
public boolean test(List<E> es) {
return removeElementsIf(es, filter) == null;
}
Expand All @@ -516,6 +525,7 @@ public void removeElementsOfNamespaceIf(String namespace, Predicate<? super E> f
prepareModification();

namespaceElements.computeIfPresent(namespace, new BiFunction<String, List<E>, List<E>>() {
@Override
public List<E> apply(String n, List<E> es) {
return removeElementsIf(es, filter);
}
Expand Down Expand Up @@ -555,6 +565,7 @@ public NamespaceList<E> build() {

int[] start = new int[] { 0 };
namespaceElements.replaceAll(new BiFunction<String, List<E>, List<E>>() {
@Override
public List<E> apply(String n, List<E> es) {
int from = start[0];
int to = start[0] += es.size();
Expand All @@ -571,6 +582,7 @@ private void prepareModification() {
// namespace-lists for subsequent modification
namespaceElements = new LinkedHashMap<>(namespaceElements);
namespaceElements.replaceAll(new BiFunction<String, List<E>, List<E>>() {
@Override
public List<E> apply(String n, List<E> es) {
return new ArrayList<>(es);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class EquinoxEventPublisher {

private final EquinoxContainer container;

private Object monitor = new Object();
private final Object monitor = new Object();
private EventManager eventManager;

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1653,7 +1653,7 @@ static class Range {
private Version leftVersion;
private Version rightVersion;
private char rightRule = 0;
private Collection<Version> excludes = new ArrayList<>(0);
private final Collection<Version> excludes = new ArrayList<>(0);

@Override
public String toString() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

public class SystemBundleActivator implements BundleActivator {
private EquinoxFactoryManager urlFactoryManager;
private List<ServiceRegistration<?>> registrations = new ArrayList<>(10);
private final List<ServiceRegistration<?>> registrations = new ArrayList<>(10);
private SecurityManager setSecurityManagner;

@SuppressWarnings("deprecation")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ private static void addRequirers(Set<Bundle> importing, ModuleWiring wiring, Str
/**
* @deprecated
*/
@Deprecated
@Override
public String getSpecificationVersion() {
return getVersion().toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public DefineClassResult(Class<?> clazz, boolean defined) {

private static final class ClassNameLock {
static final Function<String, ClassNameLock> SUPPLIER = new Function<String, ClassNameLock>() {
@Override
public ClassNameLock apply(String className) {
return new ClassNameLock(className);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
* with the highest version will be returned.
*/
public class GlobalPolicy implements IBuddyPolicy {
private FrameworkWiring frameworkWiring;
private final FrameworkWiring frameworkWiring;

public GlobalPolicy(FrameworkWiring frameworkWiring) {
this.frameworkWiring = frameworkWiring;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public class ClasspathManager {
private ArrayMap<String, String> loadedLibraries = null;
// used to detect recusive defineClass calls for the same class on the same
// class loader (bug 345500)
private ThreadLocal<DefineContext> currentDefineContext = new ThreadLocal<>();
private final ThreadLocal<DefineContext> currentDefineContext = new ThreadLocal<>();

/**
* Constructs a classpath manager for the given generation and module class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public boolean isReadOnly() {
/**
* @deprecated
*/
@Deprecated
@Override
public boolean setURL(URL value, boolean lock) throws IllegalStateException {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ public class EventAdminAdapter implements ServiceTrackerCustomizer<Object, Objec
private static Collection<String> eventAdminObjectClass = Arrays.asList("org.osgi.service.event.EventAdmin"); //$NON-NLS-1$
private static Collection<String> eventHandlerObjectClass = Arrays.asList("org.osgi.service.event.EventHandler"); //$NON-NLS-1$

private ServiceTracker<Object, Object> eventAdminTracker;
private ServiceTracker<Object, Object> eventHandlerTracker;
private BundleContext context;
private final ServiceTracker<Object, Object> eventAdminTracker;
private final ServiceTracker<Object, Object> eventHandlerTracker;
private final BundleContext context;
private ServiceReference<Object> eventAdmin;
private int logEventHandlers;
private ExtendedLogReaderServiceFactory logReaderServiceFactory;
private final ExtendedLogReaderServiceFactory logReaderServiceFactory;
private EventAdminLogListener logListener;

public EventAdminAdapter(BundleContext context, ExtendedLogReaderServiceFactory logReaderServiceFactory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ void executeNextTask(OrderedTaskQueue taskQueue) {
*/
class OrderedTaskQueue {
private final Queue<OrderedTask> dependencyQueue = new LinkedList<>();
private AtomicReference<OrderedTask> firstTask = new AtomicReference<>();
private final AtomicReference<OrderedTask> firstTask = new AtomicReference<>();

void execute(Runnable task, int numListeners) {
executeOrderedTask(task, this, numListeners);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ void delete(SecurityRow securityRow, boolean firstTry) {
/**
* @deprecated
*/
@Deprecated
@Override
public ConditionalPermissionInfo addConditionalPermissionInfo(ConditionInfo[] conds, PermissionInfo[] perms) {
return setConditionalPermissionInfo(null, conds, perms, true);
Expand Down Expand Up @@ -287,6 +288,7 @@ public AccessControlContext getAccessControlContext(String[] signers) {
/**
* @deprecated
*/
@Deprecated
@Override
public ConditionalPermissionInfo getConditionalPermissionInfo(String name) {
synchronized (lock) {
Expand All @@ -297,6 +299,7 @@ public ConditionalPermissionInfo getConditionalPermissionInfo(String name) {
/**
* @deprecated
*/
@Deprecated
@Override
public Enumeration<ConditionalPermissionInfo> getConditionalPermissionInfos() {
// could implement our own Enumeration, but we don't care about performance
Expand All @@ -312,6 +315,7 @@ public Enumeration<ConditionalPermissionInfo> getConditionalPermissionInfos() {
/**
* @deprecated
*/
@Deprecated
@Override
public ConditionalPermissionInfo setConditionalPermissionInfo(String name, ConditionInfo[] conds,
PermissionInfo[] perms) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ PermissionInfo[] internalGetPermissionInfos() {
/**
* @deprecated
*/
@Deprecated
@Override
public void delete() {
securityAdmin.delete(this, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public PermissionInfo[] getPermissionInfos() {
/**
* @deprecated
*/
@Deprecated
@Override
public void delete() {
throw new UnsupportedOperationException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
*/
public abstract class AuthorizationEngine {

private EventManager manager = new EventManager();
private EventDispatcher<AuthorizationListener, Object, AuthorizationEvent> dispatcher = new AuthEventDispatcher();
private final EventManager manager = new EventManager();
private final EventDispatcher<AuthorizationListener, Object, AuthorizationEvent> dispatcher = new AuthEventDispatcher();
private final ServiceTracker<AuthorizationListener, AuthorizationListener> listenerTracker;

public AuthorizationEngine(BundleContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ private boolean isSignatureFile(String entry) {
return false;
}

@Override
public int read() throws IOException {
if (nextEntryInput != null) {
int result = nextEntryInput.read();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* content handler.
*/
public class ContentHandlerFactoryImpl extends MultiplexingFactory implements java.net.ContentHandlerFactory {
private ServiceTracker<ContentHandler, ContentHandler> contentHandlerTracker;
private final ServiceTracker<ContentHandler, ContentHandler> contentHandlerTracker;

private static final String contentHandlerClazz = "java.net.ContentHandler"; //$NON-NLS-1$
private static final String CONTENT_HANDLER_PKGS = "java.content.handler.pkgs"; //$NON-NLS-1$
Expand All @@ -49,7 +49,7 @@ public class ContentHandlerFactoryImpl extends MultiplexingFactory implements ja
private static final List<Class<?>> ignoredClasses = Arrays.asList(
new Class<?>[] { MultiplexingContentHandler.class, ContentHandlerFactoryImpl.class, URLConnection.class });

private Map<String, ContentHandlerProxy> proxies;
private final Map<String, ContentHandlerProxy> proxies;
private java.net.ContentHandlerFactory parentFactory;

public ContentHandlerFactoryImpl(BundleContext context, EquinoxContainer container) {
Expand Down
Loading

0 comments on commit 657162c

Please sign in to comment.