Skip to content

Remove SideEffectsOnly annotations #113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 12, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 0 additions & 2 deletions src/java.base/share/classes/java/io/BufferedReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import org.checkerframework.checker.nullness.qual.EnsuresNonNullIf;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.dataflow.qual.Pure;
import org.checkerframework.dataflow.qual.SideEffectsOnly;
import org.checkerframework.framework.qual.AnnotatedFor;

import java.util.Iterator;
Expand Down Expand Up @@ -597,7 +596,6 @@ public boolean hasNext() {
}

@Override
@SideEffectsOnly("this")
public String next(/*@NonEmpty Iterator<String> this*/) {
if (nextLine != null || hasNext()) {
String line = nextLine;
Expand Down
3 changes: 0 additions & 3 deletions src/java.base/share/classes/java/lang/CharSequence.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.checkerframework.checker.nonempty.qual.NonEmpty;
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.util.NoSuchElementException;
Expand Down Expand Up @@ -174,7 +173,6 @@ public boolean hasNext() {
return cur < length();
}

@SideEffectsOnly("this")
public int nextInt(@NonEmpty CharIterator this) {
if (hasNext()) {
return charAt(cur++);
Expand Down Expand Up @@ -251,7 +249,6 @@ public boolean hasNext() {
return cur < length();
}

@SideEffectsOnly("this")
public int nextInt(@NonEmpty CodePointIterator this) {
final int length = length();

Expand Down
2 changes: 0 additions & 2 deletions src/java.base/share/classes/java/lang/StackStreamFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import org.checkerframework.checker.nonempty.qual.EnsuresNonEmptyIf;
import org.checkerframework.dataflow.qual.Pure;
import org.checkerframework.dataflow.qual.SideEffectsOnly;
import jdk.internal.reflect.MethodAccessor;
import jdk.internal.reflect.ConstructorAccessor;
import java.lang.StackWalker.Option;
Expand Down Expand Up @@ -335,7 +334,6 @@ private int getNextBatch() {
*
* @see #tryNextFrame
*/
@SideEffectsOnly("this")
final Class<?> nextFrame() {
if (!hasNext()) {
return null;
Expand Down
33 changes: 1 addition & 32 deletions src/java.base/share/classes/java/lang/StringBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.checkerframework.checker.regex.qual.PolyRegex;
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.vm.annotation.IntrinsicCandidate;
Expand Down Expand Up @@ -96,7 +95,7 @@
* @see java.lang.String
* @since 1.5
*/
@AnnotatedFor({"lock", "nullness", "index", "regex", "sideeffectsonly"})
@AnnotatedFor({"lock", "nullness", "index", "regex"})
public final class StringBuilder
extends AbstractStringBuilder
implements java.io.Serializable, Comparable<StringBuilder>, CharSequence
Expand Down Expand Up @@ -178,14 +177,12 @@ public int compareTo(StringBuilder another) {
}

@Override
@SideEffectsOnly("this")
public StringBuilder append(@GuardSatisfied @Nullable Object obj) {
return append(String.valueOf(obj));
}

@Override
@IntrinsicCandidate
@SideEffectsOnly("this")
public StringBuilder append(@Nullable String str) {
super.append(str);
return this;
Expand All @@ -210,14 +207,12 @@ public StringBuilder append(@Nullable String str) {
* @param sb the {@code StringBuffer} to append.
* @return a reference to this object.
*/
@SideEffectsOnly("this")
public StringBuilder append(@Nullable StringBuffer sb) {
super.append(sb);
return this;
}

@Override
@SideEffectsOnly("this")
public StringBuilder append(@Nullable CharSequence s) {
super.append(s);
return this;
Expand All @@ -227,14 +222,12 @@ public StringBuilder append(@Nullable CharSequence s) {
* @throws IndexOutOfBoundsException {@inheritDoc}
*/
@Override
@SideEffectsOnly("this")
public StringBuilder append(@Nullable CharSequence s, @IndexOrHigh({"#1"}) int start, @IndexOrHigh({"#1"}) int end) {
super.append(s, start, end);
return this;
}

@Override
@SideEffectsOnly("this")
public StringBuilder append(char[] str) {
super.append(str);
return this;
Expand All @@ -244,51 +237,44 @@ public StringBuilder append(char[] str) {
* @throws IndexOutOfBoundsException {@inheritDoc}
*/
@Override
@SideEffectsOnly("this")
public StringBuilder append(char[] str, @IndexOrHigh({"#1"}) int offset, @LTLengthOf(value={"#1"}, offset={"#2 - 1"}) @NonNegative int len) {
super.append(str, offset, len);
return this;
}

@Override
@SideEffectsOnly("this")
public StringBuilder append(boolean b) {
super.append(b);
return this;
}

@Override
@IntrinsicCandidate
@SideEffectsOnly("this")
public StringBuilder append(char c) {
super.append(c);
return this;
}

@Override
@IntrinsicCandidate
@SideEffectsOnly("this")
public StringBuilder append(int i) {
super.append(i);
return this;
}

@Override
@SideEffectsOnly("this")
public StringBuilder append(long lng) {
super.append(lng);
return this;
}

@Override
@SideEffectsOnly("this")
public StringBuilder append(float f) {
super.append(f);
return this;
}

@Override
@SideEffectsOnly("this")
public StringBuilder append(double d) {
super.append(d);
return this;
Expand All @@ -298,7 +284,6 @@ public StringBuilder append(double d) {
* @since 1.5
*/
@Override
@SideEffectsOnly("this")
public StringBuilder appendCodePoint(int codePoint) {
super.appendCodePoint(codePoint);
return this;
Expand All @@ -308,7 +293,6 @@ public StringBuilder appendCodePoint(int codePoint) {
* @throws StringIndexOutOfBoundsException {@inheritDoc}
*/
@Override
@SideEffectsOnly("this")
public StringBuilder delete(@NonNegative int start, @NonNegative int end) {
super.delete(start, end);
return this;
Expand All @@ -318,7 +302,6 @@ public StringBuilder delete(@NonNegative int start, @NonNegative int end) {
* @throws StringIndexOutOfBoundsException {@inheritDoc}
*/
@Override
@SideEffectsOnly("this")
public StringBuilder deleteCharAt(@NonNegative int index) {
super.deleteCharAt(index);
return this;
Expand All @@ -328,7 +311,6 @@ public StringBuilder deleteCharAt(@NonNegative int index) {
* @throws StringIndexOutOfBoundsException {@inheritDoc}
*/
@Override
@SideEffectsOnly("this")
public StringBuilder replace(@NonNegative int start, @NonNegative int end, String str) {
super.replace(start, end, str);
return this;
Expand All @@ -338,7 +320,6 @@ public StringBuilder replace(@NonNegative int start, @NonNegative int end, Strin
* @throws StringIndexOutOfBoundsException {@inheritDoc}
*/
@Override
@SideEffectsOnly("this")
public StringBuilder insert(@NonNegative int index, char[] str, @IndexOrHigh({"#2"}) int offset,
@IndexOrHigh({"#2"}) int len)
{
Expand All @@ -350,7 +331,6 @@ public StringBuilder insert(@NonNegative int index, char[] str, @IndexOrHigh({"#
* @throws StringIndexOutOfBoundsException {@inheritDoc}
*/
@Override
@SideEffectsOnly("this")
public StringBuilder insert(@NonNegative int offset, @GuardSatisfied @Nullable Object obj) {
super.insert(offset, obj);
return this;
Expand All @@ -360,7 +340,6 @@ public StringBuilder insert(@NonNegative int offset, @GuardSatisfied @Nullable O
* @throws StringIndexOutOfBoundsException {@inheritDoc}
*/
@Override
@SideEffectsOnly("this")
public StringBuilder insert(@NonNegative int offset, @Nullable String str) {
super.insert(offset, str);
return this;
Expand All @@ -370,7 +349,6 @@ public StringBuilder insert(@NonNegative int offset, @Nullable String str) {
* @throws StringIndexOutOfBoundsException {@inheritDoc}
*/
@Override
@SideEffectsOnly("this")
public StringBuilder insert(@NonNegative int offset, char[] str) {
super.insert(offset, str);
return this;
Expand All @@ -380,7 +358,6 @@ public StringBuilder insert(@NonNegative int offset, char[] str) {
* @throws IndexOutOfBoundsException {@inheritDoc}
*/
@Override
@SideEffectsOnly("this")
public StringBuilder insert(@NonNegative int dstOffset, @Nullable CharSequence s) {
super.insert(dstOffset, s);
return this;
Expand All @@ -390,7 +367,6 @@ public StringBuilder insert(@NonNegative int dstOffset, @Nullable CharSequence s
* @throws IndexOutOfBoundsException {@inheritDoc}
*/
@Override
@SideEffectsOnly("this")
public StringBuilder insert(@NonNegative int dstOffset, @Nullable CharSequence s,
@NonNegative int start, @NonNegative int end)
{
Expand All @@ -402,7 +378,6 @@ public StringBuilder insert(@NonNegative int dstOffset, @Nullable CharSequence s
* @throws StringIndexOutOfBoundsException {@inheritDoc}
*/
@Override
@SideEffectsOnly("this")
public StringBuilder insert(@NonNegative int offset, boolean b) {
super.insert(offset, b);
return this;
Expand All @@ -412,7 +387,6 @@ public StringBuilder insert(@NonNegative int offset, boolean b) {
* @throws IndexOutOfBoundsException {@inheritDoc}
*/
@Override
@SideEffectsOnly("this")
public StringBuilder insert(@NonNegative int offset, char c) {
super.insert(offset, c);
return this;
Expand All @@ -422,7 +396,6 @@ public StringBuilder insert(@NonNegative int offset, char c) {
* @throws StringIndexOutOfBoundsException {@inheritDoc}
*/
@Override
@SideEffectsOnly("this")
public StringBuilder insert(@NonNegative int offset, int i) {
super.insert(offset, i);
return this;
Expand All @@ -432,7 +405,6 @@ public StringBuilder insert(@NonNegative int offset, int i) {
* @throws StringIndexOutOfBoundsException {@inheritDoc}
*/
@Override
@SideEffectsOnly("this")
public StringBuilder insert(@NonNegative int offset, long l) {
super.insert(offset, l);
return this;
Expand All @@ -442,7 +414,6 @@ public StringBuilder insert(@NonNegative int offset, long l) {
* @throws StringIndexOutOfBoundsException {@inheritDoc}
*/
@Override
@SideEffectsOnly("this")
public StringBuilder insert(@NonNegative int offset, float f) {
super.insert(offset, f);
return this;
Expand All @@ -452,7 +423,6 @@ public StringBuilder insert(@NonNegative int offset, float f) {
* @throws StringIndexOutOfBoundsException {@inheritDoc}
*/
@Override
@SideEffectsOnly("this")
public StringBuilder insert(@NonNegative int offset, double d) {
super.insert(offset, d);
return this;
Expand Down Expand Up @@ -483,7 +453,6 @@ public StringBuilder insert(@NonNegative int offset, double d) {
}

@Override
@SideEffectsOnly("this")
public StringBuilder reverse() {
super.reverse();
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.checkerframework.checker.nonempty.qual.EnsuresNonEmptyIf;
import org.checkerframework.checker.nonempty.qual.NonEmpty;
import org.checkerframework.dataflow.qual.Pure;
import org.checkerframework.dataflow.qual.SideEffectsOnly;

import java.util.*;
import jdk.internal.vm.annotation.Stable;
Expand Down Expand Up @@ -103,7 +102,6 @@ public boolean hasNext() {
}

@Override
@SideEffectsOnly("this")
public Object next(@NonEmpty AsIterator this) {
int i = bumpIndex();
if (resolving)
Expand Down
2 changes: 0 additions & 2 deletions src/java.base/share/classes/java/net/URL.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
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 java.io.File;
Expand Down Expand Up @@ -1348,7 +1347,6 @@ public boolean hasNext() {
return getNext();
}

@SideEffectsOnly("this")
public URLStreamHandlerProvider next(/*@NonEmpty Iterator<URLStreamHandlerProvider> this*/) {
if (!getNext())
throw new NoSuchElementException();
Expand Down
2 changes: 0 additions & 2 deletions src/java.base/share/classes/java/nio/charset/Charset.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.checkerframework.checker.nonempty.qual.EnsuresNonEmptyIf;
import org.checkerframework.checker.nonempty.qual.NonEmpty;
import org.checkerframework.dataflow.qual.Pure;
import org.checkerframework.dataflow.qual.SideEffectsOnly;

import jdk.internal.misc.VM;
import sun.nio.cs.ThreadLocalCoders;
Expand Down Expand Up @@ -363,7 +362,6 @@ public boolean hasNext() {
return getNext();
}

@SideEffectsOnly("this")
public CharsetProvider next(/*@NonEmpty Iterator<CharsetProvider> this*/) {
if (!getNext())
throw new NoSuchElementException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.checkerframework.checker.nonempty.qual.EnsuresNonEmptyIf;
import org.checkerframework.checker.nonempty.qual.NonEmpty;
import org.checkerframework.dataflow.qual.Pure;
import org.checkerframework.dataflow.qual.SideEffectsOnly;

import java.io.Closeable;
import java.io.IOException;
Expand Down Expand Up @@ -112,7 +111,6 @@ public boolean hasNext() {
}

@Override
@SideEffectsOnly("this")
public Event next(@NonEmpty FileTreeIterator this) {
if (!walker.isOpen())
throw new IllegalStateException();
Expand Down
2 changes: 0 additions & 2 deletions src/java.base/share/classes/java/nio/file/Files.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.checkerframework.checker.signedness.qual.PolySigned;
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 @@ -3888,7 +3887,6 @@ public boolean hasNext() {
throw new UncheckedIOException(e.getCause());
}
}
@SideEffectsOnly("this")
@Override
public Path next(/*@NonEmpty Iterator<Path> this*/) {
try {
Expand Down
Loading