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

The documentation of the String.regionMatches method contains error

    XMLWordPrintable

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P3
    • Resolution: Approved
    • Fix Version/s: 17
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Compatibility Kind:
      source
    • Compatibility Risk:
      minimal
    • Compatibility Risk Description:
      Only affects documentation.
    • Interface Kind:
      Java API
    • Scope:
      SE

      Description

      Summary

      Change documentation for String.regionMatches fix incorrect use of String.substring.

      Problem

      Existing documentation for String.regionMatches contains two instances of String.substring where the second argument is treated as length instead of end offset.

      Solution

      Correct both instances to use the correct second argument.

      Specification

      diff --git a/src/java.base/share/classes/java/lang/String.java b/src/java.base/share/classes/java/lang/String.java
      index 6ceaf74da49..316f1455d7b 100644
      --- a/src/java.base/share/classes/java/lang/String.java
      +++ b/src/java.base/share/classes/java/lang/String.java
      @@ -2169,9 +2169,9 @@ public final class String
            * ignoring case if and only if {@code ignoreCase} is true.
            * The sequences {@code tsequence} and {@code osequence} are compared,
            * where {@code tsequence} is the sequence produced as if by calling
      -     * {@code this.substring(toffset, len).codePoints()} and {@code osequence}
      -     * is the sequence produced as if by calling
      -     * {@code other.substring(ooffset, len).codePoints()}.
      +     * {@code this.substring(toffset, toffset + len).codePoints()} and
      +     * {@code osequence} is the sequence produced as if by calling
      +     * {@code other.substring(ooffset, ooffset + len).codePoints()}.
            * The result is {@code true} if and only if all of the following
            * are true:
            * <ul><li>{@code toffset} is non-negative.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jlaskey Jim Laskey
              Reporter:
              webbuggrp Webbug Group
              Reviewed By:
              Roger Riggs
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: