On Tue, 25 Feb 2025 23:58:21 GMT, Justin Lu <j...@openjdk.org> wrote:

> Please review this PR which prevents an `AIOOBE` from leaking out when 
> `java.util.Calendar.Builder` is used to build a Japanese calendar with an era 
> value too large.
> 
> Note that we don't check under `BEFORE_MEIJI`/0 as historically Japanese 
> calendar ignores negative values during normalization. See 
> `JapaneseImperialCalendar` L2018: `date.setEra(era > 0 ? eras[era] : null);`. 
> 
> We also check against `eras.length` over `REIWA`/5 due to the possibility of 
> additional eras via the property override. (Which ensures 
> `SupplementalJapaneseEraTestRun.java` passes, which also tests against 
> building (and succeeding) with an era value of 6.

Looks good to me. I would expect a test case with 
`jdk.calendar.japanese.supplemental.era` defined with something, and 7 would 
throw an IAE.

src/java.base/share/classes/java/util/JapaneseImperialCalendar.java line 1862:

> 1860:             // BEFORE_MEIJI to be ignored during normalization
> 1861:             // We check against eras.length over Reiwa ERA due to 
> possibility
> 1862:             // of additional eras via 
> "jdk.calendar.japanese.supplemental.era"

The possibility is not only that emergency property, but by design Japanese 
calendar eras increase when the current emperor abdicates.

-------------

PR Review: https://git.openjdk.org/jdk/pull/23789#pullrequestreview-2645256501
PR Review Comment: https://git.openjdk.org/jdk/pull/23789#discussion_r1972020190

Reply via email to