diff options
author | Alex Blewitt | 2015-07-31 22:08:17 +0000 |
---|---|---|
committer | Alex Blewitt | 2015-09-03 10:21:11 +0000 |
commit | 9d920dc184c0ea2271a9f088d1af6f52df1b4eed (patch) | |
tree | 6022f848e592ea43b840222a49ea0304f00c722e | |
parent | 678c63a96bd3bce570a62beb5546ca0b29d608a0 (diff) | |
download | eclipse.platform.debug-9d920dc184c0ea2271a9f088d1af6f52df1b4eed.tar.gz eclipse.platform.debug-9d920dc184c0ea2271a9f088d1af6f52df1b4eed.tar.xz eclipse.platform.debug-9d920dc184c0ea2271a9f088d1af6f52df1b4eed.zip |
Bug 474074 - Replace new Boolean with Boolean.valueOfI20150908-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
`new Boolean(...).booleanValue()` to `Boolean.parseBoolean(...)`.
Change-Id: I95bed6f2af0293c20d1ac7076ca151b85d1f962d
Signed-off-by: Alex Blewitt <alex.blewitt@gmail.com>
4 files changed, 10 insertions, 12 deletions
diff --git a/org.eclipse.debug.examples.core/pdavm/src/org/eclipse/debug/examples/pdavm/PDAVirtualMachine.java b/org.eclipse.debug.examples.core/pdavm/src/org/eclipse/debug/examples/pdavm/PDAVirtualMachine.java index 4f473c9d1..9589a844b 100644 --- a/org.eclipse.debug.examples.core/pdavm/src/org/eclipse/debug/examples/pdavm/PDAVirtualMachine.java +++ b/org.eclipse.debug.examples.core/pdavm/src/org/eclipse/debug/examples/pdavm/PDAVirtualMachine.java @@ -902,7 +902,7 @@ public class PDAVirtualMachine { void debugEventStop(Args args) { String event = args.getNextStringArg(); int stop = args.getNextIntArg(); - fEventStops.put(event, new Boolean(stop > 0)); + fEventStops.put(event, Boolean.valueOf(stop > 0)); sendCommandResponse("ok\n"); //$NON-NLS-1$ } @@ -1051,7 +1051,7 @@ public class PDAVirtualMachine { int line = args.getNextIntArg(); int stopVM = args.getNextIntArg(); - fBreakpoints.put(new Integer(line), new Boolean(stopVM != 0)); + fBreakpoints.put(new Integer(line), Boolean.valueOf(stopVM != 0)); sendCommandResponse("ok\n"); //$NON-NLS-1$ } diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/PresentationContextTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/PresentationContextTests.java index 792c3745a..9959c5d06 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/PresentationContextTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/PresentationContextTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2013 Wind River Systems and others. + * Copyright (c) 2008, 2015 Wind River Systems 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 @@ -36,7 +36,7 @@ public class PresentationContextTests extends TestCase { PresentationContext context = new PresentationContext("test"); //$NON-NLS-1$ context.setProperty("string", "string"); //$NON-NLS-1$ //$NON-NLS-2$ context.setProperty("integer", new Integer(1)); //$NON-NLS-1$ - context.setProperty("boolean", new Boolean(true)); //$NON-NLS-1$ + context.setProperty("boolean", Boolean.TRUE); //$NON-NLS-1$ context.setProperty("persistable", ResourcesPlugin.getWorkspace().getRoot().getAdapter(IPersistableElement.class)); //$NON-NLS-1$ final XMLMemento memento = XMLMemento.createWriteRoot("TEST"); //$NON-NLS-1$ @@ -46,7 +46,7 @@ public class PresentationContextTests extends TestCase { context.initProperties(memento); assertEquals("Wrong value restored", "string", context.getProperty("string")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ assertEquals("Wrong value restored", new Integer(1), context.getProperty("integer")); //$NON-NLS-1$ //$NON-NLS-2$ - assertEquals("Wrong value restored", new Boolean(true), context.getProperty("boolean")); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("Wrong value restored", Boolean.TRUE, context.getProperty("boolean")); //$NON-NLS-1$ //$NON-NLS-2$ assertEquals("Wrong value restored", ResourcesPlugin.getWorkspace().getRoot(), context.getProperty("persistable")); //$NON-NLS-1$ //$NON-NLS-2$ context.dispose(); } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalTreeModelViewer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalTreeModelViewer.java index cbd39c940..223d7ffcb 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalTreeModelViewer.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalTreeModelViewer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2013 IBM Corporation and others. + * Copyright (c) 2006, 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 @@ -1833,7 +1833,7 @@ public class InternalTreeModelViewer extends TreeViewer implements IInternalTree if (!accepted) { item.setChecked(!checked); } else { - item.setData(PREV_CHECKED_KEY, new Boolean(checked)); + item.setData(PREV_CHECKED_KEY, Boolean.valueOf(checked)); } } else { ((TreeModelContentProvider) contentProvider).cancelRestore(path, IModelDelta.SELECT|IModelDelta.REVEAL); diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderPropertyPage.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderPropertyPage.java index 483b652c6..a0bd3a0f9 100644 --- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderPropertyPage.java +++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderPropertyPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 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 @@ -874,8 +874,7 @@ public final class BuilderPropertyPage extends PropertyPage implements ICheckSta String val = command.getArguments().get(COMMAND_ENABLED); if(val != null) { //null means enabled, see #doPerformOk - Boolean enabled = new Boolean(val); - return enabled.booleanValue(); + return Boolean.parseBoolean(val); } } else if (element instanceof ILaunchConfiguration) { try { @@ -996,8 +995,7 @@ public final class BuilderPropertyPage extends PropertyPage implements ICheckSta Map<String, String> args = command.getArguments(); String val = args.get(COMMAND_ENABLED); if(val != null) { - Boolean enabled = new Boolean(val); - if (!enabled.booleanValue()) { + if (!Boolean.parseBoolean(val)) { ILaunchConfiguration config= disableCommand(command); if (config != null) { data= BuilderUtils.commandFromLaunchConfig(project,config); |