classlib: remove deprecated constructors of primitive wrappers (#754)

This commit is contained in:
Ivan Hetman 2023-09-21 17:05:18 +03:00 committed by GitHub
parent 94e34188c3
commit 7589eb23fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 95 additions and 98 deletions

View File

@ -275,8 +275,8 @@ public abstract class TDateFormat extends TFormat {
protected Field(String fieldName, int calendarField) {
super(fieldName);
this.calendarField = calendarField;
if (calendarField != -1 && table.get(new Integer(calendarField)) == null) {
table.put(new Integer(calendarField), this);
if (calendarField != -1 && table.get(calendarField) == null) {
table.put(calendarField, this);
}
}
@ -289,7 +289,7 @@ public abstract class TDateFormat extends TFormat {
throw new IllegalArgumentException();
}
return table.get(new Integer(calendarField));
return table.get(calendarField);
}
}
}

View File

@ -63,7 +63,7 @@ abstract class TAbstractSet {
protected boolean isSecondPassVisited;
protected String index = new Integer(TAbstractSet.counter++).toString();
protected String index = Integer.toString(TAbstractSet.counter++);
private int type;

View File

@ -83,7 +83,7 @@ class TQuantifier extends TSpecialToken implements Cloneable {
@Override
public String toString() {
return "{" + min + "," + ((max == Integer.MAX_VALUE) ? "" : new Integer(max).toString()) + "}";
return "{" + min + "," + ((max == Integer.MAX_VALUE) ? "" : Integer.toString(max)) + "}";
}
@Override

View File

@ -109,7 +109,7 @@ public class MessageFormatTest {
buffer.append(" def ");
buffer.append(DateFormat.getDateInstance().format(date));
buffer.append(" ghi ");
buffer.append(NumberFormat.getInstance().format(new Double(7.2)));
buffer.append(NumberFormat.getInstance().format(7.2));
buffer.append(" jkl high mnop 123");
assertTrue("Wrong answer:\n" + result + "\n" + buffer, result.equals(buffer.toString()));

View File

@ -146,7 +146,7 @@ public class HashtableTest {
// Test for method java.util.Hashtable(java.util.Map)
Map<String, Object> map = new TreeMap<>();
Object firstVal = "Gabba";
Object secondVal = new Integer(5);
Object secondVal = 5;
map.put("Gah", firstVal);
map.put("Ooga", secondVal);
Hashtable<String, Object> ht = new Hashtable<>(map);
@ -386,9 +386,9 @@ public class HashtableTest {
}
Map<Integer, String> map = new Hashtable<>(101);
map.put(new Integer(1), "1");
map.put(new Integer(102), "102");
map.put(new Integer(203), "203");
map.put(1, "1");
map.put(102, "102");
map.put(203, "203");
Iterator<Integer> it = map.keySet().iterator();
Integer remove1 = it.next();
it.remove();
@ -402,15 +402,15 @@ public class HashtableTest {
assertTrue("Wrong contents", map.keySet().iterator().next().equals(list.get(0)));
Map<Integer, String> map2 = new Hashtable<>(101);
map2.put(new Integer(1), "1");
map2.put(new Integer(4), "4");
map2.put(1, "1");
map2.put(4, "4");
Iterator<Integer> it2 = map2.keySet().iterator();
Integer remove3 = it2.next();
Integer next;
if (remove3.intValue() == 1) {
next = new Integer(4);
next = 4;
} else {
next = new Integer(1);
next = 1;
}
it2.hasNext();
it2.remove();
@ -476,7 +476,7 @@ public class HashtableTest {
// Test for method java.lang.Object
// java.util.Hashtable.put(java.lang.Object, java.lang.Object)
Hashtable<String, Integer> h = hashtableClone(ht100);
Integer key = new Integer(100);
Integer key = 100;
h.put("Value 100", key);
assertTrue("Key/Value not inserted", h.size() == 1 && (h.contains(key)));
}
@ -558,13 +558,13 @@ public class HashtableTest {
Hashtable<Integer, Integer> myHashtable = new Hashtable<>();
for (int i = 0; i < 100; i++) {
myHashtable.put(new Integer(i), new Integer(i));
myHashtable.put(i, i);
}
Collection<Integer> values = myHashtable.values();
new UnmodifiableCollectionTestSupport(values).runTest();
values.remove(new Integer(0));
values.remove(0);
assertTrue("Removing from the values collection should remove from the original map",
!myHashtable.containsValue(new Integer(0)));
!myHashtable.containsValue(0));
}
@Test

View File

@ -126,9 +126,8 @@ public class TreeMapTest {
public TreeMapTest() {
tm = new TreeMap<>();
for (int i = 0; i < objArray.length; i++) {
Object x = new Integer(i);
objArray[i] = x;
tm.put(x.toString(), x);
objArray[i] = i;
tm.put(Integer.toString(i), i);
}
}
@ -139,12 +138,12 @@ public class TreeMapTest {
TreeMap<Object, Object> reversedTreeMap = new TreeMap<>(comp);
assertTrue("TreeMap answered incorrect comparator", reversedTreeMap
.comparator() == comp);
reversedTreeMap.put(new Integer(1).toString(), new Integer(1));
reversedTreeMap.put(new Integer(2).toString(), new Integer(2));
reversedTreeMap.put(Integer.toString(1), 1);
reversedTreeMap.put(Integer.toString(2), 2);
assertTrue("TreeMap does not use comparator (firstKey was incorrect)",
reversedTreeMap.firstKey().equals(new Integer(2).toString()));
reversedTreeMap.firstKey().equals(Integer.toString(2)));
assertTrue("TreeMap does not use comparator (lastKey was incorrect)",
reversedTreeMap.lastKey().equals(new Integer(1).toString()));
reversedTreeMap.lastKey().equals(Integer.toString(1)));
}
@Test
@ -162,15 +161,15 @@ public class TreeMapTest {
// Test for method java.util.TreeMap(java.util.SortedMap)
Comparator<Object> comp = new ReversedComparator();
TreeMap<Object, Object> reversedTreeMap = new TreeMap<>(comp);
reversedTreeMap.put(new Integer(1).toString(), new Integer(1));
reversedTreeMap.put(new Integer(2).toString(), new Integer(2));
reversedTreeMap.put(Integer.toString(1), 1);
reversedTreeMap.put(Integer.toString(2), 2);
TreeMap<Object, Object> anotherTreeMap = new TreeMap<>(reversedTreeMap);
assertTrue("New tree map does not answer correct comparator",
anotherTreeMap.comparator() == comp);
assertTrue("TreeMap does not use comparator (firstKey was incorrect)",
anotherTreeMap.firstKey().equals(new Integer(2).toString()));
anotherTreeMap.firstKey().equals(Integer.toString(2)));
assertTrue("TreeMap does not use comparator (lastKey was incorrect)",
anotherTreeMap.lastKey().equals(new Integer(1).toString()));
anotherTreeMap.lastKey().equals(Integer.toString(1)));
}
@Test
@ -219,12 +218,12 @@ public class TreeMapTest {
Comparator<Object> comp = new ReversedComparator();
TreeMap<Object, Object> reversedTreeMap = new TreeMap<>(comp);
assertTrue("TreeMap answered incorrect comparator", reversedTreeMap.comparator() == comp);
reversedTreeMap.put(new Integer(1).toString(), new Integer(1));
reversedTreeMap.put(new Integer(2).toString(), new Integer(2));
reversedTreeMap.put(Integer.toString(1), 1);
reversedTreeMap.put(Integer.toString(2), 2);
assertTrue("TreeMap does not use comparator (firstKey was incorrect)",
reversedTreeMap.firstKey().equals(new Integer(2).toString()));
reversedTreeMap.firstKey().equals(Integer.toString(2)));
assertTrue("TreeMap does not use comparator (lastKey was incorrect)",
reversedTreeMap.lastKey().equals(new Integer(1).toString()));
reversedTreeMap.lastKey().equals(Integer.toString(1)));
}
@Test
@ -280,7 +279,7 @@ public class TreeMapTest {
Map<Object, Object> head = tm.headMap("100");
assertEquals("Returned map of incorrect size", 3, head.size());
assertTrue("Returned incorrect elements", head.containsKey("0")
&& head.containsValue(new Integer("1"))
&& head.containsValue(Integer.parseInt("1"))
&& head.containsKey("10"));
// Regression for Harmony-1026
@ -377,7 +376,7 @@ public class TreeMapTest {
Set<Object> ks = tm.keySet();
assertTrue("Returned set of incorrect size", ks.size() == objArray.length);
for (int i = 0; i < tm.size(); i++) {
assertTrue("Returned set is missing keys", ks.contains(new Integer(i).toString()));
assertTrue("Returned set is missing keys", ks.contains(Integer.toString(i)));
}
}
@ -396,7 +395,7 @@ public class TreeMapTest {
assertTrue("Failed to put mapping", tm.get("Hello") == o);
tm = new TreeMap<>();
assertNull(tm.put(new Integer(1), new Object()));
assertNull(tm.put(1, new Object()));
}
@Test
@ -567,9 +566,9 @@ public class TreeMapTest {
myTreeMap.put(objArray[i], objArray[i]);
}
Collection<Object> values = myTreeMap.values();
values.remove(new Integer(0));
values.remove(0);
assertTrue("Removing from the values collection should remove from the original map",
!myTreeMap.containsValue(new Integer(0)));
!myTreeMap.containsValue(0));
}
/*

View File

@ -108,7 +108,7 @@ public class MatcherTest {
StringBuffer sb = new StringBuffer();
for (int i = 0; m.find(); i++) {
m.appendReplacement(sb, new Integer(i * 10 + i).toString());
m.appendReplacement(sb, Integer.toString(i * 10 + i));
}
m.appendTail(sb);
assertEquals("Today is 0-11-22 ...", sb.toString());
@ -120,7 +120,7 @@ public class MatcherTest {
Matcher m = p.matcher("xx $ equals to xx rur.");
StringBuffer sb = new StringBuffer();
for (int i = 1; m.find(); i *= 30) {
String rep = new Integer(i).toString() + " $1";
String rep = i + " $1";
m.appendReplacement(sb, rep);
}
m.appendTail(sb);

View File

@ -608,16 +608,16 @@ public class PatternTest {
@Test
public void testBug197() {
Object[] vals = { ":", new Integer(2),
new String[] { "boo", "and:foo" }, ":", new Integer(5),
new String[] { "boo", "and", "foo" }, ":", new Integer(-2),
new String[] { "boo", "and", "foo" }, ":", new Integer(3),
new String[] { "boo", "and", "foo" }, ":", new Integer(1),
new String[] { "boo:and:foo" }, "o", new Integer(5),
Object[] vals = { ":", 2,
new String[] { "boo", "and:foo" }, ":", 5,
new String[] { "boo", "and", "foo" }, ":", -2,
new String[] { "boo", "and", "foo" }, ":", 3,
new String[] { "boo", "and", "foo" }, ":", 1,
new String[] { "boo:and:foo" }, "o", 5,
new String[] { "b", "", ":and:f", "", "" }, "o",
new Integer(4), new String[] { "b", "", ":and:f", "o" }, "o",
new Integer(-2), new String[] { "b", "", ":and:f", "", "" },
"o", new Integer(0), new String[] { "b", "", ":and:f" } };
4, new String[] { "b", "", ":and:f", "o" }, "o",
-2, new String[] { "b", "", ":and:f", "", "" },
"o", 0, new String[] { "b", "", ":and:f" } };
for (int i = 0; i < vals.length / 3;) {
String[] res = Pattern.compile(vals[i++].toString()).split("boo:and:foo", (Integer) vals[i++]);

View File

@ -68,17 +68,17 @@ public class CollectionTestSupport {
// setup
Collection<Integer> myCollection = new TreeSet<>();
myCollection.add(new Integer(101));
myCollection.add(new Integer(102));
myCollection.add(new Integer(103));
myCollection.add(101);
myCollection.add(102);
myCollection.add(103);
// add
assertTrue("CollectionTest - a) add did not work", col.add(new Integer(101)));
assertTrue("CollectionTest - b) add did not work", col.contains(new Integer(101)));
assertTrue("CollectionTest - a) add did not work", col.add(101));
assertTrue("CollectionTest - b) add did not work", col.contains(101));
// remove
assertTrue("CollectionTest - a) remove did not work", col.remove(new Integer(101)));
assertTrue("CollectionTest - b) remove did not work", !col.contains(new Integer(101)));
assertTrue("CollectionTest - a) remove did not work", col.remove(101));
assertTrue("CollectionTest - b) remove did not work", !col.contains(101));
// addAll
assertTrue("CollectionTest - a) addAll failed", col.addAll(myCollection));
@ -86,28 +86,26 @@ public class CollectionTestSupport {
// containsAll
assertTrue("CollectionTest - a) containsAll failed", col.containsAll(myCollection));
col.remove(new Integer(101));
col.remove(101);
assertTrue("CollectionTest - b) containsAll failed", !col.containsAll(myCollection));
// removeAll
assertTrue("CollectionTest - a) removeAll failed", col.removeAll(myCollection));
assertTrue("CollectionTest - b) removeAll failed", !col.removeAll(myCollection));
assertTrue("CollectionTest - c) removeAll failed", !col.contains(new Integer(102)));
assertTrue("CollectionTest - d) removeAll failed", !col.contains(new Integer(103)));
assertTrue("CollectionTest - c) removeAll failed", !col.contains(102));
assertTrue("CollectionTest - d) removeAll failed", !col.contains(103));
// retianAll
col.addAll(myCollection);
assertTrue("CollectionTest - a) retainAll failed", col.retainAll(myCollection));
assertTrue("CollectionTest - b) retainAll failed", !col.retainAll(myCollection));
assertTrue("CollectionTest - c) retainAll failed", col.containsAll(myCollection));
assertTrue("CollectionTest - d) retainAll failed", !col.contains(new Integer(0)));
assertTrue("CollectionTest - e) retainAll failed", !col.contains(new Integer(50)));
assertTrue("CollectionTest - d) retainAll failed", !col.contains(0));
assertTrue("CollectionTest - e) retainAll failed", !col.contains(50));
// clear
col.clear();
assertTrue("CollectionTest - a) clear failed", col.isEmpty());
assertTrue("CollectionTest - b) clear failed", !col.contains(new Integer(101)));
assertTrue("CollectionTest - b) clear failed", !col.contains(101));
}
}

View File

@ -71,51 +71,51 @@ public class ListTestSupport {
Object elem;
elem = list.get(counter);
hashCode = 31 * hashCode + elem.hashCode();
assertTrue("ListTest - get failed", elem.equals(new Integer(counter)));
assertTrue("ListTest - get failed", elem.equals(counter));
}
assertTrue("ListTest - hashCode failed", hashCode == list.hashCode());
list.add(50, new Integer(1000));
assertTrue("ListTest - a) add with index failed--did not insert", list.get(50).equals(new Integer(1000)));
list.add(50, 1000);
assertTrue("ListTest - a) add with index failed--did not insert", list.get(50).equals(1000));
assertTrue("ListTest - b) add with index failed--did not move following elements",
list.get(51).equals(new Integer(50)));
list.get(51).equals(50));
assertTrue("ListTest - c) add with index failed--affected previous elements",
list.get(49).equals(new Integer(49)));
list.get(49).equals(49));
list.set(50, new Integer(2000));
assertTrue("ListTest - a) set failed--did not set", list.get(50).equals(new Integer(2000)));
assertTrue("ListTest - b) set failed--affected following elements", list.get(51).equals(new Integer(50)));
assertTrue("ListTest - c) set failed--affected previous elements", list.get(49).equals(new Integer(49)));
list.set(50, 2000);
assertTrue("ListTest - a) set failed--did not set", list.get(50).equals(2000));
assertTrue("ListTest - b) set failed--affected following elements", list.get(51).equals(50));
assertTrue("ListTest - c) set failed--affected previous elements", list.get(49).equals(49));
list.remove(50);
assertTrue("ListTest - a) remove with index failed--did not remove", list.get(50).equals(new Integer(50)));
assertTrue("ListTest - a) remove with index failed--did not remove", list.get(50).equals(50));
assertTrue("ListTest - b) remove with index failed--did not move following elements",
list.get(51).equals(new Integer(51)));
list.get(51).equals(51));
assertTrue("ListTest - c) remove with index failed--affected previous elements",
list.get(49).equals(new Integer(49)));
list.get(49).equals(49));
List<Integer> myList = new LinkedList<>();
myList.add(new Integer(500));
myList.add(new Integer(501));
myList.add(new Integer(502));
myList.add(500);
myList.add(501);
myList.add(502);
list.addAll(50, myList);
assertTrue("ListTest - a) addAll with index failed--did not insert", list.get(50).equals(new Integer(500)));
assertTrue("ListTest - b) addAll with index failed--did not insert", list.get(51).equals(new Integer(501)));
assertTrue("ListTest - c) addAll with index failed--did not insert", list.get(52).equals(new Integer(502)));
assertTrue("ListTest - a) addAll with index failed--did not insert", list.get(50).equals(500));
assertTrue("ListTest - b) addAll with index failed--did not insert", list.get(51).equals(501));
assertTrue("ListTest - c) addAll with index failed--did not insert", list.get(52).equals(502));
assertTrue("ListTest - d) addAll with index failed--did not move following elements",
list.get(53).equals(new Integer(50)));
list.get(53).equals(50));
assertTrue("ListTest - e) addAll with index failed--affected previous elements",
list.get(49).equals(new Integer(49)));
list.get(49).equals(49));
List<Integer> mySubList = list.subList(50, 53);
assertEquals(3, mySubList.size());
assertTrue("ListTest - a) sublist Failed--does not contain correct elements",
mySubList.get(0).equals(new Integer(500)));
mySubList.get(0).equals(500));
assertTrue("ListTest - b) sublist Failed--does not contain correct elements",
mySubList.get(1).equals(new Integer(501)));
mySubList.get(1).equals(501));
assertTrue("ListTest - c) sublist Failed--does not contain correct elements",
mySubList.get(2).equals(new Integer(502)));
mySubList.get(2).equals(502));
t_listIterator(mySubList);
@ -128,7 +128,7 @@ public class ListTestSupport {
for (int counter = 0; li.hasNext(); counter++) {
Object elem;
elem = li.next();
assertTrue("ListTest - listIterator failed", elem.equals(new Integer(counter)));
assertTrue("ListTest - listIterator failed", elem.equals(counter));
}
new CollectionTestSupport(list).runTest();
@ -186,8 +186,8 @@ public class ListTestSupport {
}
assertTrue("list iterator previous() exception", exception);
Integer add1 = new Integer(600);
Integer add2 = new Integer(601);
Integer add1 = 600;
Integer add2 = 601;
li.add(add1);
assertTrue("list iterator add(), size()", list.size() == (orgSize + 1));
assertEquals("list iterator add(), nextIndex()", 1, li.nextIndex());

View File

@ -71,21 +71,21 @@ public class UnmodifiableCollectionTestSupport {
// contains
assertTrue("UnmodifiableCollectionTest - should contain 0", col
.contains(new Integer(0)));
.contains(0));
assertTrue("UnmodifiableCollectionTest - should contain 50", col
.contains(new Integer(50)));
.contains(50));
assertTrue("UnmodifiableCollectionTest - should not contain 100", !col
.contains(new Integer(100)));
.contains(100));
// containsAll
HashSet<Integer> hs = new HashSet<>();
hs.add(new Integer(0));
hs.add(new Integer(25));
hs.add(new Integer(99));
hs.add(0);
hs.add(25);
hs.add(99);
assertTrue(
"UnmodifiableCollectionTest - should contain set of 0, 25, and 99",
col.containsAll(hs));
hs.add(new Integer(100));
hs.add(100);
assertTrue(
"UnmodifiableCollectionTest - should not contain set of 0, 25, 99 and 100",
!col.containsAll(hs));

View File

@ -49,7 +49,7 @@ public class DependencyTestData {
}
public static void arrays() {
Object[] array = { new String("123"), new Integer(123), String.class };
Object[] array = { new String("123"), 123, String.class };
MetaAssertions.assertTypes(array[0], String.class, Integer.class, Class.class);
}