Skip to content

Commit

Permalink
replace deprecated Constructor based initialization of primitive type…
Browse files Browse the repository at this point in the history
…'s Wrapper Class with WrapperClass.valueOf(value)
  • Loading branch information
eklaDFF committed Aug 3, 2024
1 parent 385eb79 commit a64a935
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
19 changes: 9 additions & 10 deletions src/tests/gov/nasa/jpf/test/java/lang/BoxObjectCacheTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@
*/
package gov.nasa.jpf.test.java.lang;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import gov.nasa.jpf.util.test.TestJPF;

import org.junit.Test;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
* regression test for java.lang.Integer
*/
Expand Down Expand Up @@ -135,7 +134,7 @@ public void testIntCacheBoxObject() throws SecurityException, NoSuchMethodExcept
Integer i1 = Integer.valueOf( 1); // should be cached
assertTrue( i1.intValue() == 1);

Integer i2 = new Integer(1);
Integer i2 = Integer.valueOf(1);
Method m = Integer.class.getMethod("intValue", new Class[0]);
Integer i3 = (Integer) m.invoke(i2, new Object[0]);
assertTrue( i1 == i3);
Expand All @@ -149,7 +148,7 @@ public void testCharacterCacheBoxObject() throws SecurityException, NoSuchMethod
Character c1 = Character.valueOf( '?'); // should be cached
assertTrue( c1.charValue() == '?');

Character c2 = new Character('?');
Character c2 = Character.valueOf('?');
Method m = Character.class.getMethod("charValue", new Class[0]);
Character c3 = (Character) m.invoke(c2, new Object[0]);
assertTrue( c1 == c3);
Expand All @@ -163,7 +162,7 @@ public void testByteCacheBoxObject() throws SecurityException, NoSuchMethodExcep
Byte b1 = Byte.valueOf( (byte)1); // should be cached
assertTrue( b1.byteValue() == 1);

Byte b2 = new Byte((byte)1);
Byte b2 = Byte.valueOf((byte)1);
Method m = Byte.class.getMethod("byteValue", new Class[0]);
Byte b3 = (Byte) m.invoke(b2, new Object[0]);
assertTrue( b1 == b3);
Expand All @@ -177,7 +176,7 @@ public void testShortCacheBoxObject() throws SecurityException, NoSuchMethodExce
Short s1 = Short.valueOf((short)1); // should be cached
assertTrue( s1.shortValue() == 1);

Short s2 = new Short((short)1);
Short s2 = Short.valueOf((short)1);
Method m = Short.class.getMethod("shortValue", new Class[0]);
Short s3 = (Short) m.invoke(s2, new Object[0]);
assertTrue( s1 == s3);
Expand All @@ -191,7 +190,7 @@ public void testLongCacheBoxObject() throws SecurityException, NoSuchMethodExcep
Long l1 = Long.valueOf(1); // should be cached
assertTrue( l1.longValue() == 1);

Long l2 = new Long(1);
Long l2 = Long.valueOf(1);
Method m = Long.class.getMethod("longValue", new Class[0]);
Long l3 = (Long) m.invoke(l2, new Object[0]);
assertTrue( l1 == l3);
Expand All @@ -205,7 +204,7 @@ public void testBooleanCacheBoxObject() throws SecurityException, NoSuchMethodEx
Boolean b1 = Boolean.valueOf(true); // should be cached
assertTrue( b1.booleanValue() == true);

Boolean b2 = new Boolean(true);
Boolean b2 = Boolean.valueOf(true);
Method m = Boolean.class.getMethod("booleanValue", new Class[0]);
Boolean b3 = (Boolean) m.invoke(b2, new Object[0]);
assertTrue( b1 == b3);
Expand Down
2 changes: 1 addition & 1 deletion src/tests/gov/nasa/jpf/test/mc/basic/AttrsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ int goModel (double d, int i) {
}
}

@SuppressWarnings("deprecation")
@SuppressWarnings("removal") // Integer o = new Integer(v)
@Test public void testInteger() {
if (verifyNoPropertyViolation()) {
int v = 42;
Expand Down
6 changes: 3 additions & 3 deletions src/tests/gov/nasa/jpf/util/SparseClusterArrayTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@

package gov.nasa.jpf.util;

import static gov.nasa.jpf.util.SparseClusterArray.S1;
import gov.nasa.jpf.util.SparseClusterArray.Entry;
import gov.nasa.jpf.util.SparseClusterArray.Snapshot;
import gov.nasa.jpf.util.test.TestJPF;
import org.junit.Test;

import java.util.HashMap;
import java.util.Random;

import org.junit.Test;
import static gov.nasa.jpf.util.SparseClusterArray.S1;

/**
* unit test for gov.nasa.jpf.util.SparseClusterArray
Expand Down Expand Up @@ -182,7 +182,7 @@ public void testClone() {
@Override
@SuppressWarnings("deprecation")
public Integer clone (Integer other) {
return new Integer(other);
return Integer.valueOf(other);
}
};
SparseClusterArray<Integer> newArr = arr.deepCopy(cloner);
Expand Down
2 changes: 1 addition & 1 deletion src/tests/java11/StringConcatenationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public void testStringConcatenationWith_multipleStrings() {
@Test
public void testStringConcatenationWith_mixedTypes() {
if (verifyNoPropertyViolation()) {
Character ch = new Character('@');
Character ch = Character.valueOf('@');
byte b = 10;
String name = "xyz";
char dot = '.';
Expand Down

0 comments on commit a64a935

Please sign in to comment.