<i18n dev> RFR: 4737887: (cal) API: Calendar methods taking field should document exceptions

Justin Lu jlu at openjdk.org
Fri Apr 14 20:33:29 UTC 2023


Many Calendar methods that take in a field parameter should document that they throw an ArrayIndexOutOfBoundsException if field is not between 0 and `Calendar.FIELD_COUNT`.

This PR adds a clause to the class description to make the above apparent.

`Calendar.Roll(int, int)`, `Calendar.roll(int, boolean)`, and `Calendar.add(int, int)` should all be documented that they throw an `IllegalArgumentException` if any calendar fields have out-of-range values in non-lenient mode or if field is
`Calendar.ZONE_OFFSET`, `Calendar.DST_OFFSET`, or unknown.

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

Commit messages:
 - Replace method exceptions with a general clause in class description
 - Readjust add and roll to throw IAE (since jCal is private and cannot be specified)
 - Adjust add and roll
 - Adjust Add and Roll spec to use existing wording
 - Add exceptions to Calendar methods

Changes: https://git.openjdk.org/jdk/pull/13234/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=13234&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-4737887
  Stats: 20 lines in 1 file changed: 13 ins; 5 del; 2 mod
  Patch: https://git.openjdk.org/jdk/pull/13234.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/13234/head:pull/13234

PR: https://git.openjdk.org/jdk/pull/13234


More information about the i18n-dev mailing list