diff options
author | Alexander Kurtakov | 2017-08-18 10:52:34 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2017-08-18 10:52:34 +0000 |
commit | 08b1c52015387463c263add217c6807d0aec7dba (patch) | |
tree | 4c3b099cfa963f165a65201e9c4d3ee00422480d | |
parent | 102c8038d5de2c3a0511eb13ebf947f18f046183 (diff) | |
download | rt.equinox.p2-08b1c52015387463c263add217c6807d0aec7dba.tar.gz rt.equinox.p2-08b1c52015387463c263add217c6807d0aec7dba.tar.xz rt.equinox.p2-08b1c52015387463c263add217c6807d0aec7dba.zip |
Bug 521108 - Move p2 core to Java 8
Bump minor version, add missing Override annotations, remove duplicate
type declarations, try-with-resources.
Change-Id: I4dc835c94677520b8219b9eae1157cfd41f37ab6
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
19 files changed, 184 insertions, 192 deletions
diff --git a/bundles/org.eclipse.equinox.p2.core/.classpath b/bundles/org.eclipse.equinox.p2.core/.classpath index 64c5e31b7..eca7bdba8 100644 --- a/bundles/org.eclipse.equinox.p2.core/.classpath +++ b/bundles/org.eclipse.equinox.p2.core/.classpath @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="src" path="src"/> <classpathentry kind="output" path="bin"/> diff --git a/bundles/org.eclipse.equinox.p2.core/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.equinox.p2.core/.settings/org.eclipse.jdt.core.prefs index 31d9ed4bb..8803f562d 100644 --- a/bundles/org.eclipse.equinox.p2.core/.settings/org.eclipse.jdt.core.prefs +++ b/bundles/org.eclipse.equinox.p2.core/.settings/org.eclipse.jdt.core.prefs @@ -10,13 +10,17 @@ org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnull.secondary= org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary= org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -33,7 +37,7 @@ org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod= org.eclipse.jdt.core.compiler.problem.discouragedReference=error org.eclipse.jdt.core.compiler.problem.emptyStatement=warning org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled org.eclipse.jdt.core.compiler.problem.fieldHiding=warning @@ -50,7 +54,7 @@ org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=error org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore @@ -59,7 +63,7 @@ org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore @@ -67,19 +71,21 @@ org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning +org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error org.eclipse.jdt.core.compiler.problem.nullReference=warning org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore -org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore @@ -95,6 +101,9 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=warning +org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled +org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=info org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore @@ -102,6 +111,7 @@ org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled +org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedImport=error org.eclipse.jdt.core.compiler.problem.unusedLabel=warning org.eclipse.jdt.core.compiler.problem.unusedLocal=warning @@ -114,7 +124,7 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.8 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 diff --git a/bundles/org.eclipse.equinox.p2.core/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.core/META-INF/MANIFEST.MF index 4c3a8fb40..3e94df325 100644 --- a/bundles/org.eclipse.equinox.p2.core/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.equinox.p2.core;singleton:=true -Bundle-Version: 2.4.100.qualifier +Bundle-Version: 2.5.0.qualifier Bundle-ClassPath: . Bundle-Activator: org.eclipse.equinox.internal.p2.core.Activator Bundle-Vendor: %providerName @@ -67,7 +67,7 @@ Export-Package: org.eclipse.equinox.internal.p2.core;x-friends:="org.eclipse.equ org.eclipse.equinox.p2.core;version="2.0.0", org.eclipse.equinox.p2.core.spi;version="2.1.0" Require-Bundle: org.eclipse.equinox.common;bundle-version="[3.5.0,4.0.0)" -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-ActivationPolicy: lazy Service-Component: OSGI-INF/eventBus.xml, OSGI-INF/agentProvider.xml Import-Package: org.eclipse.osgi.framework.eventmgr;version="1.2.0", diff --git a/bundles/org.eclipse.equinox.p2.core/pom.xml b/bundles/org.eclipse.equinox.p2.core/pom.xml index 11720d736..8014ca9bc 100644 --- a/bundles/org.eclipse.equinox.p2.core/pom.xml +++ b/bundles/org.eclipse.equinox.p2.core/pom.xml @@ -9,6 +9,6 @@ </parent> <groupId>org.eclipse.equinox</groupId> <artifactId>org.eclipse.equinox.p2.core</artifactId> - <version>2.4.100-SNAPSHOT</version> + <version>2.5.0-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project> diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/Activator.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/Activator.java index 4ee7e8649..bb835c086 100644 --- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/Activator.java +++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/Activator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2012 IBM Corporation and others. + * Copyright (c) 2007, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -155,7 +155,7 @@ public class Activator implements BundleActivator { //lazy init if the bundle has been started if (context == null) return null; - logTracker = new ServiceTracker<FrameworkLog, FrameworkLog>(context, FrameworkLog.class, null); + logTracker = new ServiceTracker<>(context, FrameworkLog.class, null); logTracker.open(); return logTracker; } @@ -231,12 +231,13 @@ public class Activator implements BundleActivator { } } + @Override public void start(BundleContext aContext) throws Exception { instance = this; Activator.context = aContext; URI defaultLocation = URIUtil.fromString(aContext.getProperty(PROP_CONFIG_DIR) + DEFAULT_AGENT_LOCATION + '/'); agentDataLocation = buildLocation(PROP_AGENT_DATA_AREA, defaultLocation, false, true); - Dictionary<String, Object> locationProperties = new Hashtable<String, Object>(); + Dictionary<String, Object> locationProperties = new Hashtable<>(); if (agentDataLocation != null) { locationProperties.put("type", PROP_AGENT_DATA_AREA); //$NON-NLS-1$ agentLocationRegistration = aContext.registerService(IAgentLocation.class, agentDataLocation, locationProperties); @@ -244,6 +245,7 @@ public class Activator implements BundleActivator { registerAgent(); } + @Override public void stop(BundleContext aContext) throws Exception { unregisterAgent(); instance = null; diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/AgentLocation.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/AgentLocation.java index f29e978d6..e504a62e3 100644 --- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/AgentLocation.java +++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/AgentLocation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -25,14 +25,17 @@ public class AgentLocation implements IAgentLocation { this.location = location; } + @Override public synchronized URI getRootLocation() { return location; } + @Override public URI getDataArea(String touchpointId) { return URIUtil.append(getRootLocation(), touchpointId + '/'); } + @Override public String toString() { if (location == null) return "No location specified"; //$NON-NLS-1$ diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/DefaultAgentProvider.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/DefaultAgentProvider.java index d2e851dd3..fc14781e1 100644 --- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/DefaultAgentProvider.java +++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/DefaultAgentProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2016 IBM Corporation and others. + * Copyright (c) 2009, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -15,7 +15,6 @@ import java.util.Dictionary; import java.util.Hashtable; import org.eclipse.equinox.p2.core.*; import org.osgi.framework.*; -import org.osgi.framework.Constants; /** * Default implementation of {@link IProvisioningAgentProvider}. @@ -27,12 +26,13 @@ public class DefaultAgentProvider implements IProvisioningAgentProvider { this.context = aContext; } + @Override public IProvisioningAgent createAgent(URI location) { ProvisioningAgent result = new ProvisioningAgent(); result.setBundleContext(context); result.setLocation(location); IAgentLocation agentLocation = (IAgentLocation) result.getService(IAgentLocation.SERVICE_NAME); - Dictionary<String, Object> properties = new Hashtable<String, Object>(5); + Dictionary<String, Object> properties = new Hashtable<>(5); if (agentLocation != null) properties.put("locationURI", String.valueOf(agentLocation.getRootLocation())); //$NON-NLS-1$ //make the currently running system have a higher service ranking diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/EventBusComponent.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/EventBusComponent.java index 095efdee3..0ac73a7e9 100644 --- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/EventBusComponent.java +++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/EventBusComponent.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 IBM Corporation and others. + * Copyright (c) 2009, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -18,9 +18,7 @@ import org.eclipse.equinox.p2.core.spi.IAgentServiceFactory; * Factory for creating {@link IProvisioningEventBus} instances. */ public class EventBusComponent implements IAgentServiceFactory { - /* (non-Javadoc) - * @see org.eclipse.equinox.p2.core.spi.IAgentServiceFactory#createService(org.eclipse.equinox.p2.core.IProvisioningAgent) - */ + @Override public Object createService(IProvisioningAgent agent) { return new ProvisioningEventBus(); } diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/ProvisioningAgent.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/ProvisioningAgent.java index 0a18fef65..4d0f16b12 100644 --- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/ProvisioningAgent.java +++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/ProvisioningAgent.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 IBM Corporation and others. + * Copyright (c) 2009, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -40,9 +40,7 @@ public class ProvisioningAgent implements IProvisioningAgent, ServiceTrackerCust registerService(IProvisioningAgent.INSTALLER_PROFILEID, "_SELF_"); //$NON-NLS-1$ } - /* (non-Javadoc) - * @see org.eclipse.equinox.p2.core.IProvisioningAgent#getService(java.lang.String) - */ + @Override public Object getService(String serviceName) { //synchronize so concurrent gets always obtain the same service synchronized (agentServices) { @@ -62,7 +60,7 @@ public class ProvisioningAgent implements IProvisioningAgent, ServiceTrackerCust return null; ServiceReference<IAgentServiceFactory> firstRef = Collections.max(refs); //track the factory so that we can automatically remove the service when the factory goes away - ServiceTracker<IAgentServiceFactory, Object> tracker = new ServiceTracker<IAgentServiceFactory, Object>(context, firstRef, this); + ServiceTracker<IAgentServiceFactory, Object> tracker = new ServiceTracker<>(context, firstRef, this); tracker.open(); IAgentServiceFactory factory = (IAgentServiceFactory) tracker.getService(); if (factory == null) { @@ -85,6 +83,7 @@ public class ProvisioningAgent implements IProvisioningAgent, ServiceTrackerCust throw new IllegalStateException("Attempt to access stopped agent: " + this); //$NON-NLS-1$ } + @Override public void registerService(String serviceName, Object service) { checkRunning(); agentServices.put(serviceName, service); @@ -111,6 +110,7 @@ public class ProvisioningAgent implements IProvisioningAgent, ServiceTrackerCust registerService(IAgentLocation.SERVICE_NAME, agentLocation); } + @Override public void unregisterService(String serviceName, Object service) { synchronized (agentServices) { if (stopped) @@ -122,10 +122,11 @@ public class ProvisioningAgent implements IProvisioningAgent, ServiceTrackerCust ((IAgentService) service).stop(); } + @Override public void stop() { List<Object> toStop; synchronized (agentServices) { - toStop = new ArrayList<Object>(agentServices.values()); + toStop = new ArrayList<>(agentServices.values()); } //give services a chance to do their own shutdown for (Object service : toStop) { @@ -150,25 +151,19 @@ public class ProvisioningAgent implements IProvisioningAgent, ServiceTrackerCust this.reg = reg; } - /*(non-Javadoc) - * @see org.osgi.util.tracker.ServiceTrackerCustomizer#addingService(org.osgi.framework.ServiceReference) - */ + @Override public Object addingService(ServiceReference<IAgentServiceFactory> reference) { if (stopped) return null; return context.getService(reference); } - /*(non-Javadoc) - * @see org.osgi.util.tracker.ServiceTrackerCustomizer#modifiedService(org.osgi.framework.ServiceReference, java.lang.Object) - */ + @Override public void modifiedService(ServiceReference<IAgentServiceFactory> reference, Object service) { //nothing to do } - /*(non-Javadoc) - * @see org.osgi.util.tracker.ServiceTrackerCustomizer#removedService(org.osgi.framework.ServiceReference, java.lang.Object) - */ + @Override public void removedService(ServiceReference<IAgentServiceFactory> reference, Object factoryService) { if (stopped) return; diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/ProvisioningEventBus.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/ProvisioningEventBus.java index 50448df95..fc1617679 100644 --- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/ProvisioningEventBus.java +++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/ProvisioningEventBus.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 IBM Corporation and others. + * Copyright (c) 2007, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -22,8 +22,8 @@ import org.eclipse.osgi.framework.eventmgr.*; * Default implementation of the {@link IProvisioningEventBus} service. */ public class ProvisioningEventBus implements EventDispatcher<ProvisioningListener, ProvisioningListener, EventObject>, IProvisioningEventBus, IAgentService { - private final CopyOnWriteIdentityMap<ProvisioningListener, ProvisioningListener> syncListeners = new CopyOnWriteIdentityMap<ProvisioningListener, ProvisioningListener>(); - private final CopyOnWriteIdentityMap<ProvisioningListener, ProvisioningListener> asyncListeners = new CopyOnWriteIdentityMap<ProvisioningListener, ProvisioningListener>(); + private final CopyOnWriteIdentityMap<ProvisioningListener, ProvisioningListener> syncListeners = new CopyOnWriteIdentityMap<>(); + private final CopyOnWriteIdentityMap<ProvisioningListener, ProvisioningListener> asyncListeners = new CopyOnWriteIdentityMap<>(); private EventManager eventManager = new EventManager("Provisioning Event Dispatcher"); //$NON-NLS-1$ private Object dispatchEventLock = new Object(); @@ -36,9 +36,7 @@ public class ProvisioningEventBus implements EventDispatcher<ProvisioningListene super(); } - /* (non-Javadoc) - * @see org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus#addListener(org.eclipse.equinox.internal.provisional.p2.core.eventbus.ProvisioningListener) - */ + @Override public void addListener(ProvisioningListener toAdd) { if (toAdd instanceof SynchronousProvisioningListener) { synchronized (syncListeners) { @@ -51,9 +49,7 @@ public class ProvisioningEventBus implements EventDispatcher<ProvisioningListene } } - /* (non-Javadoc) - * @see org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus#removeListener(org.eclipse.equinox.internal.provisional.p2.core.eventbus.ProvisioningListener) - */ + @Override public void removeListener(ProvisioningListener toRemove) { if (toRemove instanceof SynchronousProvisioningListener) { synchronized (syncListeners) { @@ -66,16 +62,14 @@ public class ProvisioningEventBus implements EventDispatcher<ProvisioningListene } } - /* (non-Javadoc) - * @see org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus#publishEvent(java.util.EventObject) - */ + @Override public void publishEvent(EventObject event) { synchronized (dispatchEventLock) { if (closed) return; } /* queue to hold set of listeners */ - ListenerQueue<ProvisioningListener, ProvisioningListener, EventObject> listeners = new ListenerQueue<ProvisioningListener, ProvisioningListener, EventObject>(eventManager); + ListenerQueue<ProvisioningListener, ProvisioningListener, EventObject> listeners = new ListenerQueue<>(eventManager); /* synchronize while building the listener list */ synchronized (syncListeners) { @@ -85,7 +79,7 @@ public class ProvisioningEventBus implements EventDispatcher<ProvisioningListene listeners.dispatchEventSynchronous(0, event); } - listeners = new ListenerQueue<ProvisioningListener, ProvisioningListener, EventObject>(eventManager); + listeners = new ListenerQueue<>(eventManager); synchronized (asyncListeners) { listeners.queueListeners(asyncListeners.entrySet(), this); synchronized (dispatchEventLock) { @@ -95,9 +89,7 @@ public class ProvisioningEventBus implements EventDispatcher<ProvisioningListene } } - /* (non-Javadoc) - * @see org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus#dispatchEvent(java.lang.Object, java.lang.Object, int, java.lang.Object) - */ + @Override public void dispatchEvent(ProvisioningListener eventListener, ProvisioningListener listenerObject, int eventAction, EventObject eventObject) { synchronized (dispatchEventLock) { if (closed) @@ -117,9 +109,7 @@ public class ProvisioningEventBus implements EventDispatcher<ProvisioningListene } } - /* (non-Javadoc) - * @see org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus#close() - */ + @Override public void close() { boolean interrupted = false; synchronized (dispatchEventLock) { @@ -139,16 +129,12 @@ public class ProvisioningEventBus implements EventDispatcher<ProvisioningListene Thread.currentThread().interrupt(); } - /*(non-Javadoc) - * @see org.eclipse.equinox.p2.core.spi.IAgentService#start() - */ + @Override public void start() { //nothing to do } - /*(non-Javadoc) - * @see org.eclipse.equinox.p2.core.spi.IAgentService#stop() - */ + @Override public void stop() { close(); } diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/CollectionUtils.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/CollectionUtils.java index edbf40ab5..017d4d5de 100644 --- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/CollectionUtils.java +++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/CollectionUtils.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -31,14 +31,17 @@ public class CollectionUtils { this.array = array; } + @Override public boolean contains(Object o) { return indexOf(o) != -1; } + @Override public E get(int index) { return array[index]; } + @Override public int indexOf(Object o) { int size = array.length; if (o == null) { @@ -53,6 +56,7 @@ public class CollectionUtils { return -1; } + @Override public Iterator<E> iterator() { return listIterator(); } @@ -61,24 +65,29 @@ public class CollectionUtils { * Rapid iterator, motivated by the fact that we don't need to check * for concurrent modifications. */ + @Override public ListIterator<E> listIterator() { return new ListIterator<E>() { private int index = 0; + @Override public boolean hasNext() { return index < array.length; } + @Override public E next() { if (index >= array.length) throw new NoSuchElementException(); return array[index++]; } + @Override public boolean hasPrevious() { return index > 0; } + @Override public E previous() { if (--index < 0) { ++index; @@ -87,28 +96,34 @@ public class CollectionUtils { return array[index]; } + @Override public int nextIndex() { return index; } + @Override public int previousIndex() { return index - 1; } + @Override public void remove() { throw new UnsupportedOperationException(); } + @Override public void set(E e) { throw new UnsupportedOperationException(); } + @Override public void add(E e) { throw new UnsupportedOperationException(); } }; } + @Override public int lastIndexOf(Object o) { int idx = array.length; if (o == null) { @@ -123,18 +138,22 @@ public class CollectionUtils { return -1; } + @Override public E set(int index, E element) { throw new UnsupportedOperationException(); } + @Override public int size() { return array.length; } + @Override public Object[] toArray() { return array.clone(); } + @Override @SuppressWarnings("unchecked") public <T> T[] toArray(T[] a) { int size = array.length; @@ -172,7 +191,7 @@ public class CollectionUtils { * @return The unmodifiable list */ public static <T> List<T> unmodifiableList(T[] array) { - return array == null || array.length == 0 ? Collections.<T> emptyList() : new UnmodifiableArrayList<T>(array); + return array == null || array.length == 0 ? Collections.<T> emptyList() : new UnmodifiableArrayList<>(array); } /** @@ -197,7 +216,7 @@ public class CollectionUtils { if (properties == null || properties.isEmpty()) return Collections.<String, String> emptyMap(); - Map<String, String> props = new HashMap<String, String>(properties.size()); + Map<String, String> props = new HashMap<>(properties.size()); putAll(properties, props); return props; } diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/FileUtils.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/FileUtils.java index 1d81d8117..17dfd95f9 100644 --- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/FileUtils.java +++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/FileUtils.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 IBM Corporation and others. + * Copyright (c) 2007, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -21,12 +21,11 @@ public class FileUtils { private static File[] untarFile(File source, File outputDir) throws IOException, TarException { TarFile tarFile = new TarFile(source); - List<File> untarredFiles = new ArrayList<File>(); + List<File> untarredFiles = new ArrayList<>(); try { for (Enumeration<TarEntry> e = tarFile.entries(); e.hasMoreElements();) { TarEntry entry = e.nextElement(); - InputStream input = tarFile.getInputStream(entry); - try { + try (InputStream input = tarFile.getInputStream(entry)) { File outFile = new File(outputDir, entry.getName()); outFile = outFile.getCanonicalFile(); //bug 266844 untarredFiles.add(outFile); @@ -45,8 +44,6 @@ public class FileUtils { } outFile.setLastModified(entry.getTime()); } - } finally { - input.close(); } } } finally { @@ -69,16 +66,13 @@ public class FileUtils { throw ioException; } } - InputStream in = new FileInputStream(zipFile); - try { + try (InputStream in = new FileInputStream(zipFile)) { return unzipStream(in, zipFile.length(), outputDir, null, null); } catch (IOException e) { // add the file name to the message IOException ioException = new IOException(NLS.bind(Messages.Util_Error_Unzipping, zipFile, e.getMessage())); ioException.initCause(e); throw ioException; - } finally { - in.close(); } } @@ -87,16 +81,13 @@ public class FileUtils { * monitor may be null. */ public static File[] unzipFile(File zipFile, File outputDir, String taskName, IProgressMonitor monitor) throws IOException { - InputStream in = new FileInputStream(zipFile); - try { + try (InputStream in = new FileInputStream(zipFile)) { return unzipStream(in, zipFile.length(), outputDir, taskName, monitor); } catch (IOException e) { // add the file name to the message IOException ioException = new IOException(NLS.bind(Messages.Util_Error_Unzipping, zipFile, e.getMessage())); ioException.initCause(e); throw ioException; - } finally { - in.close(); } } @@ -105,37 +96,37 @@ public class FileUtils { */ public static File[] unzipStream(InputStream stream, long size, File outputDir, String taskName, IProgressMonitor monitor) throws IOException { InputStream is = monitor == null ? stream : stream; // new ProgressMonitorInputStream(stream, size, size, taskName, monitor); TODO Commented code - ZipInputStream in = new ZipInputStream(new BufferedInputStream(is)); - ZipEntry ze = in.getNextEntry(); - if (ze == null) { - // There must be at least one entry in a zip file. - // When there isn't getNextEntry returns null. - in.close(); - throw new IOException(Messages.Util_Invalid_Zip_File_Format); - } - ArrayList<File> unzippedFiles = new ArrayList<File>(); - do { - File outFile = new File(outputDir, ze.getName()); - unzippedFiles.add(outFile); - if (ze.isDirectory()) { - outFile.mkdirs(); - } else { - if (outFile.exists()) { - outFile.delete(); + ArrayList<File> unzippedFiles = new ArrayList<>(); + try (ZipInputStream in = new ZipInputStream(new BufferedInputStream(is))) { + ZipEntry ze = in.getNextEntry(); + if (ze == null) { + // There must be at least one entry in a zip file. + // When there isn't getNextEntry returns null. + in.close(); + throw new IOException(Messages.Util_Invalid_Zip_File_Format); + } + do { + File outFile = new File(outputDir, ze.getName()); + unzippedFiles.add(outFile); + if (ze.isDirectory()) { + outFile.mkdirs(); } else { - outFile.getParentFile().mkdirs(); - } - try { - copyStream(in, false, new FileOutputStream(outFile), true); - } catch (FileNotFoundException e) { - // TEMP: ignore this for now in case we're trying to replace - // a running eclipse.exe + if (outFile.exists()) { + outFile.delete(); + } else { + outFile.getParentFile().mkdirs(); + } + try { + copyStream(in, false, new FileOutputStream(outFile), true); + } catch (FileNotFoundException e) { + // TEMP: ignore this for now in case we're trying to replace + // a running eclipse.exe + } + outFile.setLastModified(ze.getTime()); } - outFile.setLastModified(ze.getTime()); - } - in.closeEntry(); - } while ((ze = in.getNextEntry()) != null); - in.close(); + in.closeEntry(); + } while ((ze = in.getNextEntry()) != null); + } return unzippedFiles.toArray(new File[unzippedFiles.size()]); } @@ -211,20 +202,8 @@ public class FileUtils { copy(source, destination, new File(root, list[i].getName()), false); } else { destinationFile.getParentFile().mkdirs(); - InputStream in = null; - OutputStream out = null; - try { - in = new BufferedInputStream(new FileInputStream(sourceFile)); - out = new BufferedOutputStream(new FileOutputStream(destinationFile)); + try (InputStream in = new BufferedInputStream(new FileInputStream(sourceFile)); OutputStream out = new BufferedOutputStream(new FileOutputStream(destinationFile));) { copyStream(in, false, out, false); - } finally { - try { - if (in != null) - in.close(); - } finally { - if (out != null) - out.close(); - } } } } @@ -247,27 +226,13 @@ public class FileUtils { * @throws IOException if there is an IO issue during this operation. */ public static void zip(File[] inclusions, File[] exclusions, File destinationArchive, IPathComputer pathComputer) throws IOException { - FileOutputStream fileOutput = new FileOutputStream(destinationArchive); - ZipOutputStream output = new ZipOutputStream(fileOutput); - HashSet<File> exclusionSet = exclusions == null ? new HashSet<File>() : new HashSet<File>(Arrays.asList(exclusions)); - HashSet<IPath> directoryEntries = new HashSet<IPath>(); - try { + try (FileOutputStream fileOutput = new FileOutputStream(destinationArchive); ZipOutputStream output = new ZipOutputStream(fileOutput)) { + HashSet<File> exclusionSet = exclusions == null ? new HashSet<>() : new HashSet<>(Arrays.asList(exclusions)); + HashSet<IPath> directoryEntries = new HashSet<>(); for (int i = 0; i < inclusions.length; i++) { pathComputer.reset(); zip(output, inclusions[i], exclusionSet, pathComputer, directoryEntries); } - } finally { - try { - output.close(); - } catch (IOException e) { - // closing a zip file with no entries apparently fails on some JREs. - // if we failed closing the zip, try closing the raw file. - try { - fileOutput.close(); - } catch (IOException e2) { - // give up. - } - } } } @@ -332,22 +297,20 @@ public class FileUtils { // foo/bar.txt // foo/something/bar2.txt // foo/something/else/bar3.txt - Arrays.sort(files, new Comparator<File>() { - public int compare(File arg0, File arg1) { - Path a = new Path(arg0.getAbsolutePath()); - Path b = new Path(arg1.getAbsolutePath()); - if (a.segmentCount() == b.segmentCount()) { - if (arg0.isDirectory() && arg1.isFile()) - return 1; - else if (arg0.isDirectory() && arg1.isDirectory()) - return 0; - else if (arg0.isFile() && arg1.isDirectory()) - return -1; - else - return 0; - } - return a.segmentCount() - b.segmentCount(); + Arrays.sort(files, (arg0, arg1) -> { + Path a = new Path(arg0.getAbsolutePath()); + Path b = new Path(arg1.getAbsolutePath()); + if (a.segmentCount() == b.segmentCount()) { + if (arg0.isDirectory() && arg1.isFile()) + return 1; + else if (arg0.isDirectory() && arg1.isDirectory()) + return 0; + else if (arg0.isFile() && arg1.isDirectory()) + return -1; + else + return 0; } + return a.segmentCount() - b.segmentCount(); }); for (int i = 0; i < files.length; i++) @@ -360,8 +323,7 @@ public class FileUtils { */ private static void zipFile(ZipOutputStream output, File source, IPathComputer pathComputer, Set<IPath> directoryEntries) throws IOException { boolean isManifest = false; //manifest files are special - InputStream input = new BufferedInputStream(new FileInputStream(source)); - try { + try (InputStream input = new BufferedInputStream(new FileInputStream(source))) { IPath entryPath = pathComputer.computePath(source); if (entryPath.isAbsolute()) throw new IOException(Messages.Util_Absolute_Entry); @@ -384,11 +346,6 @@ public class FileUtils { //TODO: something about duplicate entries, and rethrow other exceptions } finally { try { - input.close(); - } catch (IOException e) { - // ignore - } - try { output.closeEntry(); } catch (IOException e) { // ignore @@ -430,6 +387,7 @@ public class FileUtils { */ public static IPathComputer createRootPathComputer(final File root) { return new IPathComputer() { + @Override public IPath computePath(File source) { IPath result = new Path(source.getAbsolutePath()); IPath rootPath = new Path(root.getAbsolutePath()); @@ -437,6 +395,7 @@ public class FileUtils { return result.setDevice(null); } + @Override public void reset() { //nothing } @@ -467,6 +426,7 @@ public class FileUtils { return new IPathComputer() { IPathComputer computer = null; + @Override public IPath computePath(File source) { if (computer == null) { IPath sourcePath = new Path(source.getAbsolutePath()); @@ -476,6 +436,7 @@ public class FileUtils { return computer.computePath(source); } + @Override public void reset() { computer = null; } @@ -489,12 +450,14 @@ public class FileUtils { */ public static IPathComputer createParentPrefixComputer(final int segmentsToKeep) { return new IPathComputer() { + @Override public IPath computePath(File source) { IPath sourcePath = new Path(source.getAbsolutePath()); sourcePath = sourcePath.removeFirstSegments(Math.max(0, sourcePath.segmentCount() - segmentsToKeep)); return sourcePath.setDevice(null); } + @Override public void reset() { //nothing } diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/LogHelper.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/LogHelper.java index 749401c68..0dffb5462 100644 --- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/LogHelper.java +++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/LogHelper.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 IBM Corporation and others. + * Copyright (c) 2007, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -39,7 +39,7 @@ public class LogHelper { */ private static FrameworkLogEntry getLog(IStatus status) { Throwable t = status.getException(); - ArrayList<FrameworkLogEntry> childlist = new ArrayList<FrameworkLogEntry>(); + ArrayList<FrameworkLogEntry> childlist = new ArrayList<>(); int stackCode = t instanceof CoreException ? 1 : 0; // ensure a substatus inside a CoreException is properly logged diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/OrderedProperties.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/OrderedProperties.java index 45676cb57..c7faf921f 100644 --- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/OrderedProperties.java +++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/OrderedProperties.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 IBM Corporation and others. + * Copyright (c) 2007, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -40,12 +40,12 @@ public class OrderedProperties extends Dictionary<String, String> implements Map public OrderedProperties(int size) { super(); - propertyMap = new LinkedHashMap<String, String>(size); + propertyMap = new LinkedHashMap<>(size); } public OrderedProperties(OrderedProperties properties) { super(); - propertyMap = new LinkedHashMap<String, String>(properties.size()); + propertyMap = new LinkedHashMap<>(properties.size()); putAll(properties); } @@ -79,60 +79,73 @@ public class OrderedProperties extends Dictionary<String, String> implements Map */ private void init() { if (propertyMap == null) { - propertyMap = new LinkedHashMap<String, String>(); + propertyMap = new LinkedHashMap<>(); } } + @Override public int size() { return propertyMap == null ? 0 : propertyMap.size(); } + @Override public boolean isEmpty() { return propertyMap == null ? true : propertyMap.isEmpty(); } + @Override public synchronized void clear() { propertyMap = null; } + @Override public String put(String key, String value) { init(); return propertyMap.put(key, value); } + @Override public boolean containsKey(Object key) { return propertyMap != null ? propertyMap.containsKey(key) : false; } + @Override public boolean containsValue(Object value) { return propertyMap != null ? propertyMap.containsValue(value) : false; } + @Override public Set<Map.Entry<String, String>> entrySet() { return propertyMap != null ? propertyMap.entrySet() : Collections.<Map.Entry<String, String>> emptySet(); } + @Override public String get(Object key) { return propertyMap != null ? propertyMap.get(key) : null; } + @Override public Set<String> keySet() { return propertyMap != null ? propertyMap.keySet() : Collections.<String> emptySet(); } + @Override public void putAll(Map<? extends String, ? extends String> arg0) { init(); propertyMap.putAll(arg0); } + @Override public String remove(Object key) { return propertyMap != null ? propertyMap.remove(key) : null; } + @Override public Collection<String> values() { return propertyMap != null ? propertyMap.values() : Collections.<String> emptyList(); } + @Override public boolean equals(Object o) { if (o == this) return true; @@ -154,10 +167,12 @@ public class OrderedProperties extends Dictionary<String, String> implements Map return this.propertyMap.equals(o); } + @Override public int hashCode() { return propertyMap == null || propertyMap.isEmpty() ? 0 : propertyMap.hashCode(); } + @Override public String toString() { StringBuffer sb = new StringBuffer(); sb.append(propertyMap); @@ -172,19 +187,23 @@ public class OrderedProperties extends Dictionary<String, String> implements Map this.iterator = elems.iterator(); } + @Override public boolean hasMoreElements() { return iterator.hasNext(); } + @Override public String nextElement() { return iterator.next(); } } + @Override public Enumeration<String> elements() { return new StringsEnum(propertyMap.values()); } + @Override public Enumeration<String> keys() { return new StringsEnum(propertyMap.keySet()); } @@ -198,22 +217,27 @@ public class OrderedProperties extends Dictionary<String, String> implements Map } } + @Override public synchronized Object setProperty(String key, String value) { throw new UnsupportedOperationException(); } + @Override public synchronized String put(String key, String value) { throw new UnsupportedOperationException(); } + @Override public synchronized String remove(Object key) { throw new UnsupportedOperationException(); } + @Override public synchronized void putAll(Map<? extends String, ? extends String> t) { throw new UnsupportedOperationException(); } + @Override public synchronized void clear() { throw new UnsupportedOperationException(); } diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/StringHelper.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/StringHelper.java index 5a0dbd509..3d533ec59 100644 --- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/StringHelper.java +++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/StringHelper.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 IBM Corporation and others. + * Copyright (c) 2008, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -26,7 +26,7 @@ public class StringHelper { if (spec.length() > 0) resultArr = new String[] {spec}; } else { - List<String> result = new ArrayList<String>(); + List<String> result = new ArrayList<>(); while (splitIdx >= 0) { String part = spec.substring(0, splitIdx).trim(); if (part.length() > 0) diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/TarFile.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/TarFile.java index 56b672d80..ef93fcb82 100644 --- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/TarFile.java +++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/TarFile.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 IBM Corporation and others. + * Copyright (c) 2008, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -72,10 +72,12 @@ public class TarFile { */ public Enumeration<TarEntry> entries() { return new Enumeration<TarEntry>() { + @Override public boolean hasMoreElements() { return (curEntry != null); } + @Override public TarEntry nextElement() { TarEntry oldEntry = curEntry; try { @@ -114,6 +116,7 @@ public class TarFile { internalEntryStream = new FileInputStream(file); } entryStream = new TarInputStream(internalEntryStream, entry) { + @Override public void close() { // Ignore close() since we want to reuse the stream. } @@ -131,10 +134,7 @@ public class TarFile { return file.getPath(); } - /* (non-Javadoc) - * @see java.util.zip.ZipFile#finalize() - * - */ + @Override protected void finalize() throws Throwable { close(); } diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/TarInputStream.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/TarInputStream.java index 01238f8d2..ab978e69d 100644 --- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/TarInputStream.java +++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/TarInputStream.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 IBM Corporation and others. + * Copyright (c) 2008, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -306,9 +306,7 @@ public class TarInputStream extends FilterInputStream { return entry; } - /* (non-Javadoc) - * @see java.io.FilterInputStream#read(byte[], int, int) - */ + @Override public int read(byte[] b, int off, int len) throws IOException { if (nextEOF == 0) { return -1; @@ -323,9 +321,7 @@ public class TarInputStream extends FilterInputStream { return size; } - /* (non-Javadoc) - * @see java.io.FilterInputStream#read() - */ + @Override public int read() throws IOException { byte[] data = new byte[1]; int size = read(data, 0, 1); diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/p2/core/StrongPool.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/p2/core/StrongPool.java index d1780388b..e385f7b21 100644 --- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/p2/core/StrongPool.java +++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/p2/core/StrongPool.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 IBM Corporation and others. + * Copyright (c) 2011, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -24,11 +24,9 @@ import java.util.Map; * @since 2.1 */ public class StrongPool<T> implements IPool<T> { - private Map<T, T> pool = new HashMap<T, T>(); + private Map<T, T> pool = new HashMap<>(); - /* (non-Javadoc) - * @see org.eclipse.equinox.p2.core.IPool#add(T) - */ + @Override public T add(T newObject) { if (newObject == null) { return null; diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/p2/core/WeakPool.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/p2/core/WeakPool.java index 3f389fc75..0a35e7506 100644 --- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/p2/core/WeakPool.java +++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/p2/core/WeakPool.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 IBM Corporation and others. + * Copyright (c) 2011, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -24,11 +24,9 @@ import java.util.WeakHashMap; * @since 2.1 */ public class WeakPool<T> implements IPool<T> { - private Map<T, WeakReference<T>> pool = new WeakHashMap<T, WeakReference<T>>(); + private Map<T, WeakReference<T>> pool = new WeakHashMap<>(); - /* (non-Javadoc) - * @see org.eclipse.equinox.p2.core.IPool#add(T) - */ + @Override public T add(T newObject) { if (newObject == null) { return null; @@ -41,7 +39,7 @@ public class WeakPool<T> implements IPool<T> { return reference; } } - pool.put(newObject, new WeakReference<T>(newObject)); + pool.put(newObject, new WeakReference<>(newObject)); return newObject; } } |