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

The documentation of the String.regionMatches method contains error

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P3 P3
    • 17
    • core-libs
    • None
    • source
    • minimal
    • Only affects documentation.
    • Java API
    • SE

      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.

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

              Created:
              Updated:
              Resolved: