From 2b624af1a9db44a8750720c9c70f62444b7dee06 Mon Sep 17 00:00:00 2001 From: rpatil Date: Fri, 14 Dec 2018 18:11:32 +0530 Subject: [PATCH] 8215377: JDK-8171049 Breaks JCK signature tests - Era.getDisplayName doesn't work with non-IsoChronology Reviewed-by: coffeys, rpatil Contributed-by: Deepak kejriwal --- .../classes/java/time/chrono/HijrahEra.java | 17 -------- .../classes/java/time/chrono/MinguoEra.java | 20 --------- .../java/time/chrono/ThaiBuddhistEra.java | 20 --------- .../java/time/chrono/TestEraDisplayName.java | 41 +------------------ 4 files changed, 1 insertion(+), 97 deletions(-) diff --git a/src/share/classes/java/time/chrono/HijrahEra.java b/src/share/classes/java/time/chrono/HijrahEra.java index 33e8cd948..4390f698c 100644 --- a/src/share/classes/java/time/chrono/HijrahEra.java +++ b/src/share/classes/java/time/chrono/HijrahEra.java @@ -64,13 +64,10 @@ package java.time.chrono; import static java.time.temporal.ChronoField.ERA; import java.time.DateTimeException; -import java.time.format.DateTimeFormatterBuilder; -import java.time.format.TextStyle; import java.time.temporal.ChronoField; import java.time.temporal.TemporalField; import java.time.temporal.UnsupportedTemporalTypeException; import java.time.temporal.ValueRange; -import java.util.Locale; /** * An era in the Hijrah calendar system. @@ -158,18 +155,4 @@ public enum HijrahEra implements Era { return Era.super.range(field); } - /** - * {@inheritDoc} - * - * @param style {@inheritDoc} - * @param locale {@inheritDoc} - */ - @Override - public String getDisplayName(TextStyle style, Locale locale) { - return new DateTimeFormatterBuilder() - .appendText(ERA, style) - .toFormatter(locale) - .withChronology(HijrahChronology.INSTANCE) - .format(HijrahDate.now()); -} } diff --git a/src/share/classes/java/time/chrono/MinguoEra.java b/src/share/classes/java/time/chrono/MinguoEra.java index 8e6629d1b..fd96de196 100644 --- a/src/share/classes/java/time/chrono/MinguoEra.java +++ b/src/share/classes/java/time/chrono/MinguoEra.java @@ -61,12 +61,7 @@ */ package java.time.chrono; -import static java.time.temporal.ChronoField.ERA; - import java.time.DateTimeException; -import java.time.format.DateTimeFormatterBuilder; -import java.time.format.TextStyle; -import java.util.Locale; /** * An era in the Minguo calendar system. @@ -157,19 +152,4 @@ public enum MinguoEra implements Era { return ordinal(); } - /** - * {@inheritDoc} - * - * @param style {@inheritDoc} - * @param locale {@inheritDoc} - */ - @Override - public String getDisplayName(TextStyle style, Locale locale) { - return new DateTimeFormatterBuilder() - .appendText(ERA, style) - .toFormatter(locale) - .withChronology(MinguoChronology.INSTANCE) - .format(this == ROC ? MinguoDate.of(1, 1, 1) : MinguoDate.of(0, 1, 1)); -} - } diff --git a/src/share/classes/java/time/chrono/ThaiBuddhistEra.java b/src/share/classes/java/time/chrono/ThaiBuddhistEra.java index d9d1dce03..e3e6e86fa 100644 --- a/src/share/classes/java/time/chrono/ThaiBuddhistEra.java +++ b/src/share/classes/java/time/chrono/ThaiBuddhistEra.java @@ -61,12 +61,7 @@ */ package java.time.chrono; -import static java.time.temporal.ChronoField.ERA; - import java.time.DateTimeException; -import java.time.format.DateTimeFormatterBuilder; -import java.time.format.TextStyle; -import java.util.Locale; /** * An era in the Thai Buddhist calendar system. @@ -157,19 +152,4 @@ public enum ThaiBuddhistEra implements Era { return ordinal(); } - /** - * {@inheritDoc} - * - * @param style {@inheritDoc} - * @param locale {@inheritDoc} - */ - @Override - public String getDisplayName(TextStyle style, Locale locale) { - return new DateTimeFormatterBuilder() - .appendText(ERA, style) - .toFormatter(locale) - .withChronology(ThaiBuddhistChronology.INSTANCE) - .format(this == BE ? ThaiBuddhistDate.of(1, 1, 1) : ThaiBuddhistDate.of(0, 1, 1)); -} - } diff --git a/test/java/time/test/java/time/chrono/TestEraDisplayName.java b/test/java/time/test/java/time/chrono/TestEraDisplayName.java index 69a585522..1ff5f2a4d 100644 --- a/test/java/time/test/java/time/chrono/TestEraDisplayName.java +++ b/test/java/time/test/java/time/chrono/TestEraDisplayName.java @@ -39,7 +39,7 @@ import static org.testng.Assert.assertEquals; * chrono implementation. * Note: The exact result may depend on locale data provider's implementation. * - * @bug 8171049 + * @bug 8171049 8215377 * @run testng/othervm -Djava.locale.providers=CLDR TestEraDisplayName */ @Test @@ -90,45 +90,6 @@ public class TestEraDisplayName { { JapaneseEra.TAISHO, TextStyle.NARROW, Locale.JAPAN, "T" }, { JapaneseEra.SHOWA, TextStyle.NARROW, Locale.JAPAN, "S" }, { JapaneseEra.HEISEI, TextStyle.NARROW, Locale.JAPAN, "H" }, - - // ThaiBuddhistEra - { ThaiBuddhistEra.BEFORE_BE, TextStyle.FULL, Locale.US, "BC" }, - { ThaiBuddhistEra.BE, TextStyle.FULL, Locale.US, "B.E." }, - { ThaiBuddhistEra.BEFORE_BE, TextStyle.FULL, THAI, "BC" }, - { ThaiBuddhistEra.BE, TextStyle.FULL, THAI, - "\u0e1e\u0e38\u0e17\u0e18\u0e28\u0e31\u0e01\u0e23\u0e32\u0e0a" }, - { ThaiBuddhistEra.BEFORE_BE, TextStyle.SHORT, Locale.US, "BC" }, - { ThaiBuddhistEra.BE, TextStyle.SHORT, Locale.US, "B.E." }, - { ThaiBuddhistEra.BEFORE_BE, TextStyle.SHORT, THAI, - "\u0e1b\u0e35\u0e01\u0e48\u0e2d\u0e19\u0e04\u0e23\u0e34\u0e2a" + - "\u0e15\u0e4c\u0e01\u0e32\u0e25\u0e17\u0e35\u0e48" }, - { ThaiBuddhistEra.BE, TextStyle.SHORT, THAI, "\u0e1e.\u0e28." }, - { ThaiBuddhistEra.BEFORE_BE, TextStyle.NARROW, Locale.US, "BC" }, - { ThaiBuddhistEra.BE, TextStyle.NARROW, Locale.US, "B.E." }, - { ThaiBuddhistEra.BEFORE_BE, TextStyle.NARROW, THAI, "BC" }, - { ThaiBuddhistEra.BE, TextStyle.NARROW, THAI, "B.E." }, - - // MinguoEra - { MinguoEra.BEFORE_ROC, TextStyle.FULL, Locale.US, "Before R.O.C." }, - { MinguoEra.ROC, TextStyle.FULL, Locale.US, "R.O.C." }, - { MinguoEra.BEFORE_ROC, TextStyle.FULL, Locale.TAIWAN, "\u6c11\u570b\u524d" }, - { MinguoEra.ROC, TextStyle.FULL, Locale.TAIWAN, "\u6c11\u570b" }, - { MinguoEra.BEFORE_ROC, TextStyle.SHORT, Locale.US, "Before R.O.C." }, - { MinguoEra.ROC, TextStyle.SHORT, Locale.US, "R.O.C." }, - { MinguoEra.BEFORE_ROC, TextStyle.SHORT, Locale.TAIWAN, "\u6c11\u570b\u524d" }, - { MinguoEra.ROC, TextStyle.SHORT, Locale.TAIWAN, "\u6c11\u570b" }, - { MinguoEra.BEFORE_ROC, TextStyle.NARROW, Locale.US, "0" }, - { MinguoEra.ROC, TextStyle.NARROW, Locale.US, "1" }, - { MinguoEra.BEFORE_ROC, TextStyle.NARROW, Locale.TAIWAN, "0" }, - { MinguoEra.ROC, TextStyle.NARROW, Locale.TAIWAN, "1" }, - - // HijrahEra - { HijrahEra.AH, TextStyle.FULL, Locale.US, "AH" }, - { HijrahEra.AH, TextStyle.FULL, EGYPT, "\u0647\u0640" }, - { HijrahEra.AH, TextStyle.SHORT, Locale.US, "AH" }, - { HijrahEra.AH, TextStyle.SHORT, EGYPT, "\u0647\u0640" }, - { HijrahEra.AH, TextStyle.NARROW, Locale.US, "1" }, - { HijrahEra.AH, TextStyle.NARROW, EGYPT, "1" }, }; } -- GitLab