Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Blewitt2015-09-07 18:44:26 +0000
committerAlex Blewitt2015-09-11 07:51:36 +0000
commit2fe3fff966fde4cedc73ca8c1df13b2fd4d605a7 (patch)
treecd5c19a1363e899af66de1bdce90920ae5fd32ce /org.eclipse.debug.tests
parent368177ac20c448cd2e6d7d5f2d983c9734b14a49 (diff)
downloadeclipse.platform.debug-2fe3fff966fde4cedc73ca8c1df13b2fd4d605a7.tar.gz
eclipse.platform.debug-2fe3fff966fde4cedc73ca8c1df13b2fd4d605a7.tar.xz
eclipse.platform.debug-2fe3fff966fde4cedc73ca8c1df13b2fd4d605a7.zip
Bug 476814 - Replace new Integer() with Integer.valueOf()
Using Integer.valueOf() instead of new Integer() allows for the runtime to cache commonly instantiated values; typically, this will be for values in the range -128..127. Using valueOf is preferred for this reason. Change-Id: I1022eb4973b760b830ace5d39b76eea9353d4ca2 Signed-off-by: Alex Blewitt <alex.blewitt@gmail.com>
Diffstat (limited to 'org.eclipse.debug.tests')
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchConfigurationTests.java12
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ContentTests.java6
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/PresentationContextTests.java4
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/TestModelUpdatesListener.java14
4 files changed, 18 insertions, 18 deletions
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchConfigurationTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchConfigurationTests.java
index 065ffa2b3..65dc6c1bc 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchConfigurationTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchConfigurationTests.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
@@ -354,7 +354,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
Map<?, ?> attributes = handle.getAttributes();
// retrieve attributes
assertEquals("String1 should be String1", "String1", attributes.get("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- assertEquals("Int1 should be 1", new Integer(1), attributes.get("Int1")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("Int1 should be 1", Integer.valueOf(1), attributes.get("Int1")); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Boolean1 should be true", Boolean.TRUE, attributes.get("Boolean1")); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Boolean2 should be false", Boolean.FALSE, attributes.get("Boolean2")); //$NON-NLS-1$ //$NON-NLS-2$
@@ -1440,7 +1440,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
try {
ILaunchConfigurationWorkingCopy wc = lc.getWorkingCopy();
assertNotNull("Should have a working copy of the testig launch configuration", wc); //$NON-NLS-1$
- setResourceMappings(wc, new ResourceItem[] { new ResourceItem("test.project", new Integer(IResource.PROJECT)) }); //$NON-NLS-1$
+ setResourceMappings(wc, new ResourceItem[] { new ResourceItem("test.project", Integer.valueOf(IResource.PROJECT)) }); //$NON-NLS-1$
IResource[] res = wc.getMappedResources();
assertNotNull("There should be mapped resources", res); //$NON-NLS-1$
assertTrue("There should be one project", res.length == 1); //$NON-NLS-1$
@@ -1462,7 +1462,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
try {
ILaunchConfigurationWorkingCopy wc = lc.getWorkingCopy();
assertNotNull("Should have a working copy of the testig launch configuration", wc); //$NON-NLS-1$
- setResourceMappings(wc, new ResourceItem[] { new ResourceItem("test/project", new Integer(IResource.PROJECT)) }); //$NON-NLS-1$
+ setResourceMappings(wc, new ResourceItem[] { new ResourceItem("test/project", Integer.valueOf(IResource.PROJECT)) }); //$NON-NLS-1$
IResource[] res = wc.getMappedResources();
assertNull("There should be no mapped resources", res); //$NON-NLS-1$
}
@@ -1483,7 +1483,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
try {
ILaunchConfigurationWorkingCopy wc = lc.getWorkingCopy();
assertNotNull("Should have a working copy of the testig launch configuration", wc); //$NON-NLS-1$
- setResourceMappings(wc, new ResourceItem[] { new ResourceItem("test\\project", new Integer(IResource.PROJECT)) }); //$NON-NLS-1$
+ setResourceMappings(wc, new ResourceItem[] { new ResourceItem("test\\project", Integer.valueOf(IResource.PROJECT)) }); //$NON-NLS-1$
IResource[] res = wc.getMappedResources();
if(Platform.OS_WIN32.equals(Platform.getOS())) {
assertNull("There should be no mapped resources", res); //$NON-NLS-1$
@@ -1509,7 +1509,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
try {
ILaunchConfigurationWorkingCopy wc = lc.getWorkingCopy();
assertNotNull("Should have a working copy of the testig launch configuration", wc); //$NON-NLS-1$
- setResourceMappings(wc, new ResourceItem[] { new ResourceItem("/project", new Integer(IResource.PROJECT)) }); //$NON-NLS-1$
+ setResourceMappings(wc, new ResourceItem[] { new ResourceItem("/project", Integer.valueOf(IResource.PROJECT)) }); //$NON-NLS-1$
IResource[] res = wc.getMappedResources();
assertNotNull("There should be mapped resources", res); //$NON-NLS-1$
}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ContentTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ContentTests.java
index 076181461..7275130a1 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ContentTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ContentTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2013 Wind River Systems and others.
+ * Copyright (c) 2009, 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
@@ -378,12 +378,12 @@ abstract public class ContentTests extends TestCase implements ITestModelUpdates
private boolean areCapturedChildrenUpdatesComplete(List<IViewerUpdate> capturedUpdates, int childCount) {
List<Integer> expectedChildren = new ArrayList<Integer>();
for (int i = 0; i < childCount; i++) {
- expectedChildren.add(new Integer(i));
+ expectedChildren.add(Integer.valueOf(i));
}
IChildrenUpdate[] updates = capturedUpdates.toArray(new IChildrenUpdate[0]);
for (int i = 0; i < updates.length; i++) {
for (int j = 0; j < updates[i].getLength(); j++) {
- expectedChildren.remove( new Integer(updates[i].getOffset() + j) );
+ expectedChildren.remove( Integer.valueOf(updates[i].getOffset() + j) );
}
}
return expectedChildren.isEmpty();
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 9959c5d06..0409c367e 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
@@ -35,7 +35,7 @@ public class PresentationContextTests extends TestCase {
public void testSaveRestore () {
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("integer", Integer.valueOf(1)); //$NON-NLS-1$
context.setProperty("boolean", Boolean.TRUE); //$NON-NLS-1$
context.setProperty("persistable", ResourcesPlugin.getWorkspace().getRoot().getAdapter(IPersistableElement.class)); //$NON-NLS-1$
@@ -45,7 +45,7 @@ public class PresentationContextTests extends TestCase {
context = new PresentationContext("test"); //$NON-NLS-1$
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", Integer.valueOf(1), context.getProperty("integer")); //$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.tests/src/org/eclipse/debug/tests/viewer/model/TestModelUpdatesListener.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/TestModelUpdatesListener.java
index aedcc1824..99e5b5137 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/TestModelUpdatesListener.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/TestModelUpdatesListener.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2013 Wind River Systems and others.
+ * Copyright (c) 2009, 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
@@ -261,13 +261,13 @@ public class TestModelUpdatesListener
childrenIndexes = new TreeSet<Integer>();
fChildrenUpdatesScheduled.put(path, childrenIndexes);
}
- childrenIndexes.add(new Integer(index));
+ childrenIndexes.add(Integer.valueOf(index));
}
public void removeChildrenUpdate(TreePath path, int index) {
Set<?> childrenIndexes = fChildrenUpdatesScheduled.get(path);
if (childrenIndexes != null) {
- childrenIndexes.remove(new Integer(index));
+ childrenIndexes.remove(Integer.valueOf(index));
if (childrenIndexes.isEmpty()) {
fChildrenUpdatesScheduled.remove(path);
}
@@ -411,7 +411,7 @@ public class TestModelUpdatesListener
Set<Integer> childrenIndexes = new HashSet<Integer>();
for (int i = 0; i < children.length; i++) {
if (!isFiltered(children[i], filters)) {
- childrenIndexes.add(new Integer(i));
+ childrenIndexes.add(Integer.valueOf(i));
}
}
fChildrenUpdatesScheduled.put(path, childrenIndexes);
@@ -601,7 +601,7 @@ public class TestModelUpdatesListener
IChildrenUpdate update = ((IChildrenUpdate)itr.next());
Set<?> set = fChildrenUpdatesScheduled.get(update.getElementPath());
for (int i = update.getOffset(); set != null && i < update.getOffset() + update.getLength(); i++) {
- if (set.contains(new Integer(i))) {
+ if (set.contains(Integer.valueOf(i))) {
runningCount++;
}
}
@@ -610,7 +610,7 @@ public class TestModelUpdatesListener
IChildrenUpdate update = ((IChildrenUpdate)itr.next());
Set<?> set = fChildrenUpdatesScheduled.get(update.getElementPath());
for (int i = update.getOffset(); set != null && i < update.getOffset() + update.getLength(); i++) {
- if (set.contains(new Integer(i))) {
+ if (set.contains(Integer.valueOf(i))) {
runningCount++;
}
}
@@ -668,7 +668,7 @@ public class TestModelUpdatesListener
Set<?> childrenIndexes = fChildrenUpdatesScheduled.get(updatePath);
if (childrenIndexes != null) {
for (int i = start; i < end; i++) {
- childrenIndexes.remove(new Integer(i));
+ childrenIndexes.remove(Integer.valueOf(i));
}
if (childrenIndexes.isEmpty()) {
fChildrenUpdatesScheduled.remove(updatePath);

Back to the top