lovubuntu / checker-framework

Automatically exported from code.google.com/p/checker-framework
0 stars 0 forks source link

A few more JDK Nullable annotations #336

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
These are a few more JDK stubs I have needed:

package java.sql;

public interface ResultSet {
    @Nullable String getString(int columnIndex);
}

package java.util;

public class Arrays {
    public static <T extends @Nullable Object> List<T> asList(T... a);
}

package javax.management;

public interface NotificationBroadcaster {
    public void addNotificationListener(NotificationListener listener,
            @Nullable NotificationFilter filter, @Nullable Object handback);
}

public interface MBeanServer {
    public Set<ObjectName> queryNames(@Nullable ObjectName name, @Nullable QueryExp query);
}

Original issue reported on code.google.com by trask.st...@gmail.com on 13 Jun 2014 at 8:25

GoogleCodeExporter commented 9 years ago
Also:

package java.lang.reflect;

public class Constructor<T> {
    public T newInstance(@Nullable Object... initargs);
}

package java.net;

public class URL {
    public boolean equals(@Nullable Object obj);
}

package java.security;

public class ProtectionDomain {
    public @Nullable CodeSource getCodeSource();
}

Original comment by trask.st...@gmail.com on 15 Aug 2014 at 1:46

GoogleCodeExporter commented 9 years ago
And:

public class ClassLoader {
    protected @Nullable URL findResource(String name);
}

Original comment by trask.st...@gmail.com on 16 Aug 2014 at 1:02

GoogleCodeExporter commented 9 years ago
And:

public class Arrays {
    public static void fill(@Nullable Object[] a, @Nullable Object val);
}

Original comment by trask.st...@gmail.com on 28 Sep 2014 at 9:16

GoogleCodeExporter commented 9 years ago
Thanks for suggesting these!

I have applied most of your suggestions (see revision 6ffff01adf7d), along with 
additional annotations missing from the given classes.  More specifically:

java.sql.ResultSet: 40 @Nullable annotations added
javax.management.NotificationBroadcaster: 2 @Nullable annotations added
javax.management.MBeanServer: 42 @Nullable annotations added
java.lang.reflect.Constructor: 1 @Nullable annotation added
java.security.ProtectionDomain: 11 @Nullable annotations added
java.lang.ClassLoader: 8 @Nullable annotations added
java.util.Arrays: 4 @PolyNull annotations added for fill method (@Nullable 
would be too restrictive:  it would prohibit safe code if used as suggested)

I have not yet applied two of the suggestions.  I could add them to the 
annotated JDK, but I believe they indicate other bugs that should be fixed.  I 
will open separate issues for those bugs.  In particular:

package java.util;
public class Arrays {
    public static <T extends @Nullable Object> List<T> asList(T... a);
}
This should already be the behavior due to the CLIMB-to-top defaulting rules.
This seems like a bug in the creation of the annotated JDK.

package java.net;
public class URL {
    public boolean equals(@Nullable Object obj);
}
It would be better for the JDK creation process to handle this automatically 
via inheritance of annotations from superclasses (or, better, for the 
type-checker to look up annotations on superclasses).  It would be tedious to 
have to annotate every equals method in the entire JDK.

Original comment by michael.ernst@gmail.com on 29 Sep 2014 at 6:05

GoogleCodeExporter commented 9 years ago
The two issues that I have not already fixed now have their own issues in the 
issue tracker:  issue 370 and issue 371.

Original comment by michael.ernst@gmail.com on 30 Sep 2014 at 7:19

GoogleCodeExporter commented 9 years ago
Fixed in release 1.8.7

Original comment by Jonathan...@gmail.com on 30 Oct 2014 at 11:12