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

StringIndexOutOfBoundsException from /.*((a[^a]+){2})c$/.exec('ababc')

XMLWordPrintable

    • b21
    • generic
    • generic

      FULL PRODUCT VERSION :
      java version "1.8.0_121"
      Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 25.71-b01-internal-jvmci-0.24, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Linux stola-ThinkPad 3.16.0-38-generic #52~14.04.1-Ubuntu SMP Fri May 8 09:43:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      Evaluation of /.*((a[^a]+){2})c$/.exec('ababc') results in StringIndexOutOfBoundsException

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Start jjs
      2. Enter /.*((a[^a]+){2})c$/.exec('ababc')
      => java.lang.StringIndexOutOfBoundsException: String index out of range: -1 is printed into the console

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Correct result, i.e., ababc, abab, ab printed into the console.
      ACTUAL -
      java.lang.StringIndexOutOfBoundsException: String index out of range: -1 is printed into the console

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      java.lang.StringIndexOutOfBoundsException: String index out of range: -1

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      /.*((a[^a]+){2})c$/.exec('ababc')
      ---------- END SOURCE ----------

            pmuthuswamy Priya Lakshmi Muthuswamy (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: