diff options
author | Alexander Kurtakov | 2017-10-09 06:34:38 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2017-10-09 06:34:38 +0000 |
commit | a64ad46b0c7bd1d48664b01abc05fe16156a0a85 (patch) | |
tree | 8c7c7902e03e7043289948ffec2a6281b2ad540e | |
parent | c57f0da20d8de7f1e8d1cbb211ce476a516b3b71 (diff) | |
download | rt.equinox.p2-a64ad46b0c7bd1d48664b01abc05fe16156a0a85.tar.gz rt.equinox.p2-a64ad46b0c7bd1d48664b01abc05fe16156a0a85.tar.xz rt.equinox.p2-a64ad46b0c7bd1d48664b01abc05fe16156a0a85.zip |
Bug 525733 - Move operations bundle to Java 8
* Bump BREE.
* Bump minor version.
* Enable warnings for newer versions.
* Lambda conversion.
* Rename parameters to not collide with parent variables.
* Remove redundant type arguments
Change-Id: I5d022021db56baa19b5b7185bd679170159f6de9
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
24 files changed, 195 insertions, 171 deletions
diff --git a/bundles/org.eclipse.equinox.p2.operations/.classpath b/bundles/org.eclipse.equinox.p2.operations/.classpath index 64c5e31b7..eca7bdba8 100644 --- a/bundles/org.eclipse.equinox.p2.operations/.classpath +++ b/bundles/org.eclipse.equinox.p2.operations/.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.operations/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.equinox.p2.operations/.settings/org.eclipse.jdt.core.prefs index 449cf187f..6cf497422 100644 --- a/bundles/org.eclipse.equinox.p2.operations/.settings/org.eclipse.jdt.core.prefs +++ b/bundles/org.eclipse.equinox.p2.operations/.settings/org.eclipse.jdt.core.prefs @@ -6,29 +6,46 @@ org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch org.eclipse.jdt.core.circularClasspath=error org.eclipse.jdt.core.classpath.exclusionPatterns=enabled 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 org.eclipse.jdt.core.compiler.doc.comment.support=enabled org.eclipse.jdt.core.compiler.maxProblemPerUnit=1000 +org.eclipse.jdt.core.compiler.problem.APILeak=warning org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning org.eclipse.jdt.core.compiler.problem.deprecation=warning org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled 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=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 org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning org.eclipse.jdt.core.compiler.problem.forbiddenReference=error org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning @@ -36,41 +53,79 @@ org.eclipse.jdt.core.compiler.problem.invalidJavadoc=error 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.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled 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 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=warning +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning +org.eclipse.jdt.core.compiler.problem.terminalDeprecation=warning org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled 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 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 +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=enabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=enabled 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.operations/.settings/org.eclipse.jdt.ui.prefs b/bundles/org.eclipse.equinox.p2.operations/.settings/org.eclipse.jdt.ui.prefs index dbe72f165..6fd24f5e3 100644 --- a/bundles/org.eclipse.equinox.p2.operations/.settings/org.eclipse.jdt.ui.prefs +++ b/bundles/org.eclipse.equinox.p2.operations/.settings/org.eclipse.jdt.ui.prefs @@ -1,4 +1,3 @@ -#Sun Sep 23 11:59:14 EDT 2007 eclipse.preferences.version=1 editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true formatter_profile=_core @@ -12,18 +11,25 @@ sp_cleanup.add_default_serial_version_id=true sp_cleanup.add_generated_serial_version_id=false sp_cleanup.add_missing_annotations=true sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false sp_cleanup.add_missing_nls_tags=false sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=false sp_cleanup.add_serial_version_id=false sp_cleanup.always_use_blocks=true sp_cleanup.always_use_parentheses_in_expressions=false sp_cleanup.always_use_this_for_non_static_field_access=false sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_functional_interfaces=false sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.correct_indentation=false sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=false +sp_cleanup.insert_inferred_type_arguments=false sp_cleanup.make_local_variable_final=false sp_cleanup.make_parameters_final=false sp_cleanup.make_private_fields_final=true +sp_cleanup.make_type_abstract_if_missing_method=false sp_cleanup.make_variable_declarations_final=true sp_cleanup.never_use_blocks=false sp_cleanup.never_use_parentheses_in_expressions=true @@ -35,6 +41,7 @@ sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class= sp_cleanup.qualify_static_member_accesses_with_declaring_class=false sp_cleanup.qualify_static_method_accesses_with_declaring_class=false sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_redundant_type_arguments=false sp_cleanup.remove_trailing_whitespaces=false sp_cleanup.remove_trailing_whitespaces_all=true sp_cleanup.remove_trailing_whitespaces_ignore_empty=false @@ -48,8 +55,10 @@ sp_cleanup.remove_unused_private_methods=true sp_cleanup.remove_unused_private_types=true sp_cleanup.sort_members=false sp_cleanup.sort_members_all=false +sp_cleanup.use_anonymous_class_creation=false sp_cleanup.use_blocks=false sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_lambda=false sp_cleanup.use_parentheses_in_expressions=false sp_cleanup.use_this_for_non_static_field_access=false sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true diff --git a/bundles/org.eclipse.equinox.p2.operations/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.operations/META-INF/MANIFEST.MF index 572c2ac2a..7ee9870f8 100644 --- a/bundles/org.eclipse.equinox.p2.operations/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.operations/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.equinox.p2.operations;singleton:=true -Bundle-Version: 2.4.300.qualifier +Bundle-Version: 2.5.0.qualifier Bundle-Activator: org.eclipse.equinox.internal.p2.operations.Activator Bundle-Vendor: %providerName Bundle-Localization: plugin @@ -10,7 +10,7 @@ Export-Package: org.eclipse.equinox.internal.p2.operations;x-friends:="org.eclip org.eclipse.equinox.p2.operations;version="2.0.0" Require-Bundle: org.eclipse.equinox.common;bundle-version="3.6.0", org.eclipse.core.jobs;bundle-version="3.5.0" -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-ActivationPolicy: lazy Import-Package: org.eclipse.equinox.internal.p2.core.helpers, org.eclipse.equinox.internal.p2.director, diff --git a/bundles/org.eclipse.equinox.p2.operations/pom.xml b/bundles/org.eclipse.equinox.p2.operations/pom.xml index cfcd963f6..6659b210f 100644 --- a/bundles/org.eclipse.equinox.p2.operations/pom.xml +++ b/bundles/org.eclipse.equinox.p2.operations/pom.xml @@ -19,6 +19,6 @@ </parent> <groupId>org.eclipse.equinox</groupId> <artifactId>org.eclipse.equinox.p2.operations</artifactId> - <version>2.4.300-SNAPSHOT</version> + <version>2.5.0-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project> diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/Activator.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/Activator.java index 8d5a2fc02..ff230a21f 100644 --- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/Activator.java +++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/Activator.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 @@ -24,10 +24,12 @@ public class Activator implements BundleActivator { return context; } + @Override public void start(BundleContext bundleContext) throws Exception { Activator.context = bundleContext; } + @Override public void stop(BundleContext bundleContext) throws Exception { Activator.context = null; } diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/PlannerResolutionJob.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/PlannerResolutionJob.java index 78264ab90..f8931b17e 100644 --- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/PlannerResolutionJob.java +++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/PlannerResolutionJob.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 @@ -65,6 +65,7 @@ public class PlannerResolutionJob extends ProvisioningJob implements IProfileCha this.firstPass = firstPass; } + @Override public IStatus runModal(IProgressMonitor monitor) { SubMonitor sub; if (evaluator != null) { @@ -117,6 +118,7 @@ public class PlannerResolutionJob extends ProvisioningJob implements IProfileCha return report; } + @Override public String getProfileId() { return profileId; } diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/RemediationResolutionJob.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/RemediationResolutionJob.java index 1c10d322f..528591415 100644 --- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/RemediationResolutionJob.java +++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/RemediationResolutionJob.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 IBM Corporation and others. + * Copyright (c) 2010, 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 @@ -31,6 +31,7 @@ public class RemediationResolutionJob extends PlannerResolutionJob { this.requestHolder = requestFromOperation; } + @Override public IStatus runModal(IProgressMonitor monitor) { SubMonitor sub = SubMonitor.convert(monitor, 2); try { diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/RequestFlexer.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/RequestFlexer.java index cb1a3ca70..e071acc21 100644 --- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/RequestFlexer.java +++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/RequestFlexer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013 Red Hat, Inc. and others + * Copyright (c) 2013, 2017 Red Hat, 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 @@ -41,10 +41,10 @@ public class RequestFlexer { private ProvisioningContext provisioningContext; - Set<IRequirement> requirementsForElementsBeingInstalled = new HashSet<IRequirement>(); - Set<IRequirement> requirementsForElementsAlreadyInstalled = new HashSet<IRequirement>(); - Map<IRequirement, Map<String, String>> propertiesPerRequirement = new HashMap<IRequirement, Map<String, String>>(); - Map<IRequirement, List<String>> removedPropertiesPerRequirement = new HashMap<IRequirement, List<String>>(); + Set<IRequirement> requirementsForElementsBeingInstalled = new HashSet<>(); + Set<IRequirement> requirementsForElementsAlreadyInstalled = new HashSet<>(); + Map<IRequirement, Map<String, String>> propertiesPerRequirement = new HashMap<>(); + Map<IRequirement, List<String>> removedPropertiesPerRequirement = new HashMap<>(); IProfile profile; @@ -137,8 +137,8 @@ public class RequestFlexer { private IProfileChangeRequest computeEffectiveChangeRequest(IProvisioningPlan intermediaryPlan, IProfileChangeRequest loosenedRequest, IProfileChangeRequest originalRequest) { IProfileChangeRequest finalChangeRequest = planner.createChangeRequest(profile); // We have the following two variables because a IPCRequest can not be muted - Set<IInstallableUnit> iusToAdd = new HashSet<IInstallableUnit>(); - Set<IInstallableUnit> iusToRemove = new HashSet<IInstallableUnit>(); + Set<IInstallableUnit> iusToAdd = new HashSet<>(); + Set<IInstallableUnit> iusToRemove = new HashSet<>(); for (IRequirement beingInstalled : requirementsForElementsBeingInstalled) { IQuery<IInstallableUnit> query = QueryUtil.createMatchQuery(beingInstalled.getMatches()); @@ -176,7 +176,7 @@ public class RequestFlexer { iusToRemove.addAll(originalRequest.getRemovals()); //Remove entries that are both in the additions and removals (since this is a no-op) - HashSet<IInstallableUnit> commons = new HashSet<IInstallableUnit>(iusToAdd); + HashSet<IInstallableUnit> commons = new HashSet<>(iusToAdd); if (commons.retainAll(iusToRemove)) { iusToAdd.removeAll(commons); iusToRemove.removeAll(commons); @@ -248,11 +248,11 @@ public class RequestFlexer { SubMonitor subMonitor = SubMonitor.convert(monitor, requestedAdditions.size()); for (IInstallableUnit addedIU : requestedAdditions) { SubMonitor iterationMonitor = subMonitor.split(1); - Collection<IInstallableUnit> potentialUpdates = allowDifferentVersion ? findAllVersionsAvailable(addedIU, iterationMonitor) : new ArrayList<IInstallableUnit>(); + Collection<IInstallableUnit> potentialUpdates = allowDifferentVersion ? findAllVersionsAvailable(addedIU, iterationMonitor) : new ArrayList<>(); foundDifferentVersionsForElementsToInstall = (foundDifferentVersionsForElementsToInstall || (potentialUpdates.size() == 0 ? false : true)); potentialUpdates.add(addedIU); //Make sure that we include the IU that we were initially trying to install - Collection<IRequirement> newRequirement = new ArrayList<IRequirement>(1); + Collection<IRequirement> newRequirement = new ArrayList<>(1); IRequirement req = createORRequirement(potentialUpdates, allowPartialInstall || isRequestedInstallationOptional(addedIU, originalRequest)); newRequirement.add(req); newRequest.addExtraRequirements(newRequirement); @@ -271,9 +271,9 @@ public class RequestFlexer { //This keeps track for each requirement created (those created to loosen the constraint), of the original IU and the properties associated with it in the profile //This is used for more easily construct the final profile change request private void rememberIUProfileProperties(IInstallableUnit iu, IRequirement req, IProfileChangeRequest originalRequest, boolean includeProfile) { - Map<String, String> allProperties = new HashMap<String, String>(); + Map<String, String> allProperties = new HashMap<>(); if (includeProfile) { - Map<String, String> tmp = new HashMap<String, String>(profile.getInstallableUnitProperties(iu)); + Map<String, String> tmp = new HashMap<>(profile.getInstallableUnitProperties(iu)); List<String> propertiesToRemove = ((ProfileChangeRequest) originalRequest).getInstallableUnitProfilePropertiesToRemove().get(iu); if (propertiesToRemove != null) { for (String toRemove : propertiesToRemove) { @@ -302,7 +302,7 @@ public class RequestFlexer { } private Collection<IInstallableUnit> findAllVersionsAvailable(IInstallableUnit iu, IProgressMonitor monitor) { - Collection<IInstallableUnit> allVersions = new HashSet<IInstallableUnit>(); + Collection<IInstallableUnit> allVersions = new HashSet<>(); SubMonitor sub = SubMonitor.convert(monitor, 2); allVersions.addAll(findIUsWithSameId(iu, sub.newChild(1))); allVersions.addAll(findUpdates(iu, sub.newChild(1))); @@ -317,7 +317,7 @@ public class RequestFlexer { private Collection<IInstallableUnit> findUpdates(IInstallableUnit iu, IProgressMonitor monitor) { SubMonitor subMonitor = SubMonitor.convert(monitor, 1); - Collection<IInstallableUnit> availableUpdates = new HashSet<IInstallableUnit>(); + Collection<IInstallableUnit> availableUpdates = new HashSet<>(); IQueryResult<IInstallableUnit> updatesAvailable = planner.updatesFor(iu, provisioningContext, subMonitor.split(1)); for (Iterator<IInstallableUnit> iterator = updatesAvailable.iterator(); iterator.hasNext();) { availableUpdates.add(iterator.next()); @@ -350,10 +350,10 @@ public class RequestFlexer { Set<IInstallableUnit> allRoots = getRoots(); for (IInstallableUnit existingIU : allRoots) { - Collection<IInstallableUnit> potentialUpdates = allowInstalledUpdate ? findUpdates(existingIU, monitor) : new HashSet<IInstallableUnit>(); + Collection<IInstallableUnit> potentialUpdates = allowInstalledUpdate ? findUpdates(existingIU, monitor) : new HashSet<>(); foundDifferentVersionsForElementsInstalled = (foundDifferentVersionsForElementsInstalled || (potentialUpdates.size() == 0 ? false : true)); potentialUpdates.add(existingIU); - Collection<IRequirement> newRequirement = new ArrayList<IRequirement>(1); + Collection<IRequirement> newRequirement = new ArrayList<>(1); //when the element is requested for removal or is installed optionally we make sure to mark it optional, otherwise the removal woudl fail IRequirement req = createORRequirement(potentialUpdates, allowInstalledRemoval || removalRequested(existingIU, originalRequest) || isOptionallyInstalled(existingIU, originalRequest)); newRequirement.add(req); diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/ResolutionResult.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/ResolutionResult.java index 16d360cf2..5254edc6c 100644 --- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/ResolutionResult.java +++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/ResolutionResult.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 @@ -24,7 +24,7 @@ import org.eclipse.equinox.p2.metadata.IInstallableUnit; public class ResolutionResult { private static final String NESTING_INDENT = " "; //$NON-NLS-1$ - private final HashMap<IInstallableUnit, MultiStatus> iuToStatusMap = new HashMap<IInstallableUnit, MultiStatus>(); + private final HashMap<IInstallableUnit, MultiStatus> iuToStatusMap = new HashMap<>(); private MultiStatus summaryStatus; public IStatus getSummaryStatus() { diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/SearchForUpdatesResolutionJob.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/SearchForUpdatesResolutionJob.java index 5fcd8f152..fe359bd20 100644 --- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/SearchForUpdatesResolutionJob.java +++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/SearchForUpdatesResolutionJob.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 IBM Corporation and others. + * Copyright (c) 2010, 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 @@ -31,6 +31,7 @@ public class SearchForUpdatesResolutionJob extends PlannerResolutionJob { this.operation = operation; } + @Override public IStatus runModal(IProgressMonitor monitor) { SubMonitor sub = SubMonitor.convert(monitor); try { @@ -48,6 +49,7 @@ public class SearchForUpdatesResolutionJob extends PlannerResolutionJob { } // This is made public for the automated tests + @Override public ProfileChangeRequest getProfileChangeRequest() { return request; } diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/InstallOperation.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/InstallOperation.java index 79b613ce7..e5a59bfc6 100644 --- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/InstallOperation.java +++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/InstallOperation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2012 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 @@ -66,10 +66,7 @@ public class InstallOperation extends ProfileChangeOperation { this.toInstall = toInstall; } - /* - * (non-Javadoc) - * @see org.eclipse.equinox.p2.operations.ProfileChangeOperation#computeProfileChangeRequest(org.eclipse.core.runtime.MultiStatus, org.eclipse.core.runtime.IProgressMonitor) - */ + @Override protected void computeProfileChangeRequest(MultiStatus status, IProgressMonitor monitor) { request = ProfileChangeRequest.createByProfileId(session.getProvisioningAgent(), profileId); IProfile profile = session.getProfileRegistry().getProfile(profileId); @@ -146,16 +143,12 @@ public class InstallOperation extends ProfileChangeOperation { request.setInstallableUnitProfileProperty(entryToInstall, IProfile.PROP_PROFILE_ROOT_IU, Boolean.toString(true)); } - /* (non-Javadoc) - * @see org.eclipse.equinox.p2.operations.ProfileChangeOperation#getResolveJobName() - */ + @Override protected String getResolveJobName() { return Messages.InstallOperation_ResolveJobName; } - /* (non-Javadoc) - * @see org.eclipse.equinox.p2.operations.ProfileChangeOperation#getProvisioningJobName() - */ + @Override protected String getProvisioningJobName() { return Messages.InstallOperation_InstallJobName; @@ -170,14 +163,12 @@ public class InstallOperation extends ProfileChangeOperation { @Override IFailedStatusEvaluator getSecondPassEvaluator() { - return new IFailedStatusEvaluator() { - public ProvisioningContext getSecondPassProvisioningContext(IProvisioningPlan failedPlan) { - // Follow metadata repository references if the first try fails - // There should be real API for this! - if (missingRequirement(failedPlan)) - context.setProperty(ProvisioningContext.FOLLOW_REPOSITORY_REFERENCES, Boolean.toString(true)); - return context; - } + return failedPlan -> { + // Follow metadata repository references if the first try fails + // There should be real API for this! + if (missingRequirement(failedPlan)) + context.setProperty(ProvisioningContext.FOLLOW_REPOSITORY_REFERENCES, Boolean.toString(true)); + return context; }; } diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/OperationFactory.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/OperationFactory.java index c016de25b..77f341dd3 100644 --- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/OperationFactory.java +++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/OperationFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Sonatype, Inc. and others. + * Copyright (c) 2011, 2017 Sonatype, 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 @@ -51,7 +51,7 @@ public class OperationFactory { //Return a list of IUs from the list of versionedIDs originally provided private Collection<IInstallableUnit> gatherIUs(IQueryable<IInstallableUnit> searchContext, Collection<? extends IVersionedId> ius, boolean checkIUs, IProgressMonitor monitor) throws ProvisionException { - Collection<IInstallableUnit> gatheredIUs = new ArrayList<IInstallableUnit>(ius.size()); + Collection<IInstallableUnit> gatheredIUs = new ArrayList<>(ius.size()); for (IVersionedId versionedId : ius) { if (!checkIUs && versionedId instanceof IInstallableUnit) { @@ -134,7 +134,7 @@ public class OperationFactory { IProfileRegistry registry = (IProfileRegistry) getAgent().getService(IProfileRegistry.SERVICE_NAME); IProfile profile = registry.getProfile(IProfileRegistry.SELF); if (profile == null) - return new CollectionResult<IInstallableUnit>(null); + return new CollectionResult<>(null); if (rootsOnly) return profile.query(new UserVisibleRootQuery(), monitor); return profile.query(QueryUtil.ALL_UNITS, monitor); diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProfileChangeOperation.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProfileChangeOperation.java index ec1923553..7fce4a549 100644 --- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProfileChangeOperation.java +++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProfileChangeOperation.java @@ -1,5 +1,5 @@ /*******************************************************************************
- * Copyright (c) 2009, 2013 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
@@ -353,10 +353,7 @@ public abstract class ProfileChangeOperation implements IProfileChangeJob { return context;
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.equinox.p2.operations.IProfileChangeJob#getProfileId()
- */
+ @Override
public String getProfileId() {
return profileId;
}
@@ -380,15 +377,11 @@ public abstract class ProfileChangeOperation implements IProfileChangeJob { }
IFailedStatusEvaluator getSecondPassEvaluator() {
- return new IFailedStatusEvaluator() {
- public ProvisioningContext getSecondPassProvisioningContext(IProvisioningPlan failedPlan) {
- return null;
- }
- };
+ return failedPlan -> null;
}
- protected void updateJobProvisioningContexts(PlannerResolutionJob job, ProvisioningContext context) {
- job.setFirstPassProvisioningContext(context);
+ protected void updateJobProvisioningContexts(PlannerResolutionJob resolutionJob, ProvisioningContext provisioningContext) {
+ resolutionJob.setFirstPassProvisioningContext(provisioningContext);
}
}
diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProfileModificationJob.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProfileModificationJob.java index fbab41a70..abf920518 100644 --- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProfileModificationJob.java +++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProfileModificationJob.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 @@ -55,18 +55,12 @@ public class ProfileModificationJob extends ProvisioningJob implements IProfileC this.phaseSet = phaseSet; } - /* - * (non-Javadoc) - * @see org.eclipse.equinox.p2.operations.IProfileChangeJob#getProfileId() - */ + @Override public String getProfileId() { return profileId; } - /* - * (non-Javadoc) - * @see org.eclipse.equinox.p2.operations.ProvisioningJob#runModal(org.eclipse.core.runtime.IProgressMonitor) - */ + @Override public IStatus runModal(IProgressMonitor monitor) { if (monitor == null) monitor = new NullProgressMonitor(); @@ -92,10 +86,7 @@ public class ProfileModificationJob extends ProvisioningJob implements IProfileC this.taskName = label; } - /* - * (non-Javadoc) - * @see org.eclipse.equinox.p2.operations.ProvisioningJob#getRestartPolicy() - */ + @Override public int getRestartPolicy() { //if we are installing into self we must always use the restart policy if (IProfileRegistry.SELF.equals(profileId)) diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProvisioningJob.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProvisioningJob.java index e0c57a8df..91f861fc7 100644 --- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProvisioningJob.java +++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProvisioningJob.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 @@ -10,12 +10,11 @@ *******************************************************************************/ package org.eclipse.equinox.p2.operations; -import org.eclipse.equinox.p2.core.ProvisionException; - import org.eclipse.core.runtime.*; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.equinox.internal.p2.operations.Activator; import org.eclipse.equinox.internal.p2.operations.Messages; +import org.eclipse.equinox.p2.core.ProvisionException; import org.eclipse.osgi.util.NLS; /** @@ -40,54 +39,64 @@ public abstract class ProvisioningJob extends Job { additionalMonitor = monitor2; } + @Override public void beginTask(String name, int totalWork) { super.beginTask(name, totalWork); additionalMonitor.beginTask(name, totalWork); } + @Override public void clearBlocked() { super.clearBlocked(); if (additionalMonitor instanceof IProgressMonitorWithBlocking) ((IProgressMonitorWithBlocking) additionalMonitor).clearBlocked(); } + @Override public void done() { super.done(); additionalMonitor.done(); } + @Override public void internalWorked(double work) { super.internalWorked(work); additionalMonitor.internalWorked(work); } + @Override public boolean isCanceled() { if (super.isCanceled()) return true; return additionalMonitor.isCanceled(); } + @Override public void setBlocked(IStatus reason) { super.setBlocked(reason); if (additionalMonitor instanceof IProgressMonitorWithBlocking) ((IProgressMonitorWithBlocking) additionalMonitor).setBlocked(reason); } + @Override public void setCanceled(boolean b) { super.setCanceled(b); additionalMonitor.setCanceled(b); } + @Override public void setTaskName(String name) { super.setTaskName(name); additionalMonitor.setTaskName(name); } + @Override public void subTask(String name) { super.subTask(name); additionalMonitor.subTask(name); } + @Override public void worked(int work) { super.worked(work); additionalMonitor.worked(work); @@ -170,6 +179,7 @@ public abstract class ProvisioningJob extends Job { * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) * */ + @Override public final IStatus run(IProgressMonitor monitor) { IProgressMonitor wrappedMonitor = getCombinedProgressMonitor(monitor, additionalMonitor); IStatus status = Status.OK_STATUS; diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProvisioningSession.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProvisioningSession.java index 5e906f4d0..72aff8ab0 100644 --- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProvisioningSession.java +++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProvisioningSession.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2015 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 @@ -221,6 +221,7 @@ public class ProvisioningSession { public void rememberJob(Job job) { scheduledJobs.add(job); job.addJobChangeListener(new JobChangeAdapter() { + @Override public void done(IJobChangeEvent event) { scheduledJobs.remove(event.getJob()); } diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/RemediationOperation.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/RemediationOperation.java index ab0d55748..c6770d5d8 100644 --- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/RemediationOperation.java +++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/RemediationOperation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013 Red Hat, Inc. and others + * Copyright (c) 2013, 2017 Red Hat, 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 @@ -19,7 +19,6 @@ import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.metadata.Version; import org.eclipse.equinox.p2.planner.IPlanner; import org.eclipse.equinox.p2.planner.IProfileChangeRequest; -import org.eclipse.equinox.p2.repository.IRunnableWithProgress; /** * <p> @@ -66,7 +65,7 @@ public class RemediationOperation extends ProfileChangeOperation { public RemediationOperation(ProvisioningSession session, IProfileChangeRequest originalRequest, RemedyConfig[] remedyConfigs) { super(session); this.originalRequest = originalRequest; - remedies = new ArrayList<Remedy>(); + remedies = new ArrayList<>(); this.remedyConfigs = remedyConfigs; } @@ -101,7 +100,7 @@ public class RemediationOperation extends ProfileChangeOperation { private IStatus computeAllRemediations(IProgressMonitor monitor) { SubMonitor sub = SubMonitor.convert(monitor, remedyConfigs.length); sub.setTaskName(Messages.RemediationOperation_ProfileChangeRequestProgress); - List<Remedy> tmpRemedies = new ArrayList<Remedy>(remedyConfigs.length); + List<Remedy> tmpRemedies = new ArrayList<>(remedyConfigs.length); try { for (int i = 0; i < remedyConfigs.length; i++) { sub.subTask((i + 1) + " / " + remedyConfigs.length); //$NON-NLS-1$ @@ -185,6 +184,7 @@ public class RemediationOperation extends ProfileChangeOperation { return Messages.RemediationOperation_RemediationJobName; } + @Override public ProvisioningJob getProvisioningJob(IProgressMonitor monitor) { IStatus status = getResolutionResult(); if (status.getSeverity() != IStatus.CANCEL && status.getSeverity() != IStatus.ERROR) { @@ -201,6 +201,7 @@ public class RemediationOperation extends ProfileChangeOperation { return (ProfileChangeRequest) originalRequest; } + @Override void makeResolveJob(final IProgressMonitor monitor) { // throw away any previous requests request = null; @@ -209,17 +210,15 @@ public class RemediationOperation extends ProfileChangeOperation { // for the resolution job to get the request from the operation after it has been // computed. final ProfileChangeRequest[] requestHolder = new ProfileChangeRequest[1]; - job = new RemediationResolutionJob(getResolveJobName(), session, profileId, request, getFirstPassProvisioningContext(), getSecondPassEvaluator(), noChangeRequest, new IRunnableWithProgress() { - public void run(IProgressMonitor mon) throws OperationCanceledException { - SubMonitor sub = SubMonitor.convert(mon, 2); - // We only check for other jobs running if this job is *not* scheduled - if (job.getState() == Job.NONE && session.hasScheduledOperationsFor(profileId)) { - noChangeRequest.add(PlanAnalyzer.getStatus(IStatusCodes.OPERATION_ALREADY_IN_PROGRESS, null)); - } else { - sub.worked(1); - computeProfileChangeRequest(noChangeRequest, sub.newChild(1)); - requestHolder[0] = RemediationOperation.this.request; - } + job = new RemediationResolutionJob(getResolveJobName(), session, profileId, request, getFirstPassProvisioningContext(), getSecondPassEvaluator(), noChangeRequest, mon -> { + SubMonitor sub = SubMonitor.convert(mon, 2); + // We only check for other jobs running if this job is *not* scheduled + if (job.getState() == Job.NONE && session.hasScheduledOperationsFor(profileId)) { + noChangeRequest.add(PlanAnalyzer.getStatus(IStatusCodes.OPERATION_ALREADY_IN_PROGRESS, null)); + } else { + sub.worked(1); + computeProfileChangeRequest(noChangeRequest, sub.newChild(1)); + requestHolder[0] = RemediationOperation.this.request; } }, requestHolder, this); } @@ -232,7 +231,7 @@ public class RemediationOperation extends ProfileChangeOperation { } private void computeRemedyDetails(Remedy remedy) { - ArrayList<String> updateIds = new ArrayList<String>(); + ArrayList<String> updateIds = new ArrayList<>(); for (IInstallableUnit addedIU : remedy.getRequest().getAdditions()) { for (IInstallableUnit removedIU : remedy.getRequest().getRemovals()) { if (removedIU.getId().equals(addedIU.getId())) { diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/Remedy.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/Remedy.java index 59d3ff859..648e980f2 100644 --- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/Remedy.java +++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/Remedy.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013 Red Hat, Inc. and others + * Copyright (c) 2013, 2017 Red Hat, 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 @@ -45,7 +45,7 @@ public class Remedy { public Remedy(IProfileChangeRequest originalRequest) { this.originalRequest = originalRequest; - this.iusDetails = new ArrayList<RemedyIUDetail>(); + this.iusDetails = new ArrayList<>(); } public RemedyConfig getConfig() { diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/RemedyConfig.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/RemedyConfig.java index 53c8007cc..89a18168c 100644 --- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/RemedyConfig.java +++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/RemedyConfig.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013 Red Hat, Inc. and others + * Copyright (c) 2013, 2017 Red Hat, 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 @@ -46,7 +46,7 @@ public class RemedyConfig { } public static RemedyConfig[] getAllRemedyConfigs() { - Collection<RemedyConfig> remedyConfigs = new ArrayList<RemedyConfig>(); + Collection<RemedyConfig> remedyConfigs = new ArrayList<>(); int allMasks = (1 << 4); for (int i = 1; i < allMasks; i++) { RemedyConfig remedyConfig = new RemedyConfig(); diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/SynchronizeOperation.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/SynchronizeOperation.java index 3e9e4c493..da615804d 100644 --- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/SynchronizeOperation.java +++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/SynchronizeOperation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Sonatype, Inc. and others. + * Copyright (c) 2011, 2017 Sonatype, 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 @@ -47,10 +47,7 @@ public class SynchronizeOperation extends InstallOperation { super(session, toInstall); } - /* - * (non-Javadoc) - * @see org.eclipse.equinox.p2.operations.ProfileChangeOperation#computeProfileChangeRequest(org.eclipse.core.runtime.MultiStatus, org.eclipse.core.runtime.IProgressMonitor) - */ + @Override protected void computeProfileChangeRequest(MultiStatus status, IProgressMonitor monitor) { request = ProfileChangeRequest.createByProfileId(session.getProvisioningAgent(), profileId); IProfile profile; diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/UninstallOperation.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/UninstallOperation.java index e9899eaf5..5adac9c39 100644 --- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/UninstallOperation.java +++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/UninstallOperation.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 @@ -18,7 +18,8 @@ import org.eclipse.core.runtime.MultiStatus; import org.eclipse.equinox.internal.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.p2.operations.IFailedStatusEvaluator; import org.eclipse.equinox.internal.p2.operations.Messages; -import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.ProvisioningContext; import org.eclipse.equinox.p2.metadata.IInstallableUnit; /** @@ -55,9 +56,7 @@ public class UninstallOperation extends ProfileChangeOperation { this.toUninstall = toUninstall; } - /* (non-Javadoc) - * @see org.eclipse.equinox.p2.operations.ProfileChangeOperation#computeProfileChangeRequest(org.eclipse.core.runtime.IProgressMonitor) - */ + @Override protected void computeProfileChangeRequest(MultiStatus status, IProgressMonitor monitor) { request = ProfileChangeRequest.createByProfileId(session.getProvisioningAgent(), profileId); request.removeAll(toUninstall); @@ -71,16 +70,12 @@ public class UninstallOperation extends ProfileChangeOperation { } - /* (non-Javadoc) - * @see org.eclipse.equinox.p2.operations.ProfileChangeOperation#getProvisioningJobName() - */ + @Override protected String getProvisioningJobName() { return Messages.UninstallOperation_ProvisioningJobName; } - /* (non-Javadoc) - * @see org.eclipse.equinox.p2.operations.ProfileChangeOperation#getResolveJobName() - */ + @Override protected String getResolveJobName() { return Messages.UninstallOperation_ResolveJobName; } @@ -95,10 +90,6 @@ public class UninstallOperation extends ProfileChangeOperation { @Override IFailedStatusEvaluator getSecondPassEvaluator() { - return new IFailedStatusEvaluator() { - public ProvisioningContext getSecondPassProvisioningContext(IProvisioningPlan failedPlan) { - return context; - } - }; + return failedPlan -> context; } } diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/Update.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/Update.java index 3a071c3d5..1280cf083 100644 --- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/Update.java +++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/Update.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 @@ -34,9 +34,7 @@ public class Update { this.replacement = replacement; } - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ + @Override public boolean equals(Object obj) { if (this == obj) return true; @@ -52,9 +50,7 @@ public class Update { return toUpdate.equals(other.toUpdate) && replacement.equals(other.replacement); } - /* (non-Javadoc) - * @see java.lang.Object#hashCode() - */ + @Override public int hashCode() { final int prime = 31; int result = 1; @@ -63,9 +59,7 @@ public class Update { return result; } - /*(non-Javadoc) - * @see java.lang.Object#toString() - */ + @Override public String toString() { return "Update " + toUpdate.toString() + " ==> " + replacement.toString(); //$NON-NLS-1$ //$NON-NLS-2$ } diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/UpdateOperation.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/UpdateOperation.java index b8bf802b2..8706c7a1e 100644 --- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/UpdateOperation.java +++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/UpdateOperation.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 @@ -21,7 +21,6 @@ import org.eclipse.equinox.p2.engine.query.UserVisibleRootQuery; import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.planner.ProfileInclusionRules; import org.eclipse.equinox.p2.query.*; -import org.eclipse.equinox.p2.repository.IRunnableWithProgress; /** * An UpdateOperation describes an operation that updates {@link IInstallableUnit}s in @@ -68,7 +67,7 @@ public class UpdateOperation extends ProfileChangeOperation { public static final int STATUS_NOTHING_TO_UPDATE = IStatusCodes.NOTHING_TO_UPDATE; private Collection<IInstallableUnit> iusToUpdate; - private HashMap<IInstallableUnit, List<Update>> possibleUpdatesByIU = new HashMap<IInstallableUnit, List<Update>>(); + private HashMap<IInstallableUnit, List<Update>> possibleUpdatesByIU = new HashMap<>(); private List<Update> defaultUpdates; /** @@ -103,7 +102,7 @@ public class UpdateOperation extends ProfileChangeOperation { * updates. */ public void setSelectedUpdates(Update[] defaultUpdates) { - this.defaultUpdates = new ArrayList<Update>(Arrays.asList(defaultUpdates)); + this.defaultUpdates = new ArrayList<>(Arrays.asList(defaultUpdates)); } /** @@ -126,7 +125,7 @@ public class UpdateOperation extends ProfileChangeOperation { * @return an array of all possible updates */ public Update[] getPossibleUpdates() { - ArrayList<Update> all = new ArrayList<Update>(); + ArrayList<Update> all = new ArrayList<>(); for (List<Update> updates : possibleUpdatesByIU.values()) all.addAll(updates); return all.toArray(new Update[all.size()]); @@ -140,7 +139,7 @@ public class UpdateOperation extends ProfileChangeOperation { } else { // We must consult the planner IQueryResult<IInstallableUnit> replacements = session.getPlanner().updatesFor(iu, context, monitor); - updates = new ArrayList<Update>(); + updates = new ArrayList<>(); for (Iterator<IInstallableUnit> replacementIterator = replacements.iterator(); replacementIterator.hasNext();) { // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=273967 // In the case of patches, it's possible that a patch is returned as an available update @@ -158,16 +157,14 @@ public class UpdateOperation extends ProfileChangeOperation { return updates.toArray(new Update[updates.size()]); } - /* (non-Javadoc) - * @see org.eclipse.equinox.p2.operations.ProfileChangeOperation#computeProfileChangeRequest(org.eclipse.core.runtime.IProgressMonitor) - */ + @Override protected void computeProfileChangeRequest(MultiStatus status, IProgressMonitor monitor) { // Here we create a profile change request by finding the latest version available for any replacement, unless // otherwise specified in the selections. // We have to consider the scenario where the only updates available are patches, in which case the original // IU should not be removed as part of the update. - Set<IInstallableUnit> toBeUpdated = new HashSet<IInstallableUnit>(); - HashSet<Update> elementsToPlan = new HashSet<Update>(); + Set<IInstallableUnit> toBeUpdated = new HashSet<>(); + HashSet<Update> elementsToPlan = new HashSet<>(); boolean selectionSpecified = defaultUpdates != null; IProfile profile = session.getProfileRegistry().getProfile(profileId); if (profile == null) @@ -192,7 +189,7 @@ public class UpdateOperation extends ProfileChangeOperation { // Patches are keyed by their id because they are unique and should not be compared to // each other. Updates are keyed by the IU they are updating so we can compare the // versions and select the latest one - HashMap<String, Update> latestVersions = new HashMap<String, Update>(); + HashMap<String, Update> latestVersions = new HashMap<>(); boolean foundUpdate = false; boolean foundPatch = false; for (int j = 0; j < updates.length; j++) { @@ -212,7 +209,7 @@ public class UpdateOperation extends ProfileChangeOperation { // If there is a true update available, ignore any patches found // Patches are keyed by their own id if (foundPatch && foundUpdate) { - Set<String> keys = new HashSet<String>(); + Set<String> keys = new HashSet<>(); keys.addAll(latestVersions.keySet()); for (String id : keys) { // Get rid of things keyed by a different id. We've already made sure @@ -237,7 +234,7 @@ public class UpdateOperation extends ProfileChangeOperation { for (Update update : elementsToPlan) { IInstallableUnit theUpdate = update.replacement; if (defaultUpdates == null) { - defaultUpdates = new ArrayList<Update>(); + defaultUpdates = new ArrayList<>(); defaultUpdates.add(update); } else { if (!defaultUpdates.contains(update)) @@ -255,24 +252,17 @@ public class UpdateOperation extends ProfileChangeOperation { sub.done(); } - /* (non-Javadoc) - * @see org.eclipse.equinox.p2.operations.ProfileChangeOperation#getProvisioningJobName() - */ + @Override protected String getProvisioningJobName() { return Messages.UpdateOperation_UpdateJobName; } - /* (non-Javadoc) - * @see org.eclipse.equinox.p2.operations.ProfileChangeOperation#getResolveJobName() - */ + @Override protected String getResolveJobName() { return Messages.UpdateOperation_ResolveJobName; } - /* - * (non-Javadoc) - * @see org.eclipse.equinox.p2.operations.ProfileChangeOperation#prepareToResolve() - */ + @Override protected void prepareToResolve() { super.prepareToResolve(); if (iusToUpdate == null) { @@ -303,9 +293,8 @@ public class UpdateOperation extends ProfileChangeOperation { * Overridden to delay computation of the profile change request until the resolution * occurs. This is done because computing the request is expensive (it involves searching * for updates). - * (non-Javadoc) - * @see org.eclipse.equinox.p2.operations.ProfileChangeOperation#makeResolveJob(org.eclipse.core.runtime.IProgressMonitor) */ + @Override void makeResolveJob(IProgressMonitor monitor) { // throw away any previous requests request = null; @@ -314,15 +303,13 @@ public class UpdateOperation extends ProfileChangeOperation { // for the resolution job to get the request from the operation after it has been // computed. final ProfileChangeRequest[] requestHolder = new ProfileChangeRequest[1]; - job = new SearchForUpdatesResolutionJob(getResolveJobName(), session, profileId, request, getFirstPassProvisioningContext(), getSecondPassEvaluator(), noChangeRequest, new IRunnableWithProgress() { - public void run(IProgressMonitor mon) throws OperationCanceledException { - // We only check for other jobs running if this job is *not* scheduled - if (job.getState() == Job.NONE && session.hasScheduledOperationsFor(profileId)) { - noChangeRequest.add(PlanAnalyzer.getStatus(IStatusCodes.OPERATION_ALREADY_IN_PROGRESS, null)); - } else { - computeProfileChangeRequest(noChangeRequest, mon); - requestHolder[0] = UpdateOperation.this.request; - } + job = new SearchForUpdatesResolutionJob(getResolveJobName(), session, profileId, request, getFirstPassProvisioningContext(), getSecondPassEvaluator(), noChangeRequest, mon -> { + // We only check for other jobs running if this job is *not* scheduled + if (job.getState() == Job.NONE && session.hasScheduledOperationsFor(profileId)) { + noChangeRequest.add(PlanAnalyzer.getStatus(IStatusCodes.OPERATION_ALREADY_IN_PROGRESS, null)); + } else { + computeProfileChangeRequest(noChangeRequest, mon); + requestHolder[0] = UpdateOperation.this.request; } }, requestHolder, this); } @@ -332,9 +319,8 @@ public class UpdateOperation extends ProfileChangeOperation { * before we've computed the profile change request, so we must ensure that we * have already computed the profile change request. * - * (non-Javadoc) - * @see org.eclipse.equinox.p2.operations.ProfileChangeOperation#hasResolved() */ + @Override public boolean hasResolved() { return request != null && super.hasResolved(); } |