diff --git a/jdk/test/java/text/Format/DateFormat/Bug4322313.java b/jdk/test/java/text/Format/DateFormat/Bug4322313.java index bea772e63e6..b6ddef99a1b 100644 --- a/jdk/test/java/text/Format/DateFormat/Bug4322313.java +++ b/jdk/test/java/text/Format/DateFormat/Bug4322313.java @@ -50,110 +50,110 @@ public class Bug4322313 extends IntlTest { Object[][] valids = { /* given ID offset format('z'), ('Z') index */ - {"GMT+03:04", new Long(-184 * mpm), "GMT+03:04", "+0304", new Integer(9)}, - {"GMT+13:42", new Long(-822 * mpm), "GMT+13:42", "+1342", new Integer(9)}, - {"GMT+00:00", new Long(0), "GMT+00:00", "+0000", new Integer(9)}, - {"GMT+1:11", new Long(-71 * mpm), "GMT+01:11", "+0111", new Integer(8)}, - {"GMT +13:42", new Long(0), "GMT", "+0000", new Integer(3)}, - {" GMT", new Long(0), "GMT", "+0000", new Integer(4)}, - {"+0304", new Long(-184 * mpm), "GMT+03:04", "+0304", new Integer(5)}, - {"+1342", new Long(-822 * mpm), "GMT+13:42", "+1342", new Integer(5)}, - {"+0000", new Long(0), "GMT+00:00", "+0000", new Integer(5)}, - {" +1342", new Long(-822 * mpm), "GMT+13:42", "+1342", new Integer(6)}, + {"GMT+03:04", -184L * mpm, "GMT+03:04", "+0304", 9}, + {"GMT+13:42", -822L * mpm, "GMT+13:42", "+1342", 9}, + {"GMT+00:00", 0L, "GMT+00:00", "+0000", 9}, + {"GMT+1:11", -71L * mpm, "GMT+01:11", "+0111", 8}, + {"GMT +13:42", 0L, "GMT", "+0000", 3}, + {" GMT", 0L, "GMT", "+0000", 4}, + {"+0304", -184L * mpm, "GMT+03:04", "+0304", 5}, + {"+1342", -822L * mpm, "GMT+13:42", "+1342", 5}, + {"+0000", 0L, "GMT+00:00", "+0000", 5}, + {" +1342", -822L * mpm, "GMT+13:42", "+1342", 6}, /* ISO-LATIN-1 digits */ - {"GMT+\u0030\u0031:\u0032\u0033", new Long(-83 * mpm), "GMT+01:23", "+0123", new Integer(9)}, + {"GMT+\u0030\u0031:\u0032\u0033", -83L * mpm, "GMT+01:23", "+0123", 9}, /* In fact, this test case is skipped because TimeZone class can't * recognize TimeZone IDs like "+00234" or "-00234". */ - {"+00234", new Long(-23 * mpm), "GMT+00:23", "+0023", new Integer(5)}, + {"+00234", -23L * mpm, "GMT+00:23", "+0023", 5}, - {"GMT-03:04", new Long(184 * mpm), "GMT-03:04", "-0304", new Integer(9)}, - {"GMT-13:42", new Long(822 * mpm), "GMT-13:42", "-1342", new Integer(9)}, - {"GMT-00:00", new Long(0), "GMT+00:00", "+0000", new Integer(9)}, - {"GMT-1:11", new Long(71 * mpm), "GMT-01:11", "-0111", new Integer(8)}, - {"GMT -13:42", new Long(0), "GMT", "+0000", new Integer(3)}, - {"-0304", new Long(184 * mpm), "GMT-03:04", "-0304", new Integer(5)}, - {"-1342", new Long(822 * mpm), "GMT-13:42", "-1342", new Integer(5)}, - {" -1342", new Long(822 * mpm), "GMT-13:42", "-1342", new Integer(6)}, + {"GMT-03:04", 184L * mpm, "GMT-03:04", "-0304", 9}, + {"GMT-13:42", 822L * mpm, "GMT-13:42", "-1342", 9}, + {"GMT-00:00", 0L, "GMT+00:00", "+0000", 9}, + {"GMT-1:11", 71L * mpm, "GMT-01:11", "-0111", 8}, + {"GMT -13:42", 0L, "GMT", "+0000", 3}, + {"-0304", 184L * mpm, "GMT-03:04", "-0304", 5}, + {"-1342", 822L * mpm, "GMT-13:42", "-1342", 5}, + {" -1342", 822L * mpm, "GMT-13:42", "-1342", 6}, /* ISO-LATIN-1 digits */ - {"GMT-\u0030\u0031:\u0032\u0033", new Long(83 * mpm), "GMT-01:23", "-0123", new Integer(9)}, + {"GMT-\u0030\u0031:\u0032\u0033", 83L * mpm, "GMT-01:23", "-0123", 9}, /* In fact, this test case is skipped because TimeZone class can't * recognize TimeZone IDs like "+00234" or "-00234". */ - {"-00234", new Long(23 * mpm), "GMT+00:23", "-0023", new Integer(5)}, + {"-00234", 23L * mpm, "GMT+00:23", "-0023", 5}, }; Object[][] invalids = { /* given ID error index */ - {"GMT+8", new Integer(5)}, - {"GMT+18", new Integer(6)}, - {"GMT+208", new Integer(6)}, - {"GMT+0304", new Integer(6)}, - {"GMT+42195", new Integer(5)}, - {"GMT+5:8", new Integer(7)}, - {"GMT+23:60", new Integer(8)}, - {"GMT+11:1", new Integer(8)}, - {"GMT+24:13", new Integer(5)}, - {"GMT+421:950", new Integer(5)}, - {"GMT+0a:0A", new Integer(5)}, - {"GMT+ 13:42", new Integer(4)}, - {"GMT+13 :42", new Integer(6)}, - {"GMT+13: 42", new Integer(7)}, - {"GMT+-13:42", new Integer(4)}, - {"G M T", new Integer(0)}, - {"+8", new Integer(2)}, - {"+18", new Integer(3)}, - {"+208", new Integer(4)}, - {"+2360", new Integer(4)}, - {"+2413", new Integer(2)}, - {"+42195", new Integer(2)}, - {"+0AbC", new Integer(2)}, - {"+ 1342", new Integer(1)}, - {"+-1342", new Integer(1)}, - {"1342", new Integer(0)}, + {"GMT+8", 5}, + {"GMT+18", 6}, + {"GMT+208", 6}, + {"GMT+0304", 6}, + {"GMT+42195", 5}, + {"GMT+5:8", 7}, + {"GMT+23:60", 8}, + {"GMT+11:1", 8}, + {"GMT+24:13", 5}, + {"GMT+421:950", 5}, + {"GMT+0a:0A", 5}, + {"GMT+ 13:42", 4}, + {"GMT+13 :42", 6}, + {"GMT+13: 42", 7}, + {"GMT+-13:42", 4}, + {"G M T", 0}, + {"+8", 2}, + {"+18", 3}, + {"+208", 4}, + {"+2360", 4}, + {"+2413", 2}, + {"+42195", 2}, + {"+0AbC", 2}, + {"+ 1342", 1}, + {"+-1342", 1}, + {"1342", 0}, /* Arabic-Indic digits */ - {"GMT+\u0660\u0661:\u0662\u0663", new Integer(4)}, + {"GMT+\u0660\u0661:\u0662\u0663", 4}, /* Extended Arabic-Indic digits */ - {"GMT+\u06f0\u06f1:\u06f2\u06f3", new Integer(4)}, + {"GMT+\u06f0\u06f1:\u06f2\u06f3", 4}, /* Devanagari digits */ - {"GMT+\u0966\u0967:\u0968\u0969", new Integer(4)}, + {"GMT+\u0966\u0967:\u0968\u0969", 4}, /* Fullwidth digits */ - {"GMT+\uFF10\uFF11:\uFF12\uFF13", new Integer(4)}, + {"GMT+\uFF10\uFF11:\uFF12\uFF13", 4}, - {"GMT-8", new Integer(5)}, - {"GMT-18", new Integer(6)}, - {"GMT-208", new Integer(6)}, - {"GMT-0304", new Integer(6)}, - {"GMT-42195", new Integer(5)}, - {"GMT-5:8", new Integer(7)}, - {"GMT-23:60", new Integer(8)}, - {"GMT-11:1", new Integer(8)}, - {"GMT-24:13", new Integer(5)}, - {"GMT-421:950", new Integer(5)}, - {"GMT-0a:0A", new Integer(5)}, - {"GMT- 13:42", new Integer(4)}, - {"GMT-13 :42", new Integer(6)}, - {"GMT-13: 42", new Integer(7)}, - {"GMT-+13:42", new Integer(4)}, - {"-8", new Integer(2)}, - {"-18", new Integer(3)}, - {"-208", new Integer(4)}, - {"-2360", new Integer(4)}, - {"-2413", new Integer(2)}, - {"-42195", new Integer(2)}, - {"-0AbC", new Integer(2)}, - {"- 1342", new Integer(1)}, - {"--1342", new Integer(1)}, - {"-802", new Integer(2)}, + {"GMT-8", 5}, + {"GMT-18", 6}, + {"GMT-208", 6}, + {"GMT-0304", 6}, + {"GMT-42195", 5}, + {"GMT-5:8", 7}, + {"GMT-23:60", 8}, + {"GMT-11:1", 8}, + {"GMT-24:13", 5}, + {"GMT-421:950", 5}, + {"GMT-0a:0A", 5}, + {"GMT- 13:42", 4}, + {"GMT-13 :42", 6}, + {"GMT-13: 42", 7}, + {"GMT-+13:42", 4}, + {"-8", 2}, + {"-18", 3}, + {"-208", 4}, + {"-2360", 4}, + {"-2413", 2}, + {"-42195", 2}, + {"-0AbC", 2}, + {"- 1342", 1}, + {"--1342", 1}, + {"-802", 2}, /* Arabic-Indic digits */ - {"GMT-\u0660\u0661:\u0662\u0663", new Integer(4)}, + {"GMT-\u0660\u0661:\u0662\u0663", 4}, /* Extended Arabic-Indic digits */ - {"GMT-\u06f0\u06f1:\u06f2\u06f3", new Integer(4)}, + {"GMT-\u06f0\u06f1:\u06f2\u06f3", 4}, /* Devanagari digits */ - {"GMT-\u0966\u0967:\u0968\u0969", new Integer(4)}, + {"GMT-\u0966\u0967:\u0968\u0969", 4}, /* Fullwidth digits */ - {"GMT-\uFF10\uFF11:\uFF12\uFF13", new Integer(4)}, + {"GMT-\uFF10\uFF11:\uFF12\uFF13", 4}, }; try { diff --git a/jdk/test/java/text/Format/DateFormat/Bug4736959.java b/jdk/test/java/text/Format/DateFormat/Bug4736959.java index cdb9cad20b4..00fa8d0840a 100644 --- a/jdk/test/java/text/Format/DateFormat/Bug4736959.java +++ b/jdk/test/java/text/Format/DateFormat/Bug4736959.java @@ -30,6 +30,7 @@ import java.text.*; import java.util.*; +@SuppressWarnings("deprecation") public class Bug4736959 { /** * 4736959: JSpinner won't work for AM/PM field diff --git a/jdk/test/java/text/Format/DateFormat/Bug4823811.java b/jdk/test/java/text/Format/DateFormat/Bug4823811.java index c2d35e9f64f..b1f6c9d5b9d 100644 --- a/jdk/test/java/text/Format/DateFormat/Bug4823811.java +++ b/jdk/test/java/text/Format/DateFormat/Bug4823811.java @@ -685,8 +685,8 @@ public class Bug4823811 { testNumberFormatFormatting(nfEG, -456, "456-", "ar_EG"); System.out.println("*** DecimalFormat.parse test in ar_EG"); - testNumberFormatParsing(nfEG, "123-", new Long(-123), "ar_EG"); - testNumberFormatParsing(nfEG, "123--", new Long(-123), "ar_EG"); + testNumberFormatParsing(nfEG, "123-", -123L, "ar_EG"); + testNumberFormatParsing(nfEG, "123--",-123L, "ar_EG"); testNumberFormatParsingCheckException(nfEG, "-123", 0, "ar_EG"); System.out.println("*** DecimalFormat.format test in en_US"); @@ -694,8 +694,8 @@ public class Bug4823811 { testNumberFormatFormatting(nfUS, -456, "-456", "en_US"); System.out.println("*** DecimalFormat.parse test in en_US"); - testNumberFormatParsing(nfUS, "123-", new Long(123), "en_US"); - testNumberFormatParsing(nfUS, "-123", new Long(-123), "en_US"); + testNumberFormatParsing(nfUS, "123-", 123L, "en_US"); + testNumberFormatParsing(nfUS, "-123",-123L, "en_US"); testNumberFormatParsingCheckException(nfUS, "--123", 0, "en_US"); } diff --git a/jdk/test/java/text/Format/DateFormat/Bug4845901.java b/jdk/test/java/text/Format/DateFormat/Bug4845901.java index a88b47a761e..363a3518bf0 100644 --- a/jdk/test/java/text/Format/DateFormat/Bug4845901.java +++ b/jdk/test/java/text/Format/DateFormat/Bug4845901.java @@ -55,6 +55,7 @@ public class Bug4845901 { } } + @SuppressWarnings("deprecation") static void testParse(SimpleDateFormat sdf, String str, int expectedHour) { try { Date parsedDate = sdf.parse(str); diff --git a/jdk/test/java/text/Format/DateFormat/Bug6609750.java b/jdk/test/java/text/Format/DateFormat/Bug6609750.java index ccd5d5e814b..5529bc6c812 100644 --- a/jdk/test/java/text/Format/DateFormat/Bug6609750.java +++ b/jdk/test/java/text/Format/DateFormat/Bug6609750.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,6 +37,7 @@ public class Bug6609750 { Locale defaultLocale = Locale.getDefault(); Locale.setDefault(Locale.US); + @SuppressWarnings("deprecation") Date[] dates = { new Date(9-1900, Calendar.JUNE, 12), new Date(99-1900, Calendar.JUNE, 12), diff --git a/jdk/test/java/text/Format/DateFormat/Bug6683975.java b/jdk/test/java/text/Format/DateFormat/Bug6683975.java index 1f401058e5a..0afdcd74c4a 100644 --- a/jdk/test/java/text/Format/DateFormat/Bug6683975.java +++ b/jdk/test/java/text/Format/DateFormat/Bug6683975.java @@ -66,6 +66,7 @@ public class Bug6683975 { System.err.println("\tth_TH: " + str_th_TH); } + @SuppressWarnings("deprecation") Date date = new Date(2008-1900, Calendar.SEPTEMBER, 30, 8, 0, 0); str_th = df_th.format(date); if (!expected_th[style].equals(str_th)) { diff --git a/jdk/test/java/text/Format/DateFormat/DateFormatRegression.java b/jdk/test/java/text/Format/DateFormat/DateFormatRegression.java index 5c416b0dc53..d4230fb2cb7 100644 --- a/jdk/test/java/text/Format/DateFormat/DateFormatRegression.java +++ b/jdk/test/java/text/Format/DateFormat/DateFormatRegression.java @@ -41,7 +41,7 @@ public class DateFormatRegression extends IntlTest { } public void Test4029195() { - + @SuppressWarnings("deprecation") Date today = new Date(); logln("today: " + today); @@ -74,19 +74,20 @@ public class DateFormatRegression extends IntlTest { public void Test4052408() { DateFormat fmt = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.US); + @SuppressWarnings("deprecation") Date date = new Date(97, Calendar.MAY, 3, 8, 55); String str; logln(str = fmt.format(date)); if (!str.equals("5/3/97 8:55 AM")) errln("Fail: Test broken; Want 5/3/97 8:55 AM Got " + str); - Hashtable expected = new Hashtable(); - expected.put(new Integer(DateFormat.MONTH_FIELD), "5"); - expected.put(new Integer(DateFormat.DATE_FIELD), "3"); - expected.put(new Integer(DateFormat.YEAR_FIELD), "97"); - expected.put(new Integer(DateFormat.HOUR1_FIELD), "8"); - expected.put(new Integer(DateFormat.MINUTE_FIELD), "55"); - expected.put(new Integer(DateFormat.AM_PM_FIELD), "AM"); + Map expected = new HashMap<>(); + expected.put(DateFormat.MONTH_FIELD, "5"); + expected.put(DateFormat.DATE_FIELD, "3"); + expected.put(DateFormat.YEAR_FIELD, "97"); + expected.put(DateFormat.HOUR1_FIELD, "8"); + expected.put(DateFormat.MINUTE_FIELD, "55"); + expected.put(DateFormat.AM_PM_FIELD, "AM"); StringBuffer buf = new StringBuffer(); String fieldNames[] = { @@ -120,7 +121,7 @@ public class DateFormatRegression extends IntlTest { ", \"" + str + "\", " + pos.getBeginIndex() + ", " + pos.getEndIndex()); - String exp = (String) expected.get(new Integer(i)); + String exp = expected.get(i); if ((exp == null && str.length() == 0) || str.equals(exp)) logln(" ok"); @@ -135,6 +136,7 @@ public class DateFormatRegression extends IntlTest { /** * Verify the function of the [s|g]et2DigitYearStart() API. */ + @SuppressWarnings("deprecation") public void Test4056591() { try { SimpleDateFormat fmt = new SimpleDateFormat("yyMMdd", Locale.US); @@ -255,6 +257,7 @@ public class DateFormatRegression extends IntlTest { if (!ok) errln("Fail: Lenient not working"); } + @SuppressWarnings("deprecation") public void Test4065240() { Date curDate; DateFormat shortdate, fulldate; @@ -297,6 +300,7 @@ public class DateFormatRegression extends IntlTest { Currently this bug breaks MessageFormat.toPattern */ + @SuppressWarnings("deprecation") public void Test4071441() { DateFormat fmtA = DateFormat.getInstance(); DateFormat fmtB = DateFormat.getInstance(); @@ -488,6 +492,7 @@ public class DateFormatRegression extends IntlTest { public void Test4101483() { SimpleDateFormat sdf = new SimpleDateFormat("z", Locale.US); FieldPosition fp = new FieldPosition(DateFormat.TIMEZONE_FIELD); + @SuppressWarnings("deprecation") Date d= new Date(9234567890L); StringBuffer buf = new StringBuffer(""); logln(sdf.format(d, buf, fp).toString()); @@ -508,6 +513,7 @@ public class DateFormatRegression extends IntlTest { public void Test4103340() { // choose a date that is the FIRST of some month // and some arbitrary time + @SuppressWarnings("deprecation") Date d=new Date(97, 3, 1, 1, 1, 1); SimpleDateFormat df=new SimpleDateFormat("MMMM", Locale.US); @@ -538,6 +544,7 @@ public class DateFormatRegression extends IntlTest { sdf.applyPattern(pattern); logln("pattern: \"" + pattern + "\""); + @SuppressWarnings("deprecation") Object[] DATA = { "time 10:30", new ParsePosition(10), new Date(70, Calendar.JANUARY, 1, 10, 30), "time 10:x", new ParsePosition(0), null, @@ -698,6 +705,7 @@ public class DateFormatRegression extends IntlTest { String pattern = "'TO_DATE('''dd'-'MM'-'yyyy HH:mm:ss''' , ''DD-MM-YYYY HH:MI:SS'')'"; logln("pattern=" + pattern); SimpleDateFormat format = new SimpleDateFormat(pattern, Locale.US); + @SuppressWarnings("deprecation") String result = format.format(new Date(1998-1900, Calendar.JUNE, 30, 13, 30, 0)); if (!result.equals("TO_DATE('30-06-1998 13:30:00' , 'DD-MM-YYYY HH:MI:SS')")) { errln("Fail: result=" + result); @@ -711,6 +719,7 @@ public class DateFormatRegression extends IntlTest { * 'z' at end of date format throws index exception in SimpleDateFormat * CANNOT REPRODUCE THIS BUG ON 1.2FCS */ + @SuppressWarnings("deprecation") public void Test4151706() { SimpleDateFormat fmt = new SimpleDateFormat("EEEE, dd-MMM-yy HH:mm:ss z", Locale.US); @@ -755,6 +764,7 @@ public class DateFormatRegression extends IntlTest { * Confirm that "EST"(GMT-5:00) and "CST"(GMT-6:00) are used in US * as "EST" or "CST", not Australian "EST" and "CST". */ + @SuppressWarnings("deprecation") public void Test4406615() { Locale savedLocale = Locale.getDefault(); TimeZone savedTimeZone = TimeZone.getDefault(); @@ -823,6 +833,7 @@ public class DateFormatRegression extends IntlTest { * greater than "99", are treated as literal years. So "1/2/3456" * becomes 3456 AD. Likewise, "1/2/-3" becomes -3 AD == 2 BC. */ + @SuppressWarnings("deprecation") Object[] DATA = { "02/29/00", new Date(2000-1900, Calendar.FEBRUARY, 29), "01/23/01", new Date(2001-1900, Calendar.JANUARY, 23), @@ -878,6 +889,7 @@ public class DateFormatRegression extends IntlTest { DateFormat fmt = new SimpleDateFormat(pattern, DateFormatSymbols.getInstance(Locale.US)); fmt.getCalendar().setLenient(false); + @SuppressWarnings("deprecation") Date d = new Date(2000-1900, Calendar.FEBRUARY, 29); String s = fmt.format(d); logln(d + " x " + pattern + " => " + s); @@ -957,6 +969,7 @@ public class DateFormatRegression extends IntlTest { } } + @SuppressWarnings("deprecation") public void Test4253490() throws ParseException { SimpleDateFormat fmt = new SimpleDateFormat("S", Locale.US); @@ -1026,6 +1039,7 @@ public class DateFormatRegression extends IntlTest { public void Test4250359() { DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT, Locale.US); + @SuppressWarnings("deprecation") Date d = new Date(1999-1900, Calendar.DECEMBER, 25, 1, 2, 3); String s = df.format(d); @@ -1052,6 +1066,7 @@ public class DateFormatRegression extends IntlTest { // pick up another time zone when L10N is done to that file. TimeZone.setDefault(TimeZone.getTimeZone("PST")); SimpleDateFormat fmt = new SimpleDateFormat("yy/MM/dd hh:ss zzz", Locale.JAPAN); + @SuppressWarnings("deprecation") String result = fmt.format(new Date(1999, 0, 1)); logln("format()=>" + result); if (!result.endsWith("PST")) { diff --git a/jdk/test/java/text/Format/DateFormat/DateFormatRoundTripTest.java b/jdk/test/java/text/Format/DateFormat/DateFormatRoundTripTest.java index 73d023163f1..9bf3ac3835a 100644 --- a/jdk/test/java/text/Format/DateFormat/DateFormatRoundTripTest.java +++ b/jdk/test/java/text/Format/DateFormat/DateFormatRoundTripTest.java @@ -104,7 +104,7 @@ public class DateFormatRoundTripTest extends IntlTest { String pat = null; Date date = null; - Vector newArgs = new Vector(); + List newArgs = new ArrayList<>(); for (int i=0; i#.###E00", 'm'); - test(new Double(1234), "

1.234E03"); - test(new Double(0.1234), "

1.234Em01"); - test(new Double(-1234), "m

1.234E03"); - test(new Double(-0.1234), "m

1.234Em01"); + test(1234D, "

1.234E03"); + test(0.1234, "

1.234Em01"); + test(-1234D, "m

1.234E03"); + test(-0.1234, "m

1.234Em01"); prepareFormatter("

#.###E00;#.###E00", 'm'); - test(new Double(1234), "

1.234E03"); - test(new Double(0.1234), "

1.234Em01"); - test(new Double(-1234), "1.234E03"); - test(new Double(-0.1234), "1.234Em01"); + test(1234D, "

1.234E03"); + test(0.1234, "

1.234Em01"); + test(-1234D, "1.234E03"); + test(-0.1234, "1.234Em01"); prepareFormatter("#.###E00;

#.###E00", 'm'); - test(new Double(1234), "1.234E03"); - test(new Double(0.1234), "1.234Em01"); - test(new Double(-1234), "

1.234E03"); - test(new Double(-0.1234), "

1.234Em01"); + test(1234D, "1.234E03"); + test(0.1234, "1.234Em01"); + test(-1234D, "

1.234E03"); + test(-0.1234, "

1.234Em01"); prepareFormatter("

#.###E00;

-#.###E00", 'm'); - test(new Double(1234), "

1.234E03"); - test(new Double(0.1234), "

1.234Em01"); - test(new Double(-1234), "

m1.234E03"); - test(new Double(-0.1234), "

m1.234Em01"); + test(1234D, "

1.234E03"); + test(0.1234, "

1.234Em01"); + test(-1234D, "

m1.234E03"); + test(-0.1234, "

m1.234Em01"); - test(new Double(Double.POSITIVE_INFINITY), "

\u221e"); - test(new Double(Double.NEGATIVE_INFINITY), "

m\u221e"); - test(new Double(Double.NaN), "\ufffd"); // without prefix and suffix - test(new Double(0.0), "

0E00"); - test(new Double(-0.0), "

m0E00"); // with the minus sign + test(Double.POSITIVE_INFINITY, "

\u221e"); + test(Double.NEGATIVE_INFINITY, "

m\u221e"); + test(Double.NaN, "\ufffd"); // without prefix and suffix + test(0.0, "

0E00"); + test(-0.0, "

m0E00"); // with the minus sign } static void test_BigDecimal() { @@ -151,19 +151,19 @@ public class Bug4838107 extends IntlTest { dfs = df.getDecimalFormatSymbols(); /* Test with default pattern */ - test(new Long(123456789), "123,456,789"); - test(new Long(-123456789), "-123,456,789"); + test(123456789L, "123,456,789"); + test(-123456789L, "-123,456,789"); - test(new Long(0), "0"); - test(new Long(-0), "0"); + test(0L, "0"); + test(-0L, "0"); /* Specify a pattern and the minus sign. */ prepareFormatter("

#,###;

-#,###", 'm'); - test(new Long(123456789), "

123,456,789"); - test(new Long(-123456789), "

m123,456,789"); + test(123456789L, "

123,456,789"); + test(-123456789L, "

m123,456,789"); - test(new Long(0), "

0"); - test(new Long(-0), "

0"); + test(0L, "

0"); + test(-0L, "

0"); } static void test_BigInteger() { diff --git a/jdk/test/java/text/Format/NumberFormat/Bug4944439.java b/jdk/test/java/text/Format/NumberFormat/Bug4944439.java index beb4d77c235..0e85a98119d 100644 --- a/jdk/test/java/text/Format/NumberFormat/Bug4944439.java +++ b/jdk/test/java/text/Format/NumberFormat/Bug4944439.java @@ -84,7 +84,7 @@ public class Bug4944439 { } int index = s.indexOf('.'); - Long l = new Long(s.substring(0, index)); + Long l = Long.valueOf(s.substring(0, index)); if (!l.equals(number)) { err = true; System.err.println("Failed: DecimalFormat.parse(" + s + @@ -101,7 +101,7 @@ public class Bug4944439 { number.getClass().getName()); } - Double d = new Double(s); + Double d = Double.valueOf(s); if (!d.equals(number)) { err = true; System.err.println("Failed: DecimalFormat.parse(" + s + diff --git a/jdk/test/java/text/Format/NumberFormat/Bug4990596.java b/jdk/test/java/text/Format/NumberFormat/Bug4990596.java index a8c03b8a035..2b311fb1b5f 100644 --- a/jdk/test/java/text/Format/NumberFormat/Bug4990596.java +++ b/jdk/test/java/text/Format/NumberFormat/Bug4990596.java @@ -35,6 +35,7 @@ public class Bug4990596 { new DecimalFormat().format(new MutableInteger(0)); } + @SuppressWarnings("serial") public static class MutableInteger extends Number { public int value; diff --git a/jdk/test/java/text/Format/NumberFormat/Bug6278616.java b/jdk/test/java/text/Format/NumberFormat/Bug6278616.java index 9066a7da02e..b1684b4d177 100644 --- a/jdk/test/java/text/Format/NumberFormat/Bug6278616.java +++ b/jdk/test/java/text/Format/NumberFormat/Bug6278616.java @@ -47,7 +47,7 @@ public class Bug6278616 { NumberFormat nf = NumberFormat.getInstance(); for (int j = 0; j < ints.length; j++) { - String s_i = nf.format(new Integer(ints[j])); + String s_i = nf.format(ints[j]); String s_ai = nf.format(new AtomicInteger(ints[j])); if (!s_i.equals(s_ai)) { throw new RuntimeException("format(AtomicInteger " + s_ai + @@ -57,7 +57,7 @@ public class Bug6278616 { } for (int j = 0; j < longs.length; j++) { - String s_l = nf.format(new Long(longs[j])); + String s_l = nf.format(longs[j]); String s_al = nf.format(new AtomicLong(longs[j])); if (!s_l.equals(s_al)) { throw new RuntimeException("format(AtomicLong " + s_al + diff --git a/jdk/test/java/text/Format/NumberFormat/NumberRegression.java b/jdk/test/java/text/Format/NumberFormat/NumberRegression.java index b194d270a5c..48147f35d2a 100644 --- a/jdk/test/java/text/Format/NumberFormat/NumberRegression.java +++ b/jdk/test/java/text/Format/NumberFormat/NumberRegression.java @@ -289,7 +289,7 @@ public class NumberRegression extends IntlTest { DecimalFormat df = new DecimalFormat(); Double d = (Double)df.parse("123.55456", pos=new ParsePosition(0)); if (!d.toString().equals("123.55456")) { - errln("Result -> " + d.doubleValue()); + errln("Result -> " + d); } Locale.setDefault(savedLocale); } @@ -395,11 +395,11 @@ public class NumberRegression extends IntlTest { Locale.setDefault(Locale.US); DecimalFormat df = new DecimalFormat(); String str = "0.1234"; - Double d1 = new Double(str); + Double d1 = 0.1234; Double d2 = (Double) df.parse(str, new ParsePosition(0)); logln(d1.toString()); if (d2.doubleValue() != d1.doubleValue()) - errln("Bug 4095713 test failed, new double value : " + d2.doubleValue()); + errln("Bug 4095713 test failed, new double value : " + d2); Locale.setDefault(savedLocale); } @@ -870,7 +870,7 @@ public class NumberRegression extends IntlTest { DecimalFormat fmt = new DecimalFormat("#,##0.00"); StringBuffer formatted = new StringBuffer(); FieldPosition field = new FieldPosition(0); - Double num = new Double(1234.5); + Double num = 1234.5; fmt.format(num, formatted, field); if (field.getBeginIndex() != 0 && field.getEndIndex() != 5) errln("Format 1234.5 failed. Begin index: " + field.getBeginIndex() + " End index: " + field.getEndIndex()); @@ -1416,7 +1416,7 @@ public class NumberRegression extends IntlTest { DecimalFormat fmt = new DecimalFormat("#", DecimalFormatSymbols.getInstance(Locale.US)); for (int i=0; i 0 != DATA[i] > 0) { errln("\"" + str + "\" parse(x " + fmt.getMultiplier() + ") => " + n); @@ -1637,15 +1637,15 @@ public class NumberRegression extends IntlTest { */ public void Test4217661() { Object[] DATA = { - new Double(0.001), "0", - new Double(1.001), "1", - new Double(0.006), "0.01", - new Double(1.006), "1.01", + 0.001, "0", + 1.001, "1", + 0.006, "0.01", + 1.006, "1.01", }; NumberFormat fmt = NumberFormat.getInstance(Locale.US); fmt.setMaximumFractionDigits(2); for (int i=0; i contents = parser.parse(new BufferedReader( new FileReader(file))); - Vector test = (Vector)contents.get("tests"); + List test = (List)contents.get("tests"); for (int counter = 0; counter < test.size(); counter++) { logln("creating: " + (counter / 2)); AttributedCharacterIterator iterator = - create((Hashtable)test.get(counter)); + create((Map)test.get(counter)); logln("verifying: " + (counter / 2)); - verify(iterator, (Hashtable)test.get(++counter)); + verify(iterator, (Map)test.get(++counter)); } } catch (IOException ioe) { errln("Error reading: " + ioe); } } - public void verify(AttributedCharacterIterator iterator,Hashtable table) { + @SuppressWarnings("unchecked") + public void verify(AttributedCharacterIterator iterator,Map table) { int length = Integer.parseInt((String)table.get("length")); // Verify the text @@ -185,10 +186,10 @@ public class FormatIteratorTest extends IntlTest { for (int counter = 0; counter < length; counter++) { iterator.setIndex(counter); if (!verifyAttributes(iterator.getAttributes().keySet(), - makeAttributes((Vector)table.get(Integer. + makeAttributes((List)table.get(Integer. toString(counter))))) { errln("Attributes don't match at " + counter + " expecting " + - makeAttributes((Vector)table.get(Integer.toString + makeAttributes((List)table.get(Integer.toString (counter))) + " got " + iterator.getAttributes().keySet()); } @@ -196,10 +197,10 @@ public class FormatIteratorTest extends IntlTest { for (int counter = length - 1; counter >= 0; counter--) { iterator.setIndex(counter); if (!verifyAttributes(iterator.getAttributes().keySet(), - makeAttributes((Vector)table.get(Integer. + makeAttributes((List)table.get(Integer. toString(counter))))) { errln("Attributes don't match at " + counter + " expecting " + - makeAttributes((Vector)table.get(Integer.toString + makeAttributes((List)table.get(Integer.toString (counter))) + " got " + iterator.getAttributes().keySet()); } @@ -207,31 +208,33 @@ public class FormatIteratorTest extends IntlTest { verifyLimits(iterator, table); text = escapeIfNecessary((String)table.get("text")); - Vector fps = (Vector)table.get("fieldPositions"); + List fps = (List)table.get("fieldPositions"); if (fps != null) { for (int counter = 0; counter < fps.size(); counter++) { - verifyFieldPosition(counter, (Hashtable)fps.get(counter)); + verifyFieldPosition(counter,(Map)fps.get(counter)); } } } + @SuppressWarnings("unchecked") private void verifyLimits(AttributedCharacterIterator iterator, - Hashtable table) { - Vector limits = (Vector)table.get("limits"); + Map table) { + List limits = (List)table.get("limits"); if (limits != null) { for (int counter = 0; counter < limits.size(); counter++) { - verifyLimit(iterator, (Hashtable)limits.get(counter)); + verifyLimit(iterator, (Map)limits.get(counter)); } } } private void verifyLimit(AttributedCharacterIterator iterator, - Hashtable table) { + Map table) { int begin = Integer.parseInt((String)table.get("begin")); int end = Integer.parseInt((String)table.get("end")); - Set attrs = makeAttributes((Vector)table.get("attributes")); + @SuppressWarnings("unchecked") + Set attrs = makeAttributes((List)table.get("attributes")); String begin2S = (String)table.get("begin2"); int begin2 = (begin2S != null) ? Integer.parseInt(begin2S) : begin; String end2S = (String)table.get("end2"); @@ -262,9 +265,9 @@ public class FormatIteratorTest extends IntlTest { } } - private boolean verifyAttributes(Set a, Set b) { - boolean aEmpty = (a.size() == 0); - boolean bEmpty = (b.size() == 0); + private boolean verifyAttributes(Set a, Set b) { + boolean aEmpty = a.isEmpty(); + boolean bEmpty = b.isEmpty(); if (aEmpty && bEmpty) { return true; @@ -284,14 +287,14 @@ public class FormatIteratorTest extends IntlTest { return buffer.toString(); } - private void verifyFieldPosition(int index, Hashtable table) { + private void verifyFieldPosition(int index, Map table) { Object o = table.get("field"); int begin = Integer.parseInt((String)table.get("begin")); int end = Integer.parseInt((String)table.get("end")); if (o != null) { FieldPosition fp = new FieldPosition(((Integer) - lookupField((String)o)).intValue()); + lookupField((String)o))); verifyFieldPosition(fp, begin, end, index); } @@ -322,11 +325,11 @@ public class FormatIteratorTest extends IntlTest { } } - public AttributedCharacterIterator create(Hashtable table) { + public AttributedCharacterIterator create(Map table) { format = (Format)createInstance((String)table.get("class"), - ((Vector)table.get("args")).toArray()); + ((List)table.get("args")).toArray()); value = createInstance((String)table.get("valueClass"), - ((Vector)table.get("valueArgs")).toArray()); + ((List)table.get("valueArgs")).toArray()); logln("Created format: " + format + " value " + value); AttributedCharacterIterator aci = format. @@ -343,11 +346,12 @@ public class FormatIteratorTest extends IntlTest { private Object createInstance(String className, Object[] args) { if (className.equals("java.lang.reflect.Array")) { for (int counter = 0; counter < args.length; counter++) { - if (args[counter] instanceof Vector) { - Vector v = (Vector)args[counter]; + if (args[counter] instanceof List) { + @SuppressWarnings("unchecked") + List v = (List)args[counter]; args[counter] = createInstance((String)v.get(0), - ((Vector)v.get(1)).toArray()); + ((List)v.get(1)).toArray()); } } return args; @@ -361,9 +365,9 @@ public class FormatIteratorTest extends IntlTest { } else if (className.equals("java.util.concurrent.atomic.AtomicLong")) { return new AtomicLong(Long.valueOf((String)args[0])); } else { - Class klass = lookupClass(className); - Constructor cons = klass.getConstructor( - new Class[] { String.class }); + Class klass = lookupClass(className); + Constructor cons = klass.getConstructor( + new Class[] { String.class }); Object value = cons.newInstance(args); return value; @@ -374,20 +378,20 @@ public class FormatIteratorTest extends IntlTest { } } - private Class lookupClass(String name) throws ClassNotFoundException { + private Class lookupClass(String name) throws ClassNotFoundException { try { - Class klass = Class.forName(name); + Class klass = Class.forName(name); return klass; } catch (ClassNotFoundException e1) {} try { - Class klass = Class.forName("java.lang." + name); + Class klass = Class.forName("java.lang." + name); return klass; } catch (ClassNotFoundException e1) {} - Class klass = Class.forName("java.text." + name); + Class klass = Class.forName("java.text." + name); return klass; } @@ -397,7 +401,7 @@ public class FormatIteratorTest extends IntlTest { try { int dotIndex = name.indexOf('.'); - Class klass = lookupClass(name.substring(0, dotIndex)); + Class klass = lookupClass(name.substring(0, dotIndex)); String fieldName = name.substring(dotIndex + 1); Field[] fields = klass.getFields(); @@ -429,8 +433,8 @@ public class FormatIteratorTest extends IntlTest { return string; } - public Set makeAttributes(Vector names) { - HashSet set = new HashSet(Math.max(1, names.size())); + public Set makeAttributes(List names) { + Set set = new HashSet<>(Math.max(1, names.size())); for (int counter = 0; counter < names.size(); counter++) { set.add(makeAttribute((String)names.get(counter))); diff --git a/jdk/test/java/text/Format/common/PParser.java b/jdk/test/java/text/Format/common/PParser.java index 6ada76b1059..eb7ccd11315 100644 --- a/jdk/test/java/text/Format/common/PParser.java +++ b/jdk/test/java/text/Format/common/PParser.java @@ -58,7 +58,7 @@ public class PParser { public PParser() { } - public Hashtable parse(Reader r) throws IOException { + public Map parse(Reader r) throws IOException { this.reader = r; bufferedToken = false; lineNumber = 0; @@ -91,23 +91,23 @@ public class PParser { } protected Object parseArray() throws IOException { - Vector array = new Vector(); - int token; + List array = new ArrayList<>(); + int token; while ((token = getToken()) != CLOSE_ARRAY) { if (token == MORE) { token = getToken(); } if (token != CLOSE_ARRAY) { - array.addElement(parseValue(token)); + array.add(parseValue(token)); } } return array; } - protected Hashtable parsePair() throws IOException { - Hashtable ht = new Hashtable(11); - int token; + protected Map parsePair() throws IOException { + Map ht = new HashMap<>(11); + int token; while ((token = getToken()) != CLOSE_PAIR) { if (token != STRING) { @@ -133,11 +133,12 @@ public class PParser { } protected int getToken() throws IOException { - int token = getToken(false, false); + int token = getToken(false, false); return token; } + @SuppressWarnings("fallthrough") protected int getToken(boolean wantsWS, boolean inString) throws IOException { if (bufferedToken) { @@ -225,31 +226,26 @@ public class PParser { throw new RuntimeException(errorString + " at line " + lineNumber + " column " + column); } + @SuppressWarnings("unchecked") public static void dump(Object o) { if (o instanceof String) { System.out.print(o); - } else if(o instanceof Vector) { - Enumeration e = ((Vector)o).elements(); - + } else if(o instanceof List) { dump(" ("); - while (e.hasMoreElements()) { - dump(e.nextElement()); + ((List)o).forEach((l) -> { + dump(l); dump(" -- "); - } + }); dump(" )"); } else { - Hashtable ht = (Hashtable)o; - Enumeration e = ht.keys(); - + Map ht = (Map)o; dump(" {"); - while (e.hasMoreElements()) { - Object key = e.nextElement(); - - dump(key); + ht.keySet().forEach(l -> { + dump(l); dump(" = "); - dump(ht.get(key)); + dump(ht.get(l)); dump(";"); - } + }); dump(" }"); } } @@ -259,9 +255,9 @@ public class PParser { System.out.println("need filename"); } else { try { - FileReader fr = new FileReader(args[0]); - PParser parser = new PParser(); - Hashtable ht = parser.parse(fr); + FileReader fr = new FileReader(args[0]); + PParser parser = new PParser(); + Map ht = parser.parse(fr); dump(ht); System.out.println();