Skip to content

Commit 72c372e

Browse files
authored
Annotate Proxy and ExecutionException for nullness
1 parent 65b755a commit 72c372e

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

src/java.base/share/classes/java/lang/reflect/Proxy.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525

2626
package java.lang.reflect;
2727

28+
import org.checkerframework.checker.nullness.qual.Nullable;
29+
import org.checkerframework.framework.qual.AnnotatedFor;
30+
2831
import java.lang.module.ModuleDescriptor;
2932
import java.security.AccessController;
3033
import java.security.PrivilegedAction;
@@ -282,6 +285,7 @@
282285
* @revised 9
283286
* @spec JPMS
284287
*/
288+
@AnnotatedFor({"nullness"})
285289
public class Proxy implements java.io.Serializable {
286290
private static final long serialVersionUID = -2222568056686623797L;
287291

@@ -373,7 +377,7 @@ protected Proxy(InvocationHandler h) {
373377
*/
374378
@Deprecated
375379
@CallerSensitive
376-
public static Class<?> getProxyClass(ClassLoader loader,
380+
public static Class<?> getProxyClass(@Nullable ClassLoader loader,
377381
Class<?>... interfaces)
378382
throws IllegalArgumentException
379383
{
@@ -400,7 +404,7 @@ public static Class<?> getProxyClass(ClassLoader loader,
400404
* @return a Constructor of the proxy class taking single
401405
* {@code InvocationHandler} parameter
402406
*/
403-
private static Constructor<?> getProxyConstructor(Class<?> caller,
407+
private static Constructor<?> getProxyConstructor(@Nullable Class<?> caller,
404408
ClassLoader loader,
405409
Class<?>... interfaces)
406410
{
@@ -991,7 +995,7 @@ private static Module getDynamicModule(ClassLoader loader) {
991995
* @spec JPMS
992996
*/
993997
@CallerSensitive
994-
public static Object newProxyInstance(ClassLoader loader,
998+
public static Object newProxyInstance(@Nullable ClassLoader loader,
995999
Class<?>[] interfaces,
9961000
InvocationHandler h) {
9971001
Objects.requireNonNull(h);
@@ -1008,7 +1012,7 @@ public static Object newProxyInstance(ClassLoader loader,
10081012
return newProxyInstance(caller, cons, h);
10091013
}
10101014

1011-
private static Object newProxyInstance(Class<?> caller, // null if no SecurityManager
1015+
private static Object newProxyInstance(@Nullable Class<?> caller, // null if no SecurityManager
10121016
Constructor<?> cons,
10131017
InvocationHandler h) {
10141018
/*

src/java.base/share/classes/java/util/Iterator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
@CFComment({"nullness: This @Covariant annotation is sound, but it would not be sound on",
6565
"ListIterator (a subclass of Iterator), which supports a set operation."
6666
})
67-
@AnnotatedFor({"lock"})
67+
@AnnotatedFor({"lock", "nullness"})
6868
@Covariant({0})
6969
public interface Iterator<E> {
7070
/**

src/java.base/share/classes/java/util/concurrent/ExecutionException.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535

3636
package java.util.concurrent;
3737

38+
import org.checkerframework.checker.nullness.qual.Nullable;
39+
import org.checkerframework.dataflow.qual.SideEffectFree;
40+
import org.checkerframework.framework.qual.AnnotatedFor;
41+
3842
/**
3943
* Exception thrown when attempting to retrieve the result of a task
4044
* that aborted by throwing an exception. This exception can be
@@ -44,6 +48,7 @@
4448
* @since 1.5
4549
* @author Doug Lea
4650
*/
51+
@AnnotatedFor({"nullness"})
4752
public class ExecutionException extends Exception {
4853
private static final long serialVersionUID = 7830266012832686185L;
4954

@@ -52,6 +57,7 @@ public class ExecutionException extends Exception {
5257
* The cause is not initialized, and may subsequently be
5358
* initialized by a call to {@link #initCause(Throwable) initCause}.
5459
*/
60+
@SideEffectFree
5561
protected ExecutionException() { }
5662

5763
/**
@@ -61,7 +67,8 @@ protected ExecutionException() { }
6167
*
6268
* @param message the detail message
6369
*/
64-
protected ExecutionException(String message) {
70+
@SideEffectFree
71+
protected ExecutionException(@Nullable String message) {
6572
super(message);
6673
}
6774

@@ -73,7 +80,8 @@ protected ExecutionException(String message) {
7380
* @param cause the cause (which is saved for later retrieval by the
7481
* {@link #getCause()} method)
7582
*/
76-
public ExecutionException(String message, Throwable cause) {
83+
@SideEffectFree
84+
public ExecutionException(@Nullable String message, @Nullable Throwable cause) {
7785
super(message, cause);
7886
}
7987

@@ -86,7 +94,8 @@ public ExecutionException(String message, Throwable cause) {
8694
* @param cause the cause (which is saved for later retrieval by the
8795
* {@link #getCause()} method)
8896
*/
89-
public ExecutionException(Throwable cause) {
97+
@SideEffectFree
98+
public ExecutionException(@Nullable Throwable cause) {
9099
super(cause);
91100
}
92101
}

0 commit comments

Comments
 (0)