diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/TargetDefinition.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/TargetDefinition.java index 8678042348..691a8d1dd6 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/TargetDefinition.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/TargetDefinition.java @@ -524,7 +524,7 @@ private TargetBundle[] getBundles(boolean allBundles) { } } - TargetBundle[] allResolvedBundles = all.toArray(new TargetBundle[all.size()]); + TargetBundle[] allResolvedBundles = all.toArray(TargetBundle[]::new); if (allBundles) { return allResolvedBundles; } @@ -595,7 +595,7 @@ private TargetBundle[] filterBundles(TargetBundle[] bundles, NameVersionDescript } // Return matching bundles, if we are organizing by feature, do not create invalid target bundles for missing bundle includes - List result = getMatchingBundles(bundles, included.toArray(new NameVersionDescriptor[included.size()]), !containsFeatures); + List result = getMatchingBundles(bundles, included.toArray(NameVersionDescriptor[]::new), !containsFeatures); // Add in missing features as resolved bundles with error statuses if (containsFeatures && !missingFeatures.isEmpty()) { @@ -607,7 +607,7 @@ private TargetBundle[] filterBundles(TargetBundle[] bundles, NameVersionDescript } } - return result.toArray(new TargetBundle[result.size()]); + return result.toArray(TargetBundle[]::new); } /** @@ -627,9 +627,7 @@ private TargetBundle[] filterBundles(TargetBundle[] bundles, NameVersionDescript */ static List getMatchingBundles(TargetBundle[] collection, NameVersionDescriptor[] included, boolean handleMissingBundles) { if (included == null) { - ArrayList result = new ArrayList<>(); - result.addAll(Arrays.asList(collection)); - return result; + return new ArrayList<>(Arrays.asList(collection)); } // map bundles names to available versions Map> bundleMap = new HashMap<>(collection.length); @@ -995,7 +993,7 @@ public TargetFeature[] getAllFeatures() { } } - fFeatures = result.values().toArray(new TargetFeature[result.size()]); + fFeatures = result.values().toArray(TargetFeature[]::new); return fFeatures; }