Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/java.base/share/classes/java/lang/String.java
Original file line number Diff line number Diff line change
Expand Up @@ -2174,6 +2174,7 @@ private static class CaseInsensitiveComparator
@java.io.Serial
private static final long serialVersionUID = 8575799808933029326L;

@Pure
public int compare(String s1, String s2) {
byte[] v1 = s1.value;
byte[] v2 = s2.value;
Expand Down Expand Up @@ -2617,6 +2618,7 @@ public int hashCode() {
* {@code endIndex}.
* @since 21
*/
@Pure
public int indexOf(int ch, int beginIndex, int endIndex) {
checkBoundsBeginEnd(beginIndex, endIndex, length());
return isLatin1() ? StringLatin1.indexOf(value, ch, beginIndex, endIndex)
Expand Down Expand Up @@ -2781,6 +2783,7 @@ public int indexOf(int ch, int beginIndex, int endIndex) {
* {@code endIndex}.
* @since 21
*/
@Pure
public int indexOf(String str, int beginIndex, int endIndex) {
if (str.length() == 1) {
/* Simple optimization, can be omitted without behavioral impact */
Expand Down Expand Up @@ -3474,6 +3477,7 @@ public String replace(@GuardSatisfied CharSequence target, @GuardSatisfied CharS
*
* @since 21
*/
@SideEffectFree
public String[] splitWithDelimiters(String regex, int limit) {
return split(regex, limit, true);
}
Expand Down Expand Up @@ -4093,6 +4097,7 @@ public boolean isBlank() {
*
* @since 11
*/
@SideEffectFree
public Stream<String> lines() {
return isLatin1() ? StringLatin1.lines(value) : StringUTF16.lines(value);
}
Expand Down Expand Up @@ -4490,6 +4495,7 @@ public <R> R transform(Function<? super String, ? extends R> f) {
* @return an IntStream of char values from this sequence
* @since 9
*/
@SideEffectFree
@Override
public IntStream chars() {
return StreamSupport.intStream(
Expand All @@ -4510,6 +4516,7 @@ public IntStream chars() {
* @return an IntStream of Unicode code points from this sequence
* @since 9
*/
@SideEffectFree
@Override
public IntStream codePoints() {
return StreamSupport.intStream(
Expand Down Expand Up @@ -5112,6 +5119,7 @@ static String valueOfCodePoint(int codePoint) {
* @return an {@link Optional} describing the {@linkplain String} instance
* @since 12
*/
@SideEffectFree
@Override
public Optional<String> describeConstable() {
return Optional.of(this);
Expand All @@ -5125,6 +5133,7 @@ public Optional<String> describeConstable() {
* @return the {@linkplain String} instance
* @since 12
*/
@Pure
@Override
public String resolveConstantDesc(MethodHandles.Lookup lookup) {
return this;
Expand Down
13 changes: 12 additions & 1 deletion src/java.base/share/classes/java/lang/StringBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ public final class StringBuffer
*
* @since 11
*/
@SideEffectFree
@Override
public synchronized int compareTo(StringBuffer another) {
return super.compareTo(another);
Expand All @@ -219,6 +220,7 @@ public synchronized int compareTo(StringBuffer another) {
return count;
}

@Pure
@Override
public synchronized @NonNegative int capacity() {
return super.capacity();
Expand Down Expand Up @@ -252,6 +254,7 @@ public synchronized void setLength(@NonNegative int newLength) {
* @throws IndexOutOfBoundsException {@inheritDoc}
* @see #length()
*/
@Pure
@Override
public synchronized char charAt(int index) {
return super.charAt(index);
Expand All @@ -261,6 +264,7 @@ public synchronized char charAt(int index) {
* @throws IndexOutOfBoundsException {@inheritDoc}
* @since 1.5
*/
@Pure
@Override
public synchronized int codePointAt(int index) {
return super.codePointAt(index);
Expand All @@ -270,6 +274,7 @@ public synchronized int codePointAt(int index) {
* @throws IndexOutOfBoundsException {@inheritDoc}
* @since 1.5
*/
@Pure
@Override
public synchronized int codePointBefore(int index) {
return super.codePointBefore(index);
Expand All @@ -279,6 +284,7 @@ public synchronized int codePointBefore(int index) {
* @throws IndexOutOfBoundsException {@inheritDoc}
* @since 1.5
*/
@Pure
@Override
public synchronized int codePointCount(int beginIndex, int endIndex) {
return super.codePointCount(beginIndex, endIndex);
Expand All @@ -288,6 +294,7 @@ public synchronized int codePointCount(int beginIndex, int endIndex) {
* @throws IndexOutOfBoundsException {@inheritDoc}
* @since 1.5
*/
@Pure
@Override
public synchronized int offsetByCodePoints(int index, int codePointOffset) {
return super.offsetByCodePoints(index, codePointOffset);
Expand All @@ -296,6 +303,7 @@ public synchronized int offsetByCodePoints(int index, int codePointOffset) {
/**
* @throws IndexOutOfBoundsException {@inheritDoc}
*/
@SideEffectFree
@Override
public synchronized void getChars(int srcBegin, int srcEnd, char[] dst,
@IndexOrHigh({"#3"}) int dstBegin)
Expand Down Expand Up @@ -516,6 +524,7 @@ public synchronized StringBuffer replace(int start, int end, String str) {
* @throws StringIndexOutOfBoundsException {@inheritDoc}
* @since 1.2
*/
@SideEffectFree
@Override
public synchronized String substring(int start) {
return substring(start, count);
Expand All @@ -525,6 +534,7 @@ public synchronized String substring(int start) {
* @throws IndexOutOfBoundsException {@inheritDoc}
* @since 1.4
*/
@SideEffectFree
@Override
public synchronized CharSequence subSequence(int start, int end) {
return super.substring(start, end);
Expand All @@ -534,6 +544,7 @@ public synchronized CharSequence subSequence(int start, int end) {
* @throws StringIndexOutOfBoundsException {@inheritDoc}
* @since 1.2
*/
@SideEffectFree
@Override
public synchronized String substring(int start, int end) {
return super.substring(start, end);
Expand Down Expand Up @@ -726,7 +737,6 @@ public synchronized StringBuffer reverse() {
return this;
}

@SideEffectFree
/**
* @throws IllegalArgumentException {@inheritDoc}
*
Expand All @@ -749,6 +759,7 @@ public synchronized StringBuffer repeat(CharSequence cs, int count) {
return this;
}

@SideEffectFree
@Override
@IntrinsicCandidate
public synchronized String toString(@GuardSatisfied StringBuffer this) {
Expand Down
5 changes: 4 additions & 1 deletion src/java.base/share/classes/java/lang/StringBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ public StringBuilder(CharSequence seq) {
*
* @since 11
*/
@SideEffectFree
@Override
public int compareTo(StringBuilder another) {
return super.compareTo(another);
Expand Down Expand Up @@ -493,12 +494,12 @@ public StringBuilder reverse() {
return this;
}

@SideEffectFree
/**
* @throws IllegalArgumentException {@inheritDoc}
*
* @since 21
*/
@SideEffectsOnly("this")
@Override
public StringBuilder repeat(int codePoint, int count) {
super.repeat(codePoint, count);
Expand All @@ -510,12 +511,14 @@ public StringBuilder repeat(int codePoint, int count) {
*
* @since 21
*/
@SideEffectsOnly("this")
@Override
public StringBuilder repeat(CharSequence cs, int count) {
super.repeat(cs, count);
return this;
}

@SideEffectFree
@Override
@IntrinsicCandidate
public @PolyRegex String toString(@GuardSatisfied @PolyRegex StringBuilder this) {
Expand Down
Loading