Bug 527018 - [refactoring] Replace use of Number constructors by valueOf
Includes version increment for Eclipse Photon 4.8
Change-Id: If46d17f3fd08fea451cdec233a2d352aa20a1b8c
Signed-off-by: Karsten Thoms <karsten.thoms@itemis.de>
diff --git a/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/runtime/content/BinarySignatureDescriber.java b/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/runtime/content/BinarySignatureDescriber.java
index a188e1b..ee71a27 100644
--- a/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/runtime/content/BinarySignatureDescriber.java
+++ b/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/runtime/content/BinarySignatureDescriber.java
@@ -107,7 +107,7 @@
List<Byte> bytes = new ArrayList<>();
StringTokenizer tokenizer = new StringTokenizer(data, " \t\n\r\f,"); //$NON-NLS-1$
while (tokenizer.hasMoreTokens())
- bytes.add(new Byte((byte) Integer.parseInt(tokenizer.nextToken().trim(), 16)));
+ bytes.add(Byte.valueOf((byte) Integer.parseInt(tokenizer.nextToken().trim(), 16)));
byte[] signature = new byte[bytes.size()];
for (int i = 0; i < signature.length; i++)
signature[i] = bytes.get(i).byteValue();
diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/preferences/legacy/PreferenceForwarder.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/preferences/legacy/PreferenceForwarder.java
index 94efca1..7ffa771 100644
--- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/preferences/legacy/PreferenceForwarder.java
+++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/preferences/legacy/PreferenceForwarder.java
@@ -165,9 +165,9 @@
else if (obj instanceof Integer)
return Integer.valueOf(defaults.getInt(key, INT_DEFAULT_DEFAULT));
else if (obj instanceof Double)
- return new Double(defaults.getDouble(key, DOUBLE_DEFAULT_DEFAULT));
+ return Double.valueOf(defaults.getDouble(key, DOUBLE_DEFAULT_DEFAULT));
else if (obj instanceof Float)
- return new Float(defaults.getFloat(key, FLOAT_DEFAULT_DEFAULT));
+ return Float.valueOf(defaults.getFloat(key, FLOAT_DEFAULT_DEFAULT));
else if (obj instanceof Long)
return Long.valueOf(defaults.getLong(key, LONG_DEFAULT_DEFAULT));
else if (obj instanceof byte[])
@@ -326,8 +326,8 @@
final double doubleValue = getDouble(name);
if (value == doubleValue)
return;
- Double oldValue = new Double(doubleValue);
- Double newValue = new Double(value);
+ Double oldValue = Double.valueOf(doubleValue);
+ Double newValue = Double.valueOf(value);
try {
notify = false;
if (getDefaultDouble(name) == value)
@@ -420,8 +420,8 @@
final float floatValue = getFloat(name);
if (value == floatValue)
return;
- Float oldValue = new Float(floatValue);
- Float newValue = new Float(value);
+ Float oldValue = Float.valueOf(floatValue);
+ Float newValue = Float.valueOf(value);
try {
notify = false;
if (getDefaultFloat(name) == value)
diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Preferences.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Preferences.java
index 789d1f4..89b10f6 100644
--- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Preferences.java
+++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Preferences.java
@@ -664,7 +664,7 @@
// mark as dirty since value did really change
dirty = true;
// report property change if getValue now returns different value
- firePropertyChangeEvent(name, new Double(oldValue), new Double(value));
+ firePropertyChangeEvent(name, Double.valueOf(oldValue), new Double(value));
}
}
@@ -782,7 +782,7 @@
// mark as dirty since value did really change
dirty = true;
// report property change if getValue now returns different value
- firePropertyChangeEvent(name, new Float(oldValue), new Float(value));
+ firePropertyChangeEvent(name, Float.valueOf(oldValue), new Float(value));
}
}
diff --git a/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/InjectorImpl.java b/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/InjectorImpl.java
index da65532..3423c6a 100644
--- a/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/InjectorImpl.java
+++ b/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/InjectorImpl.java
@@ -62,12 +62,12 @@
final private static Boolean DEFAULT_BOOLEAN = Boolean.FALSE;
final private static Integer DEFAULT_INTEGER = Integer.valueOf(0);
- final private static Character DEFAULT_CHAR = new Character((char) 0);
- final private static Float DEFAULT_FLOAT = new Float(0.0f);
- final private static Double DEFAULT_DOUBLE = new Double(0.0d);
+ final private static Character DEFAULT_CHAR = Character.valueOf((char) 0);
+ final private static Float DEFAULT_FLOAT = Float.valueOf(0.0f);
+ final private static Double DEFAULT_DOUBLE = Double.valueOf(0.0d);
final private static Long DEFAULT_LONG = Long.valueOf(0L);
- final private static Short DEFAULT_SHORT = new Short((short) 0);
- final private static Byte DEFAULT_BYTE = new Byte((byte) 0);
+ final private static Short DEFAULT_SHORT = Short.valueOf((short) 0);
+ final private static Byte DEFAULT_BYTE = Byte.valueOf((byte) 0);
private Map<PrimaryObjectSupplier, List<WeakReference<?>>> injectedObjects = new HashMap<>();
private Set<WeakReference<Class<?>>> injectedClasses = new HashSet<>();
diff --git a/tests/org.eclipse.core.expressions.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.core.expressions.tests/META-INF/MANIFEST.MF
index 06f4b7c..473edcd 100644
--- a/tests/org.eclipse.core.expressions.tests/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.core.expressions.tests/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.core.expressions.tests; singleton:=true
-Bundle-Version: 3.5.1.qualifier
+Bundle-Version: 3.5.100.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package:
diff --git a/tests/org.eclipse.core.expressions.tests/pom.xml b/tests/org.eclipse.core.expressions.tests/pom.xml
index 2663fb3..8f38d8c 100644
--- a/tests/org.eclipse.core.expressions.tests/pom.xml
+++ b/tests/org.eclipse.core.expressions.tests/pom.xml
@@ -19,7 +19,7 @@
</parent>
<groupId>org.eclipse.core</groupId>
<artifactId>org.eclipse.core.expressions.tests</artifactId>
- <version>3.5.1-SNAPSHOT</version>
+ <version>3.5.100-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<properties>
diff --git a/tests/org.eclipse.core.expressions.tests/src/org/eclipse/core/internal/expressions/tests/ExpressionTests.java b/tests/org.eclipse.core.expressions.tests/src/org/eclipse/core/internal/expressions/tests/ExpressionTests.java
index 6dff683..921a9be 100644
--- a/tests/org.eclipse.core.expressions.tests/src/org/eclipse/core/internal/expressions/tests/ExpressionTests.java
+++ b/tests/org.eclipse.core.expressions.tests/src/org/eclipse/core/internal/expressions/tests/ExpressionTests.java
@@ -99,7 +99,7 @@
assertEquals(Boolean.TRUE, Expressions.convertArgument("true")); //$NON-NLS-1$
assertEquals(Boolean.FALSE, Expressions.convertArgument("false")); //$NON-NLS-1$
assertEquals(Integer.valueOf(100), Expressions.convertArgument("100")); //$NON-NLS-1$
- assertEquals(new Float(1.7f), Expressions.convertArgument("1.7")); //$NON-NLS-1$
+ assertEquals(Float.valueOf(1.7f), Expressions.convertArgument("1.7")); //$NON-NLS-1$
}
public void testArgumentParsing() throws Exception {
diff --git a/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/Bug_211799.java b/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/Bug_211799.java
index 1abcb46..a5db6bf 100644
--- a/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/Bug_211799.java
+++ b/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/Bug_211799.java
@@ -31,7 +31,7 @@
}
public Long getId() {
- return new Long(this.id);
+ return Long.valueOf(this.id);
}
@Override
@@ -40,11 +40,11 @@
Long val = list.getFirst();
if (val.longValue() != id)
failure = new RuntimeException("We broke, running should have been: " + val.longValue());
- list.remove(new Long(id));
+ list.remove(Long.valueOf(id));
}
synchronized (runList) {
- runList.add(new Long(id));
+ runList.add(Long.valueOf(id));
}
return Status.OK_STATUS;
@@ -63,7 +63,7 @@
for (int i = 0; i < JOBS_TO_SCHEDULE; i++) {
synchronized (list) {
counter++;
- list.addLast(new Long(counter));
+ list.addLast(Long.valueOf(counter));
new BugJob(counter).schedule(0L);
}
}
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/ContextDynamicTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/ContextDynamicTest.java
index 692c22e..4d1df79 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/ContextDynamicTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/ContextDynamicTest.java
@@ -52,9 +52,9 @@
public synchronized void testAddRemove() {
Integer testInt = Integer.valueOf(123);
String testString = new String("abc");
- Double testDouble = new Double(1.23);
- Float testFloat = new Float(12.3);
- Character testChar = new Character('v');
+ Double testDouble = Double.valueOf(1.23);
+ Float testFloat = Float.valueOf(12.3f);
+ Character testChar = Character.valueOf('v');
// create original context
IEclipseContext context = EclipseContextFactory.create();
@@ -78,7 +78,7 @@
assertEquals(testChar, userObject.c);
// change value
- Double testDouble2 = new Double(3.45);
+ Double testDouble2 = Double.valueOf(3.45);
Integer testInt2 = Integer.valueOf(123);
context.set(Double.class.getName(), testDouble2);
context.set(Integer.class.getName(), testInt2);
@@ -115,9 +115,9 @@
public synchronized void testParentAddRemove() {
Integer testInt = Integer.valueOf(123);
String testString = new String("abc");
- Double testDouble = new Double(1.23);
- Float testFloat = new Float(12.3);
- Character testChar = new Character('v');
+ Double testDouble = Double.valueOf(1.23);
+ Float testFloat = Float.valueOf(12.3f);
+ Character testChar = Character.valueOf('v');
// create original context
IEclipseContext parentContext = EclipseContextFactory.create();
@@ -142,7 +142,7 @@
assertEquals(testChar, userObject.c);
// change value
- Double testDouble2 = new Double(3.45);
+ Double testDouble2 = Double.valueOf(3.45);
Integer testInt2 = Integer.valueOf(123);
context.set(Double.class.getName(), testDouble2);
context.set(Integer.class.getName(), testInt2);
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/ReparentingTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/ReparentingTest.java
index f70413f..6003343 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/ReparentingTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/ReparentingTest.java
@@ -194,11 +194,11 @@
IEclipseContext oldParent = EclipseContextFactory.create();
oldParent.set("String", "oldField");
oldParent.set(String.class.getName(), "old");
- oldParent.set(Float.class.getName(), new Float(12.3));
+ oldParent.set(Float.class.getName(), Float.valueOf(12.3f));
IEclipseContext newParent = EclipseContextFactory.create();
newParent.set("String", "newField");
newParent.set(String.class.getName(), "new");
- newParent.set(Float.class.getName(), new Float(34.5));
+ newParent.set(Float.class.getName(), Float.valueOf(34.5f));
IEclipseContext child = oldParent.createChild();
ObjectSuperClass object = new ObjectSuperClass();
@@ -221,7 +221,7 @@
IEclipseContext grandpa = EclipseContextFactory.create();
grandpa.set("String", "field");
grandpa.set(String.class.getName(), "s");
- grandpa.set(Float.class.getName(), new Float(12.3));
+ grandpa.set(Float.class.getName(), Float.valueOf(12.3f));
IEclipseContext oldParent = grandpa.createChild();
IEclipseContext newParent = grandpa.createChild();
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/AnnotationsInjectionTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/AnnotationsInjectionTest.java
index 72292f8..e913730 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/AnnotationsInjectionTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/AnnotationsInjectionTest.java
@@ -115,9 +115,9 @@
public synchronized void testInjection() {
Integer testInt = Integer.valueOf(123);
String testString = new String("abc");
- Double testDouble = new Double(1.23);
- Float testFloat = new Float(12.3);
- Character testChar = new Character('v');
+ Double testDouble = Double.valueOf(1.23);
+ Float testFloat = Float.valueOf(12.3f);
+ Character testChar = Character.valueOf('v');
// create context
IEclipseContext context = EclipseContextFactory.create();
@@ -215,8 +215,8 @@
// add optional services
String testString = new String("abc");
- Double testDouble = new Double(1.23);
- Float testFloat = new Float(12.3);
+ Double testDouble = Double.valueOf(1.23);
+ Float testFloat = Float.valueOf(12.3f);
context.set(String.class.getName(), testString);
context.set(Double.class.getName(), testDouble);
context.set(Float.class.getName(), testFloat);
@@ -266,7 +266,7 @@
IEclipseContext context = EclipseContextFactory.create();
context.set(Integer.class.getName(), Integer.valueOf(123));
context.set(String.class.getName(), new String("abc"));
- context.set(Float.class.getName(), new Float(12.3));
+ context.set(Float.class.getName(), Float.valueOf(12.3f));
ObjectSubClass userObject = new ObjectSubClass();
ContextInjectionFactory.inject(userObject, context);
@@ -276,7 +276,7 @@
assertEquals(0, userObject.subPreDestroyCount);
assertEquals(0, userObject.overriddenPreDestroyCount);
- context.set(Float.class.getName(), new Float(45.6));
+ context.set(Float.class.getName(), Float.valueOf(45.6f));
assertEquals(1, userObject.superPostConstructCount);
assertEquals(1, userObject.subPostConstructCount);
assertEquals(0, userObject.superPreDestroyCount);
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ContextInjectionTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ContextInjectionTest.java
index 5bbbb56..4c284ce 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ContextInjectionTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ContextInjectionTest.java
@@ -115,9 +115,9 @@
public synchronized void testInjection() {
Integer testInt = Integer.valueOf(123);
String testString = new String("abc");
- Double testDouble = new Double(1.23);
- Float testFloat = new Float(12.3);
- Character testChar = new Character('v');
+ Double testDouble = Double.valueOf(1.23);
+ Float testFloat = Float.valueOf(12.3f);
+ Character testChar = Character.valueOf('v');
// create context
IEclipseContext context = EclipseContextFactory.create();
@@ -153,9 +153,9 @@
public synchronized void testInjectionFromParent() {
Integer testInt = Integer.valueOf(123);
String testString = new String("abc");
- Double testDouble = new Double(1.23);
- Float testFloat = new Float(12.3);
- Character testChar = new Character('v');
+ Double testDouble = Double.valueOf(1.23);
+ Float testFloat = Float.valueOf(12.3f);
+ Character testChar = Character.valueOf('v');
// create parent context
IEclipseContext parentContext = EclipseContextFactory.create();
@@ -194,7 +194,7 @@
public synchronized void testInjectionAndInheritance() {
Integer testInt = Integer.valueOf(123);
String testString = new String("abc");
- Float testFloat = new Float(12.3);
+ Float testFloat = Float.valueOf(12.3f);
// create context
IEclipseContext context = EclipseContextFactory.create();
@@ -277,7 +277,7 @@
public synchronized void testInjectionCloseOverride() {
Integer testInt = Integer.valueOf(123);
String testString = new String("abc");
- Double testDouble = new Double(12.3);
+ Double testDouble = Double.valueOf(12.3);
Boolean testBoolean = Boolean.TRUE;
// create context
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/TestConstructorInjection.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/TestConstructorInjection.java
index 823baeb..0cc1681 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/TestConstructorInjection.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/TestConstructorInjection.java
@@ -97,11 +97,11 @@
context.set(Integer.class.getName(), intValue);
Boolean boolValue = Boolean.TRUE;
context.set(Boolean.class.getName(), boolValue);
- Double doubleValue = new Double(1.23);
+ Double doubleValue = Double.valueOf(1.23);
context.set(Double.class.getName(), doubleValue);
- Float floatValue = new Float(12.3);
+ Float floatValue = Float.valueOf(12.3f);
context.set(Float.class.getName(), floatValue);
- Character charValue = new Character('v');
+ Character charValue = Character.valueOf('v');
context.set(Character.class.getName(), charValue);
Object result = ContextInjectionFactory.make(TestConstructorObject.class, context);
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/InjectionPreferencesTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/InjectionPreferencesTest.java
index 2e6da51..5b713ba 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/InjectionPreferencesTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/InjectionPreferencesTest.java
@@ -240,9 +240,9 @@
assertEquals(Integer.valueOf(12), target.intField);
assertEquals(Boolean.TRUE, target.booleanField);
- assertEquals(new Double(12.35345345345d), target.doubleField);
- assertEquals(new Float(5.13f), target.floatField);
- assertEquals(new Long(131232343453453L), target.longField);
+ assertEquals(Double.valueOf(12.35345345345d), target.doubleField);
+ assertEquals(Float.valueOf(5.13f), target.floatField);
+ assertEquals(Long.valueOf(131232343453453L), target.longField);
assertEquals(Integer.valueOf(12), target.intArg);
assertEquals(Boolean.TRUE, target.booleanArg);
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/manual/ComputedValueLimitationTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/manual/ComputedValueLimitationTest.java
index cbaa2ab..2c130ae 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/manual/ComputedValueLimitationTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/manual/ComputedValueLimitationTest.java
@@ -73,7 +73,7 @@
@Override
public Object compute(IEclipseContext context, String contextKey) {
context.get(String.valueOf(System.currentTimeMillis()));
- return new Long(System.currentTimeMillis());
+ return Long.valueOf(System.currentTimeMillis());
}
}