[Checkers] Javari checker test case

Telmo telmo at MIT.EDU
Thu Apr 10 20:36:25 EDT 2008


It seems that the parameters of a method with readonly receiver are being 
seen as readonly. I'm working on the false positives. I'm not sure of what 
caused the nullpointerexception, since I didn't think 
hasImmutabilityAnnotation could ever be called on a null parameter; I'll 
also look into it, but for now I am making it return false for null 
parameters.

I added a new test for those false positives. It probably should be 
removed before the stable release if I don't fix it in time.

-Telmo

On Thu, 10 Apr 2008, Jaime Quinonez wrote:

> I updated and ran the Javari checker on the scene library and obtained
> two false positives before the checker threw an exception.  Here's the
> command I ran along with all the output (including a lot of warnings
> from the annotated jdk):  (the -cp ${CLASSPATH} was necessary)
>
> Jaime
>
> jaimeq at scallion:~/research/annotations/scene-lib$ pwd
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/scene-lib
>
> jaimeq at scallion:~/research/annotations/scene-lib$ javac -version
> javac 1.7.0-jsr308-dev-20080404
>
> jaimeq at scallion:~/research/annotations/scene-lib$ echoclasspath
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/checkers/build
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/checkers/checkers.jar
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/langtools/dist/lib/
> javap.jar
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/langtools/dist/lib/
> javac.jar
> /afs/csail.mit.edu/u/j/jaimeq/bin/jdk1.7.0/jre/lib/rt.jar
> .
> bin
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/shared/bin
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/annotator/bin
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/annotator/lib/
> commons-cli-1.0.jar
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/asmx/bin
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/scene-lib/bin
> /afs/csail.mit.edu/u/j/jaimeq/research/invariants/java
> /afs/csail.mit.edu/u/j/jaimeq/research/invariants/java/lib/bcel.jar
> /afs/csail.mit.edu/u/j/jaimeq/research/invariants/java/lib/commons-
> io.jar
> /afs/csail.mit.edu/u/j/jaimeq/research/invariants/java/lib/java-
> getopt.jar
> /afs/csail.mit.edu/u/j/jaimeq/research/invariants/java/lib/junit.jar
> /afs/csail.mit.edu/u/j/jaimeq/research/invariants/java/lib/bcel.jar
> /afs/csail.mit.edu/u/m/mernst/java/jdk/lib/tools.jar
> /afs/csail.mit.edu/u/j/jaimeq/research/invariants/java/lib/java-
> getopt.jar
>
> jaimeq at scallion:~/research/annotations/scene-lib$ javac -cp $
> {CLASSPATH} \
> -sourcepath ${HOME}/research/annotations/checkers/jdk/javari/src \
> -typeprocessor checkers.javari.JavariChecker \
> src/annotations/*.java \
> src/annotations/*/*.java \
> src/annotations/*/*/*.java \
>
>
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/checkers/jdk/javari/
> src/java/lang/Class.java:41: warning: sun.misc.Unsafe is Sun
> proprietary API and may be removed in a future release
> import sun.misc.Unsafe;
>                ^
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/checkers/jdk/javari/
> src/java/lang/Class.java:42: warning: sun.reflect.ConstantPool is Sun
> proprietary API and may be removed in a future release
> import sun.reflect.ConstantPool;
>                   ^
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/checkers/jdk/javari/
> src/java/lang/Class.java:43: warning: sun.reflect.Reflection is Sun
> proprietary API and may be removed in a future release
> import sun.reflect.Reflection;
>                   ^
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/checkers/jdk/javari/
> src/java/lang/Class.java:44: warning: sun.reflect.ReflectionFactory is
> Sun proprietary API and may be removed in a future release
> import sun.reflect.ReflectionFactory;
>                   ^
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/checkers/jdk/javari/
> src/java/lang/Class.java:45: warning: sun.reflect.SignatureIterator is
> Sun proprietary API and may be removed in a future release
> import sun.reflect.SignatureIterator;
>                   ^
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/checkers/jdk/javari/
> src/java/lang/Class.java:46: warning:
> sun.reflect.generics.factory.CoreReflectionFactory is Sun proprietary
> API and may be removed in a future release
> import sun.reflect.generics.factory.CoreReflectionFactory;
>                                    ^
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/checkers/jdk/javari/
> src/java/lang/Class.java:47: warning:
> sun.reflect.generics.factory.GenericsFactory is Sun proprietary API
> and may be removed in a future release
> import sun.reflect.generics.factory.GenericsFactory;
>                                    ^
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/checkers/jdk/javari/
> src/java/lang/Class.java:48: warning:
> sun.reflect.generics.repository.ClassRepository is Sun proprietary API
> and may be removed in a future release
> import sun.reflect.generics.repository.ClassRepository;
>                                       ^
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/checkers/jdk/javari/
> src/java/lang/Class.java:49: warning:
> sun.reflect.generics.repository.MethodRepository is Sun proprietary
> API and may be removed in a future release
> import sun.reflect.generics.repository.MethodRepository;
>                                       ^
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/checkers/jdk/javari/
> src/java/lang/Class.java:50: warning:
> sun.reflect.generics.repository.ConstructorRepository is Sun
> proprietary API and may be removed in a future release
> import sun.reflect.generics.repository.ConstructorRepository;
>                                       ^
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/checkers/jdk/javari/
> src/java/lang/Class.java:51: warning:
> sun.reflect.generics.scope.ClassScope is Sun proprietary API and may
> be removed in a future release
> import sun.reflect.generics.scope.ClassScope;
>                                  ^
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/checkers/jdk/javari/
> src/java/lang/Class.java:52: warning:
> sun.security.util.SecurityConstants is Sun proprietary API and may be
> removed in a future release
> import sun.security.util.SecurityConstants;
>                         ^
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/checkers/jdk/javari/
> src/java/lang/AbstractStringBuilder.java:11: warning:
> sun.misc.FloatingDecimal is Sun proprietary API and may be removed in
> a future release
> import sun.misc.FloatingDecimal;
>                ^
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/checkers/jdk/javari/
> src/java/lang/Class.java:2244: warning:
> sun.reflect.generics.repository.ClassRepository is Sun proprietary API
> and may be removed in a future release
>     private transient ClassRepository genericInfo;
>                       ^
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/checkers/jdk/javari/
> src/java/lang/Class.java:2247: warning:
> sun.reflect.generics.factory.GenericsFactory is Sun proprietary API
> and may be removed in a future release
>     private GenericsFactory getFactory() {
>             ^
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/checkers/jdk/javari/
> src/java/lang/Class.java:2253: warning:
> sun.reflect.generics.repository.ClassRepository is Sun proprietary API
> and may be removed in a future release
>     private ClassRepository getGenericInfo() {
>             ^
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/checkers/jdk/javari/
> src/java/lang/Class.java:2266: warning: sun.reflect.ConstantPool is
> Sun proprietary API and may be removed in a future release
>     native ConstantPool getConstantPool();
>            ^
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/checkers/jdk/javari/
> src/java/lang/Class.java:2870: warning: sun.reflect.ReflectionFactory
> is Sun proprietary API and may be removed in a future release
>     private static ReflectionFactory getReflectionFactory() {
>                    ^
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/checkers/jdk/javari/
> src/java/lang/Class.java:2878: warning: sun.reflect.ReflectionFactory
> is Sun proprietary API and may be removed in a future release
>     private static ReflectionFactory reflectionFactory;
>                    ^
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/checkers/jdk/javari/
> src/java/lang/Class.java:3097: warning:
> sun.reflect.annotation.AnnotationType is Sun proprietary API and may
> be removed in a future release
>     private AnnotationType annotationType;
>             ^
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/checkers/jdk/javari/
> src/java/lang/Class.java:3099: warning:
> sun.reflect.annotation.AnnotationType is Sun proprietary API and may
> be removed in a future release
>     void setAnnotationType(AnnotationType type) {
>                            ^
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/checkers/jdk/javari/
> src/java/lang/Class.java:3103: warning:
> sun.reflect.annotation.AnnotationType is Sun proprietary API and may
> be removed in a future release
>     AnnotationType getAnnotationType() {
>     ^
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/checkers/jdk/javari/
> src/java/io/OutputStreamWriter.java:12: warning:
> sun.nio.cs.StreamEncoder is Sun proprietary API and may be removed in
> a future release
> import sun.nio.cs.StreamEncoder;
>                  ^
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/checkers/jdk/javari/
> src/java/io/OutputStreamWriter.java:63: warning:
> sun.nio.cs.StreamEncoder is Sun proprietary API and may be removed in
> a future release
>     private final StreamEncoder se;
>                   ^
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/checkers/jdk/javari/
> src/java/lang/Float.java:11: warning: sun.misc.FloatingDecimal is Sun
> proprietary API and may be removed in a future release
> import sun.misc.FloatingDecimal;
>                ^
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/checkers/jdk/javari/
> src/java/lang/Float.java:12: warning: sun.misc.FpUtils is Sun
> proprietary API and may be removed in a future release
> import sun.misc.FpUtils;
>                ^
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/checkers/jdk/javari/
> src/java/lang/Float.java:13: warning: sun.misc.FloatConsts is Sun
> proprietary API and may be removed in a future release
> import sun.misc.FloatConsts;
>                ^
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/checkers/jdk/javari/
> src/java/lang/Float.java:14: warning: sun.misc.DoubleConsts is Sun
> proprietary API and may be removed in a future release
> import sun.misc.DoubleConsts;
>                ^
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/checkers/jdk/javari/
> src/java/lang/Double.java:11: warning: sun.misc.FloatingDecimal is Sun
> proprietary API and may be removed in a future release
> import sun.misc.FloatingDecimal;
>                ^
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/checkers/jdk/javari/
> src/java/lang/Double.java:12: warning: sun.misc.FpUtils is Sun
> proprietary API and may be removed in a future release
> import sun.misc.FpUtils;
>                ^
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/checkers/jdk/javari/
> src/java/lang/Double.java:13: warning: sun.misc.DoubleConsts is Sun
> proprietary API and may be removed in a future release
> import sun.misc.DoubleConsts;
>                ^
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/checkers/jdk/javari/
> src/java/lang/System.java:19: warning: sun.nio.ch.Interruptible is Sun
> proprietary API and may be removed in a future release
> import sun.nio.ch.Interruptible;
>                  ^
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/checkers/jdk/javari/
> src/java/lang/System.java:20: warning: sun.net.InetAddressCachePolicy
> is Sun proprietary API and may be removed in a future release
> import sun.net.InetAddressCachePolicy;
>               ^
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/checkers/jdk/javari/
> src/java/lang/System.java:21: warning: sun.reflect.Reflection is Sun
> proprietary API and may be removed in a future release
> import sun.reflect.Reflection;
>                   ^
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/checkers/jdk/javari/
> src/java/lang/System.java:22: warning:
> sun.security.util.SecurityConstants is Sun proprietary API and may be
> removed in a future release
> import sun.security.util.SecurityConstants;
>                         ^
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/checkers/jdk/javari/
> src/java/lang/System.java:23: warning:
> sun.reflect.annotation.AnnotationType is Sun proprietary API and may
> be removed in a future release
> import sun.reflect.annotation.AnnotationType;
>                              ^
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/checkers/jdk/javari/
> src/java/io/InputStreamReader.java:13: warning:
> sun.nio.cs.StreamDecoder is Sun proprietary API and may be removed in
> a future release
> import sun.nio.cs.StreamDecoder;
>                  ^
> /afs/csail.mit.edu/u/j/jaimeq/research/annotations/checkers/jdk/javari/
> src/java/io/InputStreamReader.java:48: warning:
> sun.nio.cs.StreamDecoder is Sun proprietary API and may be removed in
> a future release
>     private final StreamDecoder sd;
>                   ^
> src/annotations/AbstractAnnotation.java:28: warning: cast increases
> mutability access
>         return o instanceof Annotation && equals((/*@NonNull*/
> Annotation) o);
>                                                                          ^
> src/annotations/AbstractAnnotation.java:48: cannot invoke a Mutable
> method from a ReadOnly reference
>         return def.equals(o.def())
>                                ^
> src/annotations/AbstractAnnotation.java:49: incompatible types.
> found   : @NonNull @ReadOnly Annotation
> required: @NonNull @Mutable Annotation
>                 && myFieldMap.equals(Annotations.fieldValuesMap(o));
>                                                                 ^
>
>
> An annotation processor threw an uncaught exception.
> Consult the following stack trace for details.
> java.lang.NullPointerException
> 	at
> checkers
> .javari
> .JavariAnnotatedTypeFactory
> .getImmutabilityAnnotation(JavariAnnotatedTypeFactory.java:58)
> 	at
> checkers
> .javari
> .JavariAnnotatedTypeFactory
> .hasImmutabilityAnnotation(JavariAnnotatedTypeFactory.java:78)
> 	at checkers.javari.JavariAnnotatedTypeFactory
> $TypePostAnnotator.scan(JavariAnnotatedTypeFactory.java:362)
> 	at checkers.javari.JavariAnnotatedTypeFactory
> $TypePostAnnotator.scan(JavariAnnotatedTypeFactory.java:351)
> 	at
> checkers
> .types.AnnotatedTypeScanner.scanAndReduce(AnnotatedTypeScanner.java:109)
> 	at
> checkers
> .types.AnnotatedTypeScanner.visitWildcard(AnnotatedTypeScanner.java:175)
> 	at checkers.types.AnnotatedTypeMirror
> $AnnotatedWildcardType.accept(AnnotatedTypeMirror.java:1276)
> 	at checkers.types.AnnotatedTypeScanner.scan(AnnotatedTypeScanner.java:
> 81)
> 	at checkers.javari.JavariAnnotatedTypeFactory
> $TypePostAnnotator.scan(JavariAnnotatedTypeFactory.java:416)
> 	at checkers.javari.JavariAnnotatedTypeFactory
> $TypePostAnnotator.scan(JavariAnnotatedTypeFactory.java:351)
> 	at
> checkers
> .types.AnnotatedTypeScanner.scanAndReduce(AnnotatedTypeScanner.java:109)
> 	at checkers.types.AnnotatedTypeScanner.scan(AnnotatedTypeScanner.java:
> 98)
> 	at
> checkers
> .types.AnnotatedTypeScanner.visitDeclared(AnnotatedTypeScanner.java:120)
> 	at checkers.types.AnnotatedTypeMirror
> $AnnotatedDeclaredType.accept(AnnotatedTypeMirror.java:440)
> 	at checkers.types.AnnotatedTypeScanner.scan(AnnotatedTypeScanner.java:
> 81)
> 	at checkers.javari.JavariAnnotatedTypeFactory
> $TypePostAnnotator.scan(JavariAnnotatedTypeFactory.java:416)
> 	at checkers.javari.JavariAnnotatedTypeFactory
> $TypePostAnnotator.scan(JavariAnnotatedTypeFactory.java:351)
> 	at
> checkers.types.AnnotatedTypeScanner.visit(AnnotatedTypeScanner.java:71)
> 	at
> checkers.types.AnnotatedTypeScanner.visit(AnnotatedTypeScanner.java:65)
> 	at
> checkers
> .javari
> .JavariAnnotatedTypeFactory
> .annotateInheritedFromClass(JavariAnnotatedTypeFactory.java:89)
> 	at
> checkers
> .types.AnnotatedTypeFactory.fromTypeTree(AnnotatedTypeFactory.java:290)
> 	at checkers.types.TypeFromTree
> $TypeFromMember.visitVariable(TypeFromTree.java:295)
> 	at checkers.types.TypeFromTree
> $TypeFromMember.visitVariable(TypeFromTree.java:283)
> 	at com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:
> 727)
> 	at com.sun.source.util.SimpleTreeVisitor.visit(SimpleTreeVisitor.java:
> 52)
> 	at checkers.types.TypeFromTree
> $TypeFromMember.visitMethod(TypeFromTree.java:349)
> 	at checkers.types.TypeFromTree
> $TypeFromMember.visitMethod(TypeFromTree.java:283)
> 	at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:681)
> 	at com.sun.source.util.SimpleTreeVisitor.visit(SimpleTreeVisitor.java:
> 52)
> 	at
> checkers
> .types
> .AnnotatedTypeFactory.fromTreeWithVisitor(AnnotatedTypeFactory.java:232)
> 	at
> checkers
> .types.AnnotatedTypeFactory.fromMember(AnnotatedTypeFactory.java:263)
> 	at
> checkers
> .types.AnnotatedTypeFactory.getAnnotatedType(AnnotatedTypeFactory.java:
> 449)
> 	at checkers.basetype.BaseTypeVisitor.visitMethod(BaseTypeVisitor.java:
> 152)
> 	at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:681)
> 	at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:67)
> 	at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:80)
> 	at com.sun.source.util.TreeScanner.scan(TreeScanner.java:90)
> 	at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:98)
> 	at com.sun.source.util.TreeScanner.visitClass(TreeScanner.java:132)
> 	at checkers.basetype.BaseTypeVisitor.visitClass(BaseTypeVisitor.java:
> 123)
> 	at checkers.javari.JavariVisitor.visitClass(JavariVisitor.java:76)
> 	at checkers.javari.JavariVisitor.visitClass(JavariVisitor.java:23)
> 	at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:604)
> 	at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:49)
> 	at checkers.source.SourceChecker.process(SourceChecker.java:190)
> 	at
> com
> .sun
> .tools
> .javac
> .processing
> .JavacProcessingEnvironment
> .callProcessor(JavacProcessingEnvironment.java:733)
> 	at
> com
> .sun
> .tools
> .javac
> .processing
> .JavacProcessingEnvironment
> .discoverAndRunProcs(JavacProcessingEnvironment.java:662)
> 	at
> com
> .sun
> .tools
> .javac
> .processing
> .JavacProcessingEnvironment
> .doProcessing(JavacProcessingEnvironment.java:807)
> 	at
> com
> .sun
> .tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:995)
> 	at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:741)
> 	at com.sun.tools.javac.main.Main.compile(Main.java:380)
> 	at com.sun.tools.javac.main.Main.compile(Main.java:306)
> 	at com.sun.tools.javac.main.Main.compile(Main.java:297)
> 	at com.sun.tools.javac.Main.compile(Main.java:82)
> 	at com.sun.tools.javac.Main.main(Main.java:67)
>
> _______________________________________________
> checkers mailing list
> checkers at lists.csail.mit.edu
> https://lists.csail.mit.edu/mailman/listinfo/checkers
>



More information about the checkers mailing list