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

ArrayIndexOutOfBoundsException in CalendarBuilder.toString

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8, 11, 15
    • Fix Version/s: 15
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b09
    • CPU:
      generic
    • OS:
      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

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

                Dates

                Created:
                Updated:
                Resolved: