diff options
author | Alex Blewitt | 2015-06-18 18:55:01 +0000 |
---|---|---|
committer | Alex Blewitt | 2015-07-06 07:46:20 +0000 |
commit | 9ee96387c3c9b80f76fa76476f4d0fa5764f4919 (patch) | |
tree | 20a3db893b2db4503ac53222599a72ca3ef7d210 | |
parent | bde007b013512c536e1e8c5b616961a6a0140347 (diff) | |
download | rt.equinox.bundles-9ee96387c3c9b80f76fa76476f4d0fa5764f4919.tar.gz rt.equinox.bundles-9ee96387c3c9b80f76fa76476f4d0fa5764f4919.tar.xz rt.equinox.bundles-9ee96387c3c9b80f76fa76476f4d0fa5764f4919.zip |
Bug 470518 - Replace `new Boolean` with `Boolean.valueOf`
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.
Bug: 470518
Change-Id: I25742c65162e57fd553dd1284ec057cd4b333dbb
Signed-off-by: Alex Blewitt <alex.blewitt@gmail.com>
13 files changed, 22 insertions, 22 deletions
diff --git a/bundles/org.eclipse.equinox.app/osgi/org/osgi/service/application/ApplicationDescriptor.java b/bundles/org.eclipse.equinox.app/osgi/org/osgi/service/application/ApplicationDescriptor.java index 601037a95..cba59d680 100644 --- a/bundles/org.eclipse.equinox.app/osgi/org/osgi/service/application/ApplicationDescriptor.java +++ b/bundles/org.eclipse.equinox.app/osgi/org/osgi/service/application/ApplicationDescriptor.java @@ -205,7 +205,7 @@ public abstract class ApplicationDescriptor { } } /* replace the container's lock with the application model's lock, that's the correct */ - props.put(APPLICATION_LOCKED, new Boolean(locked[0])); + props.put(APPLICATION_LOCKED, Boolean.valueOf(locked[0])); return props; } @@ -551,4 +551,4 @@ public abstract class ApplicationDescriptor { } throw new ApplicationException(ApplicationException.APPLICATION_INVALID_STARTUP_ARGUMENT, "The value for key \"" + entry.getKey() + "\" is an invalid type \"" + clazz.getName() + "\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } -}
\ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/StructuredTextEnvironment.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/StructuredTextEnvironment.java index fe06e8365..88b8cdcff 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/StructuredTextEnvironment.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/StructuredTextEnvironment.java @@ -185,9 +185,9 @@ public class StructuredTextEnvironment { "ar".equals(language) || //$NON-NLS-1$ "fa".equals(language) || //$NON-NLS-1$ "ur".equals(language); //$NON-NLS-1$ - processingNeeded = new Boolean(isBidi); + processingNeeded = Boolean.valueOf(isBidi); } else { - processingNeeded = new Boolean(false); + processingNeeded = Boolean.FALSE; } } return processingNeeded.booleanValue(); diff --git a/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ConfigurationDictionaryTest.java b/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ConfigurationDictionaryTest.java index 7044a7e45..f4bdbb44f 100644 --- a/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ConfigurationDictionaryTest.java +++ b/bundles/org.eclipse.equinox.cm.test/src/org/eclipse/equinox/cm/test/ConfigurationDictionaryTest.java @@ -52,7 +52,7 @@ public class ConfigurationDictionaryTest extends TestCase { dict.put("6", new Byte((byte) 1)); dict.put("7", new Short((short) 1)); dict.put("8", new Character('a')); - dict.put("9", new Boolean(true)); + dict.put("9", Boolean.TRUE); dict.put("10", new String[] {"x"}); dict.put("11", new Integer[] {new Integer(1)}); dict.put("12", new Long[] {new Long(1)}); @@ -61,7 +61,7 @@ public class ConfigurationDictionaryTest extends TestCase { dict.put("15", new Byte[] {new Byte((byte) 1)}); dict.put("16", new Short[] {new Short((short) 1)}); dict.put("17", new Character[] {new Character('a')}); - dict.put("18", new Boolean[] {new Boolean(true)}); + dict.put("18", new Boolean[] {Boolean.TRUE}); dict.put("19", new int[] {1}); dict.put("20", new long[] {1}); dict.put("21", new float[] {1}); @@ -80,7 +80,7 @@ public class ConfigurationDictionaryTest extends TestCase { v.add(new Byte((byte) 1)); v.add(new Short((short) 1)); v.add(new Character('a')); - v.add(new Boolean(true)); + v.add(Boolean.TRUE); dict.put("28", v); Collection c = new ArrayList(); c.add(new String("x")); @@ -91,7 +91,7 @@ public class ConfigurationDictionaryTest extends TestCase { c.add(new Byte((byte) 1)); c.add(new Short((short) 1)); c.add(new Character('a')); - c.add(new Boolean(true)); + c.add(Boolean.TRUE); dict.put("29", c); } catch (IllegalArgumentException e) { fail(e.getMessage()); diff --git a/bundles/org.eclipse.equinox.http.jetty9/src/org/eclipse/equinox/http/jetty/internal/Activator.java b/bundles/org.eclipse.equinox.http.jetty9/src/org/eclipse/equinox/http/jetty/internal/Activator.java index e264e3e0e..76a9473e2 100644 --- a/bundles/org.eclipse.equinox.http.jetty9/src/org/eclipse/equinox/http/jetty/internal/Activator.java +++ b/bundles/org.eclipse.equinox.http.jetty9/src/org/eclipse/equinox/http/jetty/internal/Activator.java @@ -108,7 +108,7 @@ public class Activator implements BundleActivator { // HTTP Enabled (default is true) String httpEnabledProperty = context.getProperty(PROPERTY_PREFIX + JettyConstants.HTTP_ENABLED); - Boolean httpEnabled = (httpEnabledProperty == null) ? Boolean.TRUE : new Boolean(httpEnabledProperty); + Boolean httpEnabled = (httpEnabledProperty == null) ? Boolean.TRUE : Boolean.valueOf(httpEnabledProperty); defaultSettings.put(JettyConstants.HTTP_ENABLED, httpEnabled); // HTTP Port @@ -132,7 +132,7 @@ public class Activator implements BundleActivator { defaultSettings.put(JettyConstants.HTTP_HOST, httpHost); // HTTPS Enabled (default is false) - Boolean httpsEnabled = new Boolean(context.getProperty(PROPERTY_PREFIX + JettyConstants.HTTPS_ENABLED)); + Boolean httpsEnabled = Boolean.valueOf(context.getProperty(PROPERTY_PREFIX + JettyConstants.HTTPS_ENABLED)); defaultSettings.put(JettyConstants.HTTPS_ENABLED, httpsEnabled); if (httpsEnabled.booleanValue()) { @@ -171,11 +171,11 @@ public class Activator implements BundleActivator { String needclientauth = context.getProperty(PROPERTY_PREFIX + JettyConstants.SSL_NEEDCLIENTAUTH); if (needclientauth != null) - defaultSettings.put(JettyConstants.SSL_NEEDCLIENTAUTH, new Boolean(needclientauth)); + defaultSettings.put(JettyConstants.SSL_NEEDCLIENTAUTH, Boolean.valueOf(needclientauth)); String wantclientauth = context.getProperty(PROPERTY_PREFIX + JettyConstants.SSL_WANTCLIENTAUTH); if (wantclientauth != null) - defaultSettings.put(JettyConstants.SSL_WANTCLIENTAUTH, new Boolean(wantclientauth)); + defaultSettings.put(JettyConstants.SSL_WANTCLIENTAUTH, Boolean.valueOf(wantclientauth)); String protocol = context.getProperty(PROPERTY_PREFIX + JettyConstants.SSL_PROTOCOL); if (protocol != null) diff --git a/bundles/org.eclipse.equinox.http.registry/src/org/eclipse/equinox/http/registry/internal/FilterManager.java b/bundles/org.eclipse.equinox.http.registry/src/org/eclipse/equinox/http/registry/internal/FilterManager.java index 87b3b6269..7967d8ca5 100644 --- a/bundles/org.eclipse.equinox.http.registry/src/org/eclipse/equinox/http/registry/internal/FilterManager.java +++ b/bundles/org.eclipse.equinox.http.registry/src/org/eclipse/equinox/http/registry/internal/FilterManager.java @@ -120,7 +120,7 @@ public class FilterManager implements ExtensionPointTracker.Listener { initparams.put(paramName, paramValue); } - boolean loadOnStartup = new Boolean(filterElement.getAttribute(LOAD_ON_STARTUP)).booleanValue(); + boolean loadOnStartup = Boolean.valueOf(filterElement.getAttribute(LOAD_ON_STARTUP)).booleanValue(); if (loadOnStartup) wrapper.setLoadOnStartup(); diff --git a/bundles/org.eclipse.equinox.http.registry/src/org/eclipse/equinox/http/registry/internal/ServletManager.java b/bundles/org.eclipse.equinox.http.registry/src/org/eclipse/equinox/http/registry/internal/ServletManager.java index a42ab936c..402b026ae 100644 --- a/bundles/org.eclipse.equinox.http.registry/src/org/eclipse/equinox/http/registry/internal/ServletManager.java +++ b/bundles/org.eclipse.equinox.http.registry/src/org/eclipse/equinox/http/registry/internal/ServletManager.java @@ -121,7 +121,7 @@ public class ServletManager implements ExtensionPointTracker.Listener { initparams.put(paramName, paramValue); } - boolean loadOnStartup = new Boolean(servletElement.getAttribute(LOAD_ON_STARTUP)).booleanValue(); + boolean loadOnStartup = Boolean.valueOf(servletElement.getAttribute(LOAD_ON_STARTUP)).booleanValue(); if (loadOnStartup) wrapper.setLoadOnStartup(); diff --git a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/DataParser.java b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/DataParser.java index 9f8b7c1ea..5fec8b215 100644 --- a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/DataParser.java +++ b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/DataParser.java @@ -144,7 +144,7 @@ public class DataParser { case AttributeDefinition.BIGDECIMAL : return new BigDecimal(value); case AttributeDefinition.BOOLEAN : - return new Boolean(value); + return Boolean.valueOf(value); default : // Unknown data type return null; diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionsParser.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionsParser.java index c684525b8..3be12fba3 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionsParser.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionsParser.java @@ -696,7 +696,7 @@ public class ExtensionsParser extends DefaultHandler { * if Eclipse version specified in the plugin.xml (<?eclipse version="3.2"?>) is at least 3.2. */ private void initializeExtractNamespace() { - extractNamespaces = new Boolean(versionAtLeast(VERSION_3_2)).booleanValue(); + extractNamespaces = Boolean.valueOf(versionAtLeast(VERSION_3_2)).booleanValue(); } /** diff --git a/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/StorageAbstractTest.java b/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/StorageAbstractTest.java index 424ed8532..2b8d263a3 100644 --- a/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/StorageAbstractTest.java +++ b/bundles/org.eclipse.equinox.security.tests/src/org/eclipse/equinox/internal/security/tests/storage/StorageAbstractTest.java @@ -88,7 +88,7 @@ public class StorageAbstractTest extends TestCase { if (requiredID != null) options.put(IProviderHints.REQUIRED_MODULE_ID, requiredID); - options.put(IProviderHints.PROMPT_USER, new Boolean(false)); + options.put(IProviderHints.PROMPT_USER, Boolean.FALSE); return options; } diff --git a/bundles/org.eclipse.equinox.security.ui/src/org/eclipse/equinox/internal/security/ui/storage/DefaultPasswordProvider.java b/bundles/org.eclipse.equinox.security.ui/src/org/eclipse/equinox/internal/security/ui/storage/DefaultPasswordProvider.java index dad48d875..4acee60e8 100644 --- a/bundles/org.eclipse.equinox.security.ui/src/org/eclipse/equinox/internal/security/ui/storage/DefaultPasswordProvider.java +++ b/bundles/org.eclipse.equinox.security.ui/src/org/eclipse/equinox/internal/security/ui/storage/DefaultPasswordProvider.java @@ -63,7 +63,7 @@ public class DefaultPasswordProvider extends PasswordProvider { PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { public void run() { boolean reply = MessageDialog.openConfirm(StorageUtils.getShell(), SecUIMessages.exceptionTitle, SecUIMessages.exceptionDecode); - result[0] = new Boolean(reply); + result[0] = Boolean.valueOf(reply); } }); return result[0].booleanValue(); diff --git a/bundles/org.eclipse.equinox.security.ui/src/org/eclipse/equinox/internal/security/ui/storage/UICallbackProvider.java b/bundles/org.eclipse.equinox.security.ui/src/org/eclipse/equinox/internal/security/ui/storage/UICallbackProvider.java index b1d259826..8b2817f23 100644 --- a/bundles/org.eclipse.equinox.security.ui/src/org/eclipse/equinox/internal/security/ui/storage/UICallbackProvider.java +++ b/bundles/org.eclipse.equinox.security.ui/src/org/eclipse/equinox/internal/security/ui/storage/UICallbackProvider.java @@ -133,7 +133,7 @@ public class UICallbackProvider implements IUICallbacks { PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { public void run() { boolean reply = MessageDialog.openConfirm(StorageUtils.getShell(), SecUIMessages.generalDialogTitle, msg); - result[0] = new Boolean(reply); + result[0] = Boolean.valueOf(reply); } }); return result[0]; diff --git a/bundles/org.eclipse.equinox.security/src/org/eclipse/equinox/internal/security/storage/SecurePreferencesRoot.java b/bundles/org.eclipse.equinox.security/src/org/eclipse/equinox/internal/security/storage/SecurePreferencesRoot.java index 35f47453c..8f8d8cad2 100644 --- a/bundles/org.eclipse.equinox.security/src/org/eclipse/equinox/internal/security/storage/SecurePreferencesRoot.java +++ b/bundles/org.eclipse.equinox.security/src/org/eclipse/equinox/internal/security/storage/SecurePreferencesRoot.java @@ -246,7 +246,7 @@ public class SecurePreferencesRoot extends SecurePreferences implements IStorage // if this is (a headless run or JUnit) and prompt hint is not set up, set it to "false" boolean supressPrompts = !CallbacksProvider.getDefault().runningUI() || InternalExchangeUtils.isJUnitApp(); if (supressPrompts && container != null && !container.hasOption(IProviderHints.PROMPT_USER)) { - ((SecurePreferencesContainer) container).setOption(IProviderHints.PROMPT_USER, new Boolean(false)); + ((SecurePreferencesContainer) container).setOption(IProviderHints.PROMPT_USER, Boolean.FALSE); addedNoPrompt = true; } diff --git a/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/internal/wireadmin/WireReDispatcher.java b/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/internal/wireadmin/WireReDispatcher.java index 659d3e83b..3d58f6965 100644 --- a/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/internal/wireadmin/WireReDispatcher.java +++ b/bundles/org.eclipse.equinox.wireadmin/src/org/eclipse/equinox/internal/wireadmin/WireReDispatcher.java @@ -190,14 +190,14 @@ public class WireReDispatcher implements WireAdminListener { Wire wire = event.getWire(); if (wire != null) { props.put(WA_WIRE, wire); - props.put(WA_WIRE_CONNECTED, new Boolean(wire.isConnected())); + props.put(WA_WIRE_CONNECTED, wire.isConnected() ? Boolean.TRUE : Boolean.FALSE); if (wire.getFlavors() != null) { props.put(WA_WIRE_FLAVORS, wire.getFlavors()); } if (wire.getScope() != null) { props.put(WA_WIRE_SCOPE, wire.getScope()); } - props.put(WA_WIRE_VALID, new Boolean(wire.isValid())); + props.put(WA_WIRE_VALID, wire.isValid() ? Boolean.TRUE : Boolean.FALSE); } Throwable throwable = event.getThrowable(); if (throwable != null) { |