diff --git a/make/data/characterdata/CharacterData00.java.template b/make/data/characterdata/CharacterData00.java.template index 1045515b42d5c9b6c39cc1525dfe562e97666f6b..388072a4642b2b27d53fb84783e56622466f88d3 100644 --- a/make/data/characterdata/CharacterData00.java.template +++ b/make/data/characterdata/CharacterData00.java.template @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, 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 @@ -105,11 +105,21 @@ class CharacterData00 extends CharacterData { } boolean isJavaIdentifierStart(int ch) { + // isJavaIdentifierStart strictly conforms to code points assigned + // in Unicode 6.2. Since code points {32FF} and {20BB..20BF} are not + // from Unicode 6.2, return false. + if(ch == 0x32FF || (ch>= 0x20BB && ch<= 0x20BF)) + return false; int props = getProperties(ch); return ((props & $$maskIdentifierInfo) >= $$lowJavaStart); } boolean isJavaIdentifierPart(int ch) { + // isJavaIdentifierPart strictly conforms to code points assigned + // in Unicode 6.2. Since code points {32FF} and {20BB..20BF} are not + // from Unicode 6.2, return false. + if(ch == 0x32FF || (ch>= 0x20BB && ch<= 0x20BF)) + return false; int props = getProperties(ch); return ((props & $$nonzeroJavaPart) != 0); } diff --git a/make/data/unicodedata/UnicodeData.txt b/make/data/unicodedata/UnicodeData.txt index 086379eb4f34526f18ac207c7b640d60b5c66416..8c4efa2c07a3ab502951b301f25d7b0073ce69bf 100644 --- a/make/data/unicodedata/UnicodeData.txt +++ b/make/data/unicodedata/UnicodeData.txt @@ -7191,6 +7191,11 @@ 20B8;TENGE SIGN;Sc;0;ET;;;;;N;;;;; 20B9;INDIAN RUPEE SIGN;Sc;0;ET;;;;;N;;;;; 20BA;TURKISH LIRA SIGN;Sc;0;ET;;;;;N;;;;; +20BB;NORDIC MARK SIGN;Sc;0;ET;;;;;N;;;;; +20BC;MANAT SIGN;Sc;0;ET;;;;;N;;;;; +20BD;RUBLE SIGN;Sc;0;ET;;;;;N;;;;; +20BE;LARI SIGN;Sc;0;ET;;;;;N;;;;; +20BF;BITCOIN SIGN;Sc;0;ET;;;;;N;;;;; 20D0;COMBINING LEFT HARPOON ABOVE;Mn;230;NSM;;;;;N;NON-SPACING LEFT HARPOON ABOVE;;;; 20D1;COMBINING RIGHT HARPOON ABOVE;Mn;230;NSM;;;;;N;NON-SPACING RIGHT HARPOON ABOVE;;;; 20D2;COMBINING LONG VERTICAL LINE OVERLAY;Mn;1;NSM;;;;;N;NON-SPACING LONG VERTICAL BAR OVERLAY;;;; @@ -11403,6 +11408,7 @@ 32FC;CIRCLED KATAKANA WI;So;0;L; 30F0;;;;N;;;;; 32FD;CIRCLED KATAKANA WE;So;0;L; 30F1;;;;N;;;;; 32FE;CIRCLED KATAKANA WO;So;0;L; 30F2;;;;N;;;;; +32FF;SQUARE ERA NAME NEWERA;So;0;L; 5143 53F7;;;;N;SQUARED TWO IDEOGRAPHS ERA NAME NEWERA;;;; 3300;SQUARE APAATO;So;0;L; 30A2 30D1 30FC 30C8;;;;N;SQUARED APAATO;;;; 3301;SQUARE ARUHUA;So;0;L; 30A2 30EB 30D5 30A1;;;;N;SQUARED ARUHUA;;;; 3302;SQUARE ANPEA;So;0;L; 30A2 30F3 30DA 30A2;;;;N;SQUARED ANPEA;;;; diff --git a/src/share/classes/java/lang/Character.java b/src/share/classes/java/lang/Character.java index aec1cf752bc36b99a7d5ec425388cb06c4fd28e3..033f70c8d1f2e9282c0bcad62bfc6732070e0632 100644 --- a/src/share/classes/java/lang/Character.java +++ b/src/share/classes/java/lang/Character.java @@ -3928,7 +3928,9 @@ class Character implements java.io.Serializable, Comparable { 0x3220, // 3220..325F; COMMON 0x3260, // 3260..327E; HANGUL 0x327F, // 327F..32CF; COMMON - 0x32D0, // 32D0..3357; KATAKANA + 0x32D0, // 32D0..32FE; KATAKANA + 0x32FF, // 32FF ; COMMON + 0x3300, // 3300..3357; KATAKANA 0x3358, // 3358..33FF; COMMON 0x3400, // 3400..4DBF; HAN 0x4DC0, // 4DC0..4DFF; COMMON @@ -4249,7 +4251,9 @@ class Character implements java.io.Serializable, Comparable { COMMON, HANGUL, COMMON, - KATAKANA, + KATAKANA, // 32D0..32FE + COMMON, // 32FF + KATAKANA, // 3300..3357 COMMON, HAN, COMMON, diff --git a/src/share/classes/java/time/chrono/JapaneseEra.java b/src/share/classes/java/time/chrono/JapaneseEra.java index d457f98ca9b9576d59138433e7827936e8390af7..d7dac43d543e9422adbd51e2f1cc8dcaadc3585e 100644 --- a/src/share/classes/java/time/chrono/JapaneseEra.java +++ b/src/share/classes/java/time/chrono/JapaneseEra.java @@ -150,10 +150,15 @@ public final class JapaneseEra * which has the value 2. */ public static final JapaneseEra HEISEI = new JapaneseEra(2, LocalDate.of(1989, 1, 8)); + /** + * The singleton instance for the 'NewEra' era (2019-05-01 - current) + * which has the value 3. + */ + private static final JapaneseEra NEWERA = new JapaneseEra(3, LocalDate.of(2019, 5, 1)); // The number of predefined JapaneseEra constants. // There may be a supplemental era defined by the property. - private static final int N_ERA_CONSTANTS = HEISEI.getValue() + ERA_OFFSET; + private static final int N_ERA_CONSTANTS = NEWERA.getValue() + ERA_OFFSET; /** * Serialization version. @@ -171,6 +176,7 @@ public final class JapaneseEra KNOWN_ERAS[1] = TAISHO; KNOWN_ERAS[2] = SHOWA; KNOWN_ERAS[3] = HEISEI; + KNOWN_ERAS[4] = NEWERA; for (int i = N_ERA_CONSTANTS; i < ERA_CONFIG.length; i++) { CalendarDate date = ERA_CONFIG[i].getSinceDate(); LocalDate isoDate = LocalDate.of(date.getYear(), date.getMonth(), date.getDayOfMonth()); diff --git a/src/share/classes/java/util/JapaneseImperialCalendar.java b/src/share/classes/java/util/JapaneseImperialCalendar.java index e37374af15ff9ed1bb5012d4070d4787b8ca0ff2..70958c84b06285b38145f2ad6bd12bf57a89c99d 100644 --- a/src/share/classes/java/util/JapaneseImperialCalendar.java +++ b/src/share/classes/java/util/JapaneseImperialCalendar.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, 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 @@ -50,6 +50,7 @@ import sun.util.calendar.ZoneInfo; * 2 Taisho 1912-07-30 midnight local time * 3 Showa 1926-12-25 midnight local time * 4 Heisei 1989-01-08 midnight local time + * 5 NewEra 2019-05-01 midnight local time * ------------------------------------------------------ * * @@ -101,6 +102,11 @@ class JapaneseImperialCalendar extends Calendar { */ public static final int HEISEI = 4; + /** + * The ERA constant designating the NewEra era. + */ + private static final int NEWERA = 5; + private static final int EPOCH_OFFSET = 719163; // Fixed date of January 1, 1970 (Gregorian) private static final int EPOCH_YEAR = 1970; @@ -133,6 +139,9 @@ class JapaneseImperialCalendar extends Calendar { // Fixed date of the first date of each era. private static final long[] sinceFixedDates; + // The current era + private static final int currentEra; + /* *
      *                                 Greatest       Least
@@ -228,13 +237,18 @@ class JapaneseImperialCalendar extends Calendar {
         // eras[BEFORE_MEIJI] and sinceFixedDate[BEFORE_MEIJI] are the
         // same as Gregorian.
         int index = BEFORE_MEIJI;
+        int current = index;
         sinceFixedDates[index] = gcal.getFixedDate(BEFORE_MEIJI_ERA.getSinceDate());
         eras[index++] = BEFORE_MEIJI_ERA;
         for (Era e : es) {
+            if(e.getSince(TimeZone.NO_TIMEZONE) < System.currentTimeMillis()) {
+                current = index;
+            }
             CalendarDate d = e.getSinceDate();
             sinceFixedDates[index] = gcal.getFixedDate(d);
             eras[index++] = e;
         }
+        currentEra = current;
 
         LEAST_MAX_VALUES[ERA] = MAX_VALUES[ERA] = eras.length - 1;
 
@@ -1713,12 +1727,12 @@ class JapaneseImperialCalendar extends Calendar {
                     }
                 } else if (transitionYear) {
                     if (jdate.getYear() == 1) {
-                        // As of Heisei (since Meiji) there's no case
+                        // As of NewEra (since Meiji) there's no case
                         // that there are multiple transitions in a
                         // year.  Historically there was such
                         // case. There might be such case again in the
                         // future.
-                        if (era > HEISEI) {
+                        if (era > NEWERA) {
                             CalendarDate pd = eras[era - 1].getSinceDate();
                             if (normalizedYear == pd.getYear()) {
                                 d.setMonth(pd.getMonth()).setDayOfMonth(pd.getDayOfMonth());
@@ -1853,7 +1867,7 @@ class JapaneseImperialCalendar extends Calendar {
             year = isSet(YEAR) ? internalGet(YEAR) : 1;
         } else {
             if (isSet(YEAR)) {
-                era = eras.length - 1;
+                era = currentEra;
                 year = internalGet(YEAR);
             } else {
                 // Equivalent to 1970 (Gregorian)
@@ -2337,7 +2351,7 @@ class JapaneseImperialCalendar extends Calendar {
      * default ERA is the current era, but a zero (unset) ERA means before Meiji.
      */
     private int internalGetEra() {
-        return isSet(ERA) ? internalGet(ERA) : eras.length - 1;
+        return isSet(ERA) ? internalGet(ERA) : currentEra;
     }
 
     /**
diff --git a/src/share/classes/sun/text/resources/FormatData.java b/src/share/classes/sun/text/resources/FormatData.java
index bcb328d41f188f15a491c7cc4d685dc2be7351cb..a007baf67351429586bb59c00a16644e8b3bfe43 100644
--- a/src/share/classes/sun/text/resources/FormatData.java
+++ b/src/share/classes/sun/text/resources/FormatData.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2019, 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
@@ -106,6 +106,7 @@ public class FormatData extends ParallelListResourceBundle {
             "T",
             "S",
             "H",
+            "N", // NewEra
         };
 
         // Japanese imperial calendar era strings
@@ -115,6 +116,7 @@ public class FormatData extends ParallelListResourceBundle {
             "Taisho",
             "Showa",
             "Heisei",
+            "NewEra", // NewEra
         };
 
         return new Object[][] {
diff --git a/src/share/classes/sun/text/resources/JavaTimeSupplementary.java b/src/share/classes/sun/text/resources/JavaTimeSupplementary.java
index b67164be1cc0f87564e636e4028b7e4d464c9895..18a56d22e5e7b043123032af92f47de284d6542f 100644
--- a/src/share/classes/sun/text/resources/JavaTimeSupplementary.java
+++ b/src/share/classes/sun/text/resources/JavaTimeSupplementary.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2019, 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
@@ -237,6 +237,7 @@ public class JavaTimeSupplementary extends OpenListResourceBundle {
                     "Taisho",
                     "Showa",
                     "Heisei",
+                    "NewEra", // New Era
                 }
             },
             { "java.time.japanese.short.Eras",
@@ -246,6 +247,7 @@ public class JavaTimeSupplementary extends OpenListResourceBundle {
                     "Taisho",
                     "Showa",
                     "Heisei",
+                    "NewEra", // New Era
                 }
             },
             { "java.time.roc.DatePatterns",
diff --git a/src/share/classes/sun/text/resources/ja/FormatData_ja.java b/src/share/classes/sun/text/resources/ja/FormatData_ja.java
index 591cd35cb496a35b550df7fff27b62b5a39ae6ac..2dcddd1cfa511846f01a41d9d858cb472a6e6a5b 100644
--- a/src/share/classes/sun/text/resources/ja/FormatData_ja.java
+++ b/src/share/classes/sun/text/resources/ja/FormatData_ja.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2019, 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
@@ -91,6 +91,7 @@ public class FormatData_ja extends ParallelListResourceBundle {
             "\u5927\u6b63", // Taisho
             "\u662d\u548c", // Showa
             "\u5e73\u6210", // Heisei
+            "\u5143\u53f7", // NewEra
         };
         final String[] rocEras = {
             "\u6c11\u56fd\u524d",
diff --git a/src/share/classes/sun/text/resources/ja/JavaTimeSupplementary_ja.java b/src/share/classes/sun/text/resources/ja/JavaTimeSupplementary_ja.java
index 851c1d8918f00dd2776aabfe8863ed1e670b8345..cc6f5776494761ffc1c699a99e0bf54afbc2aeb0 100644
--- a/src/share/classes/sun/text/resources/ja/JavaTimeSupplementary_ja.java
+++ b/src/share/classes/sun/text/resources/ja/JavaTimeSupplementary_ja.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2019, 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
@@ -198,6 +198,7 @@ public class JavaTimeSupplementary_ja extends OpenListResourceBundle {
                     "\u5927\u6b63",
                     "\u662d\u548c",
                     "\u5e73\u6210",
+                    "\u5143\u53f7", // NewEra
                 }
             },
             { "java.time.japanese.short.Eras",
@@ -207,6 +208,7 @@ public class JavaTimeSupplementary_ja extends OpenListResourceBundle {
                     "\u5927\u6b63",
                     "\u662d\u548c",
                     "\u5e73\u6210",
+                    "\u5143\u53f7", // NewEra
                 }
             },
             { "java.time.long.Eras",
diff --git a/src/share/classes/sun/util/calendar/Era.java b/src/share/classes/sun/util/calendar/Era.java
index a013c57afd21c58e9e2b67a64a28717094fe3f21..dea9cb429dfe81eeabbd3fca6caf18736315f252 100644
--- a/src/share/classes/sun/util/calendar/Era.java
+++ b/src/share/classes/sun/util/calendar/Era.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, 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
@@ -49,6 +49,7 @@ import java.util.TimeZone;
  *                           Taisho           1912-07-30 midnight local time
  *                           Showa            1926-12-26 midnight local time
  *                           Heisei           1989-01-08 midnight local time
+ *                           NewEra           2019-05-01 midnight local time
  *   Julian calendar         BeforeCommonEra  -292275055-05-16T16:47:04.192Z
  *                           CommonEra        0000-12-30 midnight local time
  *   Taiwanese calendar      MinGuo           1911-01-01 midnight local time
diff --git a/src/share/classes/sun/util/locale/provider/CalendarNameProviderImpl.java b/src/share/classes/sun/util/locale/provider/CalendarNameProviderImpl.java
index 4a4160708f8805f0b46b42d6549ad828332230b0..10fdd3af8744f2be847b6c53aa120b499c4fb41e 100644
--- a/src/share/classes/sun/util/locale/provider/CalendarNameProviderImpl.java
+++ b/src/share/classes/sun/util/locale/provider/CalendarNameProviderImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2019, 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
@@ -35,8 +35,8 @@ import sun.util.calendar.CalendarSystem;
 import sun.util.calendar.Era;
 
 /**
- * Concrete implementation of the  {@link java.util.spi.CalendarDataProvider
- * CalendarDataProvider} class for the JRE LocaleProviderAdapter.
+ * Concrete implementation of the  {@link java.util.spi.CalendarNameProvider
+ * CalendarNameProvider} class for the JRE LocaleProviderAdapter.
  *
  * @author Masayoshi Okutsu
  * @author Naoto Sato
@@ -69,22 +69,43 @@ public class CalendarNameProviderImpl extends CalendarNameProvider implements Av
                 if (field == DAY_OF_WEEK || field == YEAR) {
                     --value;
                 }
-                if (value < 0 || value > strings.length) {
+                if (value < 0) {
                     return null;
-                } else if (value == strings.length) {
+                } else if (value >= strings.length) {
                     if (field == ERA && "japanese".equals(calendarType)) {
-                        // get the supplemental era, if any, specified through
-                        // the property "jdk.calendar.japanese.supplemental.era"
-                        // which is always the last element.
                         Era[] jeras = CalendarSystem.forName("japanese").getEras();
-                        if (jeras.length == value) {
+                        if (value <= jeras.length) {
+                            // Localized era name could not be retrieved from this provider.
+                            // This can occur either for NewEra or SupEra.
+                            //
+                            // If it's CLDR provider, try COMPAT first, which is guaranteed to have
+                            // the name for NewEra.
+                            if (type == LocaleProviderAdapter.Type.CLDR) {
+                                lr = LocaleProviderAdapter.forJRE().getLocaleResources(locale);
+                                key = getResourceKeyFor(LocaleProviderAdapter.Type.JRE,
+                                                calendarType, field, style, javatime);
+                                strings =
+                                    javatime ? lr.getJavaTimeNames(key) : lr.getCalendarNames(key);
+                            }
+                            if (strings == null || value >= strings.length) {
+                                // Get the default name for SupEra
                             Era supEra = jeras[value - 1]; // 0-based index
-                            return style == LONG ?
+                                if (javatime) {
+                                    return getBaseStyle(style) == NARROW_FORMAT ?
+                                        supEra.getAbbreviation() :
+                                        supEra.getName();
+                                } else {
+                                    return (style & LONG) != 0 ?
                                 supEra.getName() :
                                 supEra.getAbbreviation();
                         }
                     }
+                        } else {
                     return null;
+                }
+                    } else {
+                        return null;
+                    }
                 }
                 name = strings[value];
                 // If name is empty in standalone, try its `format' style.
@@ -158,7 +179,7 @@ public class CalendarNameProviderImpl extends CalendarNameProvider implements Av
         return map;
     }
 
-    private int getBaseStyle(int style) {
+    private static int getBaseStyle(int style) {
         return style & ~(SHORT_STANDALONE - SHORT_FORMAT);
     }
 
@@ -239,6 +260,11 @@ public class CalendarNameProviderImpl extends CalendarNameProvider implements Av
     }
 
     private String getResourceKey(String type, int field, int style, boolean javatime) {
+        return getResourceKeyFor(this.type, type, field, style, javatime);
+    }
+
+    private static String getResourceKeyFor(LocaleProviderAdapter.Type adapterType,
+                            String type, int field, int style, boolean javatime) {
         int baseStyle = getBaseStyle(style);
         boolean isStandalone = (style != baseStyle);
 
@@ -262,7 +288,7 @@ public class CalendarNameProviderImpl extends CalendarNameProvider implements Av
                 // JRE and CLDR use different resource key conventions
                 // due to historical reasons. (JRE DateFormatSymbols.getEras returns
                 // abbreviations while other getShort*() return abbreviations.)
-                if (this.type == LocaleProviderAdapter.Type.JRE) {
+                if (adapterType == LocaleProviderAdapter.Type.JRE) {
                     if (javatime) {
                         if (baseStyle == LONG) {
                             key.append("long.");
@@ -314,7 +340,7 @@ public class CalendarNameProviderImpl extends CalendarNameProvider implements Av
         return key.length() > 0 ? key.toString() : null;
     }
 
-    private String toStyleName(int baseStyle) {
+    private static String toStyleName(int baseStyle) {
         switch (baseStyle) {
         case SHORT:
             return "Abbreviations";
diff --git a/src/share/lib/calendars.properties b/src/share/lib/calendars.properties
index 49f68aca4920a424498aa33fdf3da8c09a721a25..8ffee4ca3ffba6460fb6f20939db3f8e44f293fb 100644
--- a/src/share/lib/calendars.properties
+++ b/src/share/lib/calendars.properties
@@ -29,12 +29,14 @@
 #   Taisho since 1912-07-30 00:00:00 local time (Gregorian)
 #   Showa  since 1926-12-25 00:00:00 local time (Gregorian)
 #   Heisei since 1989-01-08 00:00:00 local time (Gregorian)
+#   NewEra since 2019-05-01 00:00:00 local time (Gregorian)
 calendar.japanese.type: LocalGregorianCalendar
 calendar.japanese.eras: \
 	name=Meiji,abbr=M,since=-3218832000000;  \
 	name=Taisho,abbr=T,since=-1812153600000; \
 	name=Showa,abbr=S,since=-1357603200000;  \
-	name=Heisei,abbr=H,since=600220800000
+	name=Heisei,abbr=H,since=600220800000;   \
+	name=NewEra,abbr=N,since=1556668800000
 
 #
 # Taiwanese calendar
diff --git a/test/java/lang/Character/Scripts.txt b/test/java/lang/Character/Scripts.txt
index 1a8e7229cc6cd0fa28b8cd543e41649929ba1b02..c6e63c4525dde378b92770209ff8a10dfae36d83 100644
--- a/test/java/lang/Character/Scripts.txt
+++ b/test/java/lang/Character/Scripts.txt
@@ -147,6 +147,7 @@
 208D          ; Common # Ps       SUBSCRIPT LEFT PARENTHESIS
 208E          ; Common # Pe       SUBSCRIPT RIGHT PARENTHESIS
 20A0..20BA    ; Common # Sc  [27] EURO-CURRENCY SIGN..TURKISH LIRA SIGN
+20BB..20BF    ; Common # Sc   [5] NORDIC MARK SIGN..BITCOIN SIGN
 2100..2101    ; Common # So   [2] ACCOUNT OF..ADDRESSED TO THE SUBJECT
 2102          ; Common # L&       DOUBLE-STRUCK CAPITAL C
 2103..2106    ; Common # So   [4] DEGREE CELSIUS..CADA UNA
@@ -381,6 +382,7 @@
 328A..32B0    ; Common # So  [39] CIRCLED IDEOGRAPH MOON..CIRCLED IDEOGRAPH NIGHT
 32B1..32BF    ; Common # No  [15] CIRCLED NUMBER THIRTY SIX..CIRCLED NUMBER FIFTY
 32C0..32CF    ; Common # So  [16] IDEOGRAPHIC TELEGRAPH SYMBOL FOR JANUARY..LIMITED LIABILITY SIGN
+32FF          ; Common # So       SQUARE ERA NAME NEWERA
 3358..33FF    ; Common # So [168] IDEOGRAPHIC TELEGRAPH SYMBOL FOR HOUR ZERO..SQUARE GAL
 4DC0..4DFF    ; Common # So  [64] HEXAGRAM FOR THE CREATIVE HEAVEN..HEXAGRAM FOR BEFORE COMPLETION
 A700..A716    ; Common # Sk  [23] MODIFIER LETTER CHINESE TONE YIN PING..MODIFIER LETTER EXTRA-LOW LEFT-STEM TONE BAR
diff --git a/test/java/lang/Character/TestIsJavaIdentifierMethods.java b/test/java/lang/Character/TestIsJavaIdentifierMethods.java
new file mode 100644
index 0000000000000000000000000000000000000000..3e788ea0d10e0eca6cc971063790070d2badb90f
--- /dev/null
+++ b/test/java/lang/Character/TestIsJavaIdentifierMethods.java
@@ -0,0 +1,309 @@
+/*
+ * Copyright (c) 2019, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @summary Test behavior of isJavaIdentifierXX, testIsJavaLetter, and
+ *  testIsJavaLetterOrDigit methods for all code points.
+ * @bug 8218915
+ */
+
+import java.util.List;
+import java.util.ArrayList;
+
+public class TestIsJavaIdentifierMethods {
+
+    // List of new code points are not present in Unicode 6.2.
+    private static final List UNASSIGNED_CODEPOINTS_IN_6_2
+                                    = new ArrayList()
+                                    {{
+                                        add(0x20BB); // NORDIC MARK SIGN
+                                        add(0x20BC); // MANAT SIGN
+                                        add(0x20BD); // RUBLE SIGN
+                                        add(0x20BE); // LARI SIGN
+                                        add(0x20BF); // BITCOIN SIGN
+                                        add(0x32FF); // SQUARE ERA NAME NEWERA
+                                    }};
+
+    public static void main(String[] args) {
+        testIsJavaIdentifierPart_int();
+        testIsJavaIdentifierPart_char();
+        testIsJavaIdentifierStart_int();
+        testIsJavaIdentifierStart_char();
+        testIsJavaLetter();
+        testIsJavaLetterOrDigit();
+    }
+
+    /**
+     * Assertion testing for public static boolean isJavaIdentifierPart(int
+     * codePoint), A character may be part of a Java identifier if any of the
+     * following are true:
+     * 
    + *
  • it is a letter
  • + *
  • it is a currency symbol (such as '$')
  • + *
  • it is a connecting punctuation character (such as '_') + *
  • + *
  • it is a digit
  • + *
  • it is a numeric letter (such as a Roman numeral character)
  • + *
  • it is a combining mark
  • + *
  • it is a non-spacing mark
  • + *
  • isIdentifierIgnorable returns true for the + * character
  • + *
+ * All code points from (0x0000..0x10FFFF) are tested. + */ + public static void testIsJavaIdentifierPart_int() { + for (int cp = 0; cp <= Character.MAX_CODE_POINT; cp++) { + boolean expected = false; + + // Since Character.isJavaIdentifierPart(int) strictly conforms to + // character information from version 6.2 of the Unicode Standard, + // check if code point is in "UNASSIGNED_CODEPOINTS_IN_6_2" + // list. If the code point is found in list + // "UNASSIGNED_CODEPOINTS_IN_6_2", value of variable + // "expected" is considered false. + if (!UNASSIGNED_CODEPOINTS_IN_6_2.contains(cp)) { + byte type = (byte) Character.getType(cp); + expected = Character.isLetter(cp) + || type == Character.CURRENCY_SYMBOL + || type == Character.CONNECTOR_PUNCTUATION + || Character.isDigit(cp) + || type == Character.LETTER_NUMBER + || type == Character.COMBINING_SPACING_MARK + || type == Character.NON_SPACING_MARK + || Character.isIdentifierIgnorable(cp); + } + + if (Character.isJavaIdentifierPart(cp) != expected) { + throw new RuntimeException( + "Character.isJavaIdentifierPart(int) failed for codepoint " + + Integer.toHexString(cp)); + } + } + } + + /** + * Assertion testing for public static boolean isJavaIdentifierPart(char + * ch), A character may be part of a Java identifier if any of the + * following are true: + *
    + *
  • it is a letter; + *
  • it is a currency symbol (such as "$"); + *
  • it is a connecting punctuation character (such as "_"); + *
  • it is a digit; + *
  • it is a numeric letter (such as a Roman numeral character); + *
  • it is a combining mark; + *
  • it is a non-spacing mark; + *
  • isIdentifierIgnorable returns true for the character. + *
+ * All Unicode code points in the BMP (0x0000..0xFFFF) are tested. + */ + public static void testIsJavaIdentifierPart_char() { + for (int i = 0; i <= Character.MAX_VALUE; ++i) { + char ch = (char) i; + boolean expected = false; + // Since Character.isJavaIdentifierPart(char) strictly conforms to + // character information from version 6.2 of the Unicode Standard, + // check if code point is in "UNASSIGNED_CODEPOINTS_IN_6_2" + // list. If the code point is found in list + // "UNASSIGNED_CODEPOINTS_IN_6_2", value of variable + // "expected" is considered false. + if (!UNASSIGNED_CODEPOINTS_IN_6_2.contains(i)) { + byte type = (byte) Character.getType(ch); + expected = Character.isLetter(ch) + || type == Character.CURRENCY_SYMBOL + || type == Character.CONNECTOR_PUNCTUATION + || Character.isDigit(ch) + || type == Character.LETTER_NUMBER + || type == Character.COMBINING_SPACING_MARK + || type == Character.NON_SPACING_MARK + || Character.isIdentifierIgnorable(ch); + } + + if (Character.isJavaIdentifierPart((char) i) != expected) { + throw new RuntimeException( + "Character.isJavaIdentifierPart(char) failed for codepoint " + + Integer.toHexString(i)); + } + } + } + + /** + * Assertion testing for public static boolean isJavaIdentifierStart(int + * codePoint), A character may start a Java identifier if and only if it is + * one of the following: + *
    + *
  • it is a letter;
  • + *
  • getType(ch) returns LETTER_NUMBER;
  • + *
  • it is a currency symbol (such as "$");
  • + *
  • it is a connecting punctuation character (such as "_");
  • + *
+ * All Code points from (0x0000..0x10FFFF) are tested. + */ + public static void testIsJavaIdentifierStart_int() { + for (int cp = 0; cp <= Character.MAX_CODE_POINT; cp++) { + boolean expected = false; + // Since Character.isJavaIdentifierStart(int) strictly conforms to + // character information from version 6.2 of the Unicode Standard, + // check if code point is in "UNASSIGNED_CODEPOINTS_IN_6_2" + // list. If the code point is found in list + // "UNASSIGNED_CODEPOINTS_IN_6_2", value of variable + // "expected" is considered false. + if (!UNASSIGNED_CODEPOINTS_IN_6_2.contains(cp)) { + byte type = (byte) Character.getType(cp); + expected = Character.isLetter(cp) + || type == Character.LETTER_NUMBER + || type == Character.CURRENCY_SYMBOL + || type == Character.CONNECTOR_PUNCTUATION; + } + + if (Character.isJavaIdentifierStart(cp) != expected) { + throw new RuntimeException( + "Character.isJavaIdentifierStart(int) failed for codepoint " + + Integer.toHexString(cp)); + } + } + } + + /** + * Assertion testing for public static boolean isJavaIdentifierStart(char), + * A character may start a Java identifier if and only if it is + * one of the following: + *
    + *
  • it is a letter;
  • + *
  • getType(ch) returns LETTER_NUMBER;
  • + *
  • it is a currency symbol (such as "$");
  • + *
  • it is a connecting punctuation character (such as "_");
  • + *
+ * All Unicode code points in the BMP (0x0000..0xFFFF) are tested. + */ + public static void testIsJavaIdentifierStart_char() { + for (int i = 0; i <= Character.MAX_VALUE; i++) { + char ch = (char) i; + boolean expected = false; + // Since Character.isJavaIdentifierStart(char) strictly conforms to + // character information from version 6.2 of the Unicode Standard, + // check if code point is in "UNASSIGNED_CODEPOINTS_IN_6_2" + // list. If the code point is found in list + // "UNASSIGNED_CODEPOINTS_IN_6_2", value of variable + // "expected" is considered false. + if (!UNASSIGNED_CODEPOINTS_IN_6_2.contains(i)) { + byte type = (byte) Character.getType(ch); + expected = Character.isLetter(ch) + || type == Character.LETTER_NUMBER + || type == Character.CURRENCY_SYMBOL + || type == Character.CONNECTOR_PUNCTUATION; + } + + if (Character.isJavaIdentifierStart(ch) != expected) { + throw new RuntimeException( + "Character.isJavaIdentifierStart(char) failed for codepoint " + + Integer.toHexString(i)); + } + } + } + + /** + * Assertion testing for public static boolean isJavaLetter(char ch), A + * character may start a Java identifier if and only if one of the + * following is true: + *
    + *
  • isLetter(ch) returns true + *
  • getType(ch) returns LETTER_NUMBER + *
  • ch is a currency symbol (such as "$") + *
  • ch is a connecting punctuation character (such as "_"). + *
+ * All Unicode code points in the BMP (0x0000..0xFFFF) are tested. + */ + public static void testIsJavaLetter() { + for (int i = 0; i <= Character.MAX_VALUE; ++i) { + char ch = (char) i; + boolean expected = false; + // Since Character.isJavaLetter(char) strictly conforms to + // character information from version 6.2 of the Unicode Standard, + // check if code point is in "UNASSIGNED_CODEPOINTS_IN_6_2" + // list. If the code point is found in list + // "UNASSIGNED_CODEPOINTS_IN_6_2", value of variable + // "expected" is considered false. + if (!UNASSIGNED_CODEPOINTS_IN_6_2.contains(i)) { + byte type = (byte) Character.getType(ch); + expected = Character.isLetter(ch) + || type == Character.LETTER_NUMBER + || type == Character.CURRENCY_SYMBOL + || type == Character.CONNECTOR_PUNCTUATION; + } + + if (Character.isJavaLetter(ch) != expected) { + throw new RuntimeException( + "Character.isJavaLetter(ch) failed for codepoint " + + Integer.toHexString(i)); + } + } + } + + /** + * Assertion testing for public static boolean isJavaLetterOrDigit(char + * ch), A character may be part of a Java identifier if and only if any + * of the following are true: + *
    + *
  • it is a letter + *
  • it is a currency symbol (such as '$') + *
  • it is a connecting punctuation character (such as '_') + *
  • it is a digit + *
  • it is a numeric letter (such as a Roman numeral character) + *
  • it is a combining mark + *
  • it is a non-spacing mark + *
  • isIdentifierIgnorable returns true for the character. + *
+ * All Unicode code points in the BMP (0x0000..0xFFFF) are tested. + */ + public static void testIsJavaLetterOrDigit() { + for (int i = 0; i <= Character.MAX_VALUE; ++i) { + char ch = (char) i; + boolean expected = false; + // Since Character.isJavaLetterOrDigit(char) strictly conforms to + // character information from version 6.2 of the Unicode Standard, + // check if code point is in "UNASSIGNED_CODEPOINTS_IN_6_2" + // list. If the code point is found in list + // "UNASSIGNED_CODEPOINTS_IN_6_2", value of variable + // "expected" is considered false. + if (!UNASSIGNED_CODEPOINTS_IN_6_2.contains(i)) { + byte type = (byte) Character.getType(ch); + expected = Character.isLetter(ch) + || type == Character.CURRENCY_SYMBOL + || type == Character.CONNECTOR_PUNCTUATION + || Character.isDigit(ch) + || type == Character.LETTER_NUMBER + || type == Character.COMBINING_SPACING_MARK + || type == Character.NON_SPACING_MARK + || Character.isIdentifierIgnorable(ch); + } + + if (Character.isJavaLetterOrDigit(ch) != expected) { + throw new RuntimeException( + "Character.isJavaLetterOrDigit(ch) failed for codepoint " + + Integer.toHexString(i)); + } + } + } +} diff --git a/test/java/text/Format/DateFormat/WeekDateTest.java b/test/java/text/Format/DateFormat/WeekDateTest.java index f38336be690548663ce4a05e86d4692f4beb81c6..4dc99456d6bb20fe5727c08e0aabe2dfb1047b28 100644 --- a/test/java/text/Format/DateFormat/WeekDateTest.java +++ b/test/java/text/Format/DateFormat/WeekDateTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2019, 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 @@ -137,20 +137,28 @@ public class WeekDateTest { Calendar jcal = Calendar.getInstance(TimeZone.getTimeZone("GMT"), new Locale("ja", "JP", "JP")); + String format = "2-W01-2"; // 2019-12-31 == N1-12-31 + int expectedYear = 2019; + // Check the current era, Heisei or NewEra + if (System.currentTimeMillis() < 1556668800000L) { + format = "21-W01-3"; // 2008-12-31 == H20-12-31 + expectedYear = 2008; + } jcal.setFirstDayOfWeek(MONDAY); jcal.setMinimalDaysInFirstWeek(4); SimpleDateFormat sdf = new SimpleDateFormat("Y-'W'ww-u"); sdf.setCalendar(jcal); - Date d = sdf.parse("21-W01-3"); // 2008-12-31 == H20-12-31 + Date d = sdf.parse(format); GregorianCalendar gcal = newCalendar(); gcal.setTime(d); - if (gcal.get(YEAR) != 2008 + if (gcal.get(YEAR) != expectedYear || gcal.get(MONTH) != DECEMBER || gcal.get(DAY_OF_MONTH) != 31) { - String s = String.format("noWeekDateSupport: got %04d-%02d-%02d, expected 2008-12-31%n", + String s = String.format("noWeekDateSupport: got %04d-%02d-%02d, expected %4d-12-31%n", gcal.get(YEAR), gcal.get(MONTH)+1, - gcal.get(DAY_OF_MONTH)); + gcal.get(DAY_OF_MONTH), + expectedYear); throw new RuntimeException(s); } } diff --git a/test/java/time/tck/java/time/chrono/TCKJapaneseChronology.java b/test/java/time/tck/java/time/chrono/TCKJapaneseChronology.java index 2bc1f4c8ce78900fc44124f1b0d16303174cc4da..29714b3532890a83f62b770c2e6fb20da54a9b3a 100644 --- a/test/java/time/tck/java/time/chrono/TCKJapaneseChronology.java +++ b/test/java/time/tck/java/time/chrono/TCKJapaneseChronology.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2019, 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 @@ -111,6 +111,7 @@ import org.testng.annotations.Test; */ @Test public class TCKJapaneseChronology { + private static final int YDIFF_NEWERA = 2018; private static final int YDIFF_HEISEI = 1988; private static final int YDIFF_MEIJI = 1867; private static final int YDIFF_SHOWA = 1925; @@ -173,6 +174,7 @@ public class TCKJapaneseChronology { @DataProvider(name="createByEra") Object[][] data_createByEra() { return new Object[][] { + {JapaneseEra.of(3), 2020 - YDIFF_NEWERA, 2, 29, 60, LocalDate.of(2020, 2, 29)}, // NEWERA {JapaneseEra.HEISEI, 1996 - YDIFF_HEISEI, 2, 29, 60, LocalDate.of(1996, 2, 29)}, {JapaneseEra.HEISEI, 2000 - YDIFF_HEISEI, 2, 29, 60, LocalDate.of(2000, 2, 29)}, {JapaneseEra.MEIJI, 1874 - YDIFF_MEIJI, 2, 28, 59, LocalDate.of(1874, 2, 28)}, @@ -365,8 +367,11 @@ public class TCKJapaneseChronology { @DataProvider(name="prolepticYear") Object[][] data_prolepticYear() { return new Object[][] { + {3, JapaneseEra.of(3), 1, 1 + YDIFF_NEWERA, false}, // NEWERA + {3, JapaneseEra.of(3), 102, 102 + YDIFF_NEWERA, true}, // NEWERA + {2, JapaneseEra.HEISEI, 1, 1 + YDIFF_HEISEI, false}, - {2, JapaneseEra.HEISEI, 100, 100 + YDIFF_HEISEI, true}, + {2, JapaneseEra.HEISEI, 4, 4 + YDIFF_HEISEI, true}, {-1, JapaneseEra.MEIJI, 9, 9 + YDIFF_MEIJI, true}, {-1, JapaneseEra.MEIJI, 10, 10 + YDIFF_MEIJI, false}, @@ -548,6 +553,7 @@ public class TCKJapaneseChronology { { JapaneseEra.TAISHO, 0, "Taisho"}, { JapaneseEra.SHOWA, 1, "Showa"}, { JapaneseEra.HEISEI, 2, "Heisei"}, + { JapaneseEra.of(3), 3, "NewEra"}, // NEWERA }; } @@ -562,7 +568,7 @@ public class TCKJapaneseChronology { @Test public void test_Japanese_badEras() { - int badEras[] = {-1000, -998, -997, -2, 3, 4, 1000}; + int badEras[] = {-1000, -998, -997, -2, 4, 5, 1000}; for (int badEra : badEras) { try { Era era = JapaneseChronology.INSTANCE.eraOf(badEra); @@ -683,6 +689,7 @@ public class TCKJapaneseChronology { {JapaneseChronology.INSTANCE.date(1989, 1, 7), "Japanese Showa 64-01-07"}, {JapaneseChronology.INSTANCE.date(1989, 1, 8), "Japanese Heisei 1-01-08"}, {JapaneseChronology.INSTANCE.date(2012, 12, 6), "Japanese Heisei 24-12-06"}, + {JapaneseChronology.INSTANCE.date(2020, 1, 6), "Japanese NewEra 2-01-06"}, }; } diff --git a/test/java/time/tck/java/time/chrono/TCKJapaneseEra.java b/test/java/time/tck/java/time/chrono/TCKJapaneseEra.java index de83e1d3bc388cf85537229138593c42e740be57..943520dc461f4c88020b291bd7574b90b55487ea 100644 --- a/test/java/time/tck/java/time/chrono/TCKJapaneseEra.java +++ b/test/java/time/tck/java/time/chrono/TCKJapaneseEra.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2019, 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 @@ -77,6 +77,7 @@ public class TCKJapaneseEra { @DataProvider(name = "JapaneseEras") Object[][] data_of_eras() { return new Object[][] { + {JapaneseEra.of(3), "NewEra", 3}, // NEWERA {JapaneseEra.HEISEI, "Heisei", 2}, {JapaneseEra.SHOWA, "Showa", 1}, {JapaneseEra.TAISHO, "Taisho", 0}, diff --git a/test/java/time/test/java/time/chrono/TestJapaneseChronology.java b/test/java/time/test/java/time/chrono/TestJapaneseChronology.java index 3fbf8532318b27c12262a1dbaaac6213c872ece6..a1df28acf20bfcacb0bb23cff776fde2053f6733 100644 --- a/test/java/time/test/java/time/chrono/TestJapaneseChronology.java +++ b/test/java/time/test/java/time/chrono/TestJapaneseChronology.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2019, 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 @@ -58,6 +58,8 @@ public class TestJapaneseChronology { { JapaneseEra.SHOWA, 1, 12, 25, 1926 }, { JapaneseEra.SHOWA, 64, 1, 7, 1989 }, { JapaneseEra.HEISEI, 1, 1, 8, 1989 }, + { JapaneseEra.HEISEI, 31, 4, 30, 2019 }, + { JapaneseEra.of(3), 1, 5, 1, 2019 }, // NEWERA }; } @@ -74,6 +76,8 @@ public class TestJapaneseChronology { { JapaneseEra.SHOWA, 64, 7, 1, 7 }, { JapaneseEra.HEISEI, 1, 1, 1, 8 }, { JapaneseEra.HEISEI, 2, 8, 1, 8 }, + { JapaneseEra.HEISEI, 31, 120, 4, 30 }, + { JapaneseEra.of(3), 1, 1, 5, 1 }, // NEWERA }; } @@ -81,8 +85,8 @@ public class TestJapaneseChronology { Object[][] rangeData() { return new Object[][] { // field, minSmallest, minLargest, maxSmallest, maxLargest - { ChronoField.ERA, -1, -1, 2, 2}, - { ChronoField.YEAR_OF_ERA, 1, 1, 15, 999999999-1989 }, // depends on the current era + { ChronoField.ERA, -1, -1, 3, 3}, + { ChronoField.YEAR_OF_ERA, 1, 1, 15, 999999999-2019}, // depends on the current era { ChronoField.DAY_OF_YEAR, 1, 1, 7, 366}, { ChronoField.YEAR, 1873, 1873, 999999999, 999999999}, }; @@ -105,7 +109,9 @@ public class TestJapaneseChronology { { JapaneseEra.SHOWA, 65, 1, 1 }, { JapaneseEra.HEISEI, 1, 1, 7 }, { JapaneseEra.HEISEI, 1, 2, 29 }, - { JapaneseEra.HEISEI, Year.MAX_VALUE, 12, 31 }, + { JapaneseEra.HEISEI, 31, 5, 1 }, + { JapaneseEra.of(3), 1, 4, 30 }, // NEWERA + { JapaneseEra.of(3), Year.MAX_VALUE, 12, 31 }, // NEWERA }; } @@ -124,7 +130,10 @@ public class TestJapaneseChronology { { JapaneseEra.SHOWA, 65 }, { JapaneseEra.HEISEI, -1 }, { JapaneseEra.HEISEI, 0 }, - { JapaneseEra.HEISEI, Year.MAX_VALUE }, + { JapaneseEra.HEISEI, 32 }, + { JapaneseEra.of(3), -1 }, // NEWERA + { JapaneseEra.of(3), 0 }, // NEWERA + { JapaneseEra.of(3), Year.MAX_VALUE }, // NEWERA }; } @@ -141,6 +150,9 @@ public class TestJapaneseChronology { { JapaneseEra.SHOWA, 64, 8 }, { JapaneseEra.HEISEI, 1, 360 }, { JapaneseEra.HEISEI, 2, 366 }, + { JapaneseEra.HEISEI, 31, 121 }, + { JapaneseEra.of(3), 1, 246 }, // NEWERA + { JapaneseEra.of(3), 2, 367 }, // NEWERA }; } diff --git a/test/java/time/test/java/time/chrono/TestUmmAlQuraChronology.java b/test/java/time/test/java/time/chrono/TestUmmAlQuraChronology.java index ff64add432b3758c4054ef51d22cac1b8db8b30f..cb987f651804d5201220d685cdd3ca4d3ad59d6d 100644 --- a/test/java/time/test/java/time/chrono/TestUmmAlQuraChronology.java +++ b/test/java/time/test/java/time/chrono/TestUmmAlQuraChronology.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2019, 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 @@ -775,8 +775,10 @@ public class TestUmmAlQuraChronology { {HijrahDate.of(1350,5,15), "Japanese Showa 6-09-28"}, {HijrahDate.of(1434,5,1), "Japanese Heisei 25-03-13"}, {HijrahDate.of(1436,1,1), "Japanese Heisei 26-10-25"}, - {HijrahDate.of(1500,6,12), "Japanese Heisei 89-05-05"}, - {HijrahDate.of(1550,3,11), "Japanese Heisei 137-08-11"}, + {HijrahDate.of(1440,8,25), "Japanese Heisei 31-04-30"}, + {HijrahDate.of(1440,8,26), "Japanese NewEra 1-05-01"}, + {HijrahDate.of(1500,6,12), "Japanese NewEra 59-05-05"}, + {HijrahDate.of(1550,3,11), "Japanese NewEra 107-08-11"}, }; } diff --git a/test/java/time/test/java/time/format/TestNonIsoFormatter.java b/test/java/time/test/java/time/format/TestNonIsoFormatter.java index 6747cdc93a5eb069b1a30062d80976878cc597c9..2dcd634428fcf67f99b5fd577153a238c3d019a0 100644 --- a/test/java/time/test/java/time/format/TestNonIsoFormatter.java +++ b/test/java/time/test/java/time/format/TestNonIsoFormatter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2019, 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 @@ -20,6 +20,13 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + +/* + * + * @test + * @bug 8206120 + */ + package test.java.time.format; import static org.testng.Assert.assertEquals; @@ -37,6 +44,7 @@ import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; import java.time.format.DateTimeParseException; import java.time.format.FormatStyle; +import java.time.format.ResolverStyle; import java.time.format.TextStyle; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalQueries; @@ -128,6 +136,16 @@ public class TestNonIsoFormatter { }; } + @DataProvider(name="lenient_eraYear") + Object[][] lenientEraYear() { + return new Object[][] { + // Chronology, lenient era/year, strict era/year + { JAPANESE, "Meiji 123", "Heisei 2" }, + { JAPANESE, "Showa 65", "Heisei 2" }, + { JAPANESE, "Heisei 32", "NewEra 2" }, // NewEra + }; + } + @Test(dataProvider="format_data") public void test_formatLocalizedDate(Chronology chrono, Locale formatLocale, Locale numberingLocale, ChronoLocalDate date, String expected) { @@ -166,4 +184,15 @@ public class TestNonIsoFormatter { Chronology cal = ta.query(TemporalQueries.chronology()); assertEquals(cal, chrono); } + + @Test(dataProvider="lenient_eraYear") + public void test_lenientEraYear(Chronology chrono, String lenient, String strict) { + String mdStr = "-01-01"; + DateTimeFormatter dtf = new DateTimeFormatterBuilder() + .appendPattern("GGGG y-M-d") + .toFormatter() + .withChronology(chrono); + DateTimeFormatter dtfLenient = dtf.withResolverStyle(ResolverStyle.LENIENT); + assertEquals(LocalDate.parse(lenient+mdStr, dtfLenient), LocalDate.parse(strict+mdStr, dtf)); +} } diff --git a/test/java/util/Calendar/Bug8007038.java b/test/java/util/Calendar/Bug8007038.java index e197e1266d764d5e3927b7fdccf2e3471682a6ad..3029e6acb65259e8548c2d89345af049f2b96b92 100644 --- a/test/java/util/Calendar/Bug8007038.java +++ b/test/java/util/Calendar/Bug8007038.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2019, 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 @@ -45,7 +45,7 @@ public class Bug8007038 { private final static int[][] eraMinMax = { {GregorianCalendar.BC, GregorianCalendar.AD}, {0, 1}, - {0, 4}, + {0, 5}, {0, 1}, {0, 1}, {0, 1}, diff --git a/test/java/util/Calendar/Builder/BuilderTest.java b/test/java/util/Calendar/Builder/BuilderTest.java index 13036d43999be2a1941688721f87d60222737c0c..46cd21c92c963f62bf83182e8bdaeb6a3ac8f47e 100644 --- a/test/java/util/Calendar/Builder/BuilderTest.java +++ b/test/java/util/Calendar/Builder/BuilderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2019, 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 @@ -27,6 +27,7 @@ * @summary Unit test for Calendar.Builder. */ +import java.time.LocalDateTime; import java.util.*; import static java.util.Calendar.*; @@ -132,7 +133,11 @@ public class BuilderTest { .setFields(YEAR, 1, DAY_OF_YEAR, 1).build(); expected = Calendar.getInstance(jaJPJP); expected.clear(); + if (LocalDateTime.now().isBefore(LocalDateTime.of(2019, 5, 1, 0, 0))) { expected.set(1, JANUARY, 8); + } else { + expected.set(1, MAY, 1); + } check(cal, expected); // setLocale calb = builder(); diff --git a/test/java/util/Calendar/JapaneseEraNameTest.java b/test/java/util/Calendar/JapaneseEraNameTest.java new file mode 100644 index 0000000000000000000000000000000000000000..e58543a6bc7851bf25004c5df5aab13d1fba22bb --- /dev/null +++ b/test/java/util/Calendar/JapaneseEraNameTest.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2019, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8202088 + * @summary Test the localized Japanese new era name (May 1st. 2019-) + * is retrieved no matter CLDR provider contains the name or not. + * @run testng/othervm JapaneseEraNameTest + * @run testng/othervm -Djava.locale.providers=CLDR,JRE JapaneseEraNameTest + */ + +import static java.util.Calendar.*; +import static java.util.Locale.*; +import java.util.Calendar; +import java.util.Locale; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; +import static org.testng.Assert.assertEquals; + +@Test +public class JapaneseEraNameTest { + static final Calendar c = new Calendar.Builder() + .setCalendarType("japanese") + .setFields(ERA, 5, YEAR, 1, MONTH, MAY, DAY_OF_MONTH, 1) + .build(); + + @DataProvider(name="names") + Object[][] names() { + return new Object[][] { + // type, locale, name + { LONG, JAPAN, "\u5143\u53f7" }, // NewEra + { LONG, US, "NewEra" }, + { SHORT, JAPAN, "N" }, + { SHORT, US, "N" }, + }; + } + + @Test(dataProvider="names") + public void testJapaneseNewEraName(int type, Locale locale, String expected) { + assertEquals(c.getDisplayName(ERA, type, locale), expected); + } +} diff --git a/test/java/util/Calendar/JapaneseLenientEraTest.java b/test/java/util/Calendar/JapaneseLenientEraTest.java new file mode 100644 index 0000000000000000000000000000000000000000..285177219f46fa0eb66085a8868d552731ab4b83 --- /dev/null +++ b/test/java/util/Calendar/JapaneseLenientEraTest.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2019, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8206120 + * @summary Test whether lenient era is accepted in JapaneseImperialCalendar + * @run testng/othervm JapaneseLenientEraTest + */ + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.Locale; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; +import static org.testng.Assert.assertEquals; + +@Test +public class JapaneseLenientEraTest { + + @DataProvider(name="lenientEra") + Object[][] names() { + return new Object[][] { + // lenient era/year, strict era/year + { "Meiji 123", "Heisei 2" }, + { "Showa 65", "Heisei 2" }, + { "Heisei 32", "NewEra 2" }, // NewEra + }; + } + + @Test(dataProvider="lenientEra") + public void testLenientEra(String lenient, String strict) throws Exception { + Calendar c = new Calendar.Builder() + .setCalendarType("japanese") + .build(); + DateFormat df = new SimpleDateFormat("GGGG y-M-d", Locale.ROOT); + df.setCalendar(c); + Date lenDate = df.parse(lenient + "-01-01"); + df.setLenient(false); + Date strDate = df.parse(strict + "-01-01"); + assertEquals(lenDate, strDate); + } +} diff --git a/test/java/util/Calendar/NarrowNamesTest.java b/test/java/util/Calendar/NarrowNamesTest.java index 1df04763341475d85e848a21f789dd228a85ab77..16674fadb20341595bb5c217e2d9b7bc9884bb1c 100644 --- a/test/java/util/Calendar/NarrowNamesTest.java +++ b/test/java/util/Calendar/NarrowNamesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2019, 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 @@ -21,6 +21,7 @@ * questions. */ +import java.time.LocalDateTime; import java.util.*; import static java.util.GregorianCalendar.*; @@ -45,7 +46,9 @@ public class NarrowNamesTest { HOUR_OF_DAY, 10); test(US, AM_PM, "p", HOUR_OF_DAY, 23); - test(JAJPJP, DAY_OF_WEEK, "\u65e5", + test(JAJPJP, DAY_OF_WEEK, + LocalDateTime.now().isBefore(LocalDateTime.of(2019, 5, 1, 0, 0)) ? + "\u65e5" : "\u706b", // "Sun" for HEISEI, "Tue" for NEWERA YEAR, 24, MONTH, DECEMBER, DAY_OF_MONTH, 23); test(THTH, MONTH, NARROW_STANDALONE, "\u0e18.\u0e04.", YEAR, 2555, MONTH, DECEMBER, DAY_OF_MONTH, 5); diff --git a/test/java/util/Calendar/SupplementalJapaneseEraTest.java b/test/java/util/Calendar/SupplementalJapaneseEraTest.java index bfb32bd527acad38966f706dfd1fc10677df83a3..5d5afbc02978f3a1ba6e938bcaf03ebae965d966 100644 --- a/test/java/util/Calendar/SupplementalJapaneseEraTest.java +++ b/test/java/util/Calendar/SupplementalJapaneseEraTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2019, 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 @@ -60,8 +60,8 @@ import static org.testng.Assert.*; public class SupplementalJapaneseEraTest { private static final Locale WAREKI_LOCALE = Locale.forLanguageTag("ja-JP-u-ca-japanese"); - private static final String NEW_ERA_NAME = "NewEra"; - private static final String NEW_ERA_ABBR = "N.E."; + private static final String SUP_ERA_NAME = "SupEra"; + private static final String SUP_ERA_ABBR = "S.E."; private static final int NEW_ERA_YEAR = 200; private static final int NEW_ERA_MONTH = FEBRUARY; private static final int NEW_ERA_DAY = 11; @@ -96,7 +96,7 @@ public class SupplementalJapaneseEraTest { private static void testProperty() { Calendar jcal = new Calendar.Builder() .setCalendarType("japanese") - .setFields(YEAR, 1, DAY_OF_YEAR, 1) + .setFields(ERA, 6, YEAR, 1, DAY_OF_YEAR, 1) .build(); Date firstDayOfEra = jcal.getTime(); @@ -114,7 +114,7 @@ public class SupplementalJapaneseEraTest { // test long era name sdf = new SimpleDateFormat("GGGG y-MM-dd", WAREKI_LOCALE); got = sdf.format(firstDayOfEra); - expected = NEW_ERA_NAME + " 1-02-11"; + expected = SUP_ERA_NAME + " 1-02-11"; if (!expected.equals(got)) { System.err.printf("GGGG y-MM-dd: got=\"%s\", expected=\"%s\"%n", got, expected); errors++; @@ -123,7 +123,7 @@ public class SupplementalJapaneseEraTest { // test era abbreviation sdf = new SimpleDateFormat("G y-MM-dd", WAREKI_LOCALE); got = sdf.format(firstDayOfEra); - expected = NEW_ERA_ABBR+" 1-02-11"; + expected = SUP_ERA_ABBR+" 1-02-11"; if (!expected.equals(got)) { System.err.printf("G y-MM-dd: got=\"%s\", expected=\"%s\"%n", got, expected); errors++; @@ -140,30 +140,30 @@ public class SupplementalJapaneseEraTest { // test java.time.chrono.JapaneseEra JapaneseDate jdate = JapaneseDate.of(year, 2, 11); got = jdate.toString(); - expected = "Japanese " + NEW_ERA_NAME + " 1-02-11"; + expected = "Japanese " + SUP_ERA_NAME + " 1-02-11"; if (!expected.equals(got)) { System.err.printf("JapaneseDate: got=\"%s\", expected=\"%s\"%n", got, expected); errors++; } JapaneseEra jera = jdate.getEra(); got = jera.getDisplayName(TextStyle.FULL, Locale.US); - if (!NEW_ERA_NAME.equals(got)) { - System.err.printf("JapaneseEra (FULL): got=\"%s\", expected=\"%s\"%n", got, NEW_ERA_NAME); + if (!SUP_ERA_NAME.equals(got)) { + System.err.printf("JapaneseEra (FULL): got=\"%s\", expected=\"%s\"%n", got, SUP_ERA_NAME); errors++; } got = jera.getDisplayName(TextStyle.SHORT, Locale.US); - if (!NEW_ERA_NAME.equals(got)) { - System.err.printf("JapaneseEra (SHORT): got=\"%s\", expected=\"%s\"%n", got, NEW_ERA_NAME); + if (!SUP_ERA_NAME.equals(got)) { + System.err.printf("JapaneseEra (SHORT): got=\"%s\", expected=\"%s\"%n", got, SUP_ERA_NAME); errors++; } got = jera.getDisplayName(TextStyle.NARROW, Locale.US); - if (!NEW_ERA_ABBR.equals(got)) { - System.err.printf("JapaneseEra (NARROW): got=\"%s\", expected=\"%s\"%n", got, NEW_ERA_ABBR); + if (!SUP_ERA_ABBR.equals(got)) { + System.err.printf("JapaneseEra (NARROW): got=\"%s\", expected=\"%s\"%n", got, SUP_ERA_ABBR); errors++; } got = jera.getDisplayName(TextStyle.NARROW_STANDALONE, Locale.US); - if (!NEW_ERA_ABBR.equals(got)) { - System.err.printf("JapaneseEra (NARROW_STANDALONE): got=\"%s\", expected=\"%s\"%n", got, NEW_ERA_ABBR); + if (!SUP_ERA_ABBR.equals(got)) { + System.err.printf("JapaneseEra (NARROW_STANDALONE): got=\"%s\", expected=\"%s\"%n", got, SUP_ERA_ABBR); errors++; } @@ -172,10 +172,12 @@ public class SupplementalJapaneseEraTest { .appendPattern("GGGG") .appendLiteral(" ") .appendPattern("G") + .appendLiteral(" ") + .appendPattern("GGGGG") .toFormatter(Locale.US) .withChronology(JapaneseChronology.INSTANCE) .format(jdate); - expected = NEW_ERA_NAME + " " + NEW_ERA_ABBR; + expected = SUP_ERA_NAME + " " + SUP_ERA_NAME + " " + SUP_ERA_ABBR; if (!expected.equals(got)) { System.err.printf("java.time formatter long/abbr names: got=\"%s\", expected=\"%s\"%n", got, expected); errors++; @@ -230,8 +232,8 @@ public class SupplementalJapaneseEraTest { if (eras != null) { p.setProperty(JA_CAL_KEY, eras + - "; name=" + SupplementalJapaneseEraTest.NEW_ERA_NAME + - ",abbr=" + SupplementalJapaneseEraTest.NEW_ERA_ABBR + + "; name=" + SupplementalJapaneseEraTest.SUP_ERA_NAME + + ",abbr=" + SupplementalJapaneseEraTest.SUP_ERA_ABBR + ",since=" + since()); } try (BufferedWriter bw = Files.newBufferedWriter(dst)) { @@ -243,6 +245,7 @@ public class SupplementalJapaneseEraTest { return new Calendar.Builder() .setCalendarType("japanese") .setTimeZone(TimeZone.getTimeZone("GMT")) + .setFields(ERA, 5) .setDate(SupplementalJapaneseEraTest.NEW_ERA_YEAR, SupplementalJapaneseEraTest.NEW_ERA_MONTH, SupplementalJapaneseEraTest.NEW_ERA_DAY)