Skip to content

Commit

Permalink
Revert "Add aliasing annotations (typetools#57)"
Browse files Browse the repository at this point in the history
This reverts commit 4891771
  • Loading branch information
xingweitian committed Sep 29, 2020
1 parent f7e53cc commit 4013b3e
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 46 deletions.
13 changes: 6 additions & 7 deletions src/java.base/share/classes/java/lang/Exception.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.dataflow.qual.SideEffectFree;
import org.checkerframework.framework.qual.AnnotatedFor;
import org.checkerframework.common.aliasing.qual.Unique;

/**
* The class {@code Exception} and its subclasses are a form of
Expand All @@ -47,7 +46,7 @@
* @jls 11.2 Compile-Time Checking of Exceptions
* @since 1.0
*/
@AnnotatedFor({"aliasing", "nullness"})
@AnnotatedFor({"nullness"})
public class Exception extends Throwable {
static final long serialVersionUID = -3387516993124229948L;

Expand All @@ -57,7 +56,7 @@ public class Exception extends Throwable {
* call to {@link #initCause}.
*/
@SideEffectFree
public @Unique Exception() {
public Exception() {
super();
}

Expand All @@ -70,7 +69,7 @@ public class Exception extends Throwable {
* later retrieval by the {@link #getMessage()} method.
*/
@SideEffectFree
public @Unique Exception(@Nullable String message) {
public Exception(@Nullable String message) {
super(message);
}

Expand All @@ -89,7 +88,7 @@ public class Exception extends Throwable {
* @since 1.4
*/
@SideEffectFree
public @Unique Exception(@Nullable String message, @Nullable Throwable cause) {
public Exception(@Nullable String message, @Nullable Throwable cause) {
super(message, cause);
}

Expand All @@ -108,7 +107,7 @@ public class Exception extends Throwable {
* @since 1.4
*/
@SideEffectFree
public @Unique Exception(@Nullable Throwable cause) {
public Exception(@Nullable Throwable cause) {
super(cause);
}

Expand All @@ -126,7 +125,7 @@ public class Exception extends Throwable {
* be writable
* @since 1.7
*/
protected @Unique Exception(@Nullable String message, @Nullable Throwable cause,
protected Exception(@Nullable String message, @Nullable Throwable cause,
boolean enableSuppression,
boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
Expand Down
33 changes: 16 additions & 17 deletions src/java.base/share/classes/java/lang/String.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
import org.checkerframework.dataflow.qual.SideEffectFree;
import org.checkerframework.framework.qual.AnnotatedFor;
import org.checkerframework.framework.qual.CFComment;
import org.checkerframework.common.aliasing.qual.Unique;

import java.io.ObjectStreamField;
import java.io.UnsupportedEncodingException;
Expand Down Expand Up @@ -154,7 +153,7 @@
* @jls 15.18.1 String Concatenation Operator +
*/

@AnnotatedFor({"aliasing", "formatter", "index", "interning", "lock", "nullness", "regex", "signature", "signedness"})
@AnnotatedFor({"formatter", "index", "interning", "lock", "nullness", "regex", "signature", "signedness", "value"})
public final class String
implements java.io.Serializable, Comparable<String>, CharSequence {

Expand Down Expand Up @@ -251,7 +250,7 @@ public final class String
*/
@SideEffectFree
@StaticallyExecutable
public @StringVal("") @Unique String() {
public @StringVal("") String() {
this.value = "".value;
this.coder = "".coder;
}
Expand All @@ -269,7 +268,7 @@ public final class String
@SideEffectFree
@StaticallyExecutable
@HotSpotIntrinsicCandidate
public @PolyValue @Unique String(@PolyValue String original) {
public @PolyValue String(@PolyValue String original) {
this.value = original.value;
this.coder = original.coder;
this.hash = original.hash;
Expand All @@ -286,7 +285,7 @@ public final class String
*/
@SideEffectFree
@StaticallyExecutable
public @PolyValue @Unique String(char value @GuardSatisfied @PolyValue []) {
public @PolyValue String(char value @GuardSatisfied @PolyValue []) {
this(value, 0, value.length, null);
}

Expand All @@ -313,7 +312,7 @@ public final class String
*/
@SideEffectFree
@StaticallyExecutable
public @Unique String(char value @GuardSatisfied [], @IndexOrHigh({"#1"}) int offset, @LTLengthOf(value={"#1"}, offset={"#2 - 1"}) @NonNegative int count) {
public String(char value @GuardSatisfied [], @IndexOrHigh({"#1"}) int offset, @LTLengthOf(value={"#1"}, offset={"#2 - 1"}) @NonNegative int count) {
this(value, offset, count, rangeCheck(value, offset, count));
}

Expand Down Expand Up @@ -352,7 +351,7 @@ private static Void rangeCheck(char[] value, int offset, int count) {
*/
@SideEffectFree
@StaticallyExecutable
public @Unique String(int @GuardSatisfied [] codePoints, @IndexOrHigh({"#1"}) int offset, @LTLengthOf(value={"#1"}, offset={"#2 - 1"}) @NonNegative int count) {
public String(int @GuardSatisfied [] codePoints, @IndexOrHigh({"#1"}) int offset, @LTLengthOf(value={"#1"}, offset={"#2 - 1"}) @NonNegative int count) {
checkBoundsOffCount(offset, count, codePoints.length);
if (count == 0) {
this.value = "".value;
Expand Down Expand Up @@ -414,7 +413,7 @@ private static Void rangeCheck(char[] value, int offset, int count) {
@SideEffectFree
@StaticallyExecutable
@Deprecated(since="1.1")
public @Unique String(byte ascii @GuardSatisfied [], int hibyte, @IndexOrHigh({"#1"}) int offset, @LTLengthOf(value={"#1"}, offset={"#2 - 1"}) @NonNegative int count) {
public String(byte ascii @GuardSatisfied [], int hibyte, @IndexOrHigh({"#1"}) int offset, @LTLengthOf(value={"#1"}, offset={"#2 - 1"}) @NonNegative int count) {
checkBoundsOffCount(offset, count, ascii.length);
if (count == 0) {
this.value = "".value;
Expand Down Expand Up @@ -468,7 +467,7 @@ private static Void rangeCheck(char[] value, int offset, int count) {
@SideEffectFree
@StaticallyExecutable
@Deprecated(since="1.1")
public @Unique String(byte ascii @GuardSatisfied [], int hibyte) {
public String(byte ascii @GuardSatisfied [], int hibyte) {
this(ascii, hibyte, 0, ascii.length);
}

Expand Down Expand Up @@ -507,7 +506,7 @@ private static Void rangeCheck(char[] value, int offset, int count) {
*/
@SideEffectFree
@StaticallyExecutable
public @Unique String(@PolySigned byte bytes @GuardSatisfied [], @IndexOrHigh({"#1"}) int offset, @LTLengthOf(value={"#1"}, offset={"#2 - 1"}) @NonNegative int length, String charsetName)
public String(@PolySigned byte bytes @GuardSatisfied [], @IndexOrHigh({"#1"}) int offset, @LTLengthOf(value={"#1"}, offset={"#2 - 1"}) @NonNegative int length, String charsetName)
throws UnsupportedEncodingException {
if (charsetName == null)
throw new NullPointerException("charsetName");
Expand Down Expand Up @@ -550,7 +549,7 @@ private static Void rangeCheck(char[] value, int offset, int count) {
*/
@SideEffectFree
@StaticallyExecutable
public @Unique String(@PolySigned byte bytes @GuardSatisfied [], @IndexOrHigh({"#1"}) int offset, @LTLengthOf(value={"#1"}, offset={"#2 - 1"}) @NonNegative int length, Charset charset) {
public String(@PolySigned byte bytes @GuardSatisfied [], @IndexOrHigh({"#1"}) int offset, @LTLengthOf(value={"#1"}, offset={"#2 - 1"}) @NonNegative int length, Charset charset) {
if (charset == null)
throw new NullPointerException("charset");
checkBoundsOffCount(offset, length, bytes.length);
Expand Down Expand Up @@ -585,7 +584,7 @@ private static Void rangeCheck(char[] value, int offset, int count) {
*/
@SideEffectFree
@StaticallyExecutable
public @Unique String(@PolySigned byte bytes @GuardSatisfied [], String charsetName)
public String(@PolySigned byte bytes @GuardSatisfied [], String charsetName)
throws UnsupportedEncodingException {
this(bytes, 0, bytes.length, charsetName);
}
Expand All @@ -612,7 +611,7 @@ private static Void rangeCheck(char[] value, int offset, int count) {
*/
@SideEffectFree
@StaticallyExecutable
public @Unique String(@PolySigned byte bytes @GuardSatisfied [], Charset charset) {
public String(@PolySigned byte bytes @GuardSatisfied [], Charset charset) {
this(bytes, 0, bytes.length, charset);
}

Expand Down Expand Up @@ -644,7 +643,7 @@ private static Void rangeCheck(char[] value, int offset, int count) {
*/
@SideEffectFree
@StaticallyExecutable
public @Unique String(@PolySigned byte bytes @GuardSatisfied [], @IndexOrHigh({"#1"}) int offset, @LTLengthOf(value={"#1"}, offset={"#2 - 1"}) @NonNegative int length) {
public String(@PolySigned byte bytes @GuardSatisfied [], @IndexOrHigh({"#1"}) int offset, @LTLengthOf(value={"#1"}, offset={"#2 - 1"}) @NonNegative int length) {
checkBoundsOffCount(offset, length, bytes.length);
StringCoding.Result ret = StringCoding.decode(bytes, offset, length);
this.value = ret.value;
Expand All @@ -669,7 +668,7 @@ private static Void rangeCheck(char[] value, int offset, int count) {
*/
@SideEffectFree
@StaticallyExecutable
public @Unique String(@PolySigned byte @GuardSatisfied [] bytes) {
public String(@PolySigned byte @GuardSatisfied [] bytes) {
this(bytes, 0, bytes.length);
}

Expand All @@ -684,7 +683,7 @@ private static Void rangeCheck(char[] value, int offset, int count) {
*/
@SideEffectFree
@StaticallyExecutable
public @Unique String(@GuardSatisfied StringBuffer buffer) {
public String(@GuardSatisfied StringBuffer buffer) {
this(buffer.toString());
}

Expand All @@ -705,7 +704,7 @@ private static Void rangeCheck(char[] value, int offset, int count) {
*/
@SideEffectFree
@StaticallyExecutable
public @Unique String(@GuardSatisfied StringBuilder builder) {
public String(@GuardSatisfied StringBuilder builder) {
this(builder, null);
}

Expand Down
41 changes: 19 additions & 22 deletions src/java.base/share/classes/java/lang/StringBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@
import org.checkerframework.dataflow.qual.Pure;
import org.checkerframework.dataflow.qual.SideEffectFree;
import org.checkerframework.framework.qual.AnnotatedFor;
import org.checkerframework.common.aliasing.qual.Unique;
import org.checkerframework.common.aliasing.qual.LeakedToResult;
import org.checkerframework.common.aliasing.qual.NonLeaked;

import java.util.Arrays;
import jdk.internal.HotSpotIntrinsicCandidate;
Expand Down Expand Up @@ -115,7 +112,7 @@
* @see java.lang.String
* @since 1.0
*/
@AnnotatedFor({"aliasing", "lock", "nullness", "index"})
@AnnotatedFor({"lock", "nullness", "index"})
public final class StringBuffer
extends AbstractStringBuilder
implements java.io.Serializable, Comparable<StringBuffer>, CharSequence
Expand All @@ -135,7 +132,7 @@ public final class StringBuffer
* initial capacity of 16 characters.
*/
@HotSpotIntrinsicCandidate
public @Unique StringBuffer() {
public StringBuffer() {
super(16);
}

Expand All @@ -148,7 +145,7 @@ public final class StringBuffer
* argument is less than {@code 0}.
*/
@HotSpotIntrinsicCandidate
public @Unique StringBuffer(@NonNegative int capacity) {
public StringBuffer(@NonNegative int capacity) {
super(capacity);
}

Expand All @@ -160,7 +157,7 @@ public final class StringBuffer
* @param str the initial contents of the buffer.
*/
@HotSpotIntrinsicCandidate
public @Unique StringBuffer(String str) {
public StringBuffer(String str) {
super(str.length() + 16);
append(str);
}
Expand All @@ -178,7 +175,7 @@ public final class StringBuffer
* @param seq the sequence to copy.
* @since 1.5
*/
public @Unique StringBuffer(CharSequence seq) {
public StringBuffer(CharSequence seq) {
this(seq.length() + 16);
append(seq);
}
Expand Down Expand Up @@ -313,15 +310,15 @@ public synchronized void setCharAt(int index, char ch) {
}

@Override
public synchronized StringBuffer append(@LeakedToResult StringBuffer this, @NonLeaked @Nullable Object obj) {
public synchronized StringBuffer append(@Nullable Object obj) {
toStringCache = null;
super.append(String.valueOf(obj));
return this;
}

@Override
@HotSpotIntrinsicCandidate
public synchronized StringBuffer append(@LeakedToResult StringBuffer this, @NonLeaked @Nullable String str) {
public synchronized StringBuffer append(@Nullable String str) {
toStringCache = null;
super.append(str);
return this;
Expand Down Expand Up @@ -351,7 +348,7 @@ public synchronized StringBuffer append(@LeakedToResult StringBuffer this, @NonL
* @return a reference to this object.
* @since 1.4
*/
public synchronized StringBuffer append(@LeakedToResult StringBuffer this, @NonLeaked @Nullable StringBuffer sb) {
public synchronized StringBuffer append(@Nullable StringBuffer sb) {
toStringCache = null;
super.append(sb);
return this;
Expand All @@ -361,7 +358,7 @@ public synchronized StringBuffer append(@LeakedToResult StringBuffer this, @NonL
* @since 1.8
*/
@Override
synchronized StringBuffer append(@LeakedToResult StringBuffer this, @NonLeaked AbstractStringBuilder asb) {
synchronized StringBuffer append(AbstractStringBuilder asb) {
toStringCache = null;
super.append(asb);
return this;
Expand Down Expand Up @@ -389,7 +386,7 @@ synchronized StringBuffer append(@LeakedToResult StringBuffer this, @NonLeaked A
* @since 1.5
*/
@Override
public synchronized StringBuffer append(@LeakedToResult StringBuffer this, @NonLeaked @Nullable CharSequence s) {
public synchronized StringBuffer append(@Nullable CharSequence s) {
toStringCache = null;
super.append(s);
return this;
Expand All @@ -400,15 +397,15 @@ public synchronized StringBuffer append(@LeakedToResult StringBuffer this, @NonL
* @since 1.5
*/
@Override
public synchronized StringBuffer append(@LeakedToResult StringBuffer this, @NonLeaked @Nullable CharSequence s, @IndexOrHigh({"#1"}) int start, @IndexOrHigh({"#1"}) int end)
public synchronized StringBuffer append(@Nullable CharSequence s, @IndexOrHigh({"#1"}) int start, @IndexOrHigh({"#1"}) int end)
{
toStringCache = null;
super.append(s, start, end);
return this;
}

@Override
public synchronized StringBuffer append(@LeakedToResult StringBuffer this, @NonLeaked char[] str) {
public synchronized StringBuffer append(char[] str) {
toStringCache = null;
super.append(str);
return this;
Expand All @@ -418,30 +415,30 @@ public synchronized StringBuffer append(@LeakedToResult StringBuffer this, @NonL
* @throws IndexOutOfBoundsException {@inheritDoc}
*/
@Override
public synchronized StringBuffer append(@LeakedToResult StringBuffer this, @NonLeaked char[] str, @IndexOrHigh({"#1"}) int offset, @IndexOrHigh({"#1"}) int len) {
public synchronized StringBuffer append(char[] str, @IndexOrHigh({"#1"}) int offset, @IndexOrHigh({"#1"}) int len) {
toStringCache = null;
super.append(str, offset, len);
return this;
}

@Override
public synchronized StringBuffer append(@LeakedToResult StringBuffer this, @NonLeaked boolean b) {
public synchronized StringBuffer append(boolean b) {
toStringCache = null;
super.append(b);
return this;
}

@Override
@HotSpotIntrinsicCandidate
public synchronized StringBuffer append(@LeakedToResult StringBuffer this, @NonLeaked char c) {
public synchronized StringBuffer append(char c) {
toStringCache = null;
super.append(c);
return this;
}

@Override
@HotSpotIntrinsicCandidate
public synchronized StringBuffer append(@LeakedToResult StringBuffer this, @NonLeaked int i) {
public synchronized StringBuffer append(int i) {
toStringCache = null;
super.append(i);
return this;
Expand All @@ -458,21 +455,21 @@ public synchronized StringBuffer appendCodePoint(int codePoint) {
}

@Override
public synchronized StringBuffer append(@LeakedToResult StringBuffer this, @NonLeaked long lng) {
public synchronized StringBuffer append(long lng) {
toStringCache = null;
super.append(lng);
return this;
}

@Override
public synchronized StringBuffer append(@LeakedToResult StringBuffer this, @NonLeaked float f) {
public synchronized StringBuffer append(float f) {
toStringCache = null;
super.append(f);
return this;
}

@Override
public synchronized StringBuffer append(@LeakedToResult StringBuffer this, @NonLeaked double d) {
public synchronized StringBuffer append(double d) {
toStringCache = null;
super.append(d);
return this;
Expand Down

0 comments on commit 4013b3e

Please sign in to comment.