Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Blewitt2015-09-06 16:13:21 +0000
committerAlex Blewitt2015-09-07 21:49:13 +0000
commite3e578c98878b6e5bc8b9140389ffe36c5651b56 (patch)
tree6c22e2cf834d3c6a267611f2d59b9d1c45511c90 /bundles/org.eclipse.equinox.p2.publisher.eclipse
parent4c1b71edc5f460ce4dc183f592449b24dbe53c97 (diff)
downloadrt.equinox.p2-e3e578c98878b6e5bc8b9140389ffe36c5651b56.tar.gz
rt.equinox.p2-e3e578c98878b6e5bc8b9140389ffe36c5651b56.tar.xz
rt.equinox.p2-e3e578c98878b6e5bc8b9140389ffe36c5651b56.zip
The new Boolean constructor creates a new instance of a Boolean object, but it can easily be replaced with Boolean.valueOf which returns the reference to the global Boolean.TRUE or Boolean.FALSE. Replace calls to new Boolean() with Boolean.valueOf() for identical semantics except without object collection. Additionally Boolean.valueOf().booleanValue() is identical to Boolean.parseBoolean() and will result in no garbage. In addition, methods will be (slightly) smaller and parseBoolean will often be in-lined by the JIT, which can often prove that the value is non-null for faster checking. Replace Boolean.valueOf().booleanValue() chains with Boolean.parseBoolean(). Some other tests can use Wrapper.valueOf() to take advantage of the built-in caches that these objects maintain (for values in the range -128..127). Signed-off-by: Alex Blewitt <alex.blewitt@gmail.com> Change-Id: I5da4216a26ffbb6b8fd3365515ee800dd82b36ae
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.publisher.eclipse')
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/FeatureManifestParser.java17
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/ProductFile.java10
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/pde/internal/build/publisher/GatherBundleAction.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher.eclipse/src_ant/org/eclipse/equinox/internal/p2/publisher/ant/AbstractPublishTask.java10
4 files changed, 21 insertions, 20 deletions
diff --git a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/FeatureManifestParser.java b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/FeatureManifestParser.java
index 38d11afdc..955bf2ff1 100644
--- a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/FeatureManifestParser.java
+++ b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/FeatureManifestParser.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 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
@@ -23,7 +23,8 @@ import org.eclipse.equinox.p2.metadata.VersionRange;
import org.eclipse.equinox.p2.publisher.eclipse.Feature;
import org.eclipse.equinox.p2.publisher.eclipse.FeatureEntry;
import org.eclipse.osgi.util.NLS;
-import org.eclipse.pde.internal.publishing.*;
+import org.eclipse.pde.internal.publishing.Activator;
+import org.eclipse.pde.internal.publishing.Constants;
import org.xml.sax.*;
import org.xml.sax.helpers.DefaultHandler;
@@ -162,8 +163,8 @@ public class FeatureManifestParser extends DefaultHandler {
result.setApplication(attributes.getValue("application")); //$NON-NLS-1$
result.setBrandingPlugin(attributes.getValue("plugin")); //$NON-NLS-1$
- result.setExclusive(Boolean.valueOf(attributes.getValue("exclusive")).booleanValue()); //$NON-NLS-1$
- result.setPrimary(Boolean.valueOf(attributes.getValue("primary")).booleanValue()); //$NON-NLS-1$
+ result.setExclusive(Boolean.parseBoolean(attributes.getValue("exclusive"))); //$NON-NLS-1$
+ result.setPrimary(Boolean.parseBoolean(attributes.getValue("primary"))); //$NON-NLS-1$
result.setColocationAffinity(attributes.getValue("colocation-affinity")); //$NON-NLS-1$
result.setProviderName(localize(attributes.getValue("provider-name"))); //$NON-NLS-1$
@@ -204,10 +205,10 @@ public class FeatureManifestParser extends DefaultHandler {
FeatureEntry entry = new FeatureEntry(attributes.getValue("id"), attributes.getValue("version"), false); //$NON-NLS-1$ //$NON-NLS-2$
String unpack = attributes.getValue("unpack"); //$NON-NLS-1$
if (unpack != null)
- entry.setUnpack(Boolean.valueOf(unpack).booleanValue());
+ entry.setUnpack(Boolean.parseBoolean(unpack));
String optional = attributes.getValue("optional"); //$NON-NLS-1$
if (optional != null)
- entry.setOptional(Boolean.valueOf(optional).booleanValue());
+ entry.setOptional(Boolean.parseBoolean(optional));
setEnvironment(attributes, entry);
String filter = attributes.getValue("filter"); //$NON-NLS-1$
if (filter != null)
@@ -237,10 +238,10 @@ public class FeatureManifestParser extends DefaultHandler {
setEnvironment(attributes, plugin);
String unpack = attributes.getValue("unpack"); //$NON-NLS-1$
if (unpack != null)
- plugin.setUnpack(Boolean.valueOf(unpack).booleanValue());
+ plugin.setUnpack(Boolean.parseBoolean(unpack));
String fragment = attributes.getValue("fragment"); //$NON-NLS-1$
if (fragment != null)
- plugin.setFragment(Boolean.valueOf(fragment).booleanValue());
+ plugin.setFragment(Boolean.parseBoolean(fragment));
String filter = attributes.getValue("filter"); //$NON-NLS-1$
if (filter != null)
plugin.setFilter(filter);
diff --git a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/ProductFile.java b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/ProductFile.java
index 9b0358cd0..a1d37c742 100644
--- a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/ProductFile.java
+++ b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/ProductFile.java
@@ -937,7 +937,7 @@ public class ProductFile extends DefaultHandler implements IProductDescriptor {
}
value = attributes.getValue(ATTRIBUTE_AUTO_START);
if (value != null)
- info.setMarkedAsStarted(Boolean.valueOf(value).booleanValue());
+ info.setMarkedAsStarted(Boolean.parseBoolean(value));
if (bundleInfos == null)
bundleInfos = new ArrayList<BundleInfo>();
bundleInfos.add(info);
@@ -1111,9 +1111,9 @@ public class ProductFile extends DefaultHandler implements IProductDescriptor {
String pluginVersion = attributes.getValue(ATTRIBUTE_VERSION);
FeatureEntry entry = new FeatureEntry(pluginId, pluginVersion != null ? pluginVersion : GENERIC_VERSION_NUMBER, true);
- entry.setFragment(Boolean.valueOf(fragment).booleanValue());
+ entry.setFragment(Boolean.parseBoolean(fragment));
- if (fragment != null && new Boolean(fragment).booleanValue()) {
+ if (fragment != null && Boolean.parseBoolean(fragment)) {
fragments.add(entry);
} else {
plugins.add(entry);
@@ -1148,7 +1148,7 @@ public class ProductFile extends DefaultHandler implements IProductDescriptor {
if (productContentType == null) { // useFeatures attribute is taken into account only if the contentType attribute is missing
String use = attributes.getValue("useFeatures"); //$NON-NLS-1$
// for backward compatibility with the old behavior
- if (use != null && Boolean.valueOf(use).booleanValue())
+ if (use != null && Boolean.parseBoolean(use))
productContentType = ProductContentType.FEATURES;
else
productContentType = ProductContentType.BUNDLES;
@@ -1219,7 +1219,7 @@ public class ProductFile extends DefaultHandler implements IProductDescriptor {
}
private void processWin(Attributes attributes) {
- // useIco = Boolean.valueOf(attributes.getValue(P_USE_ICO)).booleanValue();
+ // useIco = Boolean.parseBoolean(attributes.getValue(P_USE_ICO));
}
private void processIco(Attributes attributes) {
diff --git a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/pde/internal/build/publisher/GatherBundleAction.java b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/pde/internal/build/publisher/GatherBundleAction.java
index d82b422fc..4881ad503 100644
--- a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/pde/internal/build/publisher/GatherBundleAction.java
+++ b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/pde/internal/build/publisher/GatherBundleAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2008, 2015 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,7 +65,7 @@ public class GatherBundleAction extends BundlesAction {
String shape = manifest.get(BUNDLE_SHAPE);
if (shape == null) {
if (unpack != null) {
- shape = Boolean.valueOf(unpack).booleanValue() ? IBundleShapeAdvice.DIR : IBundleShapeAdvice.JAR;
+ shape = Boolean.parseBoolean(unpack) ? IBundleShapeAdvice.DIR : IBundleShapeAdvice.JAR;
} else {
shape = Utils.guessUnpack(bundle, Utils.getBundleClasspath(manifest)) ? IBundleShapeAdvice.DIR : IBundleShapeAdvice.JAR;
}
diff --git a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src_ant/org/eclipse/equinox/internal/p2/publisher/ant/AbstractPublishTask.java b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src_ant/org/eclipse/equinox/internal/p2/publisher/ant/AbstractPublishTask.java
index fcba0f1eb..42a1f53dc 100644
--- a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src_ant/org/eclipse/equinox/internal/p2/publisher/ant/AbstractPublishTask.java
+++ b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src_ant/org/eclipse/equinox/internal/p2/publisher/ant/AbstractPublishTask.java
@@ -57,7 +57,7 @@ public abstract class AbstractPublishTask extends Task {
}
/**
- * If not set, default is true if we aren't set as an metadata repo
+ * If not set, default is true if we aren't set as a metadata repo
*/
public boolean isArtifactRepository() {
if (artifact != null)
@@ -160,19 +160,19 @@ public abstract class AbstractPublishTask extends Task {
}
public void setCompress(String value) {
- compress = Boolean.valueOf(value).booleanValue();
+ compress = Boolean.parseBoolean(value);
}
public void setReusePackedFiles(String value) {
- reusePackedFiles = Boolean.valueOf(value).booleanValue();
+ reusePackedFiles = Boolean.parseBoolean(value);
}
public void setAppend(String value) {
- append = Boolean.valueOf(value).booleanValue();
+ append = Boolean.parseBoolean(value);
}
public void setPublishArtifacts(String value) {
- publish = Boolean.valueOf(value).booleanValue();
+ publish = Boolean.parseBoolean(value);
}
public void setArtifactRepository(String location) {

Back to the top