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

"ab".indexOf("", 3) returns the value 2, violating the specification of indexOf

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version "1.7.0_40-ea"
      Java(TM) SE Runtime Environment (build 1.7.0_40-ea-b29)
      Java HotSpot(TM) 64-Bit Server VM (build 24.0-b48, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      OS X Yosemite, Version 10.10.1

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Not applicable

      A DESCRIPTION OF THE PROBLEM :
      s.indexOf(String, index) does not work properly in the case that the first argument is empty and the second argument is greater than the length of s.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Evaluate the call

      "ab".indexOf("", 3)




      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      System.out.println("ab".indexOf("", 3));
      ---------- END SOURCE ----------

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: