Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.dataflow.qual.Pure;
import org.checkerframework.dataflow.qual.SideEffectFree;
import org.checkerframework.dataflow.qual.SideEffectsOnly;
import org.checkerframework.framework.qual.AnnotatedFor;

import jdk.internal.math.DoubleToDecimal;
Expand Down Expand Up @@ -521,6 +522,7 @@ public int codePointBefore(@Positive int index) {
* {@code dst.length}
* </ul>
*/
@SideEffectsOnly("#3")
public void getChars(@NonNegative int srcBegin, @NonNegative int srcEnd, char[] dst, @IndexOrHigh({"#3"}) int dstBegin)
{
Preconditions.checkFromToIndex(srcBegin, srcEnd, count, Preconditions.SIOOBE_FORMATTER); // compatible to old version
Expand Down
11 changes: 11 additions & 0 deletions src/java.base/share/classes/java/lang/String.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import org.checkerframework.common.value.qual.StringVal;
import org.checkerframework.dataflow.qual.Pure;
import org.checkerframework.dataflow.qual.SideEffectFree;
import org.checkerframework.dataflow.qual.SideEffectsOnly;
import org.checkerframework.framework.qual.AnnotatedFor;
import org.checkerframework.framework.qual.CFComment;

Expand Down Expand Up @@ -1787,6 +1788,7 @@ public int codePointBefore(@LTEqLengthOf({"this"}) @Positive int index) {
* <li>{@code dstBegin+(srcEnd-srcBegin)} is larger than
* {@code dst.length}</ul>
*/
@SideEffectsOnly("#3")
public void getChars(@IndexOrHigh({"this"}) int srcBegin, @IndexOrHigh({"this"}) int srcEnd, char @GuardSatisfied [] dst, @IndexOrHigh({"#3"}) int dstBegin) {
checkBoundsBeginEnd(srcBegin, srcEnd, length());
checkBoundsOffCount(dstBegin, srcEnd - srcBegin, dst.length);
Expand Down Expand Up @@ -2174,6 +2176,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 +2620,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 +2785,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 +3479,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 +4099,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 +4497,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 +4518,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 +5121,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 +5135,7 @@ public Optional<String> describeConstable() {
* @return the {@linkplain String} instance
* @since 12
*/
@Pure
@Override
public String resolveConstantDesc(MethodHandles.Lookup lookup) {
return this;
Expand Down
14 changes: 13 additions & 1 deletion src/java.base/share/classes/java/lang/StringBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.checkerframework.common.aliasing.qual.Unique;
import org.checkerframework.dataflow.qual.Pure;
import org.checkerframework.dataflow.qual.SideEffectFree;
import org.checkerframework.dataflow.qual.SideEffectsOnly;
import org.checkerframework.framework.qual.AnnotatedFor;

import java.io.IOException;
Expand Down Expand Up @@ -208,6 +209,7 @@ public final class StringBuffer
*
* @since 11
*/
@SideEffectFree
@Override
public synchronized int compareTo(StringBuffer another) {
return super.compareTo(another);
Expand All @@ -219,6 +221,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 +255,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 +265,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 +275,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 +285,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 +295,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 +304,7 @@ public synchronized int offsetByCodePoints(int index, int codePointOffset) {
/**
* @throws IndexOutOfBoundsException {@inheritDoc}
*/
@SideEffectsOnly("#3")
@Override
public synchronized void getChars(int srcBegin, int srcEnd, char[] dst,
@IndexOrHigh({"#3"}) int dstBegin)
Expand Down Expand Up @@ -516,6 +525,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 +535,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 +545,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 +738,6 @@ public synchronized StringBuffer reverse() {
return this;
}

@SideEffectFree
/**
* @throws IllegalArgumentException {@inheritDoc}
*
Expand All @@ -749,6 +760,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
3 changes: 3 additions & 0 deletions src/java.base/share/classes/java/lang/StringLatin1.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

package java.lang;

import org.checkerframework.dataflow.qual.SideEffectsOnly;

import java.util.Arrays;
import java.util.Locale;
import java.util.Spliterator;
Expand Down Expand Up @@ -79,6 +81,7 @@ public static byte[] inflate(byte[] value, int off, int len) {
return ret;
}

@SideEffectsOnly("#3")
public static void getChars(byte[] value, int srcBegin, int srcEnd, char[] dst, int dstBegin) {
Comment thread
mernst marked this conversation as resolved.
inflate(value, srcBegin, dst, dstBegin, srcEnd - srcBegin);
}
Expand Down
3 changes: 3 additions & 0 deletions src/java.base/share/classes/java/lang/StringUTF16.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

package java.lang;

import org.checkerframework.dataflow.qual.SideEffectsOnly;

import java.util.Arrays;
import java.util.Locale;
import java.util.Spliterator;
Expand Down Expand Up @@ -247,6 +249,7 @@ static byte[] toBytesSupplementary(int cp) {
}

@IntrinsicCandidate
@SideEffectsOnly("#3")
public static void getChars(byte[] value, int srcBegin, int srcEnd, char[] dst, int dstBegin) {
// We need a range check here because 'getChar' has no checks
if (srcBegin < srcEnd) {
Expand Down
1 change: 0 additions & 1 deletion src/java.base/share/classes/java/util/EnumMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import org.checkerframework.checker.signedness.qual.UnknownSignedness;
import org.checkerframework.dataflow.qual.Pure;
import org.checkerframework.dataflow.qual.SideEffectFree;
import org.checkerframework.dataflow.qual.SideEffectsOnly;
import org.checkerframework.framework.qual.AnnotatedFor;
import org.checkerframework.framework.qual.CFComment;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@

package jdk.internal.icu.text;

import org.checkerframework.dataflow.qual.SideEffectFree;
import org.checkerframework.dataflow.qual.SideEffectsOnly;

Comment thread
mernst marked this conversation as resolved.
/**
* <code>Replaceable</code> is an interface representing a
* string of characters that supports the replacement of a range of
Expand Down Expand Up @@ -117,5 +120,6 @@ public interface Replaceable {
* @param dstStart the start offset in the destination array.
* @stable ICU 2.0
*/
@SideEffectsOnly("#3")
Comment thread
mernst marked this conversation as resolved.
void getChars(int srcStart, int srcLimit, char dst[], int dstStart);
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@

package jdk.internal.icu.text;

import org.checkerframework.dataflow.qual.SideEffectFree;
import org.checkerframework.dataflow.qual.SideEffectsOnly;

Comment thread
mernst marked this conversation as resolved.
/**
* <code>ReplaceableString</code> is an adapter class that implements the
* <code>Replaceable</code> API around an ordinary <code>StringBuffer</code>.
Expand Down Expand Up @@ -110,6 +113,7 @@ public char charAt(int offset) {
* @param dstStart the start offset in the destination array.
* @stable ICU 2.0
*/
@SideEffectsOnly("#3")
Comment thread
mernst marked this conversation as resolved.
public void getChars(int srcStart, int srcLimit, char dst[], int dstStart) {
if (srcStart != srcLimit) {
buf.getChars(srcStart, srcLimit, dst, dstStart);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
package sun.management.counter.perf;

import org.checkerframework.dataflow.qual.Pure;
import org.checkerframework.dataflow.qual.SideEffectsOnly;


import sun.management.counter.*;
import java.nio.*;
Expand Down Expand Up @@ -85,7 +83,6 @@ boolean hasNext() {
return (nextEntry < prologue.getUsed());
}

@SideEffectsOnly("this")
Counter getNextCounter() {
if (! hasNext()) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
package jdk.internal.net.http;

import org.checkerframework.dataflow.qual.Pure;
import org.checkerframework.dataflow.qual.SideEffectsOnly;

import java.util.Iterator;
import java.util.Locale;
Expand Down Expand Up @@ -208,7 +207,6 @@ public boolean hasNext () {
return index<nkeys;
}
@Override
@SideEffectsOnly("this")
public String next () {
if (index >= nkeys) {
throw new NoSuchElementException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
package jdk.internal.net.http;

import org.checkerframework.dataflow.qual.Pure;
import org.checkerframework.dataflow.qual.SideEffectsOnly;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
Expand Down Expand Up @@ -140,7 +139,6 @@ public boolean hasNext() {
}

@Override
@SideEffectsOnly("this")
public ByteBuffer next() {
ByteBuffer buffer = buffers.poll();
while (buffer == null) {
Expand Down Expand Up @@ -471,7 +469,6 @@ private boolean hasNext0() {
}

@Override
@SideEffectsOnly("this")
public ByteBuffer next() {
stateLock.lock();
try {
Expand Down
Loading
Loading