Skip to content

Commit

Permalink
ICU-22675 Migrate from deprecated boxed primitive constructors to the…
Browse files Browse the repository at this point in the history
…ir replacements
  • Loading branch information
mihnita committed Feb 27, 2024
1 parent 394341e commit 201af46
Show file tree
Hide file tree
Showing 95 changed files with 539 additions and 519 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -926,16 +926,16 @@ public void TestSurrogateBehavior() {
// offsets.put(0);
// offsets.put(1);
// char[] buffer = null;
// Integer length = new Integer(2);
// Integer cp = new Integer(0);
// Integer length = 2;
// Integer cp = 0;
// CoderResult unmap = CoderResult.unmappableForLength(2);
// CoderResult malf = CoderResult.malformedForLength(2);
// CoderResult under = CoderResult.UNDERFLOW;
//
// // set up error arrays
// Integer invalidCharLength = new Integer(1);
// Byte subChar1 = new Byte((byte)0);
// Byte subChar1_alternate = new Byte((byte)1); // for TO_U_CALLBACK_SUBSTITUTE
// Integer invalidCharLength = 1;
// Byte subChar1 = (byte)0;
// Byte subChar1_alternate = (byte)1; // for TO_U_CALLBACK_SUBSTITUTE
//
// // set up chars and bytes backups and expected values for certain cases
// CharBuffer charsBackup = bufferCopy(chars);
Expand All @@ -961,14 +961,14 @@ public void TestSurrogateBehavior() {
// // run toUWriteUChars with normal data
// Method toUWriteUChars = CharsetDecoderICU.class.getDeclaredMethod("toUWriteUChars", new Class[] { CharsetDecoderICU.class, char[].class, int.class, int.class, CharBuffer.class, IntBuffer.class, int.class});
// toUWriteUChars.setAccessible(true);
// CoderResult decoderResultExpected1 = (CoderResult)toUWriteUChars.invoke(decoder, new Object[] {decoder, new char[] {0xFFFD}, new Integer(0), new Integer(1), decoderCharsExpected1, decoderOffsetsExpected1, new Integer(bytes.position())});
// CoderResult decoderResultExpected1 = (CoderResult)toUWriteUChars.invoke(decoder, new Object[] {decoder, new char[] {0xFFFD}, Integer.valueOf(0), Integer.valueOf(1), decoderCharsExpected1, decoderOffsetsExpected1, Integer.valueOf(bytes.position())});
//
// // reset certain fields
// setFieldValue(CharsetDecoderICU.class, "invalidCharLength", decoder, invalidCharLength);
// setFieldValue(CharsetICU.class, "subChar1", ((CharsetICU) decoder.charset()), subChar1_alternate);
//
// // run toUWriteUChars again
// CoderResult decoderResultExpected2 = (CoderResult)toUWriteUChars.invoke(decoder, new Object[] {decoder, new char[] {0x1A}, new Integer(0), new Integer(1), decoderCharsExpected2, decoderOffsetsExpected2, new Integer(bytes.position())});
// CoderResult decoderResultExpected2 = (CoderResult)toUWriteUChars.invoke(decoder, new Object[] {decoder, new char[] {0x1A}, Integer.valueOf(0), Integer.valueOf(1), decoderCharsExpected2, decoderOffsetsExpected2, Integer.valueOf(bytes.position())});
//
// // begin creating the tests array
// ArrayList tests = new ArrayList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ public void TestSchSt() {
List<String> labels = index.getBucketLabels();
for (String[] testCase : testCases) {
String name = testCase[0];
int bucketIndex = Integer.valueOf(testCase[1]);
int bucketIndex = Integer.parseInt(testCase[1]);
String label = testCase[2];
String msg = "getBucketIndex(" + name + ")";
assertEquals(msg, bucketIndex, index.getBucketIndex(name));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -530,11 +530,10 @@ public void TestNewJapanese() {
};

String[] att = { "strength", };
Object[] val = { new Integer(Collator.QUATERNARY), };
Object[] val = { Collator.QUATERNARY, };

String[] attShifted = { "strength", "AlternateHandling"};
Object valShifted[] = { new Integer(Collator.QUATERNARY),
Boolean.TRUE };
Object valShifted[] = { Collator.QUATERNARY, Boolean.TRUE };

genericLocaleStarterWithOptions(Locale.JAPANESE, test1, att, val);
genericLocaleStarterWithOptions(Locale.JAPANESE, test2, att, val);
Expand Down Expand Up @@ -2210,7 +2209,7 @@ public void TestUpperFirstQuaternary()
{
String tests[] = { "B", "b", "Bb", "bB" };
String[] att = { "strength", "UpperFirst" };
Object attVals[] = { new Integer(Collator.QUATERNARY), Boolean.TRUE };
Object attVals[] = { Collator.QUATERNARY, Boolean.TRUE };
genericLocaleStarterWithOptions(new Locale("root","",""), tests, att, attVals);
}

Expand All @@ -2219,7 +2218,7 @@ public void TestJ4960()
{
String tests[] = { "\\u00e2T", "aT" };
String att[] = { "strength", "CaseLevel" };
Object attVals[] = { new Integer(Collator.PRIMARY), Boolean.TRUE };
Object attVals[] = { Collator.PRIMARY, Boolean.TRUE };
String tests2[] = { "a", "A" };
String rule = "&[first tertiary ignorable]=A=a";
String att2[] = { "CaseLevel" };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@ public void Test4179686() throws Exception {

// Iterate forward and collect all of the elements into a Vector
while ((elem = iter.next()) != CollationElementIterator.NULLORDER) {
elements.add(new Integer(elem));
elements.add(elem);
}

// Now iterate backward and make sure they're the same
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,10 +424,10 @@ public void TestGetFunctionalEquivalent() {
boolean expectAvailable = DATA[(i*3)+2].equals("t");
ULocale actual = Collator.getFunctionalEquivalent(kw[0],input,isAvailable);
if(!actual.equals(expect) || (expectAvailable!=isAvailable[0])) {
errln("#" + i + ": Collator.getFunctionalEquivalent(" + input + ")=" + actual + ", avail " + new Boolean(isAvailable[0]) + ", " +
"expected " + expect + " avail " + new Boolean(expectAvailable));
errln("#" + i + ": Collator.getFunctionalEquivalent(" + input + ")=" + actual + ", avail " + isAvailable[0] + ", " +
"expected " + expect + " avail " + expectAvailable);
} else {
logln("#" + i + ": Collator.getFunctionalEquivalent(" + input + ")=" + actual + ", avail " + new Boolean(isAvailable[0]));
logln("#" + i + ": Collator.getFunctionalEquivalent(" + input + ")=" + actual + ", avail " + isAvailable[0]);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public void TestKeywordValues(){
logln("Testing getting collation values:");
kwVals = ICUResourceBundle.getKeywordValues(ICUData.ICU_COLLATION_BASE_NAME,COLLATION_RESNAME);
for(n=0;n<kwVals.length;n++) {
logln(new Integer(n).toString() + ": " + kwVals[n]);
logln(Integer.valueOf(n).toString() + ": " + kwVals[n]);
if(DEFAULT_NAME.equals(kwVals[n])) {
errln("getKeywordValues for collation returned 'default' in the list.");
} else if(STANDARD_NAME.equals(kwVals[n])) {
Expand Down Expand Up @@ -169,16 +169,16 @@ private void getFunctionalEquivalentTestCases(String path, ClassLoader cl, Strin
ULocale inLocale = new ULocale(testCases[i+1]);
ULocale expectLocale = new ULocale(testCases[i+2]);

logln(new Integer(i/3).toString() + ": " + new Boolean(expectAvail).toString() + "\t\t" +
inLocale.toString() + "\t\t" + expectLocale.toString());
logln("" + i/3 + ": " + expectAvail + "\t\t" +
inLocale + "\t\t" + expectLocale);

ULocale equivLocale = ICUResourceBundle.getFunctionalEquivalent(path, cl, resName, keyword, inLocale, isAvail, truncate);
boolean gotAvail = isAvail[0];

if((gotAvail != expectAvail) || !equivLocale.equals(expectLocale)) {
errln(new Integer(i/3).toString() + ": Error, expected Equiv=" + new Boolean(expectAvail).toString() + "\t\t" +
inLocale.toString() + "\t\t--> " + expectLocale.toString() + ", but got " + new Boolean(gotAvail).toString() + " " +
equivLocale.toString());
errln("" + i/3 + ": Error, expected Equiv=" + expectAvail + "\t\t" +
inLocale + "\t\t--> " + expectLocale + ", but got " + gotAvail + " " +
equivLocale);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2487,7 +2487,7 @@ public void TestCoverage() {

f.format((Object)cal, buf, pos);
f.format((Object)now, buf, pos);
f.format(new Long(now.getTime()), buf, pos);
f.format(now.getTime(), buf, pos);
try {
f.format("Howdy", buf, pos);
}
Expand Down Expand Up @@ -3619,7 +3619,7 @@ public void TestFormatToCharacterIteratorCoverage() {
errln("FAIL: Date must be accepted by formatToCharacterIterator");
}

Number num = new Long(d.getTime());
Number num = d.getTime();
try {
acit = df.formatToCharacterIterator(num);
if (acit == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ public void TestRounding() {
@Test
public void testFormatToCharacterIterator() {

Number number = new Double(350.76);
Number negativeNumber = new Double(-350.76);
Number number = 350.76d;
Number negativeNumber = -350.76d;

Locale us = Locale.US;

Expand Down Expand Up @@ -339,12 +339,12 @@ public void testFormatToCharacterIterator() {
getNegativeCurrencyVectorUS());

// test multiple grouping separators
number = new Long(100300400);
number = 100300400L;
t_Format(11, number, NumberFormat.getNumberInstance(us),
getNumberVector2US());

// test 0
number = new Long(0);
number = 0L;
t_Format(12, number, NumberFormat.getNumberInstance(us),
getZeroVector());
}
Expand Down Expand Up @@ -508,7 +508,7 @@ public FieldContainer(int start, int end,

// called from support_messageformat tests
public FieldContainer(int start, int end, AttributedCharacterIterator.Attribute attribute, int value) {
this(start, end, attribute, new Integer(value));
this(start, end, attribute, Integer.valueOf(value));
}

// called from support_messageformat tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3916,7 +3916,7 @@ static void generateCXXHConstants(String thisVersion) {
System.out.println(" * Returns by value, unit of " + type + ": " + code + ".");
System.out.printf(" * Also see {@link #create%s()}.\n", name);
String getterVersion = getVersion(javaName, thisVersion);
if (Integer.valueOf(getterVersion) < 64) {
if (Integer.parseInt(getterVersion) < 64) {
getterVersion = "64";
}
if (isDraft(javaName)) {
Expand Down
Loading

0 comments on commit 201af46

Please sign in to comment.