barry-m / checker-framework

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

Stub files cannot read annotations with class literals as attributes #407

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I'm trying to write stubs for org.junit.runners.ParentRunner. My stub looks 
like the following:

class ParentRunner {
  void collectInitializationErrors(List<Throwable> errors) @UnknownInitialization(Runner.class);
}

but this fails with the exception:

error: StubParser: unhandled annotation attribute type: Runner.class class: 
class org.checkerframework.stubparser.ast.expr.ClassExpr
  Exception: java.lang.Throwable; Stack trace: org.checkerframework.framework.source.SourceChecker.errorAbort(SourceChecker.java:613)
  org.checkerframework.javacutil.ErrorReporter.errorAbort(ErrorReporter.java:28)
  org.checkerframework.framework.stub.StubParser.handleExpr(StubParser.java:1072)
  org.checkerframework.framework.stub.StubParser.getAnnotation(StubParser.java:945)
  org.checkerframework.framework.stub.StubParser.annotate(StubParser.java:652)
  org.checkerframework.framework.stub.StubParser.parseMethod(StubParser.java:501)
  org.checkerframework.framework.stub.StubParser.parse(StubParser.java:383)
  org.checkerframework.framework.stub.StubParser.parse(StubParser.java:319)
  org.checkerframework.framework.stub.StubParser.parse(StubParser.java:299)
  org.checkerframework.framework.stub.StubParser.parse(StubParser.java:294)
  org.checkerframework.framework.type.AnnotatedTypeFactory.buildIndexTypes(AnnotatedTypeFactory.java:2249)
  org.checkerframework.framework.type.GenericAnnotatedTypeFactory.postInit(GenericAnnotatedTypeFactory.java:148)
  org.checkerframework.checker.nullness.NullnessAnnotatedTypeFactory.<init>(NullnessAnnotatedTypeFactory.java:151)
  org.checkerframework.checker.nullness.NullnessVisitor.createTypeFactory(NullnessVisitor.java:109)
  org.checkerframework.checker.nullness.NullnessVisitor.createTypeFactory(NullnessVisitor.java:59)
  org.checkerframework.common.basetype.BaseTypeVisitor.<init>(BaseTypeVisitor.java:196)
  org.checkerframework.checker.initialization.InitializationVisitor.<init>(InitializationVisitor.java:71)
  org.checkerframework.checker.nullness.NullnessVisitor.<init>(NullnessVisitor.java:88)
  org.checkerframework.checker.nullness.AbstractNullnessChecker.createSourceVisitor(AbstractNullnessChecker.java:57)
  org.checkerframework.checker.nullness.AbstractNullnessChecker.createSourceVisitor(AbstractNullnessChecker.java:14)
  org.checkerframework.framework.source.AggregateVisitor.<init>(AggregateChecker.java:184)
  org.checkerframework.framework.source.AggregateChecker.createSourceVisitor(AggregateChecker.java:165)
  org.checkerframework.framework.source.SourceChecker.initChecker(SourceChecker.java:731)
  org.checkerframework.framework.source.AggregateChecker.initChecker(AggregateChecker.java:84)
  org.checkerframework.framework.source.SourceChecker.typeProcessingStart(SourceChecker.java:692)
  org.checkerframework.javacutil.AbstractTypeProcessor$AttributionTaskListener.finished(AbstractTypeProcessor.java:183)
  com.sun.tools.javac.api.ClientCodeWrapper$WrappedTaskListener.finished(ClientCodeWrapper.java:681)
  com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:111)
  com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1342)
  com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1296)
  com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:901)
  com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:860)
  com.sun.tools.javac.main.Main.compile(Main.java:523)
  com.sun.tools.javac.main.Main.compile(Main.java:381)
  com.sun.tools.javac.main.Main.compile(Main.java:370)
  com.sun.tools.javac.main.Main.compile(Main.java:361)
  com.sun.tools.javac.Main.compile(Main.java:56)
  com.sun.tools.javac.Main.main(Main.java:42)

removing the argument to the annotation fixes the issue.

Is passing arguments to annotations on a method's explicit receiver supported 
inside stubs?

Original issue reported on code.google.com by eatnumb...@google.com on 7 Mar 2015 at 12:31

GoogleCodeExporter commented 9 years ago
Currently, stub files only support annotations with string, boolean, or integer 
literals.   The location of the annotation is not relevant. 

I'll looking into adding class literals.

(This and other stub file limitations are addressed in the manual
http://types.cs.washington.edu/checker-framework/current/checker-framework-manua
l.html#stub )

Original comment by Suzanne....@gmail.com on 9 Mar 2015 at 5:22