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

ArrayIndexOutOfBoundsException in CalendarBuilder.toString

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 15
    • 8, 11, 15
    • core-libs
    • b09
    • generic
    • generic

    Description

      Filed on behalf of Clive Verghese (verghese@amazon.com). Assigning to myself (phh) as sponsor.

      CalendarBuilder's toString method has a bug which causes an ArrayIndexOutOfBoundsException exception. The class is an internal jdk class that is restricted to the java.text package. The bug is observed when the debugger reaches this class and uses the toString function to print the class.

      Steps to reproduce the issue:

      Create class CalendarBuilderReproducer.java:

      import java.text.SimpleDateFormat;
      import java.util.Date;
      import java.util.Locale;

      public class CalendarBuilderReproducer {
          public static void main(String[] args) {
              String pattern = "YYYY-ww-dd hh:mm:ss";
              SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);

              try {
                  Date date = simpleDateFormat.parse("2019-12-10 06:44:23");
              } catch(Exception e) {
                  e.printStackTrace();
              }
          }
      }

      Run the class in debug mode using command:

      `java -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:5000,server=y,suspend=y CalendarBuilderReproducer.java`

      Run jdb

      `jdb -attach 5000`

      Set a breakpoint in the CalendarBuilder class

      `stop in java.text.CalendarBuilder.set`

      Run the program using `run` command. When the breakpoint hits the second time, print the class using

      `print this`

      It will print:

      'com.sun.tools.example.debug.expr.ParseException: Unable to complete expression. Exception instance of java.lang.ArrayIndexOutOfBoundsException(id=1993) thrown'

      It should print:

      'this = "CalendarBuilder:[17=2,35=2019]"'

      Attachments

        Issue Links

          Activity

            People

              phh Paul Hohensee
              phh Paul Hohensee
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: