]> granicus.if.org Git - icu/commitdiff
ICU-20153 Make ICU4J JapaneseCalendar constants non-inlineable. (#155)
authorYoshito Umaoka <yumaoka@users.noreply.github.com>
Thu, 20 Sep 2018 08:00:47 +0000 (04:00 -0400)
committerShane Carr <shane@unicode.org>
Thu, 27 Sep 2018 21:27:41 +0000 (14:27 -0700)
icu4j/main/classes/core/src/com/ibm/icu/util/JapaneseCalendar.java

index c6351b4edf134428a418365a81eb1d415013a3f8..caf027103bf19b3789583f806228972d26723b86 100644 (file)
@@ -351,31 +351,43 @@ public class JapaneseCalendar extends GregorianCalendar {
     /**
      * @stable ICU 2.8
      */
-    static public final int CURRENT_ERA = ERA_RULES.getCurrentEraIndex();
+    static public final int CURRENT_ERA;
 
     /**
      * Constant for the era starting on Sept. 8, 1868 AD.
      * @stable  ICU 2.8
      */
-    static public final int MEIJI = 232;
+    static public final int MEIJI;
 
     /**
      * Constant for the era starting on July 30, 1912 AD.
      * @stable ICU 2.8
      */
-    static public final int TAISHO = 233;
+    static public final int TAISHO;
 
     /**
      * Constant for the era starting on Dec. 25, 1926 AD.
      * @stable ICU 2.8
      */
-    static public final int SHOWA = 234;
+    static public final int SHOWA;
 
     /**
      * Constant for the era starting on Jan. 7, 1989 AD.
      * @stable ICU 2.8
      */
-    static public final int HEISEI = 235;
+    static public final int HEISEI;
+
+    // We want to make these era constants initialized in a static initializer
+    // block to prevent javac to inline these values in a consumer code.
+    // By doing so, we can keep better binary compatibility across versions even
+    // these values are changed.
+    static {
+        MEIJI = 232;
+        TAISHO = 233;
+        SHOWA = 234;
+        HEISEI = 235;
+        CURRENT_ERA = ERA_RULES.getCurrentEraIndex();
+    }
 
     /**
      * Override GregorianCalendar.  We should really handle YEAR_WOY and