Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Blewitt2015-06-18 21:49:38 +0000
committerThomas Watson2015-07-09 16:17:28 +0000
commit7f7ccacb8f5c6966406bef59aaf350a336f2891e (patch)
treef7bccf23d0d15e0f143438c0ab538da0184083e2
parentbf1f2a7f4639ef15279e17d372b2703cde1408fe (diff)
downloadrt.equinox.framework-7f7ccacb8f5c6966406bef59aaf350a336f2891e.tar.gz
rt.equinox.framework-7f7ccacb8f5c6966406bef59aaf350a336f2891e.tar.xz
rt.equinox.framework-7f7ccacb8f5c6966406bef59aaf350a336f2891e.zip
Bug 470527 - Replace `new Boolean` with `Boolean.valueOf`I20150714-0800
Using `new Boolean()` results in the creation of a new object on the heap, when the flyweight `Boolean.TRUE` and `Boolean.FALSE` are available. Java 1.4 added a `Boolean.valueOf()` which can be used in place of `new Boolean()` but which will use the existing flyweight values instead. Globally change `new Boolean(...)` to `Boolean.valueOf(...)` and replace constant valued expressions with their flyweight counterparts. Defer changes to `org.osgi.util.xml.XMLParserActivator` to upstream OSGi. Bug: 470527 Change-Id: I122e4456a49e8eee9d88db0a3237f7e6b19a8469 Signed-off-by: Alex Blewitt <alex.blewitt@gmail.com>
-rw-r--r--bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateHelperImpl.java4
-rw-r--r--bundles/org.eclipse.osgi.tests/bundles_src/ext.framework.b/ext/framework/b/TestCondition.java2
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/appadmin/ApplicationAdminTest.java4
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/filter/FilterTests.java2
4 files changed, 6 insertions, 6 deletions
diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateHelperImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateHelperImpl.java
index 8d754739c..29f4e2b26 100644
--- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateHelperImpl.java
+++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateHelperImpl.java
@@ -620,7 +620,7 @@ class RequiresHolder {
// Get the visibility of all directly required bundles
for (int i = 0; i < required.length; i++) {
if (required[i].getSupplier() != null) {
- resolvedBundlesExported.put((BundleDescription) required[i].getSupplier(), new Boolean(required[i].isExported()));
+ resolvedBundlesExported.put((BundleDescription) required[i].getSupplier(), Boolean.valueOf(required[i].isExported()));
resolved.remove(required[i].getSupplier());
}
}
@@ -633,7 +633,7 @@ class RequiresHolder {
BundleSpecification[] fragmentRequiredBundles = fragments[i].getRequiredBundles();
for (int j = 0; j < fragmentRequiredBundles.length; j++) {
if (resolved.contains(fragmentRequiredBundles[j].getSupplier())) {
- resolvedBundlesExported.put((BundleDescription) fragmentRequiredBundles[j].getSupplier(), new Boolean(fragmentRequiredBundles[j].isExported()));
+ resolvedBundlesExported.put((BundleDescription) fragmentRequiredBundles[j].getSupplier(), Boolean.valueOf(fragmentRequiredBundles[j].isExported()));
resolved.remove(fragmentRequiredBundles[j].getSupplier());
}
}
diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/ext.framework.b/ext/framework/b/TestCondition.java b/bundles/org.eclipse.osgi.tests/bundles_src/ext.framework.b/ext/framework/b/TestCondition.java
index 3ea5acb94..ee640e929 100644
--- a/bundles/org.eclipse.osgi.tests/bundles_src/ext.framework.b/ext/framework/b/TestCondition.java
+++ b/bundles/org.eclipse.osgi.tests/bundles_src/ext.framework.b/ext/framework/b/TestCondition.java
@@ -87,7 +87,7 @@ public class TestCondition implements Condition {
for (int i = 0; i < conditions.length; i++) {
Boolean isSatisfied = (Boolean) context.get(conditions[i]);
if (isSatisfied == null) {
- isSatisfied = new Boolean(conditions[i].isSatisfied());
+ isSatisfied = Boolean.valueOf(conditions[i].isSatisfied());
context.put(conditions[i], isSatisfied);
}
if (!isSatisfied.booleanValue())
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/appadmin/ApplicationAdminTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/appadmin/ApplicationAdminTest.java
index 63d84b7eb..d5f681142 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/appadmin/ApplicationAdminTest.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/appadmin/ApplicationAdminTest.java
@@ -164,7 +164,7 @@ public class ApplicationAdminTest extends OSGiTest {
list.add(new Byte((byte) 0));
list.add(new Short((short) 1));
list.add(new Character((char) 0));
- list.add(new Boolean(true));
+ list.add(Boolean.TRUE);
doInvalidScheduleArgs(app, "schedule.testargs", args, "org/osgi/application/timer", "(minute=*)", true, false, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
args.put("test.arg5", new String[0]); //$NON-NLS-1$
@@ -186,7 +186,7 @@ public class ApplicationAdminTest extends OSGiTest {
args.put("test.arg18", new Byte((byte) 0)); //$NON-NLS-1$
args.put("test.arg19", new Short((short) 1)); //$NON-NLS-1$
args.put("test.arg20", new Character((char) 0)); //$NON-NLS-1$
- args.put("test.arg21", new Boolean(true)); //$NON-NLS-1$
+ args.put("test.arg21", Boolean.TRUE); //$NON-NLS-1$
doInvalidScheduleArgs(app, "schedule.testargs", args, "org/osgi/application/timer", "(minute=*)", true, false, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Map testMap = new HashMap();
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/filter/FilterTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/filter/FilterTests.java
index e2ca74051..95d4d5687 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/filter/FilterTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/filter/FilterTests.java
@@ -59,7 +59,7 @@ public abstract class FilterTests extends TestCase {
props.put("floatvalue", new Float(1.01));
props.put("doublevalue", new Double(2.01));
props.put("charvalue", new Character('A'));
- props.put("booleanvalue", new Boolean(true));
+ props.put("booleanvalue", Boolean.TRUE);
props.put("weirdvalue", new Hashtable());
props.put("primintarrayvalue", new int[] {1, 2, 3});
props.put("primlongarrayvalue", new long[] {1, 2, 3});

Back to the top