diff --git a/src/java.base/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java b/src/java.base/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java index 43f0bf448010..c8cfa35f41b3 100644 --- a/src/java.base/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java +++ b/src/java.base/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java @@ -168,6 +168,7 @@ public int hashCode() { prf.getAlgorithm().toLowerCase(Locale.ENGLISH).hashCode(); } @Override + @Pure public boolean equals(Object obj) { if (this == obj) return true; if (this.getClass() != obj.getClass()) return false; diff --git a/src/java.base/share/classes/java/io/FileSystem.java b/src/java.base/share/classes/java/io/FileSystem.java index 559f38a1c460..11d62fc17c2d 100644 --- a/src/java.base/share/classes/java/io/FileSystem.java +++ b/src/java.base/share/classes/java/io/FileSystem.java @@ -28,6 +28,7 @@ import org.checkerframework.checker.index.qual.IndexOrHigh; import org.checkerframework.checker.interning.qual.UsesObjectEquals; import org.checkerframework.checker.signedness.qual.SignedPositive; +import org.checkerframework.dataflow.qual.Pure; import org.checkerframework.framework.qual.AnnotatedFor; import java.lang.annotation.Native; @@ -242,6 +243,7 @@ public abstract boolean createFileExclusively(String pathname) /** * Compare two abstract pathnames lexicographically. */ + @Pure public abstract int compare(File f1, File f2); /** diff --git a/src/java.base/share/classes/java/io/InvalidClassException.java b/src/java.base/share/classes/java/io/InvalidClassException.java index 019d16e87b79..bf70b7be9a15 100644 --- a/src/java.base/share/classes/java/io/InvalidClassException.java +++ b/src/java.base/share/classes/java/io/InvalidClassException.java @@ -107,6 +107,7 @@ public InvalidClassException(String cname, @Nullable String reason, @Nullable Th /** * Produce the message and include the classname, if present. */ + @SideEffectFree @Override public String getMessage() { if (classname == null) diff --git a/src/java.base/share/classes/java/io/ObjectStreamClass.java b/src/java.base/share/classes/java/io/ObjectStreamClass.java index b61adb2344a2..bf8e58420d02 100644 --- a/src/java.base/share/classes/java/io/ObjectStreamClass.java +++ b/src/java.base/share/classes/java/io/ObjectStreamClass.java @@ -28,6 +28,7 @@ import org.checkerframework.checker.lock.qual.GuardSatisfied; import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.signature.qual.BinaryName; +import org.checkerframework.dataflow.qual.Pure; import org.checkerframework.dataflow.qual.SideEffectFree; import org.checkerframework.framework.qual.AnnotatedFor; @@ -1779,6 +1780,7 @@ private static long computeDefaultSUID(Class cl) { fieldSigs[i] = new MemberSignature(fields[i]); } Arrays.sort(fieldSigs, new Comparator<>() { + @Pure public int compare(MemberSignature ms1, MemberSignature ms2) { return ms1.name.compareTo(ms2.name); } @@ -1810,6 +1812,7 @@ public int compare(MemberSignature ms1, MemberSignature ms2) { consSigs[i] = new MemberSignature(cons[i]); } Arrays.sort(consSigs, new Comparator<>() { + @Pure public int compare(MemberSignature ms1, MemberSignature ms2) { return ms1.signature.compareTo(ms2.signature); } @@ -1833,6 +1836,7 @@ public int compare(MemberSignature ms1, MemberSignature ms2) { methSigs[i] = new MemberSignature(methods[i]); } Arrays.sort(methSigs, new Comparator<>() { + @Pure public int compare(MemberSignature ms1, MemberSignature ms2) { int comp = ms1.name.compareTo(ms2.name); if (comp == 0) { @@ -2166,6 +2170,7 @@ public int hashCode() { return hash; } + @Pure public boolean equals(@Nullable Object obj) { return obj == this || obj instanceof FieldReflectorKey other && @@ -2294,6 +2299,7 @@ public final int hashCode() { } @Override + @Pure public final boolean equals(@Nullable Object obj) { if (!(obj instanceof Key other)) return false; int n = length(); diff --git a/src/java.base/share/classes/java/io/OptionalDataException.java b/src/java.base/share/classes/java/io/OptionalDataException.java index e62169b36fd9..f2877d784a2a 100644 --- a/src/java.base/share/classes/java/io/OptionalDataException.java +++ b/src/java.base/share/classes/java/io/OptionalDataException.java @@ -24,6 +24,7 @@ */ package java.io; +import org.checkerframework.dataflow.qual.SideEffectFree; import org.checkerframework.framework.qual.AnnotatedFor; /** @@ -55,6 +56,7 @@ public class OptionalDataException extends ObjectStreamException { /* * Create an {@code OptionalDataException} with a length. */ + @SideEffectFree OptionalDataException(int len) { eof = false; length = len; @@ -64,6 +66,7 @@ public class OptionalDataException extends ObjectStreamException { * Create an {@code OptionalDataException} signifying no * more primitive data is available. */ + @SideEffectFree OptionalDataException(boolean end) { length = 0; eof = end; diff --git a/src/java.base/share/classes/java/io/UncheckedIOException.java b/src/java.base/share/classes/java/io/UncheckedIOException.java index 95df66d87efd..770cbd8bdbe0 100644 --- a/src/java.base/share/classes/java/io/UncheckedIOException.java +++ b/src/java.base/share/classes/java/io/UncheckedIOException.java @@ -25,6 +25,7 @@ package java.io; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; import org.checkerframework.dataflow.qual.SideEffectFree; import org.checkerframework.framework.qual.AnnotatedFor; @@ -75,6 +76,7 @@ public UncheckedIOException(IOException cause) { * * @return the {@code IOException} which is the cause of this exception. */ + @Pure @Override public IOException getCause() { return (IOException) super.getCause(); diff --git a/src/java.base/share/classes/java/io/WriteAbortedException.java b/src/java.base/share/classes/java/io/WriteAbortedException.java index 8df49ea0d7e3..af7ea04b5581 100644 --- a/src/java.base/share/classes/java/io/WriteAbortedException.java +++ b/src/java.base/share/classes/java/io/WriteAbortedException.java @@ -26,6 +26,7 @@ package java.io; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; import org.checkerframework.dataflow.qual.SideEffectFree; import org.checkerframework.framework.qual.AnnotatedFor; @@ -74,6 +75,7 @@ public WriteAbortedException(@Nullable String s, @Nullable Exception ex) { * Produce the message and include the message from the nested * exception, if there is one. */ + @SideEffectFree public String getMessage() { if (detail == null) return super.getMessage(); @@ -88,6 +90,7 @@ public String getMessage() { * which may be null. * @since 1.4 */ + @Pure @Override public @Nullable Throwable getCause() { return detail; diff --git a/src/java.base/share/classes/java/lang/Class.java b/src/java.base/share/classes/java/lang/Class.java index 4353f31e9d74..23e592999c26 100644 --- a/src/java.base/share/classes/java/lang/Class.java +++ b/src/java.base/share/classes/java/lang/Class.java @@ -333,6 +333,7 @@ public String toString(@GuardSatisfied Class this) { * * @since 1.8 */ + @SideEffectFree public String toGenericString() { if (isPrimitive()) { return toString(); @@ -439,6 +440,7 @@ static String typeVarBounds(TypeVariable typeVar) { */ @ForName @CallerSensitive + @SideEffectFree public static Class forName(@ClassGetName String className) throws ClassNotFoundException { Class caller = Reflection.getCallerClass(); @@ -447,6 +449,7 @@ public static Class forName(@ClassGetName String className) // Caller-sensitive adapter method for reflective invocation @CallerSensitiveAdapter + @SideEffectFree private static Class forName(String className, Class caller) throws ClassNotFoundException { ClassLoader loader = (caller == null) ? ClassLoader.getSystemClassLoader() @@ -523,6 +526,7 @@ private static Class forName(String className, Class caller) * @since 1.2 */ @CallerSensitive + @SideEffectFree public static Class forName(@ClassGetName String name, boolean initialize, @Nullable ClassLoader loader) throws ClassNotFoundException @@ -540,6 +544,7 @@ public static Class forName(@ClassGetName String name, boolean initialize, // Caller-sensitive adapter method for reflective invocation @CallerSensitiveAdapter + @SideEffectFree private static Class forName(String name, boolean initialize, ClassLoader loader, Class caller) throws ClassNotFoundException { @@ -614,6 +619,7 @@ private static native Class forName0(String name, boolean initialize, */ @SuppressWarnings("removal") @CallerSensitive + @SideEffectFree public static Class forName(Module module, String name) { Class caller = null; SecurityManager sm = System.getSecurityManager(); @@ -626,6 +632,7 @@ public static Class forName(Module module, String name) { // Caller-sensitive adapter method for reflective invocation @SuppressWarnings("removal") @CallerSensitiveAdapter + @SideEffectFree private static Class forName(Module module, String name, Class caller) { Objects.requireNonNull(module); Objects.requireNonNull(name); @@ -707,6 +714,7 @@ private static Class forName(Module module, String name, Class caller) { @SuppressWarnings("removal") @CallerSensitive @Deprecated(since="9") + @SideEffectFree public @NonNull T newInstance() throws InstantiationException, IllegalAccessException { @@ -1037,6 +1045,7 @@ public boolean isSynthetic(@GuardSatisfied Class this) { * * @since 9 */ + @Pure public Module getModule() { return module; } @@ -1053,6 +1062,7 @@ public Module getModule() { private transient Object classData; // package-private + @Pure Object getClassData() { return classData; } @@ -1072,6 +1082,7 @@ Object getClassData() { * The Java Virtual Machine Specification * @since 1.5 */ + @SideEffectFree @SuppressWarnings("unchecked") public TypeVariable>[] getTypeParameters() { ClassRepository info = getGenericInfo(); @@ -1128,6 +1139,7 @@ public TypeVariable>[] getTypeParameters() { * @return the direct superclass of the class represented by this {@code Class} object * @since 1.5 */ + @SideEffectFree public @Nullable Type getGenericSuperclass() { ClassRepository info = getGenericInfo(); if (info == null) { @@ -1189,6 +1201,7 @@ public TypeVariable>[] getTypeParameters() { * @since 9 * @jls 6.7 Fully Qualified Names */ + @Pure public @DotSeparatedIdentifiers String getPackageName() { String pn = this.packageName; if (pn == null) { @@ -1324,6 +1337,7 @@ private Class[] getInterfaces(boolean cloneArray) { * @return an array of interfaces directly implemented by this class * @since 1.5 */ + @SideEffectFree public Type[] getGenericInterfaces() { ClassRepository info = getGenericInfo(); return (info == null) ? getInterfaces() : info.getSuperInterfaces(); @@ -1432,6 +1446,7 @@ private Class elementType() { * @jvms 4.7.6 The InnerClasses Attribute * @since 20 */ + @SideEffectFree public Set accessFlags() { // Location.CLASS allows SUPER and AccessFlag.MODULE which // INNER_CLASS forbids. INNER_CLASS allows PRIVATE, PROTECTED, @@ -1455,6 +1470,7 @@ public Set accessFlags() { * a primitive type or void. * @since 1.1 */ + @SideEffectFree public native Object @Nullable [] getSigners(); @@ -1501,6 +1517,7 @@ public Set accessFlags() { * @since 1.5 */ @CallerSensitive + @SideEffectFree public @Nullable Method getEnclosingMethod() throws SecurityException { EnclosingMethodInfo enclosingInfo = getEnclosingMethodInfo(); @@ -1659,6 +1676,7 @@ private static Class toClass(Type o) { * @since 1.5 */ @CallerSensitive + @SideEffectFree public @Nullable Constructor getEnclosingConstructor() throws SecurityException { EnclosingMethodInfo enclosingInfo = getEnclosingMethodInfo(); @@ -1725,6 +1743,7 @@ private static Class toClass(Type o) { * @since 1.1 */ @CallerSensitive + @Pure public @Nullable Class getDeclaringClass() throws SecurityException { final Class candidate = getDeclaringClass0(); @@ -1739,6 +1758,7 @@ private static Class toClass(Type o) { return candidate; } + @Pure private native Class getDeclaringClass0(); @@ -1810,6 +1830,7 @@ private static Class toClass(Type o) { * @return the simple name of the underlying class * @since 1.5 */ + @Pure public @ClassGetSimpleName String getSimpleName() { if (isUnnamedClass()) { return ""; @@ -1840,6 +1861,7 @@ private String getSimpleName0() { * @return an informative string for the name of this class or interface * @since 1.8 */ + @SideEffectFree public String getTypeName() { if (isArray()) { try { @@ -1882,6 +1904,7 @@ public String getTypeName() { * @jls 6.7 Fully Qualified Names and Canonical Names * @since 1.5 */ + @Pure public @Nullable @CanonicalName String getCanonicalName() { if (isUnnamedClass()) { return null; @@ -1934,6 +1957,7 @@ private String getCanonicalName0() { */ @PreviewFeature(feature=PreviewFeature.Feature.UNNAMED_CLASSES, reflective=true) + @Pure public boolean isUnnamedClass() { return PreviewFeatures.isEnabled() && isSynthetic() && isTopLevelClass() @@ -2056,6 +2080,7 @@ private boolean hasEnclosingMethodInfo() { */ @SuppressWarnings("removal") @CallerSensitive + @SideEffectFree public Class[] getClasses() { SecurityManager sm = System.getSecurityManager(); if (sm != null) { @@ -2125,6 +2150,7 @@ public Class[] run() { * @jls 8.3 Field Declarations */ @CallerSensitive + @SideEffectFree public Field[] getFields() throws SecurityException { @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); @@ -2216,6 +2242,7 @@ public Field[] getFields() throws SecurityException { * @since 1.1 */ @CallerSensitive + @SideEffectFree public Method[] getMethods() throws SecurityException { @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); @@ -2258,6 +2285,7 @@ public Method[] getMethods() throws SecurityException { * @since 1.1 */ @CallerSensitive + @SideEffectFree public Constructor[] getConstructors() throws SecurityException { @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); @@ -2311,6 +2339,7 @@ public Constructor[] getConstructors() throws SecurityException { * @jls 8.3 Field Declarations */ @CallerSensitive + @SideEffectFree public Field getField(String name) throws NoSuchFieldException, SecurityException { Objects.requireNonNull(name); @@ -2421,7 +2450,7 @@ public Field getField(String name) * @jls 8.4 Method Declarations * @since 1.1 */ - @Pure + @SideEffectFree @GetMethod @CallerSensitive public Method getMethod(String name, Class @Nullable ... parameterTypes) @@ -2472,7 +2501,7 @@ public Method getMethod(String name, Class @Nullable ... parameterTypes) * @since 1.1 */ @GetConstructor - @Pure + @SideEffectFree @CallerSensitive public Constructor getConstructor(Class... parameterTypes) throws NoSuchMethodException, SecurityException @@ -2524,6 +2553,7 @@ public Constructor getConstructor(Class... parameterTypes) * @jls 8.5 Member Type Declarations */ @CallerSensitive + @SideEffectFree public Class[] getDeclaredClasses() throws SecurityException { @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); @@ -2577,6 +2607,7 @@ public Class[] getDeclaredClasses() throws SecurityException { * @jls 8.3 Field Declarations */ @CallerSensitive + @SideEffectFree public Field[] getDeclaredFields() throws SecurityException { @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); @@ -2639,6 +2670,7 @@ public Field[] getDeclaredFields() throws SecurityException { * @since 16 */ @CallerSensitive + @SideEffectFree public RecordComponent[] getRecordComponents() { @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); @@ -2711,6 +2743,7 @@ public RecordComponent[] getRecordComponents() { * @since 1.1 */ @CallerSensitive + @SideEffectFree public Method[] getDeclaredMethods() throws SecurityException { @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); @@ -2762,6 +2795,7 @@ public Method[] getDeclaredMethods() throws SecurityException { * @jls 8.8 Constructor Declarations */ @CallerSensitive + @SideEffectFree public Constructor[] getDeclaredConstructors() throws SecurityException { @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); @@ -2813,6 +2847,7 @@ public Constructor[] getDeclaredConstructors() throws SecurityException { * @jls 8.3 Field Declarations */ @CallerSensitive + @SideEffectFree public Field getDeclaredField(String name) throws NoSuchFieldException, SecurityException { Objects.requireNonNull(name); @@ -2880,6 +2915,7 @@ public Field getDeclaredField(String name) */ @GetMethod @CallerSensitive + @SideEffectFree public Method getDeclaredMethod(String name, Class... parameterTypes) throws NoSuchMethodException, SecurityException { Objects.requireNonNull(name); @@ -2905,6 +2941,7 @@ public Method getDeclaredMethod(String name, Class... parameterTypes) * @return the list of {@code Method} objects for the public methods of * this class matching the specified name and parameters */ + @SideEffectFree List getDeclaredPublicMethods(String name, Class... parameterTypes) { Method[] methods = privateGetDeclaredMethods(/* publicOnly */ true); ReflectionFactory factory = getReflectionFactory(); @@ -2962,6 +2999,7 @@ List getDeclaredPublicMethods(String name, Class... parameterTypes) { * @since 1.1 */ @CallerSensitive + @SideEffectFree public Constructor getDeclaredConstructor(Class... parameterTypes) throws NoSuchMethodException, SecurityException { @@ -3127,6 +3165,7 @@ public Constructor getDeclaredConstructor(Class... parameterTypes) * @revised 9 */ @CallerSensitive + @SideEffectFree public @Nullable URL getResource(String name) { name = resolveName(name); @@ -3211,6 +3250,7 @@ private boolean isOpenToCaller(String name, Class caller) { * @see java.lang.RuntimePermission * @since 1.2 */ + @SideEffectFree public java.security.ProtectionDomain getProtectionDomain() { @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); @@ -4033,6 +4073,7 @@ private static ReflectionFactory getReflectionFactory() { * @since 1.5 * @jls 8.9.1 Enum Constants */ + @SideEffectFree public @NonNull T @Nullable [] getEnumConstants() { T[] values = getEnumConstantsShared(); return (values != null) ? values.clone() : null; @@ -4110,6 +4151,7 @@ public Void run() { */ @SuppressWarnings("unchecked") @IntrinsicCandidate + @SideEffectFree public @PolyNull @Signed T cast(@PolyNull Object obj) { if (obj != null && !isInstance(obj)) throw new ClassCastException(cannotCastMsg(obj)); @@ -4143,6 +4185,7 @@ private String cannotCastMsg(Object obj) { * @since 1.5 */ @SuppressWarnings("unchecked") + @SideEffectFree public Class asSubclass(Class clazz) { if (clazz.isAssignableFrom(this)) return (Class) this; @@ -4160,6 +4203,7 @@ public Class asSubclass(Class clazz) { */ @Override @SuppressWarnings("unchecked") + @Pure public @Nullable A getAnnotation(Class annotationClass) { Objects.requireNonNull(annotationClass); @@ -4186,6 +4230,7 @@ public boolean isAnnotationPresent(@GuardSatisfied Class this, @GuardSatisfie * @since 1.8 */ @Override + @SideEffectFree public A[] getAnnotationsByType(Class annotationClass) { Objects.requireNonNull(annotationClass); @@ -4203,6 +4248,7 @@ public A[] getAnnotationsByType(Class annotationClass) * @since 1.5 */ @Override + @SideEffectFree public Annotation[] getAnnotations() { return AnnotationParser.toArray(annotationData().annotations); } @@ -4217,6 +4263,7 @@ public Annotation[] getAnnotations() { */ @Override @SuppressWarnings("unchecked") + @Pure public @Nullable A getDeclaredAnnotation(Class annotationClass) { Objects.requireNonNull(annotationClass); @@ -4232,6 +4279,7 @@ public Annotation[] getAnnotations() { * @since 1.8 */ @Override + @SideEffectFree public A[] getDeclaredAnnotationsByType(Class annotationClass) { Objects.requireNonNull(annotationClass); @@ -4247,6 +4295,7 @@ public A[] getDeclaredAnnotationsByType(Class annotati * @since 1.5 */ @Override + @SideEffectFree public Annotation[] getDeclaredAnnotations() { return AnnotationParser.toArray(annotationData().declaredAnnotations); } diff --git a/src/java.base/share/classes/java/lang/Enum.java b/src/java.base/share/classes/java/lang/Enum.java index 967fa47b1db0..c898b951d458 100644 --- a/src/java.base/share/classes/java/lang/Enum.java +++ b/src/java.base/share/classes/java/lang/Enum.java @@ -140,6 +140,7 @@ public abstract class Enum> * * @return the ordinal of this enumeration constant */ + @Pure public final @NonNegative int ordinal() { return ordinal; } @@ -233,6 +234,7 @@ protected final Object clone(@GuardSatisfied Enum this) throws CloneNotSuppor * method is the order in which the constants are declared. */ @SuppressWarnings({"rawtypes"}) + @Pure public final int compareTo(@UnknownKeyFor @Tainted E o) { Enum other = o; Enum self = this; @@ -254,6 +256,7 @@ public final int compareTo(@UnknownKeyFor @Tainted E o) { * @return the Class object corresponding to this enum constant's * enum type */ + @Pure @SuppressWarnings("unchecked") public final Class<@Tainted E> getDeclaringClass() { Class clazz = getClass(); @@ -270,6 +273,7 @@ public final int compareTo(@UnknownKeyFor @Tainted E o) { * @since 12 */ @Override + @SideEffectFree public final Optional> describeConstable() { return getDeclaringClass() .describeConstable() @@ -303,6 +307,7 @@ public final Optional> describeConstable() { * is null * @since 1.5 */ + @Pure public static > @PolyValue T valueOf(Class enumClass, @PolyValue String name) { T result = enumClass.enumConstantDirectory().get(name); @@ -373,6 +378,7 @@ private EnumDesc(ClassDesc constantClass, String constantName) { * @jvms 4.2.2 Unqualified Names * @since 12 */ + @SideEffectFree public static> EnumDesc of(ClassDesc enumClass, String constantName) { return new EnumDesc<>(enumClass, constantName); @@ -380,11 +386,13 @@ public static> EnumDesc of(ClassDesc enumClass, @Override @SuppressWarnings("unchecked") + @Pure public E resolveConstantDesc(MethodHandles.Lookup lookup) throws ReflectiveOperationException { return Enum.valueOf((Class) constantType().resolveConstantDesc(lookup), constantName()); } + @SideEffectFree @Override public String toString() { return String.format("EnumDesc[%s.%s]", constantType().displayName(), constantName()); diff --git a/src/java.base/share/classes/java/lang/NullPointerException.java b/src/java.base/share/classes/java/lang/NullPointerException.java index c63c9bf7933c..0c17de328c51 100644 --- a/src/java.base/share/classes/java/lang/NullPointerException.java +++ b/src/java.base/share/classes/java/lang/NullPointerException.java @@ -26,6 +26,7 @@ package java.lang; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; import org.checkerframework.dataflow.qual.SideEffectFree; import org.checkerframework.framework.qual.AnnotatedFor; @@ -113,6 +114,7 @@ public synchronized Throwable fillInStackTrace() { * * @return the detail message string, which may be {@code null}. */ + @Pure public String getMessage() { String message = super.getMessage(); if (message == null) { diff --git a/src/java.base/share/classes/java/lang/NumberFormatException.java b/src/java.base/share/classes/java/lang/NumberFormatException.java index c6e3607a41e4..d37b25a8386c 100644 --- a/src/java.base/share/classes/java/lang/NumberFormatException.java +++ b/src/java.base/share/classes/java/lang/NumberFormatException.java @@ -26,6 +26,7 @@ package java.lang; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.SideEffectFree; import org.checkerframework.framework.qual.AnnotatedFor; /** @@ -44,6 +45,7 @@ public class NumberFormatException extends IllegalArgumentException { /** * Constructs a {@code NumberFormatException} with no detail message. */ + @SideEffectFree public NumberFormatException () { super(); } @@ -54,6 +56,7 @@ public NumberFormatException () { * * @param s the detail message. */ + @SideEffectFree public NumberFormatException (@Nullable String s) { super (s); } diff --git a/src/java.base/share/classes/java/lang/ProcessBuilder.java b/src/java.base/share/classes/java/lang/ProcessBuilder.java index ab47968266b7..73a4e5ce93b4 100644 --- a/src/java.base/share/classes/java/lang/ProcessBuilder.java +++ b/src/java.base/share/classes/java/lang/ProcessBuilder.java @@ -28,6 +28,7 @@ import org.checkerframework.checker.mustcall.qual.MustCall; import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.tainting.qual.Untainted; +import org.checkerframework.dataflow.qual.Pure; import org.checkerframework.framework.qual.AnnotatedFor; import jdk.internal.util.OperatingSystem; @@ -680,6 +681,7 @@ public String toString() { * instances of the same type associated with non-null equal * {@code File} instances. */ + @Pure public boolean equals(@Nullable Object obj) { if (obj == this) return true; diff --git a/src/java.base/share/classes/java/lang/ProcessHandleImpl.java b/src/java.base/share/classes/java/lang/ProcessHandleImpl.java index 0aaa9f349a49..e33840c6cb29 100644 --- a/src/java.base/share/classes/java/lang/ProcessHandleImpl.java +++ b/src/java.base/share/classes/java/lang/ProcessHandleImpl.java @@ -531,6 +531,7 @@ public ProcessHandle.Info info() { } @Override + @Pure public int compareTo(ProcessHandle other) { return Long.compare(pid, ((ProcessHandleImpl) other).pid); } diff --git a/src/java.base/share/classes/java/lang/Record.java b/src/java.base/share/classes/java/lang/Record.java index 604978b5ac9b..27a574de0e9c 100644 --- a/src/java.base/share/classes/java/lang/Record.java +++ b/src/java.base/share/classes/java/lang/Record.java @@ -27,6 +27,7 @@ import org.checkerframework.checker.lock.qual.GuardSatisfied; import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.signedness.qual.UnknownSignedness; +import org.checkerframework.dataflow.qual.Pure; /** * This is the common base class of all Java language record classes. @@ -144,6 +145,7 @@ protected Record() {} * argument; {@code false} otherwise. */ @Override + @Pure public abstract boolean equals(@GuardSatisfied Record this, @GuardSatisfied @Nullable Object obj); /** diff --git a/src/java.base/share/classes/java/lang/Runtime.java b/src/java.base/share/classes/java/lang/Runtime.java index 1928ecea698d..f1e20b4804b4 100644 --- a/src/java.base/share/classes/java/lang/Runtime.java +++ b/src/java.base/share/classes/java/lang/Runtime.java @@ -29,6 +29,7 @@ import org.checkerframework.checker.interning.qual.UsesObjectEquals; import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.tainting.qual.Untainted; +import org.checkerframework.dataflow.qual.Pure; import org.checkerframework.dataflow.qual.TerminatesExecution; import org.checkerframework.framework.qual.AnnotatedFor; @@ -1362,6 +1363,7 @@ public Optional optional() { * If the given object is {@code null} */ @Override + @Pure public int compareTo(Version obj) { return compare(obj, false); } @@ -1391,6 +1393,7 @@ public int compareToIgnoreOptional(Version obj) { return compare(obj, true); } + @Pure private int compare(Version obj, boolean ignoreOpt) { if (obj == null) throw new NullPointerException(); @@ -1516,6 +1519,7 @@ public String toString() { * */ @Override + @Pure public boolean equals(@Nullable Object obj) { boolean ret = equalsIgnoreOptional(obj); if (!ret) diff --git a/src/java.base/share/classes/java/lang/StringBuffer.java b/src/java.base/share/classes/java/lang/StringBuffer.java index eddd4aa36513..87a16fa0265b 100644 --- a/src/java.base/share/classes/java/lang/StringBuffer.java +++ b/src/java.base/share/classes/java/lang/StringBuffer.java @@ -209,7 +209,7 @@ public final class StringBuffer * * @since 11 */ - @SideEffectFree + @Pure @Override public synchronized int compareTo(StringBuffer another) { return super.compareTo(another); diff --git a/src/java.base/share/classes/java/lang/StringBuilder.java b/src/java.base/share/classes/java/lang/StringBuilder.java index ba246317b5b2..2aaa29eb4a8a 100644 --- a/src/java.base/share/classes/java/lang/StringBuilder.java +++ b/src/java.base/share/classes/java/lang/StringBuilder.java @@ -176,7 +176,7 @@ public StringBuilder(CharSequence seq) { * * @since 11 */ - @SideEffectFree + @Pure @Override public int compareTo(StringBuilder another) { return super.compareTo(another); diff --git a/src/java.base/share/classes/java/lang/StringUTF16.java b/src/java.base/share/classes/java/lang/StringUTF16.java index 64916fa73125..056045cb753a 100644 --- a/src/java.base/share/classes/java/lang/StringUTF16.java +++ b/src/java.base/share/classes/java/lang/StringUTF16.java @@ -25,6 +25,7 @@ package java.lang; +import org.checkerframework.dataflow.qual.Pure; import org.checkerframework.dataflow.qual.SideEffectsOnly; import java.util.Arrays; @@ -1374,6 +1375,7 @@ public static int getChars(long l, int begin, int end, byte[] value) { return pos; } + @Pure public static boolean contentEquals(byte[] v1, byte[] v2, int len) { checkBoundsOffCount(0, len, v2); for (int i = 0; i < len; i++) { @@ -1384,6 +1386,7 @@ public static boolean contentEquals(byte[] v1, byte[] v2, int len) { return true; } + @Pure public static boolean contentEquals(byte[] value, CharSequence cs, int len) { checkOffset(len, value); for (int i = 0; i < len; i++) { diff --git a/src/java.base/share/classes/java/lang/Throwable.java b/src/java.base/share/classes/java/lang/Throwable.java index 94b262351c64..3fc171d876d5 100644 --- a/src/java.base/share/classes/java/lang/Throwable.java +++ b/src/java.base/share/classes/java/lang/Throwable.java @@ -409,7 +409,7 @@ protected Throwable(@Nullable String message, @Nullable Throwable cause, * @return The localized description of this throwable. * @since 1.1 */ - @SideEffectFree + @Pure public @Nullable String getLocalizedMessage(@GuardSatisfied Throwable this) { return getMessage(); } @@ -871,6 +871,7 @@ public synchronized Throwable fillInStackTrace() { * pertaining to this throwable. * @since 1.4 */ + @SideEffectFree public StackTraceElement[] getStackTrace() { return getOurStackTrace().clone(); } @@ -1145,6 +1146,7 @@ public final synchronized void addSuppressed(Throwable exception) { * suppressed to deliver this exception. * @since 1.7 */ + @SideEffectFree public final synchronized Throwable[] getSuppressed() { if (suppressedExceptions == SUPPRESSED_SENTINEL || suppressedExceptions == null) diff --git a/src/java.base/share/classes/java/lang/WeakPairMap.java b/src/java.base/share/classes/java/lang/WeakPairMap.java index a570acf577bc..ba42a9b213f0 100644 --- a/src/java.base/share/classes/java/lang/WeakPairMap.java +++ b/src/java.base/share/classes/java/lang/WeakPairMap.java @@ -26,6 +26,7 @@ import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.PolyNull; +import org.checkerframework.dataflow.qual.Pure; import java.lang.ref.Reference; import java.lang.ref.ReferenceQueue; @@ -292,6 +293,7 @@ public int hashCode() { } @Override + @Pure public boolean equals(@Nullable Object obj) { return this == obj || (obj instanceof Pair && @@ -333,6 +335,7 @@ public int hashCode() { } @Override + @Pure public boolean equals(@Nullable Object obj) { return obj instanceof Pair && Pair.equals(k1, k2, (Pair) obj); diff --git a/src/java.base/share/classes/java/lang/annotation/Annotation.java b/src/java.base/share/classes/java/lang/annotation/Annotation.java index 9ec974ad96c6..28e5a91f51b8 100644 --- a/src/java.base/share/classes/java/lang/annotation/Annotation.java +++ b/src/java.base/share/classes/java/lang/annotation/Annotation.java @@ -26,6 +26,8 @@ package java.lang.annotation; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; +import org.checkerframework.dataflow.qual.SideEffectFree; import org.checkerframework.framework.qual.AnnotatedFor; /** @@ -82,6 +84,7 @@ public interface Annotation { * @return true if the specified object represents an annotation * that is logically equivalent to this one, otherwise false */ + @Pure boolean equals(@Nullable Object obj); /** @@ -116,6 +119,7 @@ public interface Annotation { * * @return the hash code of this annotation */ + @Pure int hashCode(); /** @@ -128,6 +132,7 @@ public interface Annotation { * * @return a string representation of this annotation */ + @SideEffectFree String toString(); /** @@ -142,5 +147,6 @@ public interface Annotation { * @return the annotation interface of this annotation * @see Enum#getDeclaringClass */ + @Pure Class annotationType(); } diff --git a/src/java.base/share/classes/java/lang/constant/ClassDesc.java b/src/java.base/share/classes/java/lang/constant/ClassDesc.java index 7f932cb3ea68..25e860694b24 100644 --- a/src/java.base/share/classes/java/lang/constant/ClassDesc.java +++ b/src/java.base/share/classes/java/lang/constant/ClassDesc.java @@ -26,6 +26,7 @@ import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.signature.qual.FieldDescriptor; +import org.checkerframework.dataflow.qual.Pure; import java.lang.invoke.MethodHandles; import java.lang.invoke.TypeDescriptor; @@ -377,5 +378,6 @@ else if (isArray()) { * @param o the other object * @return whether this descriptor is equal to the other object */ + @Pure boolean equals(@Nullable Object o); } diff --git a/src/java.base/share/classes/java/lang/constant/MethodTypeDesc.java b/src/java.base/share/classes/java/lang/constant/MethodTypeDesc.java index 0e3841862613..8d2bb5d34e35 100644 --- a/src/java.base/share/classes/java/lang/constant/MethodTypeDesc.java +++ b/src/java.base/share/classes/java/lang/constant/MethodTypeDesc.java @@ -26,6 +26,7 @@ import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.signature.qual.MethodDescriptor; +import org.checkerframework.dataflow.qual.Pure; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; @@ -233,5 +234,6 @@ default String displayDescriptor() { * @param o the other object * @return whether this descriptor is equal to the other object */ + @Pure boolean equals(@Nullable Object o); } diff --git a/src/java.base/share/classes/java/lang/invoke/LambdaForm.java b/src/java.base/share/classes/java/lang/invoke/LambdaForm.java index 1294e07634f1..f3e6ab84e18f 100644 --- a/src/java.base/share/classes/java/lang/invoke/LambdaForm.java +++ b/src/java.base/share/classes/java/lang/invoke/LambdaForm.java @@ -1073,6 +1073,7 @@ String debugString(int indentLevel) { public boolean equals(@Nullable Object obj) { return obj instanceof LambdaForm && equals((LambdaForm)obj); } + @Pure public boolean equals(LambdaForm that) { if (this.result != that.result) return false; return Arrays.equals(this.names, that.names); @@ -1152,6 +1153,7 @@ synchronized void resolve() { } @Override + @Pure public boolean equals(@Nullable Object other) { if (this == other) return true; if (other == null) return false; @@ -1606,6 +1608,7 @@ int useCount(Name n) { return count; } + @Pure public boolean equals(Name that) { if (this == that) return true; if (isParam()) @@ -1618,6 +1621,7 @@ public boolean equals(Name that) { Arrays.equals(this.arguments, that.arguments); } @Override + @Pure public boolean equals(@Nullable Object x) { return x instanceof Name && equals((Name)x); } diff --git a/src/java.base/share/classes/java/lang/invoke/MemberName.java b/src/java.base/share/classes/java/lang/invoke/MemberName.java index 6d9ad0cc3d3b..be0a320cc741 100644 --- a/src/java.base/share/classes/java/lang/invoke/MemberName.java +++ b/src/java.base/share/classes/java/lang/invoke/MemberName.java @@ -741,6 +741,7 @@ public boolean equals(@Nullable Object that) { * two member names resolve to the same actual member, they may * be distinct references. */ + @Pure public boolean equals(MemberName that) { if (this == that) return true; if (that == null) return false; diff --git a/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java b/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java index df5827b4447e..36707f293eb0 100644 --- a/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java +++ b/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java @@ -27,6 +27,7 @@ import org.checkerframework.checker.interning.qual.UsesObjectEquals; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; import org.checkerframework.framework.qual.AnnotatedFor; import jdk.internal.access.JavaLangInvokeAccess; @@ -2176,6 +2177,7 @@ public TableSwitchCacheKey(MethodType basicType, int numberOfCases) { } @Override + @Pure public boolean equals(@Nullable Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; diff --git a/src/java.base/share/classes/java/lang/invoke/MethodType.java b/src/java.base/share/classes/java/lang/invoke/MethodType.java index 02c7b4b208ad..67e23554789a 100644 --- a/src/java.base/share/classes/java/lang/invoke/MethodType.java +++ b/src/java.base/share/classes/java/lang/invoke/MethodType.java @@ -913,6 +913,7 @@ public boolean equals(@Nullable Object x) { return false; } + @Pure private boolean equals(MethodType that) { return this.rtype == that.rtype && Arrays.equals(this.ptypes, that.ptypes); @@ -1489,6 +1490,7 @@ public WeakEntry(T key, ReferenceQueue queue) { * @see Object#equals(Object) */ @Override + @Pure public boolean equals(@Nullable Object obj) { Object mine = get(); if (obj instanceof WeakEntry) { diff --git a/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java b/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java index 9828e81487eb..dabe26ff023e 100644 --- a/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java +++ b/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java @@ -299,6 +299,7 @@ public Optional rawCompiledVersion() { * module dependence */ @Override + @Pure public int compareTo(Requires that) { if (this == that) return 0; @@ -341,6 +342,7 @@ public int compareTo(Requires that) { * dependence that is equal to this module dependence */ @Override + @Pure public boolean equals(@Nullable Object ob) { return (ob instanceof Requires that) && name.equals(that.name) && mods.equals(that.mods) @@ -525,6 +527,7 @@ public Set targets() { * export dependence */ @Override + @Pure public int compareTo(Exports that) { if (this == that) return 0; @@ -582,6 +585,7 @@ public int hashCode() { * dependence that is equal to this module dependence */ @Override + @Pure public boolean equals(@Nullable Object ob) { return (ob instanceof Exports other) && Objects.equals(this.mods, other.mods) @@ -749,6 +753,7 @@ public Set targets() { * module {@code Opens} */ @Override + @Pure public int compareTo(Opens that) { if (this == that) return 0; @@ -806,6 +811,7 @@ public int hashCode() { * dependence that is equal to this module dependence */ @Override + @Pure public boolean equals(@Nullable Object ob) { return (ob instanceof Opens other) && Objects.equals(this.mods, other.mods) @@ -887,6 +893,7 @@ private Provides(String service, List providers, boolean unused) { * {@code Provides} is less than, equal to, or greater than * the given {@code Provides} */ + @Pure public int compareTo(Provides that) { if (this == that) return 0; @@ -940,6 +947,7 @@ public int hashCode() { * {@code Provides} that is equal to this {@code Provides} */ @Override + @Pure public boolean equals(@Nullable Object ob) { return (ob instanceof Provides other) && Objects.equals(this.service, other.service) @@ -1207,6 +1215,7 @@ private int compareTokens(List ts1, List ts2) { * given module version */ @Override + @Pure public int compareTo(Version that) { int c = compareTokens(this.sequence, that.sequence); if (c != 0) return c; @@ -1237,6 +1246,7 @@ public int compareTo(Version that) { * reference that is equal to this module reference */ @Override + @Pure public boolean equals(@Nullable Object ob) { if (!(ob instanceof Version)) return false; @@ -2259,6 +2269,7 @@ public ModuleDescriptor build() { * module descriptor */ @Override + @Pure public int compareTo(ModuleDescriptor that) { if (this == that) return 0; @@ -2647,6 +2658,7 @@ private static int modsHashCode(Iterable> enums) { return h; } + @Pure private static > int compare(T obj1, T obj2) { if (obj1 != null) { @@ -2660,6 +2672,7 @@ int compare(T obj1, T obj2) { * Compares two sets of {@code Comparable} objects. */ @SuppressWarnings("unchecked") + @Pure private static > int compare(Set s1, Set s2) { T[] a1 = (T[]) s1.toArray(); diff --git a/src/java.base/share/classes/java/lang/reflect/Constructor.java b/src/java.base/share/classes/java/lang/reflect/Constructor.java index f53fa5c09643..e719f84f1680 100644 --- a/src/java.base/share/classes/java/lang/reflect/Constructor.java +++ b/src/java.base/share/classes/java/lang/reflect/Constructor.java @@ -231,6 +231,7 @@ byte[] getAnnotationBytes() { * declares the constructor represented by this object. */ @Override + @Pure public Class getDeclaringClass() { return clazz; } @@ -240,6 +241,7 @@ public Class getDeclaringClass() { * the binary name of the constructor's declaring class. */ @Override + @Pure public String getName() { return getDeclaringClass().getName(); } @@ -249,6 +251,7 @@ public String getName() { * @jls 8.8.3 Constructor Modifiers */ @Override + @Pure public int getModifiers() { return modifiers; } @@ -260,6 +263,7 @@ public int getModifiers() { */ @Override @SuppressWarnings({"rawtypes", "unchecked"}) + @SideEffectFree public TypeVariable>[] getTypeParameters() { if (getSignature() != null) { return (TypeVariable>[])getGenericInfo().getTypeParameters(); @@ -282,6 +286,7 @@ Class[] getSharedExceptionTypes() { * {@inheritDoc} */ @Override + @SideEffectFree public Class[] getParameterTypes() { return parameterTypes.clone(); } @@ -290,6 +295,7 @@ public Class[] getParameterTypes() { * {@inheritDoc} * @since 1.8 */ + @Pure public int getParameterCount() { return parameterTypes.length; } /** @@ -300,6 +306,7 @@ public Class[] getParameterTypes() { * @since 1.5 */ @Override + @SideEffectFree public Type[] getGenericParameterTypes() { return super.getGenericParameterTypes(); } @@ -308,6 +315,7 @@ public Type[] getGenericParameterTypes() { * {@inheritDoc} */ @Override + @SideEffectFree public Class[] getExceptionTypes() { return exceptionTypes.clone(); } @@ -321,6 +329,7 @@ public Class[] getExceptionTypes() { * @since 1.5 */ @Override + @SideEffectFree public Type[] getGenericExceptionTypes() { return super.getGenericExceptionTypes(); } @@ -439,6 +448,7 @@ String toShortString() { * @jls 8.9.2 Enum Body Declarations */ @Override + @SideEffectFree public String toGenericString() { return sharedToGenericString(Modifier.constructorModifiers(), false); } @@ -499,6 +509,7 @@ void specificToGenericStringHeader(StringBuilder sb) { @NewInstance @CallerSensitive @ForceInline // to ensure Reflection.getCallerClass optimization + @SideEffectFree public @NonNull T newInstance(Object ... initargs) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException @@ -619,6 +630,7 @@ byte[] getRawParameterAnnotations() { * @since 1.5 */ @Override + @Pure public @Nullable T getAnnotation(Class annotationClass) { return super.getAnnotation(annotationClass); } @@ -628,6 +640,7 @@ byte[] getRawParameterAnnotations() { * @since 1.5 */ @Override + @SideEffectFree public Annotation[] getDeclaredAnnotations() { return super.getDeclaredAnnotations(); } @@ -637,6 +650,7 @@ public Annotation[] getDeclaredAnnotations() { * @since 1.5 */ @Override + @SideEffectFree public Annotation[][] getParameterAnnotations() { return sharedGetParameterAnnotations(parameterTypes, parameterAnnotations); } @@ -670,6 +684,7 @@ boolean handleParameterNumberMismatch(int resultLength, Class[] parameterType * @since 1.8 */ @Override + @SideEffectFree public AnnotatedType getAnnotatedReturnType() { return getAnnotatedReturnType0(getDeclaringClass()); } @@ -679,6 +694,7 @@ public AnnotatedType getAnnotatedReturnType() { * @since 1.8 */ @Override + @SideEffectFree public @Nullable AnnotatedType getAnnotatedReceiverType() { Class thisDeclClass = getDeclaringClass(); Class enclosingClass = thisDeclClass.getEnclosingClass(); diff --git a/src/java.base/share/classes/java/lang/reflect/Executable.java b/src/java.base/share/classes/java/lang/reflect/Executable.java index bb7694570c2f..a1494dc782f9 100644 --- a/src/java.base/share/classes/java/lang/reflect/Executable.java +++ b/src/java.base/share/classes/java/lang/reflect/Executable.java @@ -26,6 +26,8 @@ package java.lang.reflect; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; +import org.checkerframework.dataflow.qual.SideEffectFree; import org.checkerframework.framework.qual.AnnotatedFor; import java.lang.annotation.Annotation; @@ -199,11 +201,13 @@ String sharedToGenericString(int modifierMask, boolean isDefault) { * Returns the {@code Class} object representing the class or interface * that declares the executable represented by this object. */ + @Pure public abstract Class getDeclaringClass(); /** * Returns the name of the executable represented by this object. */ + @Pure public abstract String getName(); /** @@ -211,6 +215,7 @@ String sharedToGenericString(int modifierMask, boolean isDefault) { * the executable represented by this object} * @see #accessFlags */ + @Pure public abstract int getModifiers(); /** @@ -223,6 +228,7 @@ String sharedToGenericString(int modifierMask, boolean isDefault) { * @since 20 */ @Override + @SideEffectFree public Set accessFlags() { return AccessFlag.maskToAccessFlags(getModifiers(), AccessFlag.Location.METHOD); @@ -242,6 +248,7 @@ public Set accessFlags() { * the format specified in * The Java Virtual Machine Specification */ + @SideEffectFree public abstract TypeVariable[] getTypeParameters(); // returns shared array of parameter types - must never give it out @@ -264,6 +271,7 @@ public Set accessFlags() { * @return the parameter types for the executable this object * represents */ + @SideEffectFree public abstract Class[] getParameterTypes(); /** @@ -274,6 +282,7 @@ public Set accessFlags() { * @return The number of formal parameters for the executable this * object represents */ + @Pure public abstract int getParameterCount(); /** @@ -312,6 +321,7 @@ public Set accessFlags() { * the underlying executable's parameter types refer to a parameterized * type that cannot be instantiated for any reason */ + @SideEffectFree public Type[] getGenericParameterTypes() { if (hasGenericInformation()) return getGenericInfo().getParameterTypes(); @@ -379,6 +389,7 @@ Type[] getAllGenericParameterTypes() { * @throws MalformedParametersException if the class file contains * a MethodParameters attribute that is improperly formatted. */ + @SideEffectFree public Parameter[] getParameters() { // TODO: This may eventually need to be guarded by security // mechanisms similar to those in Field, Method, etc. @@ -478,6 +489,7 @@ byte[] getTypeAnnotationBytes() { * @return the exception types declared as being thrown by the * executable this object represents */ + @SideEffectFree public abstract Class[] getExceptionTypes(); /** @@ -501,6 +513,7 @@ byte[] getTypeAnnotationBytes() { * the underlying executable's {@code throws} clause refers to a * parameterized type that cannot be instantiated for any reason */ + @SideEffectFree public Type[] getGenericExceptionTypes() { Type[] result; if (hasGenericInformation() && @@ -514,12 +527,14 @@ public Type[] getGenericExceptionTypes() { * {@return a string describing this {@code Executable}, including * any type parameters} */ + @SideEffectFree public abstract String toGenericString(); /** * {@return {@code true} if this executable was declared to take a * variable number of arguments; returns {@code false} otherwise} */ + @Pure public boolean isVarArgs() { return (getModifiers() & Modifier.VARARGS) != 0; } @@ -534,6 +549,7 @@ public boolean isVarArgs() { * @jls 13.1 The Form of a Binary * @jvms 4.6 Methods */ + @Pure public boolean isSynthetic() { return Modifier.isSynthetic(getModifiers()); } @@ -569,6 +585,7 @@ public boolean isSynthetic() { * the formal and implicit parameters, in declaration order, of * the executable represented by this object */ + @SideEffectFree public abstract Annotation[][] getParameterAnnotations(); Annotation[][] sharedGetParameterAnnotations(Class[] parameterTypes, @@ -599,6 +616,7 @@ Annotation[][] sharedGetParameterAnnotations(Class[] parameterTypes, * @throws NullPointerException {@inheritDoc} */ @Override + @Pure public @Nullable T getAnnotation(Class annotationClass) { Objects.requireNonNull(annotationClass); return annotationClass.cast(declaredAnnotations().get(annotationClass)); @@ -610,6 +628,7 @@ Annotation[][] sharedGetParameterAnnotations(Class[] parameterTypes, * @throws NullPointerException {@inheritDoc} */ @Override + @SideEffectFree public T[] getAnnotationsByType(Class annotationClass) { Objects.requireNonNull(annotationClass); @@ -620,6 +639,7 @@ public T[] getAnnotationsByType(Class annotationClass) * {@inheritDoc} */ @Override + @SideEffectFree public Annotation[] getDeclaredAnnotations() { return AnnotationParser.toArray(declaredAnnotations()); } @@ -664,6 +684,7 @@ private Map, Annotation> declaredAnnotations() { * @return an object representing the return type of the method * or constructor represented by this {@code Executable} */ + @SideEffectFree public abstract AnnotatedType getAnnotatedReturnType(); /* Helper for subclasses of Executable. @@ -708,6 +729,7 @@ AnnotatedType getAnnotatedReturnType0(Type returnType) { * @jls 8.4.1 Formal Parameters * @jls 8.8 Constructor Declarations */ + @SideEffectFree public @Nullable AnnotatedType getAnnotatedReceiverType() { if (Modifier.isStatic(this.getModifiers())) return null; @@ -758,6 +780,7 @@ Type parameterize(Class c) { * formal parameters of the method or constructor represented by this * {@code Executable} */ + @SideEffectFree public AnnotatedType[] getAnnotatedParameterTypes() { return TypeAnnotationParser.buildAnnotatedTypes(getTypeAnnotationBytes0(), SharedSecrets.getJavaLangAccess(). @@ -782,6 +805,7 @@ public AnnotatedType[] getAnnotatedParameterTypes() { * exceptions of the method or constructor represented by this {@code * Executable} */ + @SideEffectFree public AnnotatedType[] getAnnotatedExceptionTypes() { return TypeAnnotationParser.buildAnnotatedTypes(getTypeAnnotationBytes0(), SharedSecrets.getJavaLangAccess(). diff --git a/src/java.base/share/classes/java/lang/reflect/Field.java b/src/java.base/share/classes/java/lang/reflect/Field.java index ad59c39e0ea9..0f56336f93bf 100644 --- a/src/java.base/share/classes/java/lang/reflect/Field.java +++ b/src/java.base/share/classes/java/lang/reflect/Field.java @@ -242,6 +242,7 @@ public int getModifiers(@GuardSatisfied Field this) { * @since 20 */ @Override + @SideEffectFree public Set accessFlags() { return AccessFlag.maskToAccessFlags(getModifiers(), AccessFlag.Location.FIELD); } @@ -1291,6 +1292,7 @@ private void setOverrideFieldAccessor(FieldAccessor accessor) { * @throws NullPointerException {@inheritDoc} * @since 1.8 */ + @SideEffectFree @Override public T[] getAnnotationsByType(Class annotationClass) { Objects.requireNonNull(annotationClass); @@ -1341,6 +1343,7 @@ private Map, Annotation> declaredAnnotations() { * * @since 1.8 */ + @SideEffectFree public AnnotatedType getAnnotatedType() { return TypeAnnotationParser.buildAnnotatedType(getTypeAnnotationBytes0(), SharedSecrets.getJavaLangAccess(). diff --git a/src/java.base/share/classes/java/lang/reflect/InvocationTargetException.java b/src/java.base/share/classes/java/lang/reflect/InvocationTargetException.java index ae2c22e3252f..ea9f6ca7ddb2 100644 --- a/src/java.base/share/classes/java/lang/reflect/InvocationTargetException.java +++ b/src/java.base/share/classes/java/lang/reflect/InvocationTargetException.java @@ -26,6 +26,7 @@ package java.lang.reflect; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; import org.checkerframework.dataflow.qual.SideEffectFree; import org.checkerframework.framework.qual.AnnotatedFor; @@ -110,6 +111,7 @@ public InvocationTargetException(@Nullable Throwable target, @Nullable String s) * @return the cause of this exception. * @since 1.4 */ + @Pure @Override public @Nullable Throwable getCause() { return target; diff --git a/src/java.base/share/classes/java/lang/reflect/Member.java b/src/java.base/share/classes/java/lang/reflect/Member.java index 4f860a160ddf..d3e3c18f480e 100644 --- a/src/java.base/share/classes/java/lang/reflect/Member.java +++ b/src/java.base/share/classes/java/lang/reflect/Member.java @@ -25,6 +25,9 @@ package java.lang.reflect; +import org.checkerframework.dataflow.qual.Pure; +import org.checkerframework.dataflow.qual.SideEffectFree; + import java.util.Set; /** @@ -60,6 +63,7 @@ public interface Member { * @return an object representing the declaring class of the * underlying member */ + @Pure public Class getDeclaringClass(); /** @@ -68,6 +72,7 @@ public interface Member { * * @return the simple name of the underlying member */ + @Pure public String getName(); /** @@ -80,6 +85,7 @@ public interface Member { * @see Modifier * @see #accessFlags() */ + @Pure public int getModifiers(); @@ -93,6 +99,7 @@ public interface Member { * @see #getModifiers() * @since 20 */ + @SideEffectFree public default Set accessFlags() { throw new UnsupportedOperationException(); } @@ -106,5 +113,6 @@ public default Set accessFlags() { * @jls 13.1 The Form of a Binary * @since 1.5 */ + @Pure public boolean isSynthetic(); } diff --git a/src/java.base/share/classes/java/lang/reflect/Method.java b/src/java.base/share/classes/java/lang/reflect/Method.java index 113ce47f00c0..e7b4e427dcb2 100644 --- a/src/java.base/share/classes/java/lang/reflect/Method.java +++ b/src/java.base/share/classes/java/lang/reflect/Method.java @@ -109,15 +109,18 @@ public final class Method extends Executable { private Method root; // Generics infrastructure + @Pure private String getGenericSignature() {return signature;} // Accessor for factory + @SideEffectFree private GenericsFactory getFactory() { // create scope and factory return CoreReflectionFactory.make(this, MethodScope.make(this)); } // Accessor for generic info repository + @Pure @Override MethodRepository getGenericInfo() { var genericInfo = this.genericInfo; @@ -163,6 +166,7 @@ MethodRepository getGenericInfo() { * ReflectAccess) which returns a copy of this Method. The copy's * "root" field points to this Method. */ + @SideEffectFree Method copy() { // This routine enables sharing of MethodAccessor objects // among Method objects which refer to the same underlying @@ -186,6 +190,7 @@ Method copy() { /** * Make a copy of a leaf method. */ + @SideEffectFree Method leafCopy() { if (this.root == null) throw new IllegalArgumentException("Can only leafCopy a non-root Method"); @@ -211,21 +216,25 @@ public void setAccessible(boolean flag) { } @Override + @SideEffectFree void checkCanSetAccessible(Class caller) { checkCanSetAccessible(caller, clazz); } @Override + @Pure Method getRoot() { return root; } @Override + @Pure boolean hasGenericInformation() { return (getGenericSignature() != null); } @Override + @Pure byte[] getAnnotationBytes() { return annotations; } @@ -235,6 +244,7 @@ byte[] getAnnotationBytes() { * that declares the method represented by this object. */ @Override + @Pure public Class getDeclaringClass() { return clazz; } @@ -244,6 +254,7 @@ public Class getDeclaringClass() { * object, as a {@code String}. */ @Override + @Pure public @Interned @Identifier String getName() { return name; } @@ -253,6 +264,7 @@ public Class getDeclaringClass() { * @jls 8.4.3 Method Modifiers */ @Override + @Pure public int getModifiers() { return modifiers; } @@ -265,6 +277,7 @@ public int getModifiers() { */ @Override @SuppressWarnings({"rawtypes", "unchecked"}) + @SideEffectFree public TypeVariable[] getTypeParameters() { if (getGenericSignature() != null) return (TypeVariable[])getGenericInfo().getTypeParameters(); @@ -279,6 +292,7 @@ public TypeVariable[] getTypeParameters() { * @return the return type for the method this object represents */ @CFComment("lock/nullness: never returns null; returns Void instead") + @Pure public Class getReturnType() { return returnType; } @@ -308,6 +322,7 @@ public Class getReturnType() { * @since 1.5 */ @CFComment("lock/nullness: never returns null; returns Void instead") + @SideEffectFree public Type getGenericReturnType() { if (getGenericSignature() != null) { return getGenericInfo().getReturnType(); @@ -315,11 +330,13 @@ public Type getGenericReturnType() { } @Override + @Pure Class[] getSharedParameterTypes() { return parameterTypes; } @Override + @Pure Class[] getSharedExceptionTypes() { return exceptionTypes; } @@ -328,6 +345,7 @@ Class[] getSharedExceptionTypes() { * {@inheritDoc} */ @Override + @SideEffectFree public Class[] getParameterTypes() { return parameterTypes.clone(); } @@ -336,6 +354,7 @@ public Class[] getParameterTypes() { * {@inheritDoc} * @since 1.8 */ + @Pure public int getParameterCount() { return parameterTypes.length; } @@ -346,6 +365,7 @@ public Class[] getParameterTypes() { * @throws MalformedParameterizedTypeException {@inheritDoc} * @since 1.5 */ + @SideEffectFree @Override public Type[] getGenericParameterTypes() { return super.getGenericParameterTypes(); @@ -355,6 +375,7 @@ public Type[] getGenericParameterTypes() { * {@inheritDoc} */ @Override + @SideEffectFree public Class[] getExceptionTypes() { return exceptionTypes.clone(); } @@ -367,6 +388,7 @@ public Class[] getExceptionTypes() { * @since 1.5 */ @Override + @SideEffectFree public Type[] getGenericExceptionTypes() { return super.getGenericExceptionTypes(); } @@ -444,11 +466,13 @@ void specificToStringHeader(StringBuilder sb) { } @Override + @SideEffectFree String toShortString() { return "method " + getDeclaringClass().getTypeName() + '.' + toShortSignature(); } + @SideEffectFree String toShortSignature() { StringJoiner sj = new StringJoiner(",", getName() + "(", ")"); for (Class parameterType : getSharedParameterTypes()) { @@ -500,6 +524,7 @@ String toShortSignature() { * @jls 9.6.1 Annotation Interface Elements */ @Override + @SideEffectFree public String toGenericString() { return sharedToGenericString(Modifier.methodModifiers(), isDefault()); } @@ -635,6 +660,7 @@ private Object invoke(Object obj, Object[] args, Class caller) // -1 = initialized, not CS @Stable private byte callerSensitive; + @Pure private boolean isCallerSensitive() { byte cs = callerSensitive; if (cs == 0) { @@ -729,6 +755,7 @@ public boolean isSynthetic(@GuardSatisfied Method this) { * @since 1.8 * @jls 9.4 Method Declarations */ + @Pure public boolean isDefault() { // Default methods are public non-abstract instance methods // declared in an interface. @@ -760,6 +787,7 @@ private MethodAccessor acquireMethodAccessor() { // Returns MethodAccessor for this Method object, not looking up // the chain to the root + @Pure MethodAccessor getMethodAccessor() { return methodAccessor; } @@ -790,6 +818,7 @@ void setMethodAccessor(MethodAccessor accessor) { * @since 1.5 * @jls 9.6.2 Defaults for Annotation Type Elements */ + @SideEffectFree public @Nullable Object getDefaultValue() { if (annotationDefault == null) return null; @@ -814,6 +843,7 @@ void setMethodAccessor(MethodAccessor accessor) { * @throws NullPointerException {@inheritDoc} * @since 1.5 */ + @Pure @Override public @Nullable T getAnnotation(Class annotationClass) { return super.getAnnotation(annotationClass); @@ -823,6 +853,7 @@ void setMethodAccessor(MethodAccessor accessor) { * {@inheritDoc} * @since 1.5 */ + @SideEffectFree @Override public Annotation[] getDeclaredAnnotations() { return super.getDeclaredAnnotations(); @@ -833,6 +864,7 @@ public Annotation[] getDeclaredAnnotations() { * @since 1.5 */ @Override + @SideEffectFree public Annotation[][] getParameterAnnotations() { return sharedGetParameterAnnotations(parameterTypes, parameterAnnotations); } @@ -842,6 +874,7 @@ public Annotation[][] getParameterAnnotations() { * @since 1.8 */ @Override + @SideEffectFree public AnnotatedType getAnnotatedReturnType() { return getAnnotatedReturnType0(getGenericReturnType()); } diff --git a/src/java.base/share/classes/java/lang/reflect/Proxy.java b/src/java.base/share/classes/java/lang/reflect/Proxy.java index 7263f9e38a44..c4ec3ce8cc9a 100644 --- a/src/java.base/share/classes/java/lang/reflect/Proxy.java +++ b/src/java.base/share/classes/java/lang/reflect/Proxy.java @@ -26,6 +26,7 @@ package java.lang.reflect; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.SideEffectFree; import org.checkerframework.framework.qual.AnnotatedFor; import java.lang.invoke.MethodHandle; @@ -1364,6 +1365,7 @@ static class InvocationException extends ReflectiveOperationException { @java.io.Serial private static final long serialVersionUID = 0L; + @SideEffectFree InvocationException(@Nullable Throwable cause) { super(cause); } diff --git a/src/java.base/share/classes/java/math/BigDecimal.java b/src/java.base/share/classes/java/math/BigDecimal.java index f4bc48623616..893a780abf8e 100644 --- a/src/java.base/share/classes/java/math/BigDecimal.java +++ b/src/java.base/share/classes/java/math/BigDecimal.java @@ -2680,6 +2680,7 @@ public BigDecimal plus(MathContext mc) { * @return -1, 0, or 1 as the value of this {@code BigDecimal} * is negative, zero, or positive. */ + @Pure public int signum() { return (intCompact != INFLATED)? Long.signum(intCompact): @@ -2709,6 +2710,7 @@ public int scale() { * @return the precision of this {@code BigDecimal}. * @since 1.5 */ + @Pure public int precision() { int result = precision; if (result == 0) { @@ -3135,6 +3137,7 @@ public BigDecimal stripTrailingZeros() { * less than, equal to, or greater than {@code val}. */ @Override + @Pure public int compareTo(BigDecimal val) { // Quick path for equal scale and non-inflated case. if (scale == val.scale) { diff --git a/src/java.base/share/classes/java/math/MutableBigInteger.java b/src/java.base/share/classes/java/math/MutableBigInteger.java index 013edee7f270..051914604a8a 100644 --- a/src/java.base/share/classes/java/math/MutableBigInteger.java +++ b/src/java.base/share/classes/java/math/MutableBigInteger.java @@ -26,6 +26,7 @@ package java.math; import org.checkerframework.checker.interning.qual.UsesObjectEquals; +import org.checkerframework.dataflow.qual.Pure; import org.checkerframework.framework.qual.AnnotatedFor; /** @@ -265,6 +266,7 @@ void reset() { * as this MutableBigInteger is numerically less than, equal to, or * greater than {@code b}. */ + @Pure final int compare(MutableBigInteger b) { int blen = b.intLen; if (intLen < blen) diff --git a/src/java.base/share/classes/java/net/HttpCookie.java b/src/java.base/share/classes/java/net/HttpCookie.java index 273e88c24e7c..3733111d64f9 100644 --- a/src/java.base/share/classes/java/net/HttpCookie.java +++ b/src/java.base/share/classes/java/net/HttpCookie.java @@ -1117,6 +1117,7 @@ private static String stripOffSurroundingQuote(String str) { return str; } + @Pure private static boolean equalsIgnoreCase(String s, String t) { if (s == t) return true; if ((s != null) && (t != null)) { diff --git a/src/java.base/share/classes/java/net/Inet6Address.java b/src/java.base/share/classes/java/net/Inet6Address.java index 8910a4028aa8..ee2bbd92f7e7 100644 --- a/src/java.base/share/classes/java/net/Inet6Address.java +++ b/src/java.base/share/classes/java/net/Inet6Address.java @@ -273,6 +273,7 @@ String getHostAddress() { return s; } + @Pure public boolean equals(@Nullable Object o) { if (!(o instanceof Inet6AddressHolder that)) { return false; diff --git a/src/java.base/share/classes/java/net/InetAddress.java b/src/java.base/share/classes/java/net/InetAddress.java index ea69a518bdff..0151efe259aa 100644 --- a/src/java.base/share/classes/java/net/InetAddress.java +++ b/src/java.base/share/classes/java/net/InetAddress.java @@ -972,6 +972,7 @@ public InetAddress[] get() throws UnknownHostException { } @Override + @Pure public int compareTo(CachedAddresses other) { // natural order is expiry time - // compare difference of expiry times rather than diff --git a/src/java.base/share/classes/java/net/URI.java b/src/java.base/share/classes/java/net/URI.java index 48223fd5872e..c740372d7867 100644 --- a/src/java.base/share/classes/java/net/URI.java +++ b/src/java.base/share/classes/java/net/URI.java @@ -1676,6 +1676,7 @@ public int hashCode() { * @throws ClassCastException * If the given object is not a URI */ + @Pure public int compareTo(URI that) { int c; @@ -1947,6 +1948,7 @@ private static int hashIgnoringCase(int hash, String s) { return h; } + @Pure private static int compare(String s, String t) { boolean testForEquality = false; int result = percentNormalizedComparison(s, t, testForEquality); diff --git a/src/java.base/share/classes/java/net/URISyntaxException.java b/src/java.base/share/classes/java/net/URISyntaxException.java index 8ab38d52dc5e..f2d2e00635a0 100644 --- a/src/java.base/share/classes/java/net/URISyntaxException.java +++ b/src/java.base/share/classes/java/net/URISyntaxException.java @@ -132,6 +132,7 @@ public int getIndex() { * * @return A string describing the parse error */ + @SideEffectFree public String getMessage() { StringBuilder sb = new StringBuilder(); sb.append(getReason()); diff --git a/src/java.base/share/classes/java/net/URLPermission.java b/src/java.base/share/classes/java/net/URLPermission.java index 34fb7c036aa3..0b0f6cadfa78 100644 --- a/src/java.base/share/classes/java/net/URLPermission.java +++ b/src/java.base/share/classes/java/net/URLPermission.java @@ -583,6 +583,7 @@ private boolean impliesPortrange(Authority that) { thisrange[1] >= thatrange[1]; } + @Pure boolean equals(Authority that) { return this.p.equals(that.p); } diff --git a/src/java.base/share/classes/java/nio/StringCharBuffer.java b/src/java.base/share/classes/java/nio/StringCharBuffer.java index e7e582cae230..f9a4f3e462cf 100644 --- a/src/java.base/share/classes/java/nio/StringCharBuffer.java +++ b/src/java.base/share/classes/java/nio/StringCharBuffer.java @@ -173,6 +173,7 @@ public boolean equals(@Nullable Object ob) { thisRem) < 0; } + @Pure public int compareTo(CharBuffer that) { int thisPos = this.position(); int thisRem = this.limit() - thisPos; diff --git a/src/java.base/share/classes/java/nio/charset/Charset.java b/src/java.base/share/classes/java/nio/charset/Charset.java index 06f850049f60..4acb511897ac 100644 --- a/src/java.base/share/classes/java/nio/charset/Charset.java +++ b/src/java.base/share/classes/java/nio/charset/Charset.java @@ -949,6 +949,7 @@ public final ByteBuffer encode(String str) { * @return A negative integer, zero, or a positive integer as this charset * is less than, equal to, or greater than the specified charset */ + @Pure public final int compareTo(Charset that) { return (name().compareToIgnoreCase(that.name())); } @@ -971,6 +972,7 @@ public final int hashCode() { * @return {@code true} if, and only if, this charset is equal to the * given object */ + @Pure public final boolean equals(@Nullable Object ob) { if (!(ob instanceof Charset)) return false; diff --git a/src/java.base/share/classes/java/nio/charset/MalformedInputException.java b/src/java.base/share/classes/java/nio/charset/MalformedInputException.java index c598297c8a15..1e6276dd2f02 100644 --- a/src/java.base/share/classes/java/nio/charset/MalformedInputException.java +++ b/src/java.base/share/classes/java/nio/charset/MalformedInputException.java @@ -69,6 +69,7 @@ public int getInputLength() { * Returns the message. * @return the message */ + @SideEffectFree public String getMessage() { return "Input length = " + inputLength; } diff --git a/src/java.base/share/classes/java/nio/charset/UnmappableCharacterException.java b/src/java.base/share/classes/java/nio/charset/UnmappableCharacterException.java index e1bcd8a49b4f..d9fc406df218 100644 --- a/src/java.base/share/classes/java/nio/charset/UnmappableCharacterException.java +++ b/src/java.base/share/classes/java/nio/charset/UnmappableCharacterException.java @@ -69,6 +69,7 @@ public int getInputLength() { * Returns the message. * @return the message */ + @SideEffectFree public String getMessage() { return "Input length = " + inputLength; } diff --git a/src/java.base/share/classes/java/nio/file/DirectoryIteratorException.java b/src/java.base/share/classes/java/nio/file/DirectoryIteratorException.java index a3d55e97831b..f00fcaab5787 100644 --- a/src/java.base/share/classes/java/nio/file/DirectoryIteratorException.java +++ b/src/java.base/share/classes/java/nio/file/DirectoryIteratorException.java @@ -26,6 +26,7 @@ package java.nio.file; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; import org.checkerframework.dataflow.qual.SideEffectFree; import org.checkerframework.framework.qual.AnnotatedFor; @@ -71,6 +72,7 @@ public DirectoryIteratorException(IOException cause) { * * @return the cause */ + @Pure @Override public IOException getCause() { return (IOException)super.getCause(); diff --git a/src/java.base/share/classes/java/nio/file/FileSystemException.java b/src/java.base/share/classes/java/nio/file/FileSystemException.java index 1a2db737c441..234b7b60567f 100644 --- a/src/java.base/share/classes/java/nio/file/FileSystemException.java +++ b/src/java.base/share/classes/java/nio/file/FileSystemException.java @@ -121,6 +121,7 @@ public FileSystemException(@Nullable String file, @Nullable String other, @Nulla /** * Returns the detail message string. */ + @SideEffectFree @Override public @Nullable String getMessage() { if (file == null && other == null) diff --git a/src/java.base/share/classes/java/nio/file/Files.java b/src/java.base/share/classes/java/nio/file/Files.java index 829edd4b494c..c5a5fc4ea69c 100644 --- a/src/java.base/share/classes/java/nio/file/Files.java +++ b/src/java.base/share/classes/java/nio/file/Files.java @@ -1627,6 +1627,7 @@ public static boolean isSameFile(Path path, Path path2) throws IOException { * @since 12 */ @ReleasesNoLocks + @Pure public static long mismatch(Path path, Path path2) throws IOException { if (isSameFile(path, path2)) { return -1; diff --git a/src/java.base/share/classes/java/nio/file/InvalidPathException.java b/src/java.base/share/classes/java/nio/file/InvalidPathException.java index 730d2535b800..919749259c55 100644 --- a/src/java.base/share/classes/java/nio/file/InvalidPathException.java +++ b/src/java.base/share/classes/java/nio/file/InvalidPathException.java @@ -133,6 +133,7 @@ public int getIndex() { * * @return a string describing the error */ + @SideEffectFree public String getMessage() { StringBuilder sb = new StringBuilder(); sb.append(getReason()); diff --git a/src/java.base/share/classes/java/nio/file/attribute/FileTime.java b/src/java.base/share/classes/java/nio/file/attribute/FileTime.java index 9e765aa055a4..af75e179e9c6 100644 --- a/src/java.base/share/classes/java/nio/file/attribute/FileTime.java +++ b/src/java.base/share/classes/java/nio/file/attribute/FileTime.java @@ -345,6 +345,7 @@ private long toExcessNanos(long days) { * {@code FileTime} represents a time that is after {@code other} */ @Override + @Pure public int compareTo(FileTime other) { // same granularity if (unit != null && unit == other.unit) { diff --git a/src/java.base/share/classes/java/security/MessageDigest.java b/src/java.base/share/classes/java/security/MessageDigest.java index 31bcdf1514be..c834cab47ce1 100644 --- a/src/java.base/share/classes/java/security/MessageDigest.java +++ b/src/java.base/share/classes/java/security/MessageDigest.java @@ -26,6 +26,7 @@ package java.security; import org.checkerframework.checker.signedness.qual.PolySigned; +import org.checkerframework.dataflow.qual.Pure; import org.checkerframework.framework.qual.AnnotatedFor; import java.util.*; @@ -472,6 +473,7 @@ public String toString() { * * @return {@code true} if the digests are equal, {@code false} otherwise. */ + @Pure public static boolean isEqual(byte[] digesta, byte[] digestb) { if (digesta == digestb) return true; if (digesta == null || digestb == null) { diff --git a/src/java.base/share/classes/java/security/PrivilegedActionException.java b/src/java.base/share/classes/java/security/PrivilegedActionException.java index e9c3f6f143ec..9ea2389ad5c2 100644 --- a/src/java.base/share/classes/java/security/PrivilegedActionException.java +++ b/src/java.base/share/classes/java/security/PrivilegedActionException.java @@ -85,6 +85,7 @@ public Exception getException() { return (Exception)super.getCause(); } + @SideEffectFree public String toString() { String s = getClass().getName(); Throwable cause = super.getCause(); diff --git a/src/java.base/share/classes/java/security/Provider.java b/src/java.base/share/classes/java/security/Provider.java index a9da9671fec2..065718846530 100644 --- a/src/java.base/share/classes/java/security/Provider.java +++ b/src/java.base/share/classes/java/security/Provider.java @@ -28,6 +28,7 @@ import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.PolyNull; import org.checkerframework.checker.signedness.qual.UnknownSignedness; +import org.checkerframework.dataflow.qual.Pure; import org.checkerframework.framework.qual.DoesNotUnrefineReceiver; import jdk.internal.event.SecurityProviderServiceEvent; @@ -1101,6 +1102,7 @@ private ServiceKey(String type, String algorithm, boolean intern) { public int hashCode() { return type.hashCode() * 31 + algorithm.hashCode(); } + @Pure public boolean equals(@Nullable Object obj) { if (this == obj) { return true; @@ -1549,6 +1551,7 @@ public int hashCode() { return lowerString.hashCode(); } + @Pure public boolean equals(@Nullable Object obj) { if (this == obj) { return true; diff --git a/src/java.base/share/classes/java/security/cert/CertificateRevokedException.java b/src/java.base/share/classes/java/security/cert/CertificateRevokedException.java index bb630636ba14..994bd5d14784 100644 --- a/src/java.base/share/classes/java/security/cert/CertificateRevokedException.java +++ b/src/java.base/share/classes/java/security/cert/CertificateRevokedException.java @@ -180,6 +180,7 @@ public Map getExtensions() { return Collections.unmodifiableMap(extensions); } + @SideEffectFree @Override public String getMessage() { return "Certificate has been revoked, reason: " diff --git a/src/java.base/share/classes/java/text/AttributedString.java b/src/java.base/share/classes/java/text/AttributedString.java index 23f9f5909f8b..617f27a3d0f5 100644 --- a/src/java.base/share/classes/java/text/AttributedString.java +++ b/src/java.base/share/classes/java/text/AttributedString.java @@ -766,6 +766,7 @@ private final class AttributedStringIterator implements AttributedCharacterItera // Object methods. See documentation in that class. + @Pure public boolean equals(@Nullable Object obj) { if (this == obj) { return true; diff --git a/src/java.base/share/classes/java/text/Collator.java b/src/java.base/share/classes/java/text/Collator.java index 5685044ed937..ee067d245f31 100644 --- a/src/java.base/share/classes/java/text/Collator.java +++ b/src/java.base/share/classes/java/text/Collator.java @@ -360,6 +360,7 @@ public static Collator getInstance(Locale desiredLocale) { * @see java.text.CollationKey * @see java.text.Collator#getCollationKey */ + @Pure public abstract int compare(String source, String target); /** @@ -378,6 +379,7 @@ public static Collator getInstance(Locale desiredLocale) { * @since 1.2 */ @Override + @Pure public int compare(Object o1, Object o2) { return compare((String)o1, (String)o2); } diff --git a/src/java.base/share/classes/java/text/RuleBasedCollationKey.java b/src/java.base/share/classes/java/text/RuleBasedCollationKey.java index 4ccd50af2dcb..7c522042d702 100644 --- a/src/java.base/share/classes/java/text/RuleBasedCollationKey.java +++ b/src/java.base/share/classes/java/text/RuleBasedCollationKey.java @@ -60,6 +60,7 @@ final class RuleBasedCollationKey extends CollationKey { * zero if this is greater than target. * @see java.text.Collator#compare */ + @Pure public int compareTo(CollationKey target) { int result = key.compareTo(((RuleBasedCollationKey)(target)).key); diff --git a/src/java.base/share/classes/java/text/RuleBasedCollator.java b/src/java.base/share/classes/java/text/RuleBasedCollator.java index 03ab9f8f6b7e..ebfbb33ec7a8 100644 --- a/src/java.base/share/classes/java/text/RuleBasedCollator.java +++ b/src/java.base/share/classes/java/text/RuleBasedCollator.java @@ -358,6 +358,7 @@ public CollationElementIterator getCollationElementIterator( * * @throws NullPointerException if {@code source} or {@code target} is null. */ + @Pure public synchronized int compare(String source, String target) { if (source == null || target == null) { diff --git a/src/java.base/share/classes/java/time/Clock.java b/src/java.base/share/classes/java/time/Clock.java index 32b995c2817a..9ccb128e9ad0 100644 --- a/src/java.base/share/classes/java/time/Clock.java +++ b/src/java.base/share/classes/java/time/Clock.java @@ -568,6 +568,7 @@ public Instant instant() { return currentInstant(); } @Override + @Pure public boolean equals(@Nullable Object obj) { return obj instanceof SystemInstantSource; } @@ -622,6 +623,7 @@ public Instant instant() { return currentInstant(); } @Override + @Pure public boolean equals(@Nullable Object obj) { if (obj instanceof SystemClock) { return zone.equals(((SystemClock) obj).zone); @@ -673,6 +675,7 @@ public Instant instant() { return instant; } @Override + @Pure public boolean equals(@Nullable Object obj) { return obj instanceof FixedClock other && instant.equals(other.instant) @@ -723,6 +726,7 @@ public Instant instant() { return baseClock.instant().plus(offset); } @Override + @Pure public boolean equals(@Nullable Object obj) { return obj instanceof OffsetClock other && baseClock.equals(other.baseClock) @@ -781,6 +785,7 @@ public Instant instant() { return instant.minusNanos(adjust); } @Override + @Pure public boolean equals(@Nullable Object obj) { return (obj instanceof TickClock other) && tickNanos == other.tickNanos @@ -831,6 +836,7 @@ public Instant instant() { return baseSource.instant(); } @Override + @Pure public boolean equals(@Nullable Object obj) { return (obj instanceof SourceClock other) && zone.equals(other.zone) diff --git a/src/java.base/share/classes/java/time/Duration.java b/src/java.base/share/classes/java/time/Duration.java index c6c1a3977b60..134e92532ba2 100644 --- a/src/java.base/share/classes/java/time/Duration.java +++ b/src/java.base/share/classes/java/time/Duration.java @@ -1428,6 +1428,7 @@ public Duration truncatedTo(TemporalUnit unit) { * @return the comparator value, negative if less, positive if greater */ @Override + @Pure public int compareTo(Duration otherDuration) { int cmp = Long.compare(seconds, otherDuration.seconds); if (cmp != 0) { diff --git a/src/java.base/share/classes/java/time/Instant.java b/src/java.base/share/classes/java/time/Instant.java index 22bc7dd6bdfe..18088c840eba 100644 --- a/src/java.base/share/classes/java/time/Instant.java +++ b/src/java.base/share/classes/java/time/Instant.java @@ -1282,6 +1282,7 @@ public long toEpochMilli() { * @throws NullPointerException if otherInstant is null */ @Override + @Pure public int compareTo(Instant otherInstant) { int cmp = Long.compare(seconds, otherInstant.seconds); if (cmp != 0) { @@ -1299,6 +1300,7 @@ public int compareTo(Instant otherInstant) { * @return true if this instant is after the specified instant * @throws NullPointerException if otherInstant is null */ + @Pure public boolean isAfter(Instant otherInstant) { return compareTo(otherInstant) > 0; } @@ -1312,6 +1314,7 @@ public boolean isAfter(Instant otherInstant) { * @return true if this instant is before the specified instant * @throws NullPointerException if otherInstant is null */ + @Pure public boolean isBefore(Instant otherInstant) { return compareTo(otherInstant) < 0; } diff --git a/src/java.base/share/classes/java/time/LocalDate.java b/src/java.base/share/classes/java/time/LocalDate.java index a4c40e600e25..03cc2e7872c1 100644 --- a/src/java.base/share/classes/java/time/LocalDate.java +++ b/src/java.base/share/classes/java/time/LocalDate.java @@ -1997,6 +1997,7 @@ public long toEpochSecond(LocalTime time, ZoneOffset offset) { * @return the comparator value, negative if less, positive if greater */ @Override // override for Javadoc and performance + @Pure public int compareTo(ChronoLocalDate other) { if (other instanceof LocalDate) { return compareTo0((LocalDate) other); @@ -2037,6 +2038,7 @@ int compareTo0(LocalDate otherDate) { * @return true if this date is after the specified date */ @Override // override for Javadoc and performance + @Pure public boolean isAfter(ChronoLocalDate other) { if (other instanceof LocalDate) { return compareTo0((LocalDate) other) > 0; @@ -2066,6 +2068,7 @@ public boolean isAfter(ChronoLocalDate other) { * @return true if this date is before the specified date */ @Override // override for Javadoc and performance + @Pure public boolean isBefore(ChronoLocalDate other) { if (other instanceof LocalDate) { return compareTo0((LocalDate) other) < 0; @@ -2095,6 +2098,7 @@ public boolean isBefore(ChronoLocalDate other) { * @return true if this date is equal to the specified date */ @Override // override for Javadoc and performance + @Pure public boolean isEqual(ChronoLocalDate other) { if (other instanceof LocalDate) { return compareTo0((LocalDate) other) == 0; diff --git a/src/java.base/share/classes/java/time/LocalDateTime.java b/src/java.base/share/classes/java/time/LocalDateTime.java index 250aa8bce29b..67fe960ac128 100644 --- a/src/java.base/share/classes/java/time/LocalDateTime.java +++ b/src/java.base/share/classes/java/time/LocalDateTime.java @@ -1816,6 +1816,7 @@ public ZonedDateTime atZone(ZoneId zone) { * @return the comparator value, negative if less, positive if greater */ @Override // override for Javadoc and performance + @Pure public int compareTo(ChronoLocalDateTime other) { if (other instanceof LocalDateTime) { return compareTo0((LocalDateTime) other); @@ -1853,6 +1854,7 @@ private int compareTo0(LocalDateTime other) { * @return true if this date-time is after the specified date-time */ @Override // override for Javadoc and performance + @Pure public boolean isAfter(ChronoLocalDateTime other) { if (other instanceof LocalDateTime) { return compareTo0((LocalDateTime) other) > 0; @@ -1882,6 +1884,7 @@ public boolean isAfter(ChronoLocalDateTime other) { * @return true if this date-time is before the specified date-time */ @Override // override for Javadoc and performance + @Pure public boolean isBefore(ChronoLocalDateTime other) { if (other instanceof LocalDateTime) { return compareTo0((LocalDateTime) other) < 0; @@ -1911,6 +1914,7 @@ public boolean isBefore(ChronoLocalDateTime other) { * @return true if this date-time is equal to the specified date-time */ @Override // override for Javadoc and performance + @Pure public boolean isEqual(ChronoLocalDateTime other) { if (other instanceof LocalDateTime) { return compareTo0((LocalDateTime) other) == 0; diff --git a/src/java.base/share/classes/java/time/LocalTime.java b/src/java.base/share/classes/java/time/LocalTime.java index 7be383786bd2..ea9db5b41d09 100644 --- a/src/java.base/share/classes/java/time/LocalTime.java +++ b/src/java.base/share/classes/java/time/LocalTime.java @@ -1540,6 +1540,7 @@ public long toEpochSecond(LocalDate date, ZoneOffset offset) { * @return the comparator value, negative if less, positive if greater */ @Override + @Pure public int compareTo(LocalTime other) { int cmp = Integer.compare(hour, other.hour); if (cmp == 0) { @@ -1562,6 +1563,7 @@ public int compareTo(LocalTime other) { * @param other the other time to compare to, not null * @return true if this is after the specified time */ + @Pure public boolean isAfter(LocalTime other) { return compareTo(other) > 0; } @@ -1574,6 +1576,7 @@ public boolean isAfter(LocalTime other) { * @param other the other time to compare to, not null * @return true if this point is before the specified time */ + @Pure public boolean isBefore(LocalTime other) { return compareTo(other) < 0; } diff --git a/src/java.base/share/classes/java/time/MonthDay.java b/src/java.base/share/classes/java/time/MonthDay.java index 0be8163ae2b6..09f36d94c4ab 100644 --- a/src/java.base/share/classes/java/time/MonthDay.java +++ b/src/java.base/share/classes/java/time/MonthDay.java @@ -684,6 +684,7 @@ public LocalDate atYear(int year) { * @return the comparator value, negative if less, positive if greater */ @Override + @Pure public int compareTo(MonthDay other) { int cmp = (month - other.month); if (cmp == 0) { @@ -698,6 +699,7 @@ public int compareTo(MonthDay other) { * @param other the other month-day to compare to, not null * @return true if this is after the specified month-day */ + @Pure public boolean isAfter(MonthDay other) { return compareTo(other) > 0; } @@ -708,6 +710,7 @@ public boolean isAfter(MonthDay other) { * @param other the other month-day to compare to, not null * @return true if this point is before the specified month-day */ + @Pure public boolean isBefore(MonthDay other) { return compareTo(other) < 0; } diff --git a/src/java.base/share/classes/java/time/OffsetDateTime.java b/src/java.base/share/classes/java/time/OffsetDateTime.java index 9551b98b8def..8c40f2f388db 100644 --- a/src/java.base/share/classes/java/time/OffsetDateTime.java +++ b/src/java.base/share/classes/java/time/OffsetDateTime.java @@ -1810,6 +1810,7 @@ public long toEpochSecond() { * @return the comparator value, negative if less, positive if greater */ @Override + @Pure public int compareTo(OffsetDateTime other) { int cmp = compareInstant(this, other); if (cmp == 0) { @@ -1829,6 +1830,7 @@ public int compareTo(OffsetDateTime other) { * @param other the other date-time to compare to, not null * @return true if this is after the instant of the specified date-time */ + @Pure public boolean isAfter(OffsetDateTime other) { long thisEpochSec = toEpochSecond(); long otherEpochSec = other.toEpochSecond(); @@ -1846,6 +1848,7 @@ public boolean isAfter(OffsetDateTime other) { * @param other the other date-time to compare to, not null * @return true if this is before the instant of the specified date-time */ + @Pure public boolean isBefore(OffsetDateTime other) { long thisEpochSec = toEpochSecond(); long otherEpochSec = other.toEpochSecond(); @@ -1863,6 +1866,7 @@ public boolean isBefore(OffsetDateTime other) { * @param other the other date-time to compare to, not null * @return true if the instant equals the instant of the specified date-time */ + @Pure public boolean isEqual(OffsetDateTime other) { return toEpochSecond() == other.toEpochSecond() && toLocalTime().getNano() == other.toLocalTime().getNano(); diff --git a/src/java.base/share/classes/java/time/OffsetTime.java b/src/java.base/share/classes/java/time/OffsetTime.java index e70d004a9c5a..b889723e9e74 100644 --- a/src/java.base/share/classes/java/time/OffsetTime.java +++ b/src/java.base/share/classes/java/time/OffsetTime.java @@ -1290,6 +1290,7 @@ public long toEpochSecond(LocalDate date) { * @return the comparator value, negative if less, positive if greater */ @Override + @Pure public int compareTo(OffsetTime other) { if (offset.equals(other.offset)) { return time.compareTo(other.time); @@ -1313,6 +1314,7 @@ public int compareTo(OffsetTime other) { * @param other the other time to compare to, not null * @return true if this is after the instant of the specified time */ + @Pure public boolean isAfter(OffsetTime other) { return toEpochNano() > other.toEpochNano(); } @@ -1328,6 +1330,7 @@ public boolean isAfter(OffsetTime other) { * @param other the other time to compare to, not null * @return true if this is before the instant of the specified time */ + @Pure public boolean isBefore(OffsetTime other) { return toEpochNano() < other.toEpochNano(); } @@ -1343,6 +1346,7 @@ public boolean isBefore(OffsetTime other) { * @param other the other time to compare to, not null * @return true if this is equal to the instant of the specified time */ + @Pure public boolean isEqual(OffsetTime other) { return toEpochNano() == other.toEpochNano(); } diff --git a/src/java.base/share/classes/java/time/Year.java b/src/java.base/share/classes/java/time/Year.java index 23be00ccc829..951b2e93e3ac 100644 --- a/src/java.base/share/classes/java/time/Year.java +++ b/src/java.base/share/classes/java/time/Year.java @@ -1027,6 +1027,7 @@ public LocalDate atMonthDay(MonthDay monthDay) { * @return the comparator value, negative if less, positive if greater */ @Override + @Pure public int compareTo(Year other) { return year - other.year; } @@ -1037,6 +1038,7 @@ public int compareTo(Year other) { * @param other the other year to compare to, not null * @return true if this is after the specified year */ + @Pure public boolean isAfter(Year other) { return year > other.year; } @@ -1047,6 +1049,7 @@ public boolean isAfter(Year other) { * @param other the other year to compare to, not null * @return true if this point is before the specified year */ + @Pure public boolean isBefore(Year other) { return year < other.year; } diff --git a/src/java.base/share/classes/java/time/YearMonth.java b/src/java.base/share/classes/java/time/YearMonth.java index 02f33cf9d7b7..37355d51adcc 100644 --- a/src/java.base/share/classes/java/time/YearMonth.java +++ b/src/java.base/share/classes/java/time/YearMonth.java @@ -1131,6 +1131,7 @@ public LocalDate atEndOfMonth() { * @return the comparator value, negative if less, positive if greater */ @Override + @Pure public int compareTo(YearMonth other) { int cmp = (year - other.year); if (cmp == 0) { @@ -1145,6 +1146,7 @@ public int compareTo(YearMonth other) { * @param other the other year-month to compare to, not null * @return true if this is after the specified year-month */ + @Pure public boolean isAfter(YearMonth other) { return compareTo(other) > 0; } @@ -1155,6 +1157,7 @@ public boolean isAfter(YearMonth other) { * @param other the other year-month to compare to, not null * @return true if this point is before the specified year-month */ + @Pure public boolean isBefore(YearMonth other) { return compareTo(other) < 0; } diff --git a/src/java.base/share/classes/java/time/chrono/AbstractChronology.java b/src/java.base/share/classes/java/time/chrono/AbstractChronology.java index a93863927375..f6fde6ea6b4f 100644 --- a/src/java.base/share/classes/java/time/chrono/AbstractChronology.java +++ b/src/java.base/share/classes/java/time/chrono/AbstractChronology.java @@ -665,6 +665,7 @@ void addFieldValue(Map fieldValues, ChronoField field, long * @return the comparator value, negative if less, positive if greater */ @Override + @Pure public int compareTo(Chronology other) { return getId().compareTo(other.getId()); } diff --git a/src/java.base/share/classes/java/util/Arrays.java b/src/java.base/share/classes/java/util/Arrays.java index 82290825e8db..182019021720 100644 --- a/src/java.base/share/classes/java/util/Arrays.java +++ b/src/java.base/share/classes/java/util/Arrays.java @@ -797,6 +797,7 @@ static void rangeCheck(int arrayLength, @IndexOrHigh({"#1"}) int fromIndex, @Ind */ static final class NaturalOrder implements Comparator { @SuppressWarnings("unchecked") + @Pure public int compare(Object first, Object second) { return ((Comparable)first).compareTo(second); } diff --git a/src/java.base/share/classes/java/util/Calendar.java b/src/java.base/share/classes/java/util/Calendar.java index 4fb7b91f308b..b94e8d8ece05 100644 --- a/src/java.base/share/classes/java/util/Calendar.java +++ b/src/java.base/share/classes/java/util/Calendar.java @@ -2771,6 +2771,7 @@ public int hashCode(@GuardSatisfied Calendar this) { * {@code when}; {@code false} otherwise. * @see #compareTo(Calendar) */ + @Pure public boolean before(Object when) { return when instanceof Calendar && compareTo((Calendar)when) < 0; @@ -2792,6 +2793,7 @@ public boolean before(Object when) { * otherwise. * @see #compareTo(Calendar) */ + @Pure public boolean after(Object when) { return when instanceof Calendar && compareTo((Calendar)when) > 0; diff --git a/src/java.base/share/classes/java/util/Collections.java b/src/java.base/share/classes/java/util/Collections.java index ba5fcf2000fd..b62d99fe5b40 100644 --- a/src/java.base/share/classes/java/util/Collections.java +++ b/src/java.base/share/classes/java/util/Collections.java @@ -6182,6 +6182,7 @@ private static class ReverseComparator static final ReverseComparator REVERSE_ORDER = new ReverseComparator(); + @Pure public int compare(Comparable c1, Comparable c2) { return c2.compareTo(c1); } @@ -6260,6 +6261,7 @@ private static class ReverseComparator2 implements Comparator, this.cmp = cmp; } + @Pure public int compare(T t1, T t2) { return cmp.compare(t2, t1); } diff --git a/src/java.base/share/classes/java/util/Comparator.java b/src/java.base/share/classes/java/util/Comparator.java index 53c07a37638a..2e1c1e030151 100644 --- a/src/java.base/share/classes/java/util/Comparator.java +++ b/src/java.base/share/classes/java/util/Comparator.java @@ -161,6 +161,7 @@ public interface Comparator { * @throws ClassCastException if the arguments' types prevent them from * being compared by this comparator. */ + @Pure int compare(T o1, T o2); /** diff --git a/src/java.base/share/classes/java/util/Comparators.java b/src/java.base/share/classes/java/util/Comparators.java index 02a415b45817..0a8653e89e22 100644 --- a/src/java.base/share/classes/java/util/Comparators.java +++ b/src/java.base/share/classes/java/util/Comparators.java @@ -25,6 +25,7 @@ package java.util; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; import org.checkerframework.dataflow.qual.SideEffectFree; import java.io.Serializable; @@ -51,6 +52,7 @@ enum NaturalOrderComparator implements Comparator> { INSTANCE; @Override + @Pure public int compare(Comparable c1, Comparable c2) { return c1.compareTo(c2); } @@ -80,6 +82,7 @@ static final class NullComparator implements Comparator, Serializable { } @Override + @Pure public int compare(T a, T b) { if (a == null) { return (b == null) ? 0 : (nullFirst ? -1 : 1); diff --git a/src/java.base/share/classes/java/util/Date.java b/src/java.base/share/classes/java/util/Date.java index c8f9244a5daf..f7147f4c7327 100644 --- a/src/java.base/share/classes/java/util/Date.java +++ b/src/java.base/share/classes/java/util/Date.java @@ -919,6 +919,7 @@ public void setTime(@GuardSatisfied Date this, long time) { * {@code false} otherwise. * @throws NullPointerException if {@code when} is null. */ + @Pure public boolean before(@GuardSatisfied Date this, Date when) { return getMillisOf(this) < getMillisOf(when); } @@ -933,6 +934,7 @@ public boolean before(@GuardSatisfied Date this, Date when) { * {@code false} otherwise. * @throws NullPointerException if {@code when} is null. */ + @Pure public boolean after(@GuardSatisfied Date this, Date when) { return getMillisOf(this) > getMillisOf(when); } diff --git a/src/java.base/share/classes/java/util/DuplicateFormatFlagsException.java b/src/java.base/share/classes/java/util/DuplicateFormatFlagsException.java index 99024a95ce33..b83370990c3b 100644 --- a/src/java.base/share/classes/java/util/DuplicateFormatFlagsException.java +++ b/src/java.base/share/classes/java/util/DuplicateFormatFlagsException.java @@ -66,6 +66,7 @@ public String getFlags() { return flags; } + @SideEffectFree public String getMessage() { return String.format("Flags = '%s'", flags); } diff --git a/src/java.base/share/classes/java/util/FormatFlagsConversionMismatchException.java b/src/java.base/share/classes/java/util/FormatFlagsConversionMismatchException.java index 1e2a6eb73979..997c10230a8b 100644 --- a/src/java.base/share/classes/java/util/FormatFlagsConversionMismatchException.java +++ b/src/java.base/share/classes/java/util/FormatFlagsConversionMismatchException.java @@ -82,6 +82,7 @@ public char getConversion() { return c; } + @SideEffectFree public String getMessage() { return "Conversion = " + c + ", Flags = " + f; } diff --git a/src/java.base/share/classes/java/util/HexFormat.java b/src/java.base/share/classes/java/util/HexFormat.java index 7364868e2bbd..bcc1261d4a54 100644 --- a/src/java.base/share/classes/java/util/HexFormat.java +++ b/src/java.base/share/classes/java/util/HexFormat.java @@ -26,6 +26,7 @@ package java.util; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; import jdk.internal.access.JavaLangAccess; import jdk.internal.access.SharedSecrets; @@ -1048,6 +1049,7 @@ public static long fromHexDigitsToLong(CharSequence string, int fromIndex, int t * otherwise {@code false} */ @Override + @Pure public boolean equals(@Nullable Object o) { if (this == o) return true; diff --git a/src/java.base/share/classes/java/util/IllegalFormatArgumentIndexException.java b/src/java.base/share/classes/java/util/IllegalFormatArgumentIndexException.java index 891b9c2fa421..d9bf8f10b2c3 100644 --- a/src/java.base/share/classes/java/util/IllegalFormatArgumentIndexException.java +++ b/src/java.base/share/classes/java/util/IllegalFormatArgumentIndexException.java @@ -61,6 +61,7 @@ int getIndex() { return illegalIndex; } + @SideEffectFree @Override public String getMessage() { int index = getIndex(); diff --git a/src/java.base/share/classes/java/util/IllegalFormatCodePointException.java b/src/java.base/share/classes/java/util/IllegalFormatCodePointException.java index f5ee262b740f..795388fcb49a 100644 --- a/src/java.base/share/classes/java/util/IllegalFormatCodePointException.java +++ b/src/java.base/share/classes/java/util/IllegalFormatCodePointException.java @@ -67,6 +67,7 @@ public int getCodePoint() { return c; } + @SideEffectFree public String getMessage() { return String.format("Code point = %#x", c); } diff --git a/src/java.base/share/classes/java/util/IllegalFormatConversionException.java b/src/java.base/share/classes/java/util/IllegalFormatConversionException.java index 3666022a01c6..6d9c40bf9f97 100644 --- a/src/java.base/share/classes/java/util/IllegalFormatConversionException.java +++ b/src/java.base/share/classes/java/util/IllegalFormatConversionException.java @@ -82,6 +82,7 @@ public Class getArgumentClass() { } // javadoc inherited from Throwable.java + @SideEffectFree public String getMessage() { return String.format("%c != %s", c, arg.getName()); } diff --git a/src/java.base/share/classes/java/util/IllegalFormatFlagsException.java b/src/java.base/share/classes/java/util/IllegalFormatFlagsException.java index 9825a1068371..6b0cda2f5b0d 100644 --- a/src/java.base/share/classes/java/util/IllegalFormatFlagsException.java +++ b/src/java.base/share/classes/java/util/IllegalFormatFlagsException.java @@ -65,6 +65,7 @@ public String getFlags() { return flags; } + @SideEffectFree public String getMessage() { return "Flags = '" + flags + "'"; } diff --git a/src/java.base/share/classes/java/util/IllegalFormatPrecisionException.java b/src/java.base/share/classes/java/util/IllegalFormatPrecisionException.java index c29368258b82..43b1d77bfa00 100644 --- a/src/java.base/share/classes/java/util/IllegalFormatPrecisionException.java +++ b/src/java.base/share/classes/java/util/IllegalFormatPrecisionException.java @@ -64,6 +64,7 @@ public int getPrecision() { return p; } + @SideEffectFree public String getMessage() { return Integer.toString(p); } diff --git a/src/java.base/share/classes/java/util/IllegalFormatWidthException.java b/src/java.base/share/classes/java/util/IllegalFormatWidthException.java index 5adf734445fb..693a43436729 100644 --- a/src/java.base/share/classes/java/util/IllegalFormatWidthException.java +++ b/src/java.base/share/classes/java/util/IllegalFormatWidthException.java @@ -63,6 +63,7 @@ public int getWidth() { return w; } + @SideEffectFree public String getMessage() { return Integer.toString(w); } diff --git a/src/java.base/share/classes/java/util/Locale.java b/src/java.base/share/classes/java/util/Locale.java index 1eefd2e8bac8..86dff5595f6d 100644 --- a/src/java.base/share/classes/java/util/Locale.java +++ b/src/java.base/share/classes/java/util/Locale.java @@ -969,6 +969,7 @@ private LocaleKey(BaseLocale baseLocale, @Nullable LocaleExtensions extensions) } @Override + @Pure public boolean equals(@Nullable Object obj) { if (this == obj) { return true; diff --git a/src/java.base/share/classes/java/util/MissingFormatArgumentException.java b/src/java.base/share/classes/java/util/MissingFormatArgumentException.java index 847043018e07..84e37378404e 100644 --- a/src/java.base/share/classes/java/util/MissingFormatArgumentException.java +++ b/src/java.base/share/classes/java/util/MissingFormatArgumentException.java @@ -68,6 +68,7 @@ public String getFormatSpecifier() { return s; } + @SideEffectFree public String getMessage() { return "Format specifier '" + s + "'"; } diff --git a/src/java.base/share/classes/java/util/MissingFormatWidthException.java b/src/java.base/share/classes/java/util/MissingFormatWidthException.java index 19b718f9985c..f72525ff1890 100644 --- a/src/java.base/share/classes/java/util/MissingFormatWidthException.java +++ b/src/java.base/share/classes/java/util/MissingFormatWidthException.java @@ -25,6 +25,7 @@ package java.util; +import org.checkerframework.dataflow.qual.Pure; import org.checkerframework.dataflow.qual.SideEffectFree; /** @@ -66,6 +67,7 @@ public String getFormatSpecifier() { return s; } + @Pure public String getMessage() { return s; } diff --git a/src/java.base/share/classes/java/util/ResourceBundle.java b/src/java.base/share/classes/java/util/ResourceBundle.java index 6e208bfa4cec..d61dee29fcf9 100644 --- a/src/java.base/share/classes/java/util/ResourceBundle.java +++ b/src/java.base/share/classes/java/util/ResourceBundle.java @@ -731,6 +731,7 @@ boolean callerHasProvider() { } @Override + @Pure public boolean equals(@Nullable Object other) { if (this == other) { return true; diff --git a/src/java.base/share/classes/java/util/TreeMap.java b/src/java.base/share/classes/java/util/TreeMap.java index 1fb53a200849..b822f4cb1af9 100644 --- a/src/java.base/share/classes/java/util/TreeMap.java +++ b/src/java.base/share/classes/java/util/TreeMap.java @@ -1725,6 +1725,7 @@ public void remove() { * Compares two keys using the correct comparison method for this TreeMap. */ @SuppressWarnings("unchecked") + @Pure final int compare(Object k1, Object k2) { return comparator==null ? ((Comparable)k1).compareTo((K)k2) : comparator.compare((K)k1, (K)k2); diff --git a/src/java.base/share/classes/java/util/UnknownFormatConversionException.java b/src/java.base/share/classes/java/util/UnknownFormatConversionException.java index 8ba4d73e25d0..490f3baae844 100644 --- a/src/java.base/share/classes/java/util/UnknownFormatConversionException.java +++ b/src/java.base/share/classes/java/util/UnknownFormatConversionException.java @@ -66,6 +66,7 @@ public String getConversion() { } // javadoc inherited from Throwable.java + @SideEffectFree public String getMessage() { return String.format("Conversion = '%s'", s); } diff --git a/src/java.base/share/classes/java/util/UnknownFormatFlagsException.java b/src/java.base/share/classes/java/util/UnknownFormatFlagsException.java index 789d2ead28d4..2ab7927d2bcc 100644 --- a/src/java.base/share/classes/java/util/UnknownFormatFlagsException.java +++ b/src/java.base/share/classes/java/util/UnknownFormatFlagsException.java @@ -66,6 +66,7 @@ public String getFlags() { } // javadoc inherited from Throwable.java + @SideEffectFree public String getMessage() { return "Flags = " + flags; } diff --git a/src/java.base/share/classes/java/util/concurrent/ScheduledThreadPoolExecutor.java b/src/java.base/share/classes/java/util/concurrent/ScheduledThreadPoolExecutor.java index 44cf0370ae10..0e085ea4915c 100644 --- a/src/java.base/share/classes/java/util/concurrent/ScheduledThreadPoolExecutor.java +++ b/src/java.base/share/classes/java/util/concurrent/ScheduledThreadPoolExecutor.java @@ -255,6 +255,7 @@ public long getDelay(TimeUnit unit) { return unit.convert(time - System.nanoTime(), NANOSECONDS); } + @Pure public int compareTo(Delayed other) { if (other == this) // compare zero if same object return 0; diff --git a/src/java.base/share/classes/java/util/function/Predicate.java b/src/java.base/share/classes/java/util/function/Predicate.java index aceb0255ae4d..58715e69c7bc 100644 --- a/src/java.base/share/classes/java/util/function/Predicate.java +++ b/src/java.base/share/classes/java/util/function/Predicate.java @@ -25,6 +25,7 @@ package java.util.function; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.SideEffectFree; import org.checkerframework.framework.qual.AnnotatedFor; import java.util.Objects; @@ -115,6 +116,7 @@ default Predicate or(Predicate other) { * @return a predicate that tests if two arguments are equal according * to {@link Objects#equals(Object, Object)} */ + @SideEffectFree static Predicate isEqual(@Nullable Object targetRef) { return (null == targetRef) ? Objects::isNull diff --git a/src/java.base/share/classes/java/util/regex/PatternSyntaxException.java b/src/java.base/share/classes/java/util/regex/PatternSyntaxException.java index ea332059481f..0f7bb11117b4 100644 --- a/src/java.base/share/classes/java/util/regex/PatternSyntaxException.java +++ b/src/java.base/share/classes/java/util/regex/PatternSyntaxException.java @@ -106,7 +106,7 @@ public String getPattern(@GuardSatisfied PatternSyntaxException this) { * * @return The full detail message */ - @Pure + @SideEffectFree public String getMessage(@GuardSatisfied PatternSyntaxException this) { StringBuilder sb = new StringBuilder(); sb.append(desc); diff --git a/src/java.base/share/classes/java/util/zip/ZipCoder.java b/src/java.base/share/classes/java/util/zip/ZipCoder.java index e4c8e747e3c8..7d83fb9408e0 100644 --- a/src/java.base/share/classes/java/util/zip/ZipCoder.java +++ b/src/java.base/share/classes/java/util/zip/ZipCoder.java @@ -26,6 +26,7 @@ package java.util.zip; import org.checkerframework.checker.interning.qual.UsesObjectEquals; +import org.checkerframework.dataflow.qual.Pure; import org.checkerframework.framework.qual.AnnotatedFor; import java.nio.ByteBuffer; @@ -246,6 +247,7 @@ private byte[] slashBytes() { * a directory match will also be tested * */ + @Pure Comparison compare(String str, byte[] b, int off, int len, boolean matchDirectory) { String decoded = toString(b, off, len); if (decoded.startsWith(str)) { @@ -309,6 +311,7 @@ boolean hasTrailingSlash(byte[] a, int end) { } @Override + @Pure Comparison compare(String str, byte[] b, int off, int len, boolean matchDirectory) { try { byte[] encoded = JLA.getBytesNoRepl(str, UTF_8.INSTANCE); diff --git a/src/java.base/share/classes/javax/crypto/CryptoPolicyParser.java b/src/java.base/share/classes/javax/crypto/CryptoPolicyParser.java index e18bc45d3222..e755d80736a5 100644 --- a/src/java.base/share/classes/javax/crypto/CryptoPolicyParser.java +++ b/src/java.base/share/classes/javax/crypto/CryptoPolicyParser.java @@ -28,6 +28,7 @@ import org.checkerframework.checker.nonempty.qual.EnsuresNonEmptyIf; import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.dataflow.qual.Pure; +import org.checkerframework.dataflow.qual.SideEffectFree; import java.io.*; import java.util.ArrayList; @@ -635,6 +636,7 @@ public int hashCode() { return retval; } + @Pure public boolean equals(@Nullable Object obj) { if (obj == this) return true; @@ -679,14 +681,17 @@ static final class ParsingException extends GeneralSecurityException { * detail message. * @param msg the detail message. */ + @SideEffectFree ParsingException(@Nullable String msg) { super(msg); } + @SideEffectFree ParsingException(int line, String msg) { super("line " + line + ": " + msg); } + @SideEffectFree ParsingException(int line, String expect, String actual) { super("line "+line+": expected '"+expect+"', found '"+actual+"'"); } diff --git a/src/java.base/share/classes/javax/security/auth/Subject.java b/src/java.base/share/classes/javax/security/auth/Subject.java index b67c1614751f..0b6ec6dd3bed 100644 --- a/src/java.base/share/classes/javax/security/auth/Subject.java +++ b/src/java.base/share/classes/javax/security/auth/Subject.java @@ -1507,6 +1507,7 @@ public T[] toArray(T[] a) { return elements.toArray(a); } + @Pure public boolean equals(@Nullable Object o) { if (o == this) { return true; diff --git a/src/java.base/share/classes/jdk/internal/loader/AbstractClassLoaderValue.java b/src/java.base/share/classes/jdk/internal/loader/AbstractClassLoaderValue.java index c2649c0c341e..988a4c5a4202 100644 --- a/src/java.base/share/classes/jdk/internal/loader/AbstractClassLoaderValue.java +++ b/src/java.base/share/classes/jdk/internal/loader/AbstractClassLoaderValue.java @@ -27,6 +27,8 @@ import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.PolyNull; +import org.checkerframework.dataflow.qual.Pure; +import org.checkerframework.dataflow.qual.SideEffectFree; import jdk.internal.access.JavaLangAccess; import jdk.internal.access.SharedSecrets; @@ -352,6 +354,7 @@ static class RecursiveInvocationException extends IllegalStateException { @java.io.Serial private static final long serialVersionUID = 1L; + @SideEffectFree RecursiveInvocationException() { super("Recursive call"); } @@ -419,6 +422,7 @@ public boolean isEqualOrDescendantOf(AbstractClassLoaderValue clv) { } @Override + @Pure public boolean equals(@Nullable Object o) { if (this == o) return true; if (!(o instanceof Sub)) return false; diff --git a/src/java.base/share/classes/jdk/internal/org/xml/sax/SAXException.java b/src/java.base/share/classes/jdk/internal/org/xml/sax/SAXException.java index b30de64f5dd8..b63928914851 100644 --- a/src/java.base/share/classes/jdk/internal/org/xml/sax/SAXException.java +++ b/src/java.base/share/classes/jdk/internal/org/xml/sax/SAXException.java @@ -31,6 +31,8 @@ package jdk.internal.org.xml.sax; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; +import org.checkerframework.dataflow.qual.SideEffectFree; import java.io.IOException; import java.io.InvalidClassException; @@ -73,6 +75,7 @@ public class SAXException extends Exception { /** * Create a new SAXException. */ + @SideEffectFree public SAXException () { super(); @@ -84,6 +87,7 @@ public SAXException () * * @param message The error or warning message. */ + @SideEffectFree public SAXException (@Nullable String message) { super(message); } @@ -98,6 +102,7 @@ public SAXException (@Nullable String message) { * * @param e The exception to be wrapped in a SAXException. */ + @SideEffectFree public SAXException (@Nullable Exception e) { super(e); @@ -113,6 +118,7 @@ public SAXException (@Nullable Exception e) * @param message The detail message. * @param e The exception to be wrapped in a SAXException. */ + @SideEffectFree public SAXException (@Nullable String message, @Nullable Exception e) { super(message, e); @@ -128,6 +134,7 @@ public SAXException (@Nullable String message, @Nullable Exception e) * * @return The error or warning message. */ + @Pure public @Nullable String getMessage () { String message = super.getMessage(); @@ -155,6 +162,7 @@ public Exception getException () * * @return Return the cause of the exception */ + @Pure public @Nullable Throwable getCause() { return super.getCause(); } @@ -164,6 +172,7 @@ public Exception getException () * * @return A string representation of this exception. */ + @SideEffectFree public String toString () { Throwable exception = super.getCause(); diff --git a/src/java.base/share/classes/sun/security/provider/PolicyParser.java b/src/java.base/share/classes/sun/security/provider/PolicyParser.java index 958d25ee87d5..60affe87657e 100644 --- a/src/java.base/share/classes/sun/security/provider/PolicyParser.java +++ b/src/java.base/share/classes/sun/security/provider/PolicyParser.java @@ -27,6 +27,7 @@ import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.dataflow.qual.Pure; +import org.checkerframework.dataflow.qual.SideEffectFree; import java.io.*; import java.security.GeneralSecurityException; @@ -1052,6 +1053,7 @@ public String toString() { * @return true if the objects are equal, false otherwise */ @Override + @Pure public boolean equals(@Nullable Object obj) { if (this == obj) return true; @@ -1132,6 +1134,7 @@ public int hashCode() { } @Override + @Pure public boolean equals(@Nullable Object obj) { if (obj == this) return true; @@ -1313,11 +1316,13 @@ public static class ParsingException extends GeneralSecurityException { * * @param msg the detail message. */ + @SideEffectFree public ParsingException(String msg) { super(msg); i18nMessage = msg; } + @SideEffectFree public ParsingException(@Nullable String msg, LocalizedMessage localizedMsg, Object[] source) { super(msg); @@ -1325,12 +1330,14 @@ public ParsingException(@Nullable String msg, LocalizedMessage localizedMsg, this.source = source; } + @SideEffectFree public ParsingException(int line, String msg) { super("line " + line + ": " + msg); localizedMsg = new LocalizedMessage("line.number.msg"); source = new Object[] {line, msg}; } + @SideEffectFree public ParsingException(int line, String expect, String actual) { super("line " + line + ": expected [" + expect + "], found [" + actual + "]"); diff --git a/src/java.base/share/classes/sun/security/x509/AlgorithmId.java b/src/java.base/share/classes/sun/security/x509/AlgorithmId.java index 52cd0203bc34..81ac31c17358 100644 --- a/src/java.base/share/classes/sun/security/x509/AlgorithmId.java +++ b/src/java.base/share/classes/sun/security/x509/AlgorithmId.java @@ -310,6 +310,7 @@ public byte[] getEncodedParams() { * Returns true iff the argument indicates the same algorithm * with the same parameters. */ + @Pure public boolean equals(AlgorithmId other) { return algid.equals(other.algid) && Arrays.equals(encodedParams, other.encodedParams); @@ -342,6 +343,7 @@ public boolean equals(@Nullable Object other) { * Compares two algorithm IDs for equality. Returns true iff * they are the same algorithm, ignoring algorithm parameters. */ + @Pure public final boolean equals(ObjectIdentifier id) { return algid.equals((Object)id); } diff --git a/src/java.base/share/classes/sun/security/x509/RDN.java b/src/java.base/share/classes/sun/security/x509/RDN.java index 332d34cdab43..38dc80d8e407 100644 --- a/src/java.base/share/classes/sun/security/x509/RDN.java +++ b/src/java.base/share/classes/sun/security/x509/RDN.java @@ -477,6 +477,7 @@ static Comparator getInstance() { * AVA's containing a standard keyword are ordered alphabetically, * followed by AVA's containing an OID keyword, ordered numerically */ + @Pure public int compare(AVA a1, AVA a2) { boolean a1Has2253 = a1.hasRFC2253Keyword(); boolean a2Has2253 = a2.hasRFC2253Keyword(); diff --git a/src/java.base/share/classes/sun/security/x509/X509CertInfo.java b/src/java.base/share/classes/sun/security/x509/X509CertInfo.java index 94c4006f48c5..de948dbe515d 100644 --- a/src/java.base/share/classes/sun/security/x509/X509CertInfo.java +++ b/src/java.base/share/classes/sun/security/x509/X509CertInfo.java @@ -205,6 +205,7 @@ public boolean equals(@Nullable Object other) { * @param other the object being compared with this one * @return true iff the certificates are equivalent */ + @Pure public boolean equals(X509CertInfo other) { if (this == other) { return true; diff --git a/src/java.base/share/classes/sun/util/PreHashedMap.java b/src/java.base/share/classes/sun/util/PreHashedMap.java index e4d2fee3679d..d6cf4edab337 100644 --- a/src/java.base/share/classes/sun/util/PreHashedMap.java +++ b/src/java.base/share/classes/sun/util/PreHashedMap.java @@ -261,6 +261,7 @@ public int hashCode() { ? 0 : v.hashCode())); } + @Pure public boolean equals(@Nullable Object ob) { if (ob == this) return true; diff --git a/src/java.base/share/classes/sun/util/locale/BaseLocale.java b/src/java.base/share/classes/sun/util/locale/BaseLocale.java index 9b8d62898a0f..f58643642223 100644 --- a/src/java.base/share/classes/sun/util/locale/BaseLocale.java +++ b/src/java.base/share/classes/sun/util/locale/BaseLocale.java @@ -314,6 +314,7 @@ private BaseLocale getBaseLocale() { } @Override + @Pure public boolean equals(@Nullable Object obj) { if (this == obj) { return true; diff --git a/src/java.base/share/classes/sun/util/resources/Bundles.java b/src/java.base/share/classes/sun/util/resources/Bundles.java index 8f4016e83481..22dfef0f6778 100644 --- a/src/java.base/share/classes/sun/util/resources/Bundles.java +++ b/src/java.base/share/classes/sun/util/resources/Bundles.java @@ -41,6 +41,7 @@ package sun.util.resources; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; import java.lang.ref.ReferenceQueue; import java.lang.ref.SoftReference; @@ -500,6 +501,7 @@ void setProviders(ServiceLoader providers) { } @Override + @Pure public boolean equals(@Nullable Object other) { if (this == other) { return true; diff --git a/src/java.base/unix/classes/java/lang/ProcessEnvironment.java b/src/java.base/unix/classes/java/lang/ProcessEnvironment.java index 21a177dbf8a7..a7502015f3c9 100644 --- a/src/java.base/unix/classes/java/lang/ProcessEnvironment.java +++ b/src/java.base/unix/classes/java/lang/ProcessEnvironment.java @@ -146,6 +146,7 @@ public String toString() { return str; } + @Pure public boolean equals(@Nullable Object o) { return o instanceof ExternalData && Arrays.equals(getBytes(), ((ExternalData) o).getBytes()); @@ -180,10 +181,12 @@ public static Variable valueOf(byte[] bytes) { return new Variable(new String(bytes, JNU_CHARSET), bytes); } + @Pure public int compareTo(Variable variable) { return Arrays.compare(getBytes(), variable.getBytes()); } + @Pure public boolean equals(@Nullable Object o) { return o instanceof Variable && super.equals(o); } @@ -213,10 +216,12 @@ public static Value valueOf(byte[] bytes) { return new Value(new String(bytes, JNU_CHARSET), bytes); } + @Pure public int compareTo(Value value) { return Arrays.compare(getBytes(), value.getBytes()); } + @Pure public boolean equals(@Nullable Object o) { return o instanceof Value && super.equals(o); } @@ -319,6 +324,7 @@ public String setValue(String newValue) { return e.setValue(Value.valueOf(newValue)).toString(); } public String toString() {return getKey() + "=" + getValue();} + @Pure public boolean equals(@Nullable Object o) { return o instanceof StringEntry && e.equals(((StringEntry)o).e); @@ -398,6 +404,7 @@ public boolean contains(Object o) { public boolean remove(Object o) { return c.remove(Value.valueOfQueryOnly(o)); } + @Pure public boolean equals(@Nullable Object o) { return o instanceof StringValues && c.equals(((StringValues)o).c); diff --git a/src/java.base/unix/classes/sun/nio/fs/UnixPath.java b/src/java.base/unix/classes/sun/nio/fs/UnixPath.java index f87fd666b939..86b435073846 100644 --- a/src/java.base/unix/classes/sun/nio/fs/UnixPath.java +++ b/src/java.base/unix/classes/sun/nio/fs/UnixPath.java @@ -723,6 +723,7 @@ public boolean endsWith(Path other) { } @Override + @Pure public int compareTo(Path other) { int len1 = path.length; int len2 = ((UnixPath) other).path.length; diff --git a/src/java.base/windows/classes/java/lang/ProcessEnvironment.java b/src/java.base/windows/classes/java/lang/ProcessEnvironment.java index 39dad5f8d2f2..e70c0e1235ba 100644 --- a/src/java.base/windows/classes/java/lang/ProcessEnvironment.java +++ b/src/java.base/windows/classes/java/lang/ProcessEnvironment.java @@ -129,6 +129,7 @@ public String setValue(String value) { return e.setValue(validateValue(value)); } public String toString() { return getKey() + "=" + getValue();} + @Pure public boolean equals(@Nullable Object o) {return e.equals(o);} public int hashCode() {return e.hashCode();} } @@ -204,6 +205,7 @@ public Set> entrySet() { private static final class NameComparator implements Comparator { + @Pure public int compare(String s1, String s2) { // We can't use String.compareToIgnoreCase since it // canonicalizes to lower case, while Windows @@ -229,6 +231,7 @@ public int compare(String s1, String s2) { private static final class EntryComparator implements Comparator> { + @Pure public int compare(Map.Entry e1, Map.Entry e2) { return nameComparator.compare(e1.getKey(), e2.getKey()); diff --git a/src/java.base/windows/classes/sun/nio/fs/WindowsPath.java b/src/java.base/windows/classes/sun/nio/fs/WindowsPath.java index da88bc046237..6c75c950a3da 100644 --- a/src/java.base/windows/classes/sun/nio/fs/WindowsPath.java +++ b/src/java.base/windows/classes/sun/nio/fs/WindowsPath.java @@ -794,6 +794,7 @@ public boolean endsWith(Path obj) { } @Override + @Pure public int compareTo(Path obj) { if (obj == null) throw new NullPointerException(); diff --git a/src/java.compiler/share/classes/javax/lang/model/type/TypeMirror.java b/src/java.compiler/share/classes/javax/lang/model/type/TypeMirror.java index ad87c7f7048e..879e7e673f24 100644 --- a/src/java.compiler/share/classes/javax/lang/model/type/TypeMirror.java +++ b/src/java.compiler/share/classes/javax/lang/model/type/TypeMirror.java @@ -27,6 +27,7 @@ import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.signature.qual.FullyQualifiedName; +import org.checkerframework.dataflow.qual.Pure; import java.lang.annotation.Annotation; import java.util.List; @@ -124,6 +125,7 @@ public interface TypeMirror extends javax.lang.model.AnnotatedConstruct { * @param obj the object to be compared with this type * @return {@code true} if the specified object is equal to this one */ + @Pure boolean equals(@Nullable Object obj); /** diff --git a/src/java.datatransfer/share/classes/java/awt/datatransfer/DataFlavor.java b/src/java.datatransfer/share/classes/java/awt/datatransfer/DataFlavor.java index f90039b6d416..3cd1188b69e0 100644 --- a/src/java.datatransfer/share/classes/java/awt/datatransfer/DataFlavor.java +++ b/src/java.datatransfer/share/classes/java/awt/datatransfer/DataFlavor.java @@ -947,6 +947,7 @@ public boolean equals(@Nullable Object o) { * {@code DataFlavor}; {@code false} otherwise * @see #selectBestTextFlavor */ + @Pure public boolean equals(DataFlavor that) { if (that == null) { return false; @@ -1007,6 +1008,7 @@ public boolean equals(DataFlavor that) { * {@link #isMimeTypeEqual(String)} instead. */ @Deprecated + @Pure public boolean equals(String s) { if (s == null || mimeType == null) return false; diff --git a/src/java.desktop/share/classes/com/sun/beans/finder/Signature.java b/src/java.desktop/share/classes/com/sun/beans/finder/Signature.java index a34165831102..a183fb815a7d 100644 --- a/src/java.desktop/share/classes/com/sun/beans/finder/Signature.java +++ b/src/java.desktop/share/classes/com/sun/beans/finder/Signature.java @@ -113,6 +113,7 @@ && isEqual(signature.name, this.name) * @return {@code true} if first object is the same as the second object, * {@code false} otherwise */ + @Pure private static boolean isEqual(Object obj1, Object obj2) { return (obj1 == null) ? obj2 == null @@ -128,6 +129,7 @@ private static boolean isEqual(Object obj1, Object obj2) { * @return {@code true} if first array is the same as the second array, * {@code false} otherwise */ + @Pure private static boolean isEqual(Class[] args1, Class[] args2) { if ((args1 == null) || (args2 == null)) { return args1 == args2; diff --git a/src/java.desktop/share/classes/java/awt/DisplayMode.java b/src/java.desktop/share/classes/java/awt/DisplayMode.java index 973aaaa1ddc6..a3d06d67f3dc 100644 --- a/src/java.desktop/share/classes/java/awt/DisplayMode.java +++ b/src/java.desktop/share/classes/java/awt/DisplayMode.java @@ -135,6 +135,7 @@ public int getRefreshRate() { * @param dm the display mode to compare to * @return whether the two display modes are equal */ + @Pure public boolean equals(DisplayMode dm) { if (dm == null) { return false; diff --git a/src/java.desktop/share/classes/java/awt/MenuShortcut.java b/src/java.desktop/share/classes/java/awt/MenuShortcut.java index 53c33c2d91f1..f5f22fa89085 100644 --- a/src/java.desktop/share/classes/java/awt/MenuShortcut.java +++ b/src/java.desktop/share/classes/java/awt/MenuShortcut.java @@ -155,6 +155,7 @@ public boolean usesShiftModifier() { * {@code false} otherwise. * @since 1.1 */ + @Pure public boolean equals(MenuShortcut s) { return (s != null && (s.getKey() == key) && (s.usesShiftModifier() == usesShift)); diff --git a/src/java.desktop/share/classes/java/awt/RenderingHints.java b/src/java.desktop/share/classes/java/awt/RenderingHints.java index 21388d8ef6ee..2ecd2affa646 100644 --- a/src/java.desktop/share/classes/java/awt/RenderingHints.java +++ b/src/java.desktop/share/classes/java/awt/RenderingHints.java @@ -196,6 +196,7 @@ public final int hashCode() { * The equals method for all Key objects will return the same * result as the equality operator '=='. */ + @Pure public final boolean equals(@Nullable Object o) { return this == o; } diff --git a/src/java.desktop/share/classes/java/awt/font/FontRenderContext.java b/src/java.desktop/share/classes/java/awt/font/FontRenderContext.java index 407901caae2b..f73471b48920 100644 --- a/src/java.desktop/share/classes/java/awt/font/FontRenderContext.java +++ b/src/java.desktop/share/classes/java/awt/font/FontRenderContext.java @@ -321,6 +321,7 @@ public boolean equals(@Nullable Object obj) { * otherwise. * @since 1.4 */ + @Pure public boolean equals(FontRenderContext rhs) { if (this == rhs) { return true; diff --git a/src/java.desktop/share/classes/java/awt/font/GlyphVector.java b/src/java.desktop/share/classes/java/awt/font/GlyphVector.java index f6cb074a74f0..b04abfad0c65 100644 --- a/src/java.desktop/share/classes/java/awt/font/GlyphVector.java +++ b/src/java.desktop/share/classes/java/awt/font/GlyphVector.java @@ -30,6 +30,7 @@ package java.awt.font; import org.checkerframework.checker.interning.qual.UsesObjectEquals; +import org.checkerframework.dataflow.qual.Pure; import org.checkerframework.framework.qual.AnnotatedFor; import java.awt.Graphics2D; @@ -616,5 +617,6 @@ public Rectangle getGlyphPixelBounds(int index, FontRenderContext renderFRC, flo * {@code GlyphVector} equals this {@code GlyphVector}; * {@code false} otherwise. */ + @Pure public abstract boolean equals(GlyphVector set); } diff --git a/src/java.desktop/share/classes/java/awt/font/ImageGraphicAttribute.java b/src/java.desktop/share/classes/java/awt/font/ImageGraphicAttribute.java index 6093954bfb52..46e4a57d4191 100644 --- a/src/java.desktop/share/classes/java/awt/font/ImageGraphicAttribute.java +++ b/src/java.desktop/share/classes/java/awt/font/ImageGraphicAttribute.java @@ -208,6 +208,7 @@ public boolean equals(@Nullable Object rhs) { * {@code ImageGraphicAttribute} equals {@code rhs}; * {@code false} otherwise. */ + @Pure public boolean equals(ImageGraphicAttribute rhs) { if (rhs == null) { diff --git a/src/java.desktop/share/classes/java/awt/font/ShapeGraphicAttribute.java b/src/java.desktop/share/classes/java/awt/font/ShapeGraphicAttribute.java index 2669f6efa349..3608a9c413c3 100644 --- a/src/java.desktop/share/classes/java/awt/font/ShapeGraphicAttribute.java +++ b/src/java.desktop/share/classes/java/awt/font/ShapeGraphicAttribute.java @@ -237,6 +237,7 @@ public boolean equals(@Nullable Object rhs) { * {@code ShapeGraphicAttribute} equals {@code rhs}; * {@code false} otherwise. */ + @Pure public boolean equals(ShapeGraphicAttribute rhs) { if (rhs == null) { diff --git a/src/java.desktop/share/classes/java/awt/font/TextHitInfo.java b/src/java.desktop/share/classes/java/awt/font/TextHitInfo.java index b7dd9b67bd59..fae78c2538f3 100644 --- a/src/java.desktop/share/classes/java/awt/font/TextHitInfo.java +++ b/src/java.desktop/share/classes/java/awt/font/TextHitInfo.java @@ -166,6 +166,7 @@ public boolean equals(@Nullable Object obj) { * has the same {@code charIndex} and {@code isLeadingEdge} * as this {@code TextHitInfo}. */ + @Pure public boolean equals(TextHitInfo hitInfo) { return hitInfo != null && charIndex == hitInfo.charIndex && isLeadingEdge == hitInfo.isLeadingEdge; diff --git a/src/java.desktop/share/classes/java/awt/print/PrinterIOException.java b/src/java.desktop/share/classes/java/awt/print/PrinterIOException.java index ddd38f6f09de..e5826cfb0a1f 100644 --- a/src/java.desktop/share/classes/java/awt/print/PrinterIOException.java +++ b/src/java.desktop/share/classes/java/awt/print/PrinterIOException.java @@ -26,6 +26,8 @@ package java.awt.print; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; +import org.checkerframework.dataflow.qual.SideEffectFree; import java.io.IOException; import java.io.Serial; @@ -63,6 +65,7 @@ public class PrinterIOException extends PrinterException { * {@link IOException}. * @param exception the specified {@code IOException} */ + @SideEffectFree public PrinterIOException(IOException exception) { initCause(null); // Disallow subsequent initCause mException = exception; @@ -91,6 +94,7 @@ public IOException getIOException() { * @return the cause of this exception. * @since 1.4 */ + @Pure public @Nullable Throwable getCause() { return mException; } diff --git a/src/java.desktop/share/classes/javax/imageio/ImageTypeSpecifier.java b/src/java.desktop/share/classes/javax/imageio/ImageTypeSpecifier.java index 1d35eb21c25c..4ab21afe1814 100644 --- a/src/java.desktop/share/classes/javax/imageio/ImageTypeSpecifier.java +++ b/src/java.desktop/share/classes/javax/imageio/ImageTypeSpecifier.java @@ -333,6 +333,7 @@ public Interleaved(ColorSpace colorSpace, bandOffsets); } + @Pure public boolean equals(@Nullable Object o) { if (!(o instanceof Interleaved that)) { return false; @@ -473,6 +474,7 @@ public Banded(ColorSpace colorSpace, bandOffsets); } + @Pure public boolean equals(@Nullable Object o) { if (!(o instanceof Banded that)) { return false; diff --git a/src/java.desktop/share/classes/javax/swing/JEditorPane.java b/src/java.desktop/share/classes/javax/swing/JEditorPane.java index b8c64ef46a1c..4af3d9c1001d 100644 --- a/src/java.desktop/share/classes/javax/swing/JEditorPane.java +++ b/src/java.desktop/share/classes/javax/swing/JEditorPane.java @@ -26,6 +26,7 @@ package javax.swing; import org.checkerframework.checker.interning.qual.Interned; +import org.checkerframework.dataflow.qual.Pure; import org.checkerframework.framework.qual.AnnotatedFor; import java.awt.Component; @@ -2333,10 +2334,12 @@ protected void forwardUpdateToView(View v, DocumentEvent e, public void paint(Graphics g, Shape allocation) { } + @Pure protected boolean isBefore(int x, int y, Rectangle alloc) { return false; } + @Pure protected boolean isAfter(int x, int y, Rectangle alloc) { return false; } diff --git a/src/java.desktop/share/classes/javax/swing/plaf/nimbus/DerivedColor.java b/src/java.desktop/share/classes/javax/swing/plaf/nimbus/DerivedColor.java index 06a80960aad5..56de1447fcd2 100644 --- a/src/java.desktop/share/classes/javax/swing/plaf/nimbus/DerivedColor.java +++ b/src/java.desktop/share/classes/javax/swing/plaf/nimbus/DerivedColor.java @@ -190,6 +190,7 @@ static class UIResource extends DerivedColor implements javax.swing.plaf.UIResou } @Override + @Pure public boolean equals(@Nullable Object o) { return (o instanceof UIResource) && super.equals(o); } diff --git a/src/java.desktop/share/classes/javax/swing/plaf/nimbus/NimbusStyle.java b/src/java.desktop/share/classes/javax/swing/plaf/nimbus/NimbusStyle.java index 06ef60baf321..ab5121603655 100644 --- a/src/java.desktop/share/classes/javax/swing/plaf/nimbus/NimbusStyle.java +++ b/src/java.desktop/share/classes/javax/swing/plaf/nimbus/NimbusStyle.java @@ -26,6 +26,7 @@ import org.checkerframework.checker.interning.qual.Interned; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; import org.checkerframework.framework.qual.AnnotatedFor; import javax.swing.Painter; @@ -165,6 +166,7 @@ public final class NimbusStyle extends SynthStyle { private static final Comparator STATE_COMPARATOR = new Comparator() { @Override + @Pure public int compare(RuntimeState a, RuntimeState b) { return a.state - b.state; } @@ -1107,6 +1109,7 @@ void init(Object key, int xstate) { } @Override + @Pure public boolean equals(@Nullable Object obj) { final CacheKey other = (CacheKey) obj; if (obj == null) return false; diff --git a/src/java.desktop/share/classes/javax/swing/text/AbstractDocument.java b/src/java.desktop/share/classes/javax/swing/text/AbstractDocument.java index e187a0b78609..78d8e5386a52 100644 --- a/src/java.desktop/share/classes/javax/swing/text/AbstractDocument.java +++ b/src/java.desktop/share/classes/javax/swing/text/AbstractDocument.java @@ -26,6 +26,7 @@ package javax.swing.text; import org.checkerframework.checker.interning.qual.Interned; +import org.checkerframework.dataflow.qual.Pure; import org.checkerframework.framework.qual.AnnotatedFor; import java.awt.font.TextAttribute; @@ -1918,6 +1919,7 @@ public boolean isDefined(Object attrName) { * @return true if the same * @see AttributeSet#isEqual */ + @Pure public boolean isEqual(AttributeSet attr) { return attributes.isEqual(attr); } diff --git a/src/java.desktop/share/classes/javax/swing/text/SimpleAttributeSet.java b/src/java.desktop/share/classes/javax/swing/text/SimpleAttributeSet.java index 35c1ca1f94db..5a12823b35c1 100644 --- a/src/java.desktop/share/classes/javax/swing/text/SimpleAttributeSet.java +++ b/src/java.desktop/share/classes/javax/swing/text/SimpleAttributeSet.java @@ -120,6 +120,7 @@ public boolean isDefined(Object attrName) { * @param attr the second attribute set * @return true if the sets are equal, false otherwise */ + @Pure public boolean isEqual(AttributeSet attr) { return ((getAttributeCount() == attr.getAttributeCount()) && containsAttributes(attr)); @@ -375,6 +376,7 @@ public int getAttributeCount() { public boolean isDefined(Object attrName) { return false; } + @Pure public boolean isEqual(AttributeSet attr) { return (attr.getAttributeCount() == 0); } @@ -396,6 +398,7 @@ public boolean containsAttributes(AttributeSet attributes) { public AttributeSet getResolveParent() { return null; } + @Pure public boolean equals(@Nullable Object obj) { if (this == obj) { return true; diff --git a/src/java.desktop/share/classes/javax/swing/text/StyleContext.java b/src/java.desktop/share/classes/javax/swing/text/StyleContext.java index 59c3de36d593..ca312d8c5495 100644 --- a/src/java.desktop/share/classes/javax/swing/text/StyleContext.java +++ b/src/java.desktop/share/classes/javax/swing/text/StyleContext.java @@ -27,6 +27,7 @@ import org.checkerframework.checker.interning.qual.Interned; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; import org.checkerframework.framework.qual.AnnotatedFor; import java.awt.Color; @@ -906,6 +907,7 @@ public int hashCode() { * @return true if the objects are equal; * false otherwise. */ + @Pure public boolean equals(@Nullable Object obj) { if (obj instanceof AttributeSet) { AttributeSet attrs = (AttributeSet) obj; @@ -962,6 +964,7 @@ public boolean isDefined(Object key) { * @return true if the same * @see AttributeSet#isEqual */ + @Pure public boolean isEqual(AttributeSet attr) { if (attr instanceof SmallAttributeSet) { return attr == this; @@ -1277,6 +1280,7 @@ public int hashCode() { * @return true if the objects are equal; * false otherwise. */ + @Pure public boolean equals(@Nullable Object obj) { if (obj instanceof FontKey) { FontKey font = (FontKey)obj; @@ -1474,6 +1478,7 @@ public boolean isDefined(Object attrName) { * @return true if the same * @see AttributeSet#isEqual */ + @Pure public boolean isEqual(AttributeSet attr) { return attributes.isEqual(attr); } diff --git a/src/java.desktop/share/classes/javax/swing/text/html/HTML.java b/src/java.desktop/share/classes/javax/swing/text/html/HTML.java index 7f77fe80d8f1..bfad12ffe2cb 100644 --- a/src/java.desktop/share/classes/javax/swing/text/html/HTML.java +++ b/src/java.desktop/share/classes/javax/swing/text/html/HTML.java @@ -27,6 +27,7 @@ import org.checkerframework.checker.interning.qual.Interned; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; import org.checkerframework.framework.qual.AnnotatedFor; import java.io.IOException; @@ -625,6 +626,7 @@ public int hashCode() { * @return true if the objects are equal; * false otherwise */ + @Pure public boolean equals(@Nullable Object obj) { if (obj instanceof UnknownTag) { return toString().equals(obj.toString()); diff --git a/src/java.desktop/share/classes/sun/font/AttributeValues.java b/src/java.desktop/share/classes/sun/font/AttributeValues.java index 144ff215e94a..02d9d528e652 100644 --- a/src/java.desktop/share/classes/sun/font/AttributeValues.java +++ b/src/java.desktop/share/classes/sun/font/AttributeValues.java @@ -453,6 +453,7 @@ public boolean equals(@Nullable Object rhs) { return false; } + @Pure public boolean equals(AttributeValues rhs) { // test in order of most likely to differ and easiest to compare // also assumes we're generally calling this only if family, diff --git a/src/java.desktop/share/classes/sun/font/CoreMetrics.java b/src/java.desktop/share/classes/sun/font/CoreMetrics.java index d174e00621bd..487f8eddaf4a 100644 --- a/src/java.desktop/share/classes/sun/font/CoreMetrics.java +++ b/src/java.desktop/share/classes/sun/font/CoreMetrics.java @@ -87,6 +87,7 @@ public boolean equals(@Nullable Object rhs) { } } + @Pure public boolean equals(CoreMetrics rhs) { if (rhs != null) { if (this == rhs) { diff --git a/src/java.desktop/share/classes/sun/font/StandardGlyphVector.java b/src/java.desktop/share/classes/sun/font/StandardGlyphVector.java index 32000f5af5db..c98752338716 100644 --- a/src/java.desktop/share/classes/sun/font/StandardGlyphVector.java +++ b/src/java.desktop/share/classes/sun/font/StandardGlyphVector.java @@ -640,6 +640,7 @@ public GlyphJustificationInfo getGlyphJustificationInfo(int ix) { return null; } + @Pure public boolean equals(GlyphVector rhs) { if (this == rhs) { return true; @@ -1392,6 +1393,7 @@ static final class GlyphTransformInfo { } // used in sgv equality + @Pure public boolean equals(GlyphTransformInfo rhs) { if (rhs == null) { return false; diff --git a/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolder2.java b/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolder2.java index f26ffb3d4a44..88987f9b10eb 100644 --- a/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolder2.java +++ b/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolder2.java @@ -1261,6 +1261,7 @@ public boolean isSpecial() { * * @see sun.awt.shell.ShellFolder#compareTo(File) */ + @Pure public int compareTo(File file2) { if (!(file2 instanceof Win32ShellFolder2)) { if (isFileSystem() && !isSpecial()) { @@ -1374,6 +1375,7 @@ public ColumnComparator(Win32ShellFolder2 shellFolder, int columnIdx) { } // compares 2 objects within this folder by the specified column + @Pure public int compare(final File o, final File o1) { Integer result = invoke(new Callable() { public Integer call() { diff --git a/src/java.logging/share/classes/java/util/logging/Level.java b/src/java.logging/share/classes/java/util/logging/Level.java index 6afa3bfae0e0..c510edf144bf 100644 --- a/src/java.logging/share/classes/java/util/logging/Level.java +++ b/src/java.logging/share/classes/java/util/logging/Level.java @@ -29,6 +29,7 @@ import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.RequiresNonNull; import org.checkerframework.checker.signature.qual.BinaryName; +import org.checkerframework.dataflow.qual.Pure; import org.checkerframework.framework.qual.AnnotatedFor; import org.checkerframework.framework.qual.CFComment; @@ -552,6 +553,7 @@ public static synchronized Level parse(String name) throws IllegalArgumentExcept @CFComment({"nullness: It returns false in case a NullPointerException is thrown"}) @SuppressWarnings({"dereference.of.nullable"}) @Override + @Pure public boolean equals(@Nullable Object ox) { try { Level lx = (Level)ox; diff --git a/src/java.logging/share/classes/java/util/logging/LogManager.java b/src/java.logging/share/classes/java/util/logging/LogManager.java index 86e77a3ae9a1..26b87bdeee56 100644 --- a/src/java.logging/share/classes/java/util/logging/LogManager.java +++ b/src/java.logging/share/classes/java/util/logging/LogManager.java @@ -28,6 +28,7 @@ import org.checkerframework.checker.interning.qual.UsesObjectEquals; import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.signature.qual.BinaryName; +import org.checkerframework.dataflow.qual.Pure; import org.checkerframework.framework.qual.AnnotatedFor; import java.io.*; @@ -202,6 +203,7 @@ private CloseOnReset(Logger ref) { this.logger = Objects.requireNonNull(ref); } @Override + @Pure public boolean equals(@Nullable Object other) { return (other instanceof CloseOnReset) && ((CloseOnReset)other).logger == logger; } diff --git a/src/java.management/share/classes/javax/management/MBeanException.java b/src/java.management/share/classes/javax/management/MBeanException.java index be29e6c4d732..c0893b038d39 100644 --- a/src/java.management/share/classes/javax/management/MBeanException.java +++ b/src/java.management/share/classes/javax/management/MBeanException.java @@ -26,6 +26,8 @@ package javax.management; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; +import org.checkerframework.dataflow.qual.SideEffectFree; /** * Represents "user defined" exceptions thrown by MBean methods @@ -52,6 +54,7 @@ public class MBeanException extends JMException { * * @param e the wrapped exception. */ + @SideEffectFree public MBeanException(java.lang.Exception e) { super() ; exception = e ; @@ -64,6 +67,7 @@ public MBeanException(java.lang.Exception e) { * @param e the wrapped exception. * @param message the detail message. */ + @SideEffectFree public MBeanException(java.lang.Exception e, @Nullable String message) { super(message) ; exception = e ; @@ -84,6 +88,7 @@ public Exception getTargetException() { * * @return the wrapped exception. */ + @Pure public @Nullable Throwable getCause() { return exception; } diff --git a/src/java.management/share/classes/javax/management/MBeanInfo.java b/src/java.management/share/classes/javax/management/MBeanInfo.java index e666acb62b57..8da857ebf77c 100644 --- a/src/java.management/share/classes/javax/management/MBeanInfo.java +++ b/src/java.management/share/classes/javax/management/MBeanInfo.java @@ -612,6 +612,7 @@ public Boolean run() { } } + @Pure private static boolean isEqual(String s1, String s2) { boolean ret; diff --git a/src/java.management/share/classes/javax/management/ObjectName.java b/src/java.management/share/classes/javax/management/ObjectName.java index f5b26185eebf..ddda1011222a 100644 --- a/src/java.management/share/classes/javax/management/ObjectName.java +++ b/src/java.management/share/classes/javax/management/ObjectName.java @@ -2146,6 +2146,7 @@ public void setMBeanServer(MBeanServer mbs) { } * * @since 1.6 */ + @Pure public int compareTo(ObjectName name) { // Quick optimization: // diff --git a/src/java.management/share/classes/javax/management/ReflectionException.java b/src/java.management/share/classes/javax/management/ReflectionException.java index 92e9218fa67b..c9d2b953d7f4 100644 --- a/src/java.management/share/classes/javax/management/ReflectionException.java +++ b/src/java.management/share/classes/javax/management/ReflectionException.java @@ -27,6 +27,8 @@ import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; +import org.checkerframework.dataflow.qual.SideEffectFree; /** * Represents exceptions thrown in the MBean server when using the @@ -51,6 +53,7 @@ public class ReflectionException extends JMException { * * @param e the wrapped exception. */ + @SideEffectFree public ReflectionException(java.lang.Exception e) { super() ; exception = e ; @@ -63,6 +66,7 @@ public ReflectionException(java.lang.Exception e) { * @param e the wrapped exception. * @param message the detail message. */ + @SideEffectFree public ReflectionException(java.lang.Exception e, @Nullable String message) { super(message) ; exception = e ; @@ -82,6 +86,7 @@ public java.lang.Exception getTargetException() { * * @return the wrapped {@link Exception}. */ + @Pure public @Nullable Throwable getCause() { return exception; } diff --git a/src/java.management/share/classes/javax/management/RuntimeErrorException.java b/src/java.management/share/classes/javax/management/RuntimeErrorException.java index 0a77974b09d7..35feebb0992b 100644 --- a/src/java.management/share/classes/javax/management/RuntimeErrorException.java +++ b/src/java.management/share/classes/javax/management/RuntimeErrorException.java @@ -27,6 +27,8 @@ import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; +import org.checkerframework.dataflow.qual.SideEffectFree; /** * When a java.lang.Error occurs in the agent it should be caught and @@ -49,6 +51,7 @@ public class RuntimeErrorException extends JMRuntimeException { * * @param e the wrapped error. */ + @SideEffectFree public RuntimeErrorException(java.lang.Error e) { super(); error = e ; @@ -60,6 +63,7 @@ public RuntimeErrorException(java.lang.Error e) { * @param e the wrapped error. * @param message the detail message. */ + @SideEffectFree public RuntimeErrorException(java.lang.Error e, @Nullable String message) { super(message); error = e ; @@ -79,6 +83,7 @@ public java.lang.Error getTargetError() { * * @return the wrapped {@link Error}. */ + @Pure public @Nullable Throwable getCause() { return error; } diff --git a/src/java.management/share/classes/javax/management/RuntimeMBeanException.java b/src/java.management/share/classes/javax/management/RuntimeMBeanException.java index 71495dddcae1..3fcffe88373f 100644 --- a/src/java.management/share/classes/javax/management/RuntimeMBeanException.java +++ b/src/java.management/share/classes/javax/management/RuntimeMBeanException.java @@ -26,6 +26,8 @@ package javax.management; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; +import org.checkerframework.dataflow.qual.SideEffectFree; /** * Represents runtime exceptions thrown by MBean methods in @@ -51,6 +53,7 @@ public class RuntimeMBeanException extends JMRuntimeException { * * @param e the wrapped exception. */ + @SideEffectFree public RuntimeMBeanException(java.lang.RuntimeException e) { super() ; runtimeException = e ; @@ -63,6 +66,7 @@ public RuntimeMBeanException(java.lang.RuntimeException e) { * @param e the wrapped exception. * @param message the detail message. */ + @SideEffectFree public RuntimeMBeanException(java.lang.RuntimeException e, @Nullable String message) { super(message) ; runtimeException = e ; @@ -82,6 +86,7 @@ public java.lang.RuntimeException getTargetException() { * * @return the wrapped {@link RuntimeException}. */ + @Pure public @Nullable Throwable getCause() { return runtimeException; } diff --git a/src/java.management/share/classes/javax/management/RuntimeOperationsException.java b/src/java.management/share/classes/javax/management/RuntimeOperationsException.java index 481b7a02892e..304bc36a648c 100644 --- a/src/java.management/share/classes/javax/management/RuntimeOperationsException.java +++ b/src/java.management/share/classes/javax/management/RuntimeOperationsException.java @@ -27,6 +27,8 @@ import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; +import org.checkerframework.dataflow.qual.SideEffectFree; /** * Represents runtime exceptions thrown in the agent when performing operations on MBeans. @@ -50,6 +52,7 @@ public class RuntimeOperationsException extends JMRuntimeException { * * @param e the wrapped exception. */ + @SideEffectFree public RuntimeOperationsException(java.lang.RuntimeException e) { super() ; runtimeException = e ; @@ -62,6 +65,7 @@ public RuntimeOperationsException(java.lang.RuntimeException e) { * @param e the wrapped exception. * @param message the detail message. */ + @SideEffectFree public RuntimeOperationsException(java.lang.RuntimeException e, @Nullable String message) { super(message); runtimeException = e ; @@ -81,6 +85,7 @@ public java.lang.RuntimeException getTargetException() { * * @return the wrapped {@link RuntimeException}. */ + @Pure public @Nullable Throwable getCause() { return runtimeException; } diff --git a/src/java.management/share/classes/javax/management/openmbean/CompositeType.java b/src/java.management/share/classes/javax/management/openmbean/CompositeType.java index 6dc32f4e3daf..6844fd85490a 100644 --- a/src/java.management/share/classes/javax/management/openmbean/CompositeType.java +++ b/src/java.management/share/classes/javax/management/openmbean/CompositeType.java @@ -365,6 +365,7 @@ boolean isAssignableFrom(OpenType ot) { * * @return true if the specified object is equal to this CompositeType instance. */ + @Pure public boolean equals(@Nullable Object obj) { // if obj is null, return false diff --git a/src/java.management/share/classes/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java b/src/java.management/share/classes/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java index 8cc66641f68a..d572ee43aca0 100644 --- a/src/java.management/share/classes/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java +++ b/src/java.management/share/classes/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java @@ -571,6 +571,7 @@ static void check(OpenMBeanParameterInfo info) throws OpenDataException { } @SuppressWarnings({"unchecked", "rawtypes"}) + @Pure static int compare(Object x, Object y) { return ((Comparable) x).compareTo(y); } diff --git a/src/java.management/share/classes/javax/management/remote/JMXProviderException.java b/src/java.management/share/classes/javax/management/remote/JMXProviderException.java index b4d482555a58..4170144d40b4 100644 --- a/src/java.management/share/classes/javax/management/remote/JMXProviderException.java +++ b/src/java.management/share/classes/javax/management/remote/JMXProviderException.java @@ -27,6 +27,8 @@ package javax.management.remote; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; +import org.checkerframework.dataflow.qual.SideEffectFree; import java.io.IOException; @@ -47,6 +49,7 @@ public class JMXProviderException extends IOException { *

Constructs a JMXProviderException with no * specified detail message.

*/ + @SideEffectFree public JMXProviderException() { } @@ -56,6 +59,7 @@ public JMXProviderException() { * * @param message the detail message */ + @SideEffectFree public JMXProviderException(@Nullable String message) { super(message); } @@ -67,11 +71,13 @@ public JMXProviderException(@Nullable String message) { * @param message the detail message * @param cause the nested exception */ + @SideEffectFree public JMXProviderException(@Nullable String message, @Nullable Throwable cause) { super(message); this.cause = cause; } + @Pure public @Nullable Throwable getCause() { return cause; } diff --git a/src/java.management/share/classes/javax/management/remote/JMXServerErrorException.java b/src/java.management/share/classes/javax/management/remote/JMXServerErrorException.java index f8b7a78c1ff3..41783f9f336d 100644 --- a/src/java.management/share/classes/javax/management/remote/JMXServerErrorException.java +++ b/src/java.management/share/classes/javax/management/remote/JMXServerErrorException.java @@ -27,6 +27,8 @@ package javax.management.remote; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; +import org.checkerframework.dataflow.qual.SideEffectFree; import java.io.IOException; @@ -57,11 +59,13 @@ public class JMXServerErrorException extends IOException { * constructed where this parameter is null, but the standard * connectors will never do so. */ + @SideEffectFree public JMXServerErrorException(@Nullable String s, @Nullable Error err) { super(s); cause = err; } + @Pure public @Nullable Throwable getCause() { return cause; } diff --git a/src/java.naming/share/classes/com/sun/jndi/ldap/LdapName.java b/src/java.naming/share/classes/com/sun/jndi/ldap/LdapName.java index 1cd68a16099d..fd1ee963a257 100644 --- a/src/java.naming/share/classes/com/sun/jndi/ldap/LdapName.java +++ b/src/java.naming/share/classes/com/sun/jndi/ldap/LdapName.java @@ -153,6 +153,7 @@ public boolean equals(@Nullable Object obj) { (compareTo(obj) == 0)); } + @Pure public int compareTo(Object obj) { LdapName that = (LdapName)obj; @@ -635,12 +636,14 @@ public String toString() { return new String(buf); } + @Pure public boolean equals(@Nullable Object obj) { return ((obj instanceof Rdn) && (compareTo(obj) == 0)); } // Compare TypeAndValue components one by one, lexicographically. + @Pure public int compareTo(Object obj) { Rdn that = (Rdn)obj; int minSize = Math.min(tvs.size(), that.tvs.size()); @@ -710,6 +713,7 @@ public String toString() { return (type + "=" + value); } + @Pure public int compareTo(Object obj) { // NB: Any change here affecting equality must be // reflected in hashCode(). @@ -726,6 +730,7 @@ public int compareTo(Object obj) { return getValueComparable().compareTo(that.getValueComparable()); } + @Pure public boolean equals(@Nullable Object obj) { // NB: Any change here must be reflected in hashCode(). if (!(obj instanceof TypeAndValue)) { @@ -766,6 +771,7 @@ Object getUnescapedValue() { * If "value" is binary, it is returned in uppercase but * otherwise unmodified. */ + @Pure private String getValueComparable() { if (comparable != null) { return comparable; // return cached result diff --git a/src/java.naming/share/classes/javax/naming/CompositeName.java b/src/java.naming/share/classes/javax/naming/CompositeName.java index 52bffb4fa5da..82cfe1de64ae 100644 --- a/src/java.naming/share/classes/javax/naming/CompositeName.java +++ b/src/java.naming/share/classes/javax/naming/CompositeName.java @@ -330,6 +330,7 @@ public int hashCode() { * is less than, equal to, or greater than the given Object. * @throws ClassCastException if obj is not a CompositeName. */ + @Pure public int compareTo(Object obj) { if (!(obj instanceof CompositeName)) { throw new ClassCastException("Not a CompositeName"); diff --git a/src/java.naming/share/classes/javax/naming/CompoundName.java b/src/java.naming/share/classes/javax/naming/CompoundName.java index a25d3128197c..741a4a134b3f 100644 --- a/src/java.naming/share/classes/javax/naming/CompoundName.java +++ b/src/java.naming/share/classes/javax/naming/CompoundName.java @@ -314,6 +314,7 @@ public Object clone() { * @throws ClassCastException if obj is not a CompoundName. * @see #equals(java.lang.Object) */ + @Pure public int compareTo(Object obj) { if (!(obj instanceof CompoundName)) { throw new ClassCastException("Not a CompoundName"); diff --git a/src/java.naming/share/classes/javax/naming/NameImpl.java b/src/java.naming/share/classes/javax/naming/NameImpl.java index 08340c6ae41d..064bd2bf82a6 100644 --- a/src/java.naming/share/classes/javax/naming/NameImpl.java +++ b/src/java.naming/share/classes/javax/naming/NameImpl.java @@ -515,6 +515,7 @@ public boolean equals(@Nullable Object obj) { * Note: using syntax of this NameImpl and ignoring * that of comparison target. */ + @Pure public int compareTo(NameImpl obj) { if (this == obj) { return 0; diff --git a/src/java.naming/share/classes/javax/naming/NamingException.java b/src/java.naming/share/classes/javax/naming/NamingException.java index ead249808523..5c6ac3efea11 100644 --- a/src/java.naming/share/classes/javax/naming/NamingException.java +++ b/src/java.naming/share/classes/javax/naming/NamingException.java @@ -26,6 +26,8 @@ package javax.naming; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; +import org.checkerframework.dataflow.qual.SideEffectFree; /** * This is the superclass of all exceptions thrown by @@ -125,6 +127,7 @@ public class NamingException extends Exception { * additional detail about this exception. * @see java.lang.Throwable#getMessage */ + @SideEffectFree public NamingException(@Nullable String explanation) { super(explanation); resolvedName = remainingName = null; @@ -135,6 +138,7 @@ public NamingException(@Nullable String explanation) { * Constructs a new NamingException. * All fields are set to null. */ + @SideEffectFree public NamingException() { super(); resolvedName = remainingName = null; @@ -359,6 +363,7 @@ public void setRootCause(Throwable e) { * @see #initCause(Throwable) * @since 1.4 */ + @Pure public @Nullable Throwable getCause() { return getRootCause(); } @@ -399,6 +404,7 @@ public Throwable initCause(Throwable cause) { * @return The non-null string containing the string representation * of this exception. */ + @SideEffectFree public String toString() { String answer = super.toString(); diff --git a/src/java.naming/share/classes/javax/naming/ldap/LdapName.java b/src/java.naming/share/classes/javax/naming/ldap/LdapName.java index af30c7281d90..de3c1cc53ddd 100644 --- a/src/java.naming/share/classes/javax/naming/ldap/LdapName.java +++ b/src/java.naming/share/classes/javax/naming/ldap/LdapName.java @@ -712,6 +712,7 @@ public boolean equals(@Nullable Object obj) { * is less than, equal to, or greater than the given obj. * @exception ClassCastException if obj is null or not a LdapName. */ + @Pure public int compareTo(Object obj) { if (!(obj instanceof LdapName)) { diff --git a/src/java.naming/share/classes/javax/naming/ldap/Rdn.java b/src/java.naming/share/classes/javax/naming/ldap/Rdn.java index 10199394caf2..f10632022d0d 100644 --- a/src/java.naming/share/classes/javax/naming/ldap/Rdn.java +++ b/src/java.naming/share/classes/javax/naming/ldap/Rdn.java @@ -325,6 +325,7 @@ public String toString() { * is less than, equal to, or greater than the given Object. * @throws ClassCastException if obj is null or not a Rdn. */ + @Pure public int compareTo(Object obj) { if (!(obj instanceof Rdn)) { throw new ClassCastException("The obj is not a Rdn"); @@ -444,6 +445,7 @@ Object getValue() { return value; } + @Pure public int compareTo(RdnEntry that) { int diff = type.compareToIgnoreCase(that.type); if (diff != 0) { @@ -456,6 +458,7 @@ public int compareTo(RdnEntry that) { that.getValueComparable()); } + @Pure public boolean equals(@Nullable Object obj) { if (obj == this) { return true; diff --git a/src/java.naming/share/classes/javax/naming/spi/NamingManager.java b/src/java.naming/share/classes/javax/naming/spi/NamingManager.java index 61d7b101d656..b4694d427fbb 100644 --- a/src/java.naming/share/classes/javax/naming/spi/NamingManager.java +++ b/src/java.naming/share/classes/javax/naming/spi/NamingManager.java @@ -26,6 +26,8 @@ package javax.naming.spi; import org.checkerframework.checker.interning.qual.Interned; +import org.checkerframework.dataflow.qual.Pure; +import org.checkerframework.dataflow.qual.SideEffectFree; import org.checkerframework.framework.qual.AnnotatedFor; import java.security.AccessController; @@ -762,10 +764,12 @@ private static class FactoryInitializationError extends Error { @java.io.Serial static final long serialVersionUID = -5805552256848841560L; + @SideEffectFree private FactoryInitializationError(NoInitialContextException cause) { super(cause); } + @Pure @Override public NoInitialContextException getCause() { return (NoInitialContextException) super.getCause(); diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/ConnectionPool.java b/src/java.net.http/share/classes/jdk/internal/net/http/ConnectionPool.java index 8986b90148f9..13cafd34171c 100644 --- a/src/java.net.http/share/classes/jdk/internal/net/http/ConnectionPool.java +++ b/src/java.net.http/share/classes/jdk/internal/net/http/ConnectionPool.java @@ -89,6 +89,7 @@ private CacheKey(boolean secure, InetSocketAddress destination, } @Override + @Pure public boolean equals(@Nullable Object obj) { if (obj == null) { return false; diff --git a/src/java.rmi/share/classes/java/rmi/RemoteException.java b/src/java.rmi/share/classes/java/rmi/RemoteException.java index 6b74028ee071..951671fe20f9 100644 --- a/src/java.rmi/share/classes/java/rmi/RemoteException.java +++ b/src/java.rmi/share/classes/java/rmi/RemoteException.java @@ -26,6 +26,8 @@ package java.rmi; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; +import org.checkerframework.dataflow.qual.SideEffectFree; /** * A {@code RemoteException} is the common superclass for a number of @@ -67,6 +69,7 @@ public class RemoteException extends java.io.IOException { /** * Constructs a {@code RemoteException}. */ + @SideEffectFree public RemoteException() { initCause(null); // Disallow subsequent initCause } @@ -77,6 +80,7 @@ public RemoteException() { * * @param s the detail message */ + @SideEffectFree public RemoteException(@Nullable String s) { super(s); initCause(null); // Disallow subsequent initCause @@ -90,6 +94,7 @@ public RemoteException(@Nullable String s) { * @param s the detail message * @param cause the cause */ + @SideEffectFree public RemoteException(@Nullable String s, @Nullable Throwable cause) { super(s); initCause(null); // Disallow subsequent initCause @@ -102,6 +107,7 @@ public RemoteException(@Nullable String s, @Nullable Throwable cause) { * * @return the detail message */ + @SideEffectFree public String getMessage() { if (detail == null) { return super.getMessage(); @@ -118,6 +124,7 @@ public String getMessage() { * @return the cause, which may be {@code null}. * @since 1.4 */ + @Pure public @Nullable Throwable getCause() { return detail; } diff --git a/src/java.rmi/share/classes/java/rmi/server/ServerCloneException.java b/src/java.rmi/share/classes/java/rmi/server/ServerCloneException.java index 9dcf16e1ef2c..f189e4c54f9d 100644 --- a/src/java.rmi/share/classes/java/rmi/server/ServerCloneException.java +++ b/src/java.rmi/share/classes/java/rmi/server/ServerCloneException.java @@ -26,6 +26,8 @@ package java.rmi.server; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; +import org.checkerframework.dataflow.qual.SideEffectFree; /** * A {@code ServerCloneException} is thrown if a remote exception occurs @@ -68,6 +70,7 @@ public class ServerCloneException extends CloneNotSupportedException { * * @param s the detail message. */ + @SideEffectFree public ServerCloneException(@Nullable String s) { super(s); initCause(null); // Disallow subsequent initCause @@ -80,6 +83,7 @@ public ServerCloneException(@Nullable String s) { * @param s the detail message. * @param cause the cause */ + @SideEffectFree public ServerCloneException(@Nullable String s, @Nullable Exception cause) { super(s); initCause(null); // Disallow subsequent initCause @@ -92,6 +96,7 @@ public ServerCloneException(@Nullable String s, @Nullable Exception cause) { * * @return the detail message */ + @SideEffectFree public String getMessage() { if (detail == null) return super.getMessage(); @@ -108,6 +113,7 @@ public String getMessage() { * @return the cause, which may be {@code null}. * @since 1.4 */ + @Pure public @Nullable Throwable getCause() { return detail; } diff --git a/src/java.security.jgss/share/classes/org/ietf/jgss/GSSName.java b/src/java.security.jgss/share/classes/org/ietf/jgss/GSSName.java index bed5d256e459..f6ae338946fd 100644 --- a/src/java.security.jgss/share/classes/org/ietf/jgss/GSSName.java +++ b/src/java.security.jgss/share/classes/org/ietf/jgss/GSSName.java @@ -191,6 +191,7 @@ public interface GSSName { * {@link GSSException#BAD_NAMETYPE GSSException.BAD_NAMETYPE}, * {@link GSSException#FAILURE GSSException.FAILURE} */ + @Pure boolean equals(GSSName another) throws GSSException; /** diff --git a/src/java.security.jgss/share/classes/sun/security/jgss/GSSCredentialImpl.java b/src/java.security.jgss/share/classes/sun/security/jgss/GSSCredentialImpl.java index e362db843ece..ca82e089bb84 100644 --- a/src/java.security.jgss/share/classes/sun/security/jgss/GSSCredentialImpl.java +++ b/src/java.security.jgss/share/classes/sun/security/jgss/GSSCredentialImpl.java @@ -676,6 +676,7 @@ public Oid getMech() { public int getUsage() { return usage; } + @Pure public boolean equals(@Nullable Object other) { if (! (other instanceof SearchKey that)) return false; diff --git a/src/java.security.jgss/share/classes/sun/security/jgss/GSSNameImpl.java b/src/java.security.jgss/share/classes/sun/security/jgss/GSSNameImpl.java index ac364949280f..3bfc6b6d3dbe 100644 --- a/src/java.security.jgss/share/classes/sun/security/jgss/GSSNameImpl.java +++ b/src/java.security.jgss/share/classes/sun/security/jgss/GSSNameImpl.java @@ -283,6 +283,7 @@ public GSSName canonicalize(Oid mech) throws GSSException { * names are equals, then there is some mechanism that * authenticates them as the same principal. */ + @Pure public boolean equals(GSSName other) throws GSSException { if (this.isAnonymous() || other.isAnonymous()) diff --git a/src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5NameElement.java b/src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5NameElement.java index 3e3824e4f7e0..73647f9a9f91 100644 --- a/src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5NameElement.java +++ b/src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5NameElement.java @@ -223,6 +223,7 @@ public final PrincipalName getKrb5PrincipalName() { * @exception GSSException with major codes of BAD_NAMETYPE, * BAD_NAME, FAILURE */ + @Pure public boolean equals(GSSNameSpi other) throws GSSException { if (other == this) diff --git a/src/java.security.jgss/share/classes/sun/security/jgss/spi/GSSNameSpi.java b/src/java.security.jgss/share/classes/sun/security/jgss/spi/GSSNameSpi.java index 8f7fcbdaa40c..c4bd2e415791 100644 --- a/src/java.security.jgss/share/classes/sun/security/jgss/spi/GSSNameSpi.java +++ b/src/java.security.jgss/share/classes/sun/security/jgss/spi/GSSNameSpi.java @@ -56,6 +56,7 @@ public interface GSSNameSpi { * @exception GSSException with major codes of BAD_NAMETYPE, * BAD_NAME, FAILURE */ + @Pure boolean equals(GSSNameSpi name) throws GSSException; /** diff --git a/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/GSSNameElement.java b/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/GSSNameElement.java index b1cd4d782c07..f0c8961e50f3 100644 --- a/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/GSSNameElement.java +++ b/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/GSSNameElement.java @@ -235,6 +235,7 @@ public Provider getProvider() { return SunNativeProvider.INSTANCE; } + @Pure public boolean equals(GSSNameSpi other) throws GSSException { if (!(other instanceof GSSNameElement)) { return false; diff --git a/src/java.security.jgss/share/classes/sun/security/krb5/internal/rcache/AuthTimeWithHash.java b/src/java.security.jgss/share/classes/sun/security/krb5/internal/rcache/AuthTimeWithHash.java index 9d341f50f2df..78060ea44a85 100644 --- a/src/java.security.jgss/share/classes/sun/security/krb5/internal/rcache/AuthTimeWithHash.java +++ b/src/java.security.jgss/share/classes/sun/security/krb5/internal/rcache/AuthTimeWithHash.java @@ -111,6 +111,7 @@ public String toString() { } @Override + @Pure public int compareTo(AuthTimeWithHash other) { int cmp = 0; if (ctime != other.ctime) { diff --git a/src/java.security.sasl/share/classes/javax/security/sasl/SaslException.java b/src/java.security.sasl/share/classes/javax/security/sasl/SaslException.java index c11f6299997f..d82f60925b53 100644 --- a/src/java.security.sasl/share/classes/javax/security/sasl/SaslException.java +++ b/src/java.security.sasl/share/classes/javax/security/sasl/SaslException.java @@ -26,6 +26,8 @@ package javax.security.sasl; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; +import org.checkerframework.dataflow.qual.SideEffectFree; import java.io.IOException; @@ -50,6 +52,7 @@ public class SaslException extends IOException { * Constructs a new instance of {@code SaslException}. * The root exception and the detailed message are null. */ + @SideEffectFree public SaslException () { super(); } @@ -61,6 +64,7 @@ public SaslException () { * * @see java.lang.Throwable#getMessage */ + @SideEffectFree public SaslException (@Nullable String detail) { super(detail); } @@ -81,6 +85,7 @@ public SaslException (@Nullable String detail) { * @see java.lang.Throwable#getMessage * @see #getCause */ + @SideEffectFree public SaslException (@Nullable String detail, @Nullable Throwable ex) { super(detail); if (ex != null) { @@ -92,6 +97,7 @@ public SaslException (@Nullable String detail, @Nullable Throwable ex) { * Override Throwable.getCause() to ensure deserialized object from * JSR 28 would return same value for getCause() (i.e., _exception). */ + @Pure public @Nullable Throwable getCause() { return _exception; } @@ -118,6 +124,7 @@ public Throwable initCause(Throwable cause) { * @see java.lang.Throwable#getMessage */ // Override Throwable.toString() to conform to JSR 28 + @SideEffectFree public String toString() { String answer = super.toString(); if (_exception != null && _exception != this) { diff --git a/src/java.sql/share/classes/java/sql/BatchUpdateException.java b/src/java.sql/share/classes/java/sql/BatchUpdateException.java index 971592167764..6588695133ad 100644 --- a/src/java.sql/share/classes/java/sql/BatchUpdateException.java +++ b/src/java.sql/share/classes/java/sql/BatchUpdateException.java @@ -26,6 +26,7 @@ package java.sql; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.SideEffectFree; import java.io.IOException; import java.io.InvalidObjectException; @@ -98,6 +99,7 @@ public class BatchUpdateException extends SQLException { * @see #BatchUpdateException(java.lang.String, java.lang.String, int, long[], * java.lang.Throwable) */ + @SideEffectFree public BatchUpdateException( @Nullable String reason, @Nullable String SQLState, int vendorCode, int @Nullable [] updateCounts ) { super(reason, SQLState, vendorCode); @@ -133,6 +135,7 @@ public BatchUpdateException( @Nullable String reason, @Nullable String SQLState, * @see #BatchUpdateException(java.lang.String, java.lang.String, int, long[], * java.lang.Throwable) */ + @SideEffectFree public BatchUpdateException(@Nullable String reason, @Nullable String SQLState, int @Nullable [] updateCounts) { this(reason, SQLState, 0, updateCounts); @@ -165,6 +168,7 @@ public BatchUpdateException(@Nullable String reason, @Nullable String SQLState, * @see #BatchUpdateException(java.lang.String, java.lang.String, int, long[], * java.lang.Throwable) */ + @SideEffectFree public BatchUpdateException(@Nullable String reason, int @Nullable [] updateCounts) { this(reason, null, 0, updateCounts); } @@ -194,6 +198,7 @@ public BatchUpdateException(@Nullable String reason, int @Nullable [] updateCou * @see #BatchUpdateException(java.lang.String, java.lang.String, int, long[], * java.lang.Throwable) */ + @SideEffectFree public BatchUpdateException(int @Nullable [] updateCounts) { this(null, null, 0, updateCounts); } @@ -210,6 +215,7 @@ public BatchUpdateException(int @Nullable [] updateCounts) { * @see #BatchUpdateException(java.lang.String, java.lang.String, int, long[], * java.lang.Throwable) */ + @SideEffectFree public BatchUpdateException() { this(null, null, 0, null); } @@ -230,6 +236,7 @@ public BatchUpdateException() { * @see #BatchUpdateException(java.lang.String, java.lang.String, int, long[], * java.lang.Throwable) */ + @SideEffectFree public BatchUpdateException(@Nullable Throwable cause) { this((cause == null ? null : cause.toString()), null, 0, (int[])null, cause); } @@ -263,6 +270,7 @@ public BatchUpdateException(@Nullable Throwable cause) { * @see #BatchUpdateException(java.lang.String, java.lang.String, int, long[], * java.lang.Throwable) */ + @SideEffectFree public BatchUpdateException(int @Nullable []updateCounts , @Nullable Throwable cause) { this((cause == null ? null : cause.toString()), null, 0, updateCounts, cause); } @@ -294,6 +302,7 @@ public BatchUpdateException(int @Nullable []updateCounts , @Nullable Throwable c * @see #BatchUpdateException(java.lang.String, java.lang.String, int, long[], * java.lang.Throwable) */ + @SideEffectFree public BatchUpdateException(@Nullable String reason, int @Nullable []updateCounts, @Nullable Throwable cause) { this(reason, null, 0, updateCounts, cause); } @@ -327,6 +336,7 @@ public BatchUpdateException(@Nullable String reason, int @Nullable []updateCount * @see #BatchUpdateException(java.lang.String, java.lang.String, int, long[], * java.lang.Throwable) */ + @SideEffectFree public BatchUpdateException(@Nullable String reason, @Nullable String SQLState, int @Nullable []updateCounts, @Nullable Throwable cause) { this(reason, SQLState, 0, updateCounts, cause); @@ -362,6 +372,7 @@ public BatchUpdateException(@Nullable String reason, @Nullable String SQLState, * @see #BatchUpdateException(java.lang.String, java.lang.String, int, long[], * java.lang.Throwable) */ + @SideEffectFree public BatchUpdateException(@Nullable String reason, @Nullable String SQLState, int vendorCode, int @Nullable []updateCounts,@Nullable Throwable cause) { super(reason, SQLState, vendorCode, cause); @@ -429,6 +440,7 @@ public BatchUpdateException(@Nullable String reason, @Nullable String SQLState, * may be null indicating the cause is non-existent or unknown. * @since 1.8 */ + @SideEffectFree public BatchUpdateException(@Nullable String reason, @Nullable String SQLState, int vendorCode, long @Nullable []updateCounts,@Nullable Throwable cause) { super(reason, SQLState, vendorCode, cause); diff --git a/src/java.sql/share/classes/java/sql/SQLClientInfoException.java b/src/java.sql/share/classes/java/sql/SQLClientInfoException.java index f4eb3e26ef30..8aedd7de914a 100644 --- a/src/java.sql/share/classes/java/sql/SQLClientInfoException.java +++ b/src/java.sql/share/classes/java/sql/SQLClientInfoException.java @@ -25,6 +25,7 @@ package java.sql; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.SideEffectFree; import java.util.Map; @@ -66,6 +67,7 @@ public class SQLClientInfoException extends SQLException { * * @since 1.6 */ + @SideEffectFree public SQLClientInfoException() { this.failedProperties = null; @@ -90,6 +92,7 @@ public SQLClientInfoException() { * * @since 1.6 */ + @SideEffectFree public SQLClientInfoException(@Nullable Map failedProperties) { this.failedProperties = failedProperties; @@ -114,6 +117,7 @@ public SQLClientInfoException(@Nullable Map failedProp * * @since 1.6 */ + @SideEffectFree public SQLClientInfoException(@Nullable Map failedProperties, @Nullable Throwable cause) { @@ -142,6 +146,7 @@ public SQLClientInfoException(@Nullable Map failedProp * * @since 1.6 */ + @SideEffectFree public SQLClientInfoException(@Nullable String reason, @Nullable Map failedProperties) { @@ -168,6 +173,7 @@ public SQLClientInfoException(@Nullable String reason, * * @since 1.6 */ + @SideEffectFree public SQLClientInfoException(@Nullable String reason, @Nullable Map failedProperties, @Nullable Throwable cause) { @@ -197,6 +203,7 @@ public SQLClientInfoException(@Nullable String reason, * * @since 1.6 */ + @SideEffectFree public SQLClientInfoException(@Nullable String reason, @Nullable String SQLState, @Nullable Map failedProperties) { @@ -223,6 +230,7 @@ public SQLClientInfoException(@Nullable String reason, * * @since 1.6 */ + @SideEffectFree public SQLClientInfoException(@Nullable String reason, @Nullable String SQLState, @Nullable Map failedProperties, @@ -253,6 +261,7 @@ public SQLClientInfoException(@Nullable String reason, * * @since 1.6 */ + @SideEffectFree public SQLClientInfoException(@Nullable String reason, @Nullable String SQLState, int vendorCode, @@ -282,6 +291,7 @@ public SQLClientInfoException(@Nullable String reason, * * @since 1.6 */ + @SideEffectFree public SQLClientInfoException(@Nullable String reason, @Nullable String SQLState, int vendorCode, diff --git a/src/java.sql/share/classes/java/sql/SQLException.java b/src/java.sql/share/classes/java/sql/SQLException.java index f77ab4ffbd96..f14166441fb2 100644 --- a/src/java.sql/share/classes/java/sql/SQLException.java +++ b/src/java.sql/share/classes/java/sql/SQLException.java @@ -27,6 +27,7 @@ import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.dataflow.qual.Pure; +import org.checkerframework.dataflow.qual.SideEffectFree; import java.util.Iterator; import java.util.NoSuchElementException; @@ -71,6 +72,7 @@ public class SQLException extends java.lang.Exception * @param SQLState an XOPEN or SQL:2003 code identifying the exception * @param vendorCode a database vendor-specific exception code */ + @SideEffectFree public SQLException(@Nullable String reason, @Nullable String SQLState, int vendorCode) { super(reason); this.SQLState = SQLState; @@ -97,6 +99,7 @@ public SQLException(@Nullable String reason, @Nullable String SQLState, int vend * @param reason a description of the exception * @param SQLState an XOPEN or SQL:2003 code identifying the exception */ + @SideEffectFree public SQLException(@Nullable String reason, @Nullable String SQLState) { super(reason); this.SQLState = SQLState; @@ -120,6 +123,7 @@ public SQLException(@Nullable String reason, @Nullable String SQLState) { * * @param reason a description of the exception */ + @SideEffectFree public SQLException(@Nullable String reason) { super(reason); this.SQLState = null; @@ -141,6 +145,7 @@ public SQLException(@Nullable String reason) { * {@link Throwable#initCause(java.lang.Throwable)} method. * */ + @SideEffectFree public SQLException() { super(); this.SQLState = null; @@ -166,6 +171,7 @@ public SQLException() { * may be null indicating the cause is non-existent or unknown. * @since 1.6 */ + @SideEffectFree public SQLException(@Nullable Throwable cause) { super(cause); @@ -188,6 +194,7 @@ public SQLException(@Nullable Throwable cause) { * may be null indicating the cause is non-existent or unknown. * @since 1.6 */ + @SideEffectFree public SQLException(@Nullable String reason, @Nullable Throwable cause) { super(reason,cause); @@ -211,6 +218,7 @@ public SQLException(@Nullable String reason, @Nullable Throwable cause) { * the cause is non-existent or unknown. * @since 1.6 */ + @SideEffectFree public SQLException(@Nullable String reason, @Nullable String sqlState, @Nullable Throwable cause) { super(reason,cause); @@ -237,6 +245,7 @@ public SQLException(@Nullable String reason, @Nullable String sqlState, @Nullabl * may be null indicating the cause is non-existent or unknown. * @since 1.6 */ + @SideEffectFree public SQLException(@Nullable String reason, @Nullable String sqlState, int vendorCode, @Nullable Throwable cause) { super(reason,cause); diff --git a/src/java.sql/share/classes/java/sql/SQLWarning.java b/src/java.sql/share/classes/java/sql/SQLWarning.java index 84d40274b9e1..de7b554bba4a 100644 --- a/src/java.sql/share/classes/java/sql/SQLWarning.java +++ b/src/java.sql/share/classes/java/sql/SQLWarning.java @@ -26,6 +26,7 @@ package java.sql; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.SideEffectFree; /** *

An exception that provides information on database access @@ -60,6 +61,7 @@ public class SQLWarning extends SQLException { * @param SQLState an XOPEN or SQL:2003 code identifying the warning * @param vendorCode a database vendor-specific warning code */ + @SideEffectFree public SQLWarning(@Nullable String reason, @Nullable String SQLState, int vendorCode) { super(reason, SQLState, vendorCode); DriverManager.println("SQLWarning: reason(" + reason + @@ -80,6 +82,7 @@ public SQLWarning(@Nullable String reason, @Nullable String SQLState, int vendor * @param reason a description of the warning * @param SQLState an XOPEN or SQL:2003 code identifying the warning */ + @SideEffectFree public SQLWarning(@Nullable String reason, @Nullable String SQLState) { super(reason, SQLState); DriverManager.println("SQLWarning: reason(" + reason + @@ -98,6 +101,7 @@ public SQLWarning(@Nullable String reason, @Nullable String SQLState) { * * @param reason a description of the warning */ + @SideEffectFree public SQLWarning(@Nullable String reason) { super(reason); DriverManager.println("SQLWarning: reason(" + reason + ")"); @@ -113,6 +117,7 @@ public SQLWarning(@Nullable String reason) { * {@link Throwable#initCause(java.lang.Throwable)} method. * */ + @SideEffectFree public SQLWarning() { super(); DriverManager.println("SQLWarning: "); @@ -130,6 +135,7 @@ public SQLWarning() { * @param cause the underlying reason for this {@code SQLWarning} (which is saved for later retrieval by the {@code getCause()} method); may be null indicating * the cause is non-existent or unknown. */ + @SideEffectFree public SQLWarning(@Nullable Throwable cause) { super(cause); DriverManager.println("SQLWarning"); @@ -147,6 +153,7 @@ public SQLWarning(@Nullable Throwable cause) { * (which is saved for later retrieval by the {@code getCause()} method); * may be null indicating the cause is non-existent or unknown. */ + @SideEffectFree public SQLWarning(@Nullable String reason, @Nullable Throwable cause) { super(reason,cause); DriverManager.println("SQLWarning : reason("+ reason + ")"); @@ -163,6 +170,7 @@ public SQLWarning(@Nullable String reason, @Nullable Throwable cause) { * @param cause the underlying reason for this {@code SQLWarning} (which is saved for later retrieval by the {@code getCause()} method); may be null indicating * the cause is non-existent or unknown. */ + @SideEffectFree public SQLWarning(@Nullable String reason, @Nullable String SQLState, @Nullable Throwable cause) { super(reason,SQLState,cause); DriverManager.println("SQLWarning: reason(" + reason + @@ -181,6 +189,7 @@ public SQLWarning(@Nullable String reason, @Nullable String SQLState, @Nullable * @param cause the underlying reason for this {@code SQLWarning} (which is saved for later retrieval by the {@code getCause()} method); may be null indicating * the cause is non-existent or unknown. */ + @SideEffectFree public SQLWarning(@Nullable String reason, @Nullable String SQLState, int vendorCode, @Nullable Throwable cause) { super(reason,SQLState,vendorCode,cause); DriverManager.println("SQLWarning: reason(" + reason + diff --git a/src/java.xml.crypto/share/classes/javax/xml/crypto/KeySelectorException.java b/src/java.xml.crypto/share/classes/javax/xml/crypto/KeySelectorException.java index ef5e087d43b4..e865151eb558 100644 --- a/src/java.xml.crypto/share/classes/javax/xml/crypto/KeySelectorException.java +++ b/src/java.xml.crypto/share/classes/javax/xml/crypto/KeySelectorException.java @@ -28,6 +28,8 @@ package javax.xml.crypto; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; +import org.checkerframework.dataflow.qual.SideEffectFree; import java.io.PrintStream; import java.io.PrintWriter; @@ -59,6 +61,7 @@ public class KeySelectorException extends Exception { * Constructs a new {@code KeySelectorException} with * {@code null} as its detail message. */ + @SideEffectFree public KeySelectorException() { super(); } @@ -69,6 +72,7 @@ public KeySelectorException() { * * @param message the detail message */ + @SideEffectFree public KeySelectorException(@Nullable String message) { super(message); } @@ -84,6 +88,7 @@ public KeySelectorException(@Nullable String message) { * @param cause the cause (A {@code null} value is permitted, and * indicates that the cause is nonexistent or unknown.) */ + @SideEffectFree public KeySelectorException(@Nullable String message, @Nullable Throwable cause) { super(message); this.cause = cause; @@ -99,6 +104,7 @@ public KeySelectorException(@Nullable String message, @Nullable Throwable cause) * @param cause the cause (A {@code null} value is permitted, and * indicates that the cause is nonexistent or unknown.) */ + @SideEffectFree public KeySelectorException(@Nullable Throwable cause) { super(cause==null ? null : cause.toString()); this.cause = cause; @@ -113,6 +119,7 @@ public KeySelectorException(@Nullable Throwable cause) { * @return the cause of this {@code KeySelectorException} or * {@code null} if the cause is nonexistent or unknown. */ + @Pure public @Nullable Throwable getCause() { return cause; } diff --git a/src/java.xml.crypto/share/classes/javax/xml/crypto/MarshalException.java b/src/java.xml.crypto/share/classes/javax/xml/crypto/MarshalException.java index 8d68382d645a..8405c8b8d47f 100644 --- a/src/java.xml.crypto/share/classes/javax/xml/crypto/MarshalException.java +++ b/src/java.xml.crypto/share/classes/javax/xml/crypto/MarshalException.java @@ -28,6 +28,8 @@ package javax.xml.crypto; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; +import org.checkerframework.dataflow.qual.SideEffectFree; import java.io.PrintStream; import java.io.PrintWriter; @@ -67,6 +69,7 @@ public class MarshalException extends Exception { * Constructs a new {@code MarshalException} with * {@code null} as its detail message. */ + @SideEffectFree public MarshalException() { super(); } @@ -77,6 +80,7 @@ public MarshalException() { * * @param message the detail message */ + @SideEffectFree public MarshalException(@Nullable String message) { super(message); } @@ -92,6 +96,7 @@ public MarshalException(@Nullable String message) { * @param cause the cause (A {@code null} value is permitted, and * indicates that the cause is nonexistent or unknown.) */ + @SideEffectFree public MarshalException(@Nullable String message, @Nullable Throwable cause) { super(message); this.cause = cause; @@ -105,6 +110,7 @@ public MarshalException(@Nullable String message, @Nullable Throwable cause) { * @param cause the cause (A {@code null} value is permitted, and * indicates that the cause is nonexistent or unknown.) */ + @SideEffectFree public MarshalException(@Nullable Throwable cause) { super(cause==null ? null : cause.toString()); this.cause = cause; @@ -119,6 +125,7 @@ public MarshalException(@Nullable Throwable cause) { * @return the cause of this {@code MarshalException} or * {@code null} if the cause is nonexistent or unknown. */ + @Pure public @Nullable Throwable getCause() { return cause; } diff --git a/src/java.xml.crypto/share/classes/javax/xml/crypto/NoSuchMechanismException.java b/src/java.xml.crypto/share/classes/javax/xml/crypto/NoSuchMechanismException.java index 202472bb29a4..a19443f6bb8b 100644 --- a/src/java.xml.crypto/share/classes/javax/xml/crypto/NoSuchMechanismException.java +++ b/src/java.xml.crypto/share/classes/javax/xml/crypto/NoSuchMechanismException.java @@ -28,6 +28,8 @@ package javax.xml.crypto; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; +import org.checkerframework.dataflow.qual.SideEffectFree; import java.io.PrintStream; import java.io.PrintWriter; @@ -68,6 +70,7 @@ public class NoSuchMechanismException extends RuntimeException { * Constructs a new {@code NoSuchMechanismException} with * {@code null} as its detail message. */ + @SideEffectFree public NoSuchMechanismException() { super(); } @@ -78,6 +81,7 @@ public NoSuchMechanismException() { * * @param message the detail message */ + @SideEffectFree public NoSuchMechanismException(@Nullable String message) { super(message); } @@ -93,6 +97,7 @@ public NoSuchMechanismException(@Nullable String message) { * @param cause the cause (A {@code null} value is permitted, and * indicates that the cause is nonexistent or unknown.) */ + @SideEffectFree public NoSuchMechanismException(@Nullable String message, @Nullable Throwable cause) { super(message); this.cause = cause; @@ -107,6 +112,7 @@ public NoSuchMechanismException(@Nullable String message, @Nullable Throwable ca * @param cause the cause (A {@code null} value is permitted, and * indicates that the cause is nonexistent or unknown.) */ + @SideEffectFree public NoSuchMechanismException(@Nullable Throwable cause) { super(cause==null ? null : cause.toString()); this.cause = cause; @@ -121,6 +127,7 @@ public NoSuchMechanismException(@Nullable Throwable cause) { * @return the cause of this {@code NoSuchMechanismException} or * {@code null} if the cause is nonexistent or unknown. */ + @Pure public @Nullable Throwable getCause() { return cause; } diff --git a/src/java.xml.crypto/share/classes/javax/xml/crypto/URIReferenceException.java b/src/java.xml.crypto/share/classes/javax/xml/crypto/URIReferenceException.java index f23eab386cc9..b2332d878d36 100644 --- a/src/java.xml.crypto/share/classes/javax/xml/crypto/URIReferenceException.java +++ b/src/java.xml.crypto/share/classes/javax/xml/crypto/URIReferenceException.java @@ -28,6 +28,8 @@ package javax.xml.crypto; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; +import org.checkerframework.dataflow.qual.SideEffectFree; import java.io.PrintStream; import java.io.PrintWriter; @@ -70,6 +72,7 @@ public class URIReferenceException extends Exception { * Constructs a new {@code URIReferenceException} with * {@code null} as its detail message. */ + @SideEffectFree public URIReferenceException() { super(); } @@ -80,6 +83,7 @@ public URIReferenceException() { * * @param message the detail message */ + @SideEffectFree public URIReferenceException(@Nullable String message) { super(message); } @@ -95,6 +99,7 @@ public URIReferenceException(@Nullable String message) { * @param cause the cause (A {@code null} value is permitted, and * indicates that the cause is nonexistent or unknown.) */ + @SideEffectFree public URIReferenceException(@Nullable String message, @Nullable Throwable cause) { super(message); this.cause = cause; @@ -115,6 +120,7 @@ public URIReferenceException(@Nullable String message, @Nullable Throwable cause * @throws NullPointerException if {@code uriReference} is * {@code null} */ + @SideEffectFree public URIReferenceException(@Nullable String message, @Nullable Throwable cause, URIReference uriReference) { this(message, cause); @@ -133,6 +139,7 @@ public URIReferenceException(@Nullable String message, @Nullable Throwable cause * @param cause the cause (A {@code null} value is permitted, and * indicates that the cause is nonexistent or unknown.) */ + @SideEffectFree public URIReferenceException(@Nullable Throwable cause) { super(cause==null ? null : cause.toString()); this.cause = cause; @@ -158,6 +165,7 @@ public URIReference getURIReference() { * @return the cause of this {@code URIReferenceException} or * {@code null} if the cause is nonexistent or unknown. */ + @Pure public @Nullable Throwable getCause() { return cause; } diff --git a/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/TransformException.java b/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/TransformException.java index f32642d58080..04af109d3c73 100644 --- a/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/TransformException.java +++ b/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/TransformException.java @@ -28,6 +28,8 @@ package javax.xml.crypto.dsig; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; +import org.checkerframework.dataflow.qual.SideEffectFree; import java.io.PrintStream; import java.io.PrintWriter; @@ -61,6 +63,7 @@ public class TransformException extends Exception { * Constructs a new {@code TransformException} with * {@code null} as its detail message. */ + @SideEffectFree public TransformException() { super(); } @@ -71,6 +74,7 @@ public TransformException() { * * @param message the detail message */ + @SideEffectFree public TransformException(@Nullable String message) { super(message); } @@ -86,6 +90,7 @@ public TransformException(@Nullable String message) { * @param cause the cause (A {@code null} value is permitted, and * indicates that the cause is nonexistent or unknown.) */ + @SideEffectFree public TransformException(@Nullable String message, @Nullable Throwable cause) { super(message); this.cause = cause; @@ -101,6 +106,7 @@ public TransformException(@Nullable String message, @Nullable Throwable cause) { * @param cause the cause (A {@code null} value is permitted, and * indicates that the cause is nonexistent or unknown.) */ + @SideEffectFree public TransformException(@Nullable Throwable cause) { super(cause==null ? null : cause.toString()); this.cause = cause; @@ -115,6 +121,7 @@ public TransformException(@Nullable Throwable cause) { * @return the cause of this {@code TransformException} or * {@code null} if the cause is nonexistent or unknown. */ + @Pure public @Nullable Throwable getCause() { return cause; } diff --git a/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/XMLSignatureException.java b/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/XMLSignatureException.java index 5fb4c21ad7e2..f8960ffd86b6 100644 --- a/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/XMLSignatureException.java +++ b/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/XMLSignatureException.java @@ -28,6 +28,8 @@ package javax.xml.crypto.dsig; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; +import org.checkerframework.dataflow.qual.SideEffectFree; import java.io.PrintStream; import java.io.PrintWriter; @@ -58,6 +60,7 @@ public class XMLSignatureException extends Exception { * Constructs a new {@code XMLSignatureException} with * {@code null} as its detail message. */ + @SideEffectFree public XMLSignatureException() { super(); } @@ -68,6 +71,7 @@ public XMLSignatureException() { * * @param message the detail message */ + @SideEffectFree public XMLSignatureException(@Nullable String message) { super(message); } @@ -83,6 +87,7 @@ public XMLSignatureException(@Nullable String message) { * @param cause the cause (A {@code null} value is permitted, and * indicates that the cause is nonexistent or unknown.) */ + @SideEffectFree public XMLSignatureException(@Nullable String message, @Nullable Throwable cause) { super(message); this.cause = cause; @@ -98,6 +103,7 @@ public XMLSignatureException(@Nullable String message, @Nullable Throwable cause * @param cause the cause (A {@code null} value is permitted, and * indicates that the cause is nonexistent or unknown.) */ + @SideEffectFree public XMLSignatureException(@Nullable Throwable cause) { super(cause==null ? null : cause.toString()); this.cause = cause; @@ -112,6 +118,7 @@ public XMLSignatureException(@Nullable Throwable cause) { * @return the cause of this {@code XMLSignatureException} or * {@code null} if the cause is nonexistent or unknown. */ + @Pure public @Nullable Throwable getCause() { return cause; } diff --git a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignature.java b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignature.java index 96155e564fbb..127712dd6667 100644 --- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignature.java +++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignature.java @@ -586,6 +586,7 @@ public boolean validate(XMLValidateContext validateContext) } @Override + @Pure public boolean equals(@Nullable Object o) { if (this == o) { return true; diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ClassGen.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ClassGen.java index 3a1a9498d888..d1f5f85eeeb8 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ClassGen.java +++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ClassGen.java @@ -283,6 +283,7 @@ public Method containsMethod(final String name, final String signature) { * @see Object#equals(Object) */ @Override + @Pure public boolean equals(final Object obj) { return bcelComparator.equals(this, obj); } diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/xs/ListDV.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/xs/ListDV.java index 783b02a36fa9..5b4469277df6 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/xs/ListDV.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/xs/ListDV.java @@ -82,6 +82,7 @@ public synchronized String toString() { public int getLength() { return data.length; } + @Pure public boolean equals(@Nullable Object obj) { if (!(obj instanceof ListData)) return false; diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/xs/XSSimpleTypeDecl.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/xs/XSSimpleTypeDecl.java index 9a1001c67130..ea707adf0895 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/xs/XSSimpleTypeDecl.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/xs/XSSimpleTypeDecl.java @@ -1964,6 +1964,7 @@ else if (fPatternType == SPECIAL_PATTERN_NCNAME) { }//getActualValue() + @Pure public boolean isEqual(Object value1, Object value2) { if (value1 == null) { return false; diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xpath/regex/RegularExpression.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xpath/regex/RegularExpression.java index 530d67995dd2..c2074972fcf5 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xpath/regex/RegularExpression.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xpath/regex/RegularExpression.java @@ -1756,7 +1756,9 @@ else if (this.firstChar != null) { static abstract class ExpressionTarget { abstract char charAt(int index); + @Pure abstract boolean regionMatches(boolean ignoreCase, int offset, int limit, String part, int partlen); + @Pure abstract boolean regionMatches(boolean ignoreCase, int offset, int limit, int offset2, int partlen); } @@ -1776,6 +1778,7 @@ final char charAt(int index) { return target.charAt(index); } + @Pure final boolean regionMatches(boolean ignoreCase, int offset, int limit, String part, int partlen) { if (limit-offset < partlen) { @@ -1784,6 +1787,7 @@ final boolean regionMatches(boolean ignoreCase, int offset, int limit, return (ignoreCase) ? target.regionMatches(true, offset, part, 0, partlen) : target.regionMatches(offset, part, 0, partlen); } + @Pure final boolean regionMatches(boolean ignoreCase, int offset, int limit, int offset2, int partlen) { if (limit-offset < partlen) { @@ -1810,6 +1814,7 @@ char charAt(int index) { return target[index]; } + @Pure final boolean regionMatches(boolean ignoreCase, int offset, int limit, String part, int partlen) { if (offset < 0 || limit-offset < partlen) { @@ -1819,6 +1824,7 @@ final boolean regionMatches(boolean ignoreCase, int offset, int limit, : regionMatches(offset, limit, part, partlen); } + @Pure private final boolean regionMatches(int offset, int limit, String part, int partlen) { int i = 0; while (partlen-- > 0) { @@ -1849,6 +1855,7 @@ private final boolean regionMatchesIgnoreCase(int offset, int limit, String part return true; } + @Pure final boolean regionMatches(boolean ignoreCase, int offset, int limit, int offset2, int partlen) { if (offset < 0 || limit-offset < partlen) { return false; @@ -1857,6 +1864,7 @@ final boolean regionMatches(boolean ignoreCase, int offset, int limit, int offse : regionMatches(offset, limit, offset2, partlen); } + @Pure private final boolean regionMatches(int offset, int limit, int offset2, int partlen) { int i = offset2; while (partlen-- > 0) { @@ -1902,6 +1910,7 @@ final char charAt(int index) { return target.setIndex(index); } + @Pure final boolean regionMatches(boolean ignoreCase, int offset, int limit, String part, int partlen) { if (offset < 0 || limit-offset < partlen) { @@ -1911,6 +1920,7 @@ final boolean regionMatches(boolean ignoreCase, int offset, int limit, : regionMatches(offset, limit, part, partlen); } + @Pure private final boolean regionMatches(int offset, int limit, String part, int partlen) { int i = 0; while (partlen-- > 0) { @@ -1941,6 +1951,7 @@ private final boolean regionMatchesIgnoreCase(int offset, int limit, String part return true; } + @Pure final boolean regionMatches(boolean ignoreCase, int offset, int limit, int offset2, int partlen) { if (offset < 0 || limit-offset < partlen) { return false; @@ -1949,6 +1960,7 @@ final boolean regionMatches(boolean ignoreCase, int offset, int limit, int offse : regionMatches(offset, limit, offset2, partlen); } + @Pure private final boolean regionMatches(int offset, int limit, int offset2, int partlen) { int i = offset2; while (partlen-- > 0) { diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaValidator.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaValidator.java index 6634a71b7a6a..460d084e9caa 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaValidator.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaValidator.java @@ -4544,6 +4544,7 @@ public int hashCode() { return fId.hashCode() + fDepth; } + @Pure public boolean equals(@Nullable Object localIDKey) { if (localIDKey instanceof LocalIDKey) { LocalIDKey lIDKey = (LocalIDKey) localIDKey; diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/util/XSNamedMapImpl.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/util/XSNamedMapImpl.java index 1c77a50f30d7..059440c73b62 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/util/XSNamedMapImpl.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/util/XSNamedMapImpl.java @@ -194,6 +194,7 @@ public synchronized XSObject item(int index) { return fArray[index]; } + @Pure static boolean isEqual(String one, String two) { return (one != null) ? one.equals(two) : (two == null); } @@ -278,6 +279,7 @@ public XSObject getValue() { public XSObject setValue(XSObject value) { throw new UnsupportedOperationException(); } + @Pure public boolean equals(XSNamedMapEntry o) { if (o instanceof Map.Entry) { Map.Entry e = (Map.Entry) o; diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/datatype/XMLGregorianCalendarImpl.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/datatype/XMLGregorianCalendarImpl.java index 4fa47a5358cd..83e2351f0ae7 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/datatype/XMLGregorianCalendarImpl.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/datatype/XMLGregorianCalendarImpl.java @@ -1455,6 +1455,7 @@ public final void setTime(int hour, int minute, int second, int millisecond) { * @throws NullPointerException if lhs or rhs * parameters are null. */ + @Pure public int compare(XMLGregorianCalendar rhs) { XMLGregorianCalendar lhs = this; diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xni/XNIException.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xni/XNIException.java index 1217c7974077..454d31c1b3d7 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xni/XNIException.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xni/XNIException.java @@ -22,6 +22,8 @@ package com.sun.org.apache.xerces.internal.xni; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; +import org.checkerframework.dataflow.qual.SideEffectFree; /** * This exception is the base exception of all XNI exceptions. It @@ -58,6 +60,7 @@ public class XNIException * * @param message The exception message. */ + @SideEffectFree public XNIException(@Nullable String message) { super(message); } // (String) @@ -67,6 +70,7 @@ public XNIException(@Nullable String message) { * * @param exception The wrapped exception. */ + @SideEffectFree public XNIException(Exception exception) { super(exception.getMessage()); fException = exception; @@ -78,6 +82,7 @@ public XNIException(Exception exception) { * @param message The exception message. * @param exception The wrapped exception. */ + @SideEffectFree public XNIException(@Nullable String message, @Nullable Exception exception) { super(message); fException = exception; @@ -92,6 +97,7 @@ public XNIException(@Nullable String message, @Nullable Exception exception) { return fException; } // getException():Exception + @Pure public @Nullable Throwable getCause() { return fException; } diff --git a/src/java.xml/share/classes/javax/xml/datatype/XMLGregorianCalendar.java b/src/java.xml/share/classes/javax/xml/datatype/XMLGregorianCalendar.java index 27934f92cf88..075d10e0c279 100644 --- a/src/java.xml/share/classes/javax/xml/datatype/XMLGregorianCalendar.java +++ b/src/java.xml/share/classes/javax/xml/datatype/XMLGregorianCalendar.java @@ -667,6 +667,7 @@ public int getMillisecond() { * * @throws NullPointerException if {@code xmlGregorianCalendar} is null. */ + @Pure public abstract int compare(XMLGregorianCalendar xmlGregorianCalendar); /** diff --git a/src/java.xml/share/classes/javax/xml/parsers/FactoryConfigurationError.java b/src/java.xml/share/classes/javax/xml/parsers/FactoryConfigurationError.java index a399a12b5070..8bee6bec1d6f 100644 --- a/src/java.xml/share/classes/javax/xml/parsers/FactoryConfigurationError.java +++ b/src/java.xml/share/classes/javax/xml/parsers/FactoryConfigurationError.java @@ -26,6 +26,8 @@ package javax.xml.parsers; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; +import org.checkerframework.dataflow.qual.SideEffectFree; import org.checkerframework.framework.qual.AnnotatedFor; /** @@ -52,6 +54,7 @@ public class FactoryConfigurationError extends Error { * detail message. */ + @SideEffectFree public FactoryConfigurationError() { super(); this.exception = null; @@ -64,6 +67,7 @@ public FactoryConfigurationError() { * @param msg The error message for the exception. */ + @SideEffectFree public FactoryConfigurationError(@Nullable String msg) { super(msg); this.exception = null; @@ -78,6 +82,7 @@ public FactoryConfigurationError(@Nullable String msg) { * FactoryConfigurationError. */ + @SideEffectFree public FactoryConfigurationError(Exception e) { super(e.toString()); this.exception = e; @@ -92,6 +97,7 @@ public FactoryConfigurationError(Exception e) { * @param msg The detail message. */ + @SideEffectFree public FactoryConfigurationError(@Nullable Exception e, @Nullable String msg) { super(msg); this.exception = e; @@ -108,6 +114,7 @@ public FactoryConfigurationError(@Nullable Exception e, @Nullable String msg) { * @return The error message. */ + @Pure public @Nullable String getMessage () { String message = super.getMessage (); @@ -132,6 +139,7 @@ public FactoryConfigurationError(@Nullable Exception e, @Nullable String msg) { /** * use the exception chaining mechanism of JDK1.4 */ + @Pure @Override public @Nullable Throwable getCause() { return exception; diff --git a/src/java.xml/share/classes/javax/xml/parsers/ParserConfigurationException.java b/src/java.xml/share/classes/javax/xml/parsers/ParserConfigurationException.java index f8a5d0407933..31a5b1a9c1af 100644 --- a/src/java.xml/share/classes/javax/xml/parsers/ParserConfigurationException.java +++ b/src/java.xml/share/classes/javax/xml/parsers/ParserConfigurationException.java @@ -26,6 +26,7 @@ package javax.xml.parsers; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.SideEffectFree; import org.checkerframework.framework.qual.AnnotatedFor; /** @@ -43,6 +44,7 @@ public class ParserConfigurationException extends Exception { * detail message. */ + @SideEffectFree public ParserConfigurationException() { super(); } @@ -54,6 +56,7 @@ public ParserConfigurationException() { * @param msg The error message for the exception. */ + @SideEffectFree public ParserConfigurationException(@Nullable String msg) { super(msg); } diff --git a/src/java.xml/share/classes/javax/xml/stream/FactoryConfigurationError.java b/src/java.xml/share/classes/javax/xml/stream/FactoryConfigurationError.java index ea146cccdfbe..cd5fcdc0645b 100644 --- a/src/java.xml/share/classes/javax/xml/stream/FactoryConfigurationError.java +++ b/src/java.xml/share/classes/javax/xml/stream/FactoryConfigurationError.java @@ -27,6 +27,8 @@ package javax.xml.stream; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; +import org.checkerframework.dataflow.qual.SideEffectFree; /** * An error class for reporting factory configuration errors. @@ -46,6 +48,7 @@ public class FactoryConfigurationError extends Error { /** * Default constructor */ + @SideEffectFree public FactoryConfigurationError(){} /** @@ -53,6 +56,7 @@ public FactoryConfigurationError(){} * * @param e the exception to nest */ + @SideEffectFree public FactoryConfigurationError(java.lang.@Nullable Exception e){ nested = e; } @@ -64,6 +68,7 @@ public FactoryConfigurationError(java.lang.@Nullable Exception e){ * @param e the exception to nest * @param msg the message to report */ + @SideEffectFree public FactoryConfigurationError(java.lang.@Nullable Exception e, java.lang.@Nullable String msg){ super(msg); nested = e; @@ -76,6 +81,7 @@ public FactoryConfigurationError(java.lang.@Nullable Exception e, java.lang.@Nul * @param msg the message to report * @param e the exception to nest */ + @SideEffectFree public FactoryConfigurationError(java.lang.@Nullable String msg, java.lang.@Nullable Exception e){ super(msg); nested = e; @@ -86,6 +92,7 @@ public FactoryConfigurationError(java.lang.@Nullable String msg, java.lang.@Null * * @param msg the message to report */ + @SideEffectFree public FactoryConfigurationError(java.lang.@Nullable String msg) { super(msg); } @@ -101,6 +108,7 @@ public FactoryConfigurationError(java.lang.@Nullable String msg) { /** * use the exception chaining mechanism of JDK1.4 */ + @Pure @Override public @Nullable Throwable getCause() { return nested; @@ -111,6 +119,7 @@ public FactoryConfigurationError(java.lang.@Nullable String msg) { * * @return the string value of the message */ + @SideEffectFree public @Nullable String getMessage() { String msg = super.getMessage(); if(msg != null) diff --git a/src/java.xml/share/classes/javax/xml/transform/TransformerException.java b/src/java.xml/share/classes/javax/xml/transform/TransformerException.java index e9adc38a177e..59309959fb85 100644 --- a/src/java.xml/share/classes/javax/xml/transform/TransformerException.java +++ b/src/java.xml/share/classes/javax/xml/transform/TransformerException.java @@ -26,6 +26,8 @@ package javax.xml.transform; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; +import org.checkerframework.dataflow.qual.SideEffectFree; import java.lang.reflect.Method; import java.lang.reflect.InvocationTargetException; @@ -92,6 +94,7 @@ public void setLocator(@Nullable SourceLocator location) { * caused this throwable to get thrown.) * @return the cause, or null if unknown */ + @Pure @Override public @Nullable Throwable getCause() { @@ -152,6 +155,7 @@ public synchronized Throwable initCause(Throwable cause) { * * @param message The error or warning message. */ + @SideEffectFree public TransformerException(@Nullable String message) { this(message, null, null); } @@ -161,6 +165,7 @@ public TransformerException(@Nullable String message) { * * @param e The exception to be wrapped. */ + @SideEffectFree public TransformerException(@Nullable Throwable e) { this(null, null, e); } @@ -175,6 +180,7 @@ public TransformerException(@Nullable Throwable e) { * use the message from the embedded exception. * @param e Any exception */ + @SideEffectFree public TransformerException(@Nullable String message, @Nullable Throwable e) { this(message, null, e); } @@ -189,6 +195,7 @@ public TransformerException(@Nullable String message, @Nullable Throwable e) { * @param message The error or warning message. * @param locator The locator object for the error or warning. */ + @SideEffectFree public TransformerException(@Nullable String message, @Nullable SourceLocator locator) { this(message, locator, null); } @@ -201,6 +208,7 @@ public TransformerException(@Nullable String message, @Nullable SourceLocator lo * @param locator The locator object for the error or warning. * @param e Any exception */ + @SideEffectFree public TransformerException(@Nullable String message, @Nullable SourceLocator locator, @Nullable Throwable e) { super(((message == null) || (message.length() == 0)) diff --git a/src/java.xml/share/classes/javax/xml/transform/TransformerFactoryConfigurationError.java b/src/java.xml/share/classes/javax/xml/transform/TransformerFactoryConfigurationError.java index a8b0148544bd..e59461d4579c 100644 --- a/src/java.xml/share/classes/javax/xml/transform/TransformerFactoryConfigurationError.java +++ b/src/java.xml/share/classes/javax/xml/transform/TransformerFactoryConfigurationError.java @@ -26,6 +26,8 @@ package javax.xml.transform; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; +import org.checkerframework.dataflow.qual.SideEffectFree; /** * Thrown when a problem with configuration with the Transformer Factories @@ -48,6 +50,7 @@ public class TransformerFactoryConfigurationError extends Error { * Create a new TransformerFactoryConfigurationError with no * detail message. */ + @SideEffectFree public TransformerFactoryConfigurationError() { super(); @@ -61,6 +64,7 @@ public TransformerFactoryConfigurationError() { * * @param msg The error message for the exception. */ + @SideEffectFree public TransformerFactoryConfigurationError(@Nullable String msg) { super(msg); @@ -75,6 +79,7 @@ public TransformerFactoryConfigurationError(@Nullable String msg) { * @param e The exception to be encapsulated in a * TransformerFactoryConfigurationError. */ + @SideEffectFree public TransformerFactoryConfigurationError(Exception e) { super(e.toString()); @@ -90,6 +95,7 @@ public TransformerFactoryConfigurationError(Exception e) { * TransformerFactoryConfigurationError * @param msg The detail message. */ + @SideEffectFree public TransformerFactoryConfigurationError(@Nullable Exception e, @Nullable String msg) { super(msg); @@ -104,6 +110,7 @@ public TransformerFactoryConfigurationError(@Nullable Exception e, @Nullable Str * * @return The error message. */ + @Pure public String getMessage() { String message = super.getMessage(); @@ -127,6 +134,7 @@ public Exception getException() { /** * use the exception chaining mechanism of JDK1.4 */ + @Pure @Override public @Nullable Throwable getCause() { return exception; diff --git a/src/java.xml/share/classes/javax/xml/xpath/XPathException.java b/src/java.xml/share/classes/javax/xml/xpath/XPathException.java index cb9d1f526865..35697f49733b 100644 --- a/src/java.xml/share/classes/javax/xml/xpath/XPathException.java +++ b/src/java.xml/share/classes/javax/xml/xpath/XPathException.java @@ -26,6 +26,8 @@ package javax.xml.xpath; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; +import org.checkerframework.dataflow.qual.SideEffectFree; import java.io.PrintWriter; import java.io.IOException; @@ -68,6 +70,7 @@ public class XPathException extends Exception { * @throws NullPointerException When {@code message} is * {@code null}. */ + @SideEffectFree public XPathException(String message) { super(message); if ( message == null ) { @@ -86,6 +89,7 @@ public XPathException(String message) { * * @throws NullPointerException if {@code cause} is {@code null}. */ + @SideEffectFree public XPathException(Throwable cause) { super(cause); if ( cause == null ) { @@ -98,6 +102,7 @@ public XPathException(Throwable cause) { * * @return Cause of this XPathException. */ + @Pure public @Nullable Throwable getCause() { return super.getCause(); } diff --git a/src/java.xml/share/classes/org/xml/sax/SAXException.java b/src/java.xml/share/classes/org/xml/sax/SAXException.java index 8e9807b435e1..5365fff88fb5 100644 --- a/src/java.xml/share/classes/org/xml/sax/SAXException.java +++ b/src/java.xml/share/classes/org/xml/sax/SAXException.java @@ -26,6 +26,8 @@ package org.xml.sax; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; +import org.checkerframework.dataflow.qual.SideEffectFree; import java.io.IOException; import java.io.InvalidClassException; @@ -61,6 +63,7 @@ public class SAXException extends Exception { /** * Create a new SAXException. */ + @SideEffectFree public SAXException () { super(); @@ -72,6 +75,7 @@ public SAXException () * * @param message The error or warning message. */ + @SideEffectFree public SAXException (@Nullable String message) { super(message); } @@ -86,6 +90,7 @@ public SAXException (@Nullable String message) { * * @param e The exception to be wrapped in a SAXException. */ + @SideEffectFree public SAXException (@Nullable Exception e) { super(e); @@ -101,6 +106,7 @@ public SAXException (@Nullable Exception e) * @param message The detail message. * @param e The exception to be wrapped in a SAXException. */ + @SideEffectFree public SAXException (@Nullable String message, @Nullable Exception e) { super(message, e); @@ -116,6 +122,7 @@ public SAXException (@Nullable String message, @Nullable Exception e) * * @return The error or warning message. */ + @Pure public @Nullable String getMessage () { String message = super.getMessage(); @@ -143,6 +150,7 @@ public Exception getException () * * @return Return the cause of the exception */ + @Pure public @Nullable Throwable getCause() { return super.getCause(); } @@ -152,6 +160,7 @@ public Exception getException () * * @return A string representation of this exception. */ + @SideEffectFree public String toString () { Throwable exception = super.getCause(); diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java index 2621ce2c6599..573f06ae9bde 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java @@ -30,6 +30,7 @@ import org.checkerframework.checker.signature.qual.BinaryName; import org.checkerframework.checker.signature.qual.CanonicalName; import org.checkerframework.checker.signature.qual.Identifier; +import org.checkerframework.dataflow.qual.SideEffectFree; import java.lang.annotation.Annotation; import java.lang.annotation.Inherited; @@ -2587,6 +2588,7 @@ public static class CompletionFailure extends RuntimeException { private transient Supplier diagSupplier; + @SideEffectFree public CompletionFailure(Symbol sym, Supplier diagSupplier, DeferredCompletionFailureHandler dcfh) { this.dcfh = dcfh; this.sym = sym; @@ -2601,6 +2603,7 @@ public JCDiagnostic getDiagnostic() { return diag; } + @SideEffectFree @Override public String getMessage() { return getDiagnostic().getMessage(null); diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java index 92364bd24a4a..3f43b596f2a8 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java @@ -555,6 +555,7 @@ public String stringValue() { * Override this method with care. For most Type instances this should behave as ==. */ @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Pure public boolean equals(@Nullable Object t) { return this == t; } @@ -1402,6 +1403,7 @@ public String toString() { } @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Pure public boolean equals(@Nullable Object obj) { return (obj instanceof ArrayType arrayType) && (this == arrayType || elemtype.equals(arrayType.elemtype)); diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java index dd8700b6ead9..ba02a49620bd 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java @@ -27,6 +27,7 @@ import org.checkerframework.checker.interning.qual.InternedDistinct; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.Pure; import java.util.Iterator; @@ -105,6 +106,7 @@ public String toString() { } @Override + @Pure public boolean equals(@Nullable Object other) { return (other instanceof TypePathEntry entry) && this.tag == entry.tag diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java index 0c38d1394517..4797f1c5ea5f 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java @@ -27,6 +27,7 @@ import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.dataflow.qual.Pure; +import org.checkerframework.dataflow.qual.SideEffectFree; import java.lang.ref.SoftReference; import java.util.HashSet; @@ -642,6 +643,7 @@ public static class FunctionDescriptorLookupError extends RuntimeException { transient JCDiagnostic diagnostic; + @SideEffectFree FunctionDescriptorLookupError() { this.diagnostic = null; } @@ -3160,6 +3162,7 @@ class Entry { } @Override + @Pure public boolean equals(@Nullable Object obj) { return (obj instanceof Entry entry) && entry.msym == msym @@ -3846,6 +3849,7 @@ public int hashCode() { return 127 * Types.this.hashCode(t1) + Types.this.hashCode(t2); } @Override + @Pure public boolean equals(@Nullable Object obj) { return (obj instanceof TypePair typePair) && isSameType(t1, typePair.t1) @@ -4871,6 +4875,7 @@ public int hashCode() { return types.hashCode(type); } + @Pure public boolean equals(@Nullable Object obj) { return (obj instanceof UniqueType uniqueType) && types.isSameType(type, uniqueType.type); @@ -5048,6 +5053,7 @@ public static class InvalidSignatureException extends RuntimeException { private final transient Type type; + @SideEffectFree InvalidSignatureException(Type type) { this.type = type; } diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java index 5d8a931a875f..6b34c3a325c6 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java @@ -26,6 +26,7 @@ package com.sun.tools.javac.comp; import org.checkerframework.dataflow.qual.Pure; +import org.checkerframework.dataflow.qual.SideEffectFree; import com.sun.tools.javac.api.Formattable.LocalizedString; import com.sun.tools.javac.code.*; @@ -842,6 +843,7 @@ protected void reportMC(DiagnosticPosition pos, MethodCheckDiag diag, InferenceC class SharedInapplicableMethodException extends InapplicableMethodException { private static final long serialVersionUID = 0; + @SideEffectFree SharedInapplicableMethodException() { super(null); } @@ -1398,6 +1400,7 @@ public static class InapplicableMethodException extends RuntimeException { transient JCDiagnostic diagnostic; + @SideEffectFree InapplicableMethodException(JCDiagnostic diag) { this.diagnostic = diag; } diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java index 5dacdb0e8b93..2527d5e95084 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java @@ -121,12 +121,14 @@ public static char[] toArray(CharBuffer buffer) { protected enum SortFiles implements Comparator { FORWARD { @Override + @Pure public int compare(Path f1, Path f2) { return f1.getFileName().compareTo(f2.getFileName()); } }, REVERSE { @Override + @Pure public int compare(Path f1, Path f2) { return f2.getFileName().compareTo(f1.getFileName()); } @@ -1099,11 +1101,13 @@ private static class PathAndContainer implements Comparable { } @Override + @Pure public int compareTo(PathAndContainer other) { return index - other.index; } @Override + @Pure public boolean equals(@Nullable Object o) { return (o instanceof PathAndContainer pathAndContainer) && path.equals(pathAndContainer.path) diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/file/PathFileObject.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/file/PathFileObject.java index 2bd827f572f3..4936f60c0d0b 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/file/PathFileObject.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/file/PathFileObject.java @@ -589,6 +589,7 @@ public static String getSimpleName(FileObject fo) { * implementations of FileObject.toURI(). */ public static class CannotCreateUriError extends Error { private static final long serialVersionUID = 9101708840997613546L; + @SideEffectFree public CannotCreateUriError(@Nullable String value, @Nullable Throwable cause) { super(value, cause); } diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/file/RelativePath.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/file/RelativePath.java index c19218e9062a..aea280e7a92f 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/file/RelativePath.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/file/RelativePath.java @@ -73,6 +73,7 @@ public Path resolveAgainst(FileSystem fs) throws /*unchecked*/ InvalidPathExcept } @Override + @Pure public int compareTo(RelativePath other) { return path.compareTo(other.path); } diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/List.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/List.java index ab5ccc66d071..74482920ae2b 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/List.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/List.java @@ -360,6 +360,7 @@ public int hashCode() { * @see java.util.List#equals */ @Override + @Pure public boolean equals(@Nullable Object other) { if (other instanceof List javacList) return equals(this, javacList); diff --git a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11Key.java b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11Key.java index a857aea16d04..9156396bce89 100644 --- a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11Key.java +++ b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11Key.java @@ -1075,6 +1075,7 @@ public int hashCode() { } return Objects.hash(x, params.getP(), params.getG()); } + @Pure public boolean equals(@Nullable Object obj) { if (this == obj) return true; // equals() should never throw exceptions @@ -1160,6 +1161,7 @@ public int hashCode() { fetchValues(); return Objects.hash(y, params.getP(), params.getG()); } + @Pure public boolean equals(@Nullable Object obj) { if (this == obj) return true; // equals() should never throw exceptions diff --git a/src/jdk.dynalink/share/classes/jdk/dynalink/NamespaceOperation.java b/src/jdk.dynalink/share/classes/jdk/dynalink/NamespaceOperation.java index 3333fc7411d4..12a1aee97c7e 100644 --- a/src/jdk.dynalink/share/classes/jdk/dynalink/NamespaceOperation.java +++ b/src/jdk.dynalink/share/classes/jdk/dynalink/NamespaceOperation.java @@ -235,6 +235,7 @@ public boolean contains(final Namespace namespace) { * @return true if this object is equal to the other one, false otherwise. */ @Override + @Pure public boolean equals(final @Nullable Object obj) { if (obj instanceof NamespaceOperation) { final NamespaceOperation other = (NamespaceOperation)obj; diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/LongHashMap.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/LongHashMap.java index 310a74111ccc..24b03dbd74e7 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/LongHashMap.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/LongHashMap.java @@ -112,6 +112,7 @@ Object setValue(Object value) { * @return true if the specified object is equal to this map * entry. */ + @Pure public boolean equals(@Nullable Object o) { if (!(o instanceof Entry)) return false; diff --git a/src/jdk.httpserver/share/classes/com/sun/net/httpserver/Headers.java b/src/jdk.httpserver/share/classes/com/sun/net/httpserver/Headers.java index ec06e6879da2..591950c2d489 100644 --- a/src/jdk.httpserver/share/classes/com/sun/net/httpserver/Headers.java +++ b/src/jdk.httpserver/share/classes/com/sun/net/httpserver/Headers.java @@ -276,6 +276,7 @@ public void replaceAll(BiFunction, ? extend } @Override + @Pure public boolean equals(@Nullable Object o) { return map.equals(o); } @Override diff --git a/src/jdk.httpserver/share/classes/sun/net/httpserver/UnmodifiableHeaders.java b/src/jdk.httpserver/share/classes/sun/net/httpserver/UnmodifiableHeaders.java index 462ee0d881cb..e9196866284c 100644 --- a/src/jdk.httpserver/share/classes/sun/net/httpserver/UnmodifiableHeaders.java +++ b/src/jdk.httpserver/share/classes/sun/net/httpserver/UnmodifiableHeaders.java @@ -103,6 +103,7 @@ public void replaceAll(BiFunction, ? extend throw new UnsupportedOperationException ("unsupported operation"); } + @Pure public boolean equals(@Nullable Object o) {return headers.equals(o);} public int hashCode() {return headers.hashCode();} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/Register.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/Register.java index 7ce2e8e0173a..c5482f0ccbe8 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/Register.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/Register.java @@ -100,6 +100,7 @@ public int hashCode() { } @Override + @Pure public boolean equals(@Nullable Object obj) { if (obj instanceof RegisterCategory) { RegisterCategory that = (RegisterCategory) obj; @@ -169,6 +170,7 @@ public String toString() { } @Override + @Pure public int compareTo(Register o) { if (number < o.number) { return -1; diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/Infopoint.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/Infopoint.java index f7e7ce2c8be8..669fbe119350 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/Infopoint.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/Infopoint.java @@ -64,6 +64,7 @@ public String toString() { } @Override + @Pure public int compareTo(Infopoint o) { if (pcOffset < o.pcOffset) { return -1; diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/AbstractProfiledItem.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/AbstractProfiledItem.java index e56c4842239a..b1978f1d1b79 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/AbstractProfiledItem.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/AbstractProfiledItem.java @@ -62,6 +62,7 @@ public double getProbability() { * {@code o}'s probability, 0 if there are equal otherwise 1. */ @Override + @Pure public int compareTo(AbstractProfiledItem o) { // Need to swap the order of operands so that higher probabilities are sorted first return Double.compare(o.getProbability(), getProbability()); diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/Assumptions.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/Assumptions.java index a6503eee0439..51133c9c9fab 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/Assumptions.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/Assumptions.java @@ -123,6 +123,7 @@ public int hashCode() { } @Override + @Pure public boolean equals(@Nullable Object obj) { if (obj instanceof NoFinalizableSubclass) { NoFinalizableSubclass other = (NoFinalizableSubclass) obj; @@ -172,6 +173,7 @@ public int hashCode() { } @Override + @Pure public boolean equals(@Nullable Object obj) { if (obj instanceof ConcreteSubtype) { ConcreteSubtype other = (ConcreteSubtype) obj; @@ -210,6 +212,7 @@ public int hashCode() { } @Override + @Pure public boolean equals(@Nullable Object obj) { if (obj instanceof LeafType) { LeafType other = (LeafType) obj; @@ -262,6 +265,7 @@ public int hashCode() { } @Override + @Pure public boolean equals(@Nullable Object obj) { if (obj instanceof ConcreteMethod) { ConcreteMethod other = (ConcreteMethod) obj; @@ -299,6 +303,7 @@ public int hashCode() { } @Override + @Pure public boolean equals(@Nullable Object obj) { if (obj instanceof CallSiteTargetValue) { CallSiteTargetValue other = (CallSiteTargetValue) obj; diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/Value.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/Value.java index ff831770ba71..47f01151f814 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/Value.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/Value.java @@ -48,6 +48,7 @@ public String toString() { } @Override + @Pure public boolean equals(@Nullable Object other) { // Due to de-serialization this object may exist multiple times. So we compare classes // instead of the individual objects. diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java index 37ba51d8e9a5..090adfe44e4d 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java @@ -1475,6 +1475,7 @@ protected Boolean defaultAction(DocTree node, Content content) { return result; } + @Pure private boolean equalsIgnoreCase(Name name, String s) { return name != null && name.toString().equalsIgnoreCase(s); } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Extern.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Extern.java index 7cf463e4c418..2f25afa01ccf 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Extern.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Extern.java @@ -27,6 +27,7 @@ import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.dataflow.qual.Pure; +import org.checkerframework.dataflow.qual.SideEffectFree; import java.io.BufferedReader; import java.io.IOException; @@ -402,6 +403,7 @@ private boolean link(String url, String elemlisturl, Reporter reporter, boolean private static class Fault extends Exception { private static final long serialVersionUID = 0; + @SideEffectFree Fault(String msg, @Nullable Exception cause) { super(msg + (cause == null ? "" : " (" + cause + ")"), cause); } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/UncheckedDocletException.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/UncheckedDocletException.java index 92ddf1908ca9..c6d31c82de94 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/UncheckedDocletException.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/UncheckedDocletException.java @@ -26,6 +26,7 @@ package jdk.javadoc.internal.doclets.toolkit.util; import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.dataflow.qual.SideEffectFree; import jdk.javadoc.internal.doclets.toolkit.DocletException; @@ -37,6 +38,7 @@ public class UncheckedDocletException extends Error { private static final long serialVersionUID = -9131058909576418984L; + @SideEffectFree public UncheckedDocletException(DocletException de) { super(de); } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java index f6c40fa033f6..39229e618ec2 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java @@ -1457,6 +1457,7 @@ CollationKey getKey(String s) { return keys.computeIfAbsent(s, instance :: getCollationKey); } + @Pure public int compare(String s1, String s2) { return getKey(s1).compareTo(getKey(s2)); } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/VisibleMemberTable.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/VisibleMemberTable.java index 715f34c66e9d..da04bdc315ca 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/VisibleMemberTable.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/VisibleMemberTable.java @@ -1140,6 +1140,7 @@ public int hashCode() { } @Override + @Pure public boolean equals(@Nullable Object obj) { if (!(obj instanceof VisibleMemberTable other)) return false; diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ElementsTable.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ElementsTable.java index ba81e67a8633..75da22d8fa06 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ElementsTable.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ElementsTable.java @@ -1161,6 +1161,7 @@ boolean hasModule() { } @Override + @Pure public boolean equals(@Nullable Object obj) { if (obj instanceof ModulePackage that) { return this.toString().equals(that.toString()); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java index df9ef1f63834..e5cc84f44919 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java @@ -217,6 +217,7 @@ private void showToolOptions(ToolOption.Kind kind) { { collator.setStrength(Collator.PRIMARY); } @Override + @Pure public int compare(ToolOption o1, ToolOption o2) { return collator.compare(o1.primaryName, o2.primaryName); } @@ -258,6 +259,7 @@ private void showDocletOptions(Option.Kind kind) { { collator.setStrength(Collator.PRIMARY); } @Override + @Pure public int compare(Doclet.Option o1, Doclet.Option o2) { return collator.compare(o1.getNames().get(0), o2.getNames().get(0)); } diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Analyzer.java b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Analyzer.java index 4df4b97a2edd..817b6b74f645 100644 --- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Analyzer.java +++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Analyzer.java @@ -357,6 +357,7 @@ Archive targetArchive() { @Override @SuppressWarnings("unchecked") + @Pure public boolean equals(@Nullable Object o) { if (o instanceof Dep) { Dep d = (Dep) o; diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Graph.java b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Graph.java index 0521d2b1c793..32db68219f9c 100644 --- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Graph.java +++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Graph.java @@ -239,6 +239,7 @@ public String toString() { } @Override + @Pure public boolean equals(@Nullable Object o) { if (this == o) return true; if (o == null || !(o instanceof Edge)) diff --git a/src/jdk.jdi/share/classes/com/sun/tools/jdi/ByteValueImpl.java b/src/jdk.jdi/share/classes/com/sun/tools/jdi/ByteValueImpl.java index 96e04e16e071..1a6e38a9d396 100644 --- a/src/jdk.jdi/share/classes/com/sun/tools/jdi/ByteValueImpl.java +++ b/src/jdk.jdi/share/classes/com/sun/tools/jdi/ByteValueImpl.java @@ -64,6 +64,7 @@ public int hashCode() { return intValue(); } + @Pure public int compareTo(ByteValue obj) { byte other = obj.value(); return value() - other; diff --git a/src/jdk.jdi/share/classes/com/sun/tools/jdi/CharValueImpl.java b/src/jdk.jdi/share/classes/com/sun/tools/jdi/CharValueImpl.java index 627c0a59ce0a..bde95a1667de 100644 --- a/src/jdk.jdi/share/classes/com/sun/tools/jdi/CharValueImpl.java +++ b/src/jdk.jdi/share/classes/com/sun/tools/jdi/CharValueImpl.java @@ -64,6 +64,7 @@ public int hashCode() { return intValue(); } + @Pure public int compareTo(CharValue obj) { char other = obj.value(); return value() - other; diff --git a/src/jdk.jdi/share/classes/com/sun/tools/jdi/DoubleValueImpl.java b/src/jdk.jdi/share/classes/com/sun/tools/jdi/DoubleValueImpl.java index da0daae1aa0f..211ff75c393e 100644 --- a/src/jdk.jdi/share/classes/com/sun/tools/jdi/DoubleValueImpl.java +++ b/src/jdk.jdi/share/classes/com/sun/tools/jdi/DoubleValueImpl.java @@ -56,6 +56,7 @@ public boolean equals(@Nullable Object obj) { } } + @Pure public int compareTo(DoubleValue obj) { double other = obj.value(); if (value() < other) { diff --git a/src/jdk.jdi/share/classes/com/sun/tools/jdi/EventRequestManagerImpl.java b/src/jdk.jdi/share/classes/com/sun/tools/jdi/EventRequestManagerImpl.java index 41c7a484d794..4d27fdb990d4 100644 --- a/src/jdk.jdi/share/classes/com/sun/tools/jdi/EventRequestManagerImpl.java +++ b/src/jdk.jdi/share/classes/com/sun/tools/jdi/EventRequestManagerImpl.java @@ -142,6 +142,7 @@ private abstract class EventRequestImpl extends MirrorImpl implements EventReque /* * Override superclass back to default equality */ + @Pure public boolean equals(@Nullable Object obj) { return this == obj; } diff --git a/src/jdk.jdi/share/classes/com/sun/tools/jdi/FieldImpl.java b/src/jdk.jdi/share/classes/com/sun/tools/jdi/FieldImpl.java index aad8abff0c7c..32f40bc952fb 100644 --- a/src/jdk.jdi/share/classes/com/sun/tools/jdi/FieldImpl.java +++ b/src/jdk.jdi/share/classes/com/sun/tools/jdi/FieldImpl.java @@ -63,6 +63,7 @@ public int hashCode() { return Long.hashCode(ref()); } + @Pure public int compareTo(Field field) { ReferenceTypeImpl declaringType = (ReferenceTypeImpl)declaringType(); int rc = declaringType.compareTo(field.declaringType()); diff --git a/src/jdk.jdi/share/classes/com/sun/tools/jdi/FloatValueImpl.java b/src/jdk.jdi/share/classes/com/sun/tools/jdi/FloatValueImpl.java index 516867cbbf34..d19c536da5bc 100644 --- a/src/jdk.jdi/share/classes/com/sun/tools/jdi/FloatValueImpl.java +++ b/src/jdk.jdi/share/classes/com/sun/tools/jdi/FloatValueImpl.java @@ -63,6 +63,7 @@ public int hashCode() { return intValue(); } + @Pure public int compareTo(FloatValue obj) { float other = obj.value(); if (value() < other) { diff --git a/src/jdk.jdi/share/classes/com/sun/tools/jdi/IntegerValueImpl.java b/src/jdk.jdi/share/classes/com/sun/tools/jdi/IntegerValueImpl.java index 1d90da6222dd..48017d53205f 100644 --- a/src/jdk.jdi/share/classes/com/sun/tools/jdi/IntegerValueImpl.java +++ b/src/jdk.jdi/share/classes/com/sun/tools/jdi/IntegerValueImpl.java @@ -63,6 +63,7 @@ public int hashCode() { return intValue(); } + @Pure public int compareTo(IntegerValue obj) { int other = obj.value(); return (value() argumentTypes() throws ClassNotLoadedException { return types; } + @Pure public int compareTo(Method method) { ReferenceTypeImpl declaringType = (ReferenceTypeImpl)declaringType(); int rc = declaringType.compareTo(method.declaringType()); diff --git a/src/jdk.jdi/share/classes/com/sun/tools/jdi/ReferenceTypeImpl.java b/src/jdk.jdi/share/classes/com/sun/tools/jdi/ReferenceTypeImpl.java index 2d445b803cc4..e566cb0d1857 100644 --- a/src/jdk.jdi/share/classes/com/sun/tools/jdi/ReferenceTypeImpl.java +++ b/src/jdk.jdi/share/classes/com/sun/tools/jdi/ReferenceTypeImpl.java @@ -162,6 +162,7 @@ public int hashCode() { return Long.hashCode(ref()); } + @Pure public int compareTo(ReferenceType object) { /* * Note that it is critical that compareTo() == 0 diff --git a/src/jdk.jdi/share/classes/com/sun/tools/jdi/ShortValueImpl.java b/src/jdk.jdi/share/classes/com/sun/tools/jdi/ShortValueImpl.java index 5cafa7980acf..b41b2db4f34a 100644 --- a/src/jdk.jdi/share/classes/com/sun/tools/jdi/ShortValueImpl.java +++ b/src/jdk.jdi/share/classes/com/sun/tools/jdi/ShortValueImpl.java @@ -63,6 +63,7 @@ public int hashCode() { return intValue(); } + @Pure public int compareTo(ShortValue obj) { short other = obj.value(); return value() - other; diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/Type.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/Type.java index de90da72ddff..4f86455271bb 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/Type.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/Type.java @@ -290,6 +290,7 @@ public boolean equals(@Nullable Object object) { } @Override + @Pure public int compareTo(Type that) { return Long.compare(this.id, that.id); } diff --git a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ResourcePoolManager.java b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ResourcePoolManager.java index c55058eb77c0..80b9c9e8b61f 100644 --- a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ResourcePoolManager.java +++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ResourcePoolManager.java @@ -437,6 +437,7 @@ public long getUncompressedSize() { } @Override + @Pure public boolean equals(@Nullable Object other) { if (!(other instanceof CompressedModuleData)) { return false; diff --git a/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/Startup.java b/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/Startup.java index cbf7e90ccbe5..263d8fbd2abc 100644 --- a/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/Startup.java +++ b/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/Startup.java @@ -112,6 +112,7 @@ public int hashCode() { // built-ins match on name only. Time stamp isn't considered @Override + @Pure public boolean equals(@Nullable Object o) { if (!(o instanceof StartupEntry)) { return false; diff --git a/src/jdk.naming.dns/share/classes/com/sun/jndi/dns/DnsName.java b/src/jdk.naming.dns/share/classes/com/sun/jndi/dns/DnsName.java index 6b18bd6104ab..a1c9418fbecb 100644 --- a/src/jdk.naming.dns/share/classes/com/sun/jndi/dns/DnsName.java +++ b/src/jdk.naming.dns/share/classes/com/sun/jndi/dns/DnsName.java @@ -222,6 +222,7 @@ public boolean equals(@Nullable Object obj) { (compareTo(obj) == 0)); } + @Pure public int compareTo(Object obj) { Name n = (Name) obj; return compareRange(0, size(), n); // never 0 if sizes differ diff --git a/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipPath.java b/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipPath.java index c37a66cfb63f..6524beadbc3d 100644 --- a/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipPath.java +++ b/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipPath.java @@ -642,6 +642,7 @@ public boolean equals(@Nullable Object obj) { } @Override + @Pure public int compareTo(Path other) { final ZipPath o = checkPath(other); int len1 = this.path.length;