Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
GoogleCodeExporter opened this issue Jul 3, 2015 · 2 comments

Comments

@GoogleCodeExporter
Copy link

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
Copy link
Author

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

  • Changed title: Stub files cannot read annotations with class literals as attributes
  • Changed state: Accepted
  • Added labels: Type-Enhancement
  • Removed labels: Type-Defect

@mernst
Copy link
Member

mernst commented Aug 13, 2017

Fixed by 8997a34.

@mernst mernst closed this as completed Aug 13, 2017
mernst added a commit to mernst/checker-framework that referenced this issue Feb 28, 2023
Co-authored-by: Suzanne Millstein <smillst@cs.washington.edu>
Co-authored-by: Michael Ernst <mernst@cs.washington.edu>
Co-authored-by: Martin Kellogg <martin.kellogg@njit.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants