--- old/src/java.base/share/classes/sun/util/locale/provider/LocaleResources.java 2018-12-04 20:48:53.068904540 +0530 +++ new/src/java.base/share/classes/sun/util/locale/provider/LocaleResources.java 2018-12-04 20:48:52.668904540 +0530 @@ -43,6 +43,7 @@ import java.lang.ref.ReferenceQueue; import java.lang.ref.SoftReference; import java.text.MessageFormat; +import java.text.NumberFormat; import java.util.Calendar; import java.util.HashSet; import java.util.LinkedHashSet; @@ -88,6 +89,7 @@ private static final String ZONE_IDS_CACHEKEY = "ZID"; private static final String CALENDAR_NAMES = "CALN."; private static final String NUMBER_PATTERNS_CACHEKEY = "NP"; + private static final String COMPACT_NUMBER_PATTERNS_CACHEKEY = "CNP"; private static final String DATE_TIME_PATTERN = "DTP."; // TimeZoneNamesBundle exemplar city prefix @@ -479,6 +481,32 @@ } /** + * Returns the compact number format patterns. + * @param formatStyle the style for formatting a number + * @return an array of compact number patterns + */ + @SuppressWarnings("unchecked") + public String[] getCNPatterns(NumberFormat.Style formatStyle) { + + Objects.requireNonNull(formatStyle); + String[] compactNumberPatterns = null; + removeEmptyReferences(); + String width = (formatStyle == NumberFormat.Style.LONG) ? "long" : "short"; + String cacheKey = width + "." + COMPACT_NUMBER_PATTERNS_CACHEKEY; + ResourceReference data = cache.get(cacheKey); + if (data == null || ((compactNumberPatterns + = (String[]) data.get()) == null)) { + ResourceBundle resource = localeData.getNumberFormatData(locale); + compactNumberPatterns = (String[]) resource + .getObject(width + ".CompactNumberPatterns"); + cache.put(cacheKey, new ResourceReference(cacheKey, + (Object) compactNumberPatterns, referenceQueue)); + } + return compactNumberPatterns; + } + + + /** * Returns the FormatData resource bundle of this LocaleResources. * The FormatData should be used only for accessing extra * resources required by JSR 310.