Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4956479

BuddhistCalendar methods may return wrong values after exception

XMLWordPrintable

    • b30
    • generic
    • generic

      The following is a sample code for producing the problem.

      --
      import java.util.*;

      public class T {
          public static void main(String[] args) {
              Calendar cal = Calendar.getInstance(new Locale("th", "TH"));
              int year = cal.get(cal.YEAR);
              try {
                  cal.add(100, +1); // cause exception
              } catch (Exception e) {
              }
              int year2 = cal.get(cal.YEAR);
              if (year2 != year) {
                  throw new RuntimeException("wrong year value after exception: got " + year2
                                             + ", expected " + year);
              }
          }
      }
      --
      $ java -showversion T
      java version "1.5.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b28)
      Java HotSpot(TM) Client VM (build 1.5.0-beta-b28, mixed mode)

      Exception in thread "main" java.lang.RuntimeException: wrong year value after exception: got 2003, expected 2546
              at T.main(T.java:13)

            okutsu Masayoshi Okutsu
            okutsu Masayoshi Okutsu
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: