JDK-8251499 : no-placeholder compact number patterns throw IllegalArgumentException
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.text
  • Affected Version: 16
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2020-08-12
  • Updated: 2020-08-25
  • Resolved: 2020-08-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 16
16 b12Fixed
Related Reports
Relates :  
Description
Upcoming CLDR 38 will have compact number patterns without a placeholder:

https://unicode-org.atlassian.net/browse/CLDR-11045

Current JDK will throw an exception for such pattern as:

```
java.lang.IllegalArgumentException: Invalid pattern [Kun]: all patterns must include digit placement 0s
	at java.base/java.text.CompactNumberFormat.applyPattern(CompactNumberFormat.java:1405)
	at java.base/java.text.CompactNumberFormat.lambda$processCompactPatterns$0(CompactNumberFormat.java:1167)
	at java.base/java.util.regex.Matcher$1MatchResultIterator.forEachRemaining(Matcher.java:1358)
	at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
	at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:658)
	at java.base/java.text.CompactNumberFormat.processCompactPatterns(CompactNumberFormat.java:1167)
	at java.base/java.text.CompactNumberFormat.<init>(CompactNumberFormat.java:464)
```
Comments
URL: https://hg.openjdk.java.net/jdk/jdk/rev/fc8e62b399bd User: naoto Date: 2020-08-19 20:41:43 +0000
19-08-2020

The current implementation prohibits compact number patterns that include no place holders for numbers (indicated by a series of '0's). Instead of throwing an exception, the implementation should accept such patterns and format/parse numbers correctly. In the case of Somali, the formatted output wil have no number digits per the LDML spec: --- To format a number N, the greatest type less than or equal to N is used, with the appropriate plural category. N is divided by the type, after removing the number of zeros in the pattern, less 1. --- https://unicode.org/reports/tr35/tr35-numbers.html#Compact_Number_Formats
19-08-2020