typetools / typetools/checker-framework

add ability to load annotation classes from processor path

Open
#2,606 7 comments 0 reactions 1 assignee View on GitHub

@wmdietl is already working on this.

Since Jul 10, 2019.

Dominant language
Java
Stars
1.1k
Forks
440
Avg merge
1d 12h
Merged PRs (30d)
134

Description

We have a checker that has one sub-checker, with the checker and sub-checker residing in different jar files. When we place the jars on the classpath, the checker runs fine, but when we place both jars on the processor path, the subchecker fails to road.

Zip for repro:
repro-cf-crash.zip

Unzip and run this command in the repro-cf-crash directory to see the crash:

$ javac -processorpath typesafe-builder-checker.jar:returnsrecv-checker-master-SNAPSHOT.jar:checker-2.8.1.jar:spring-expression-5.1.7.RELEASE.jar:lombok-1.18.8.jar:auto-value-annotations-1.6.5.jar Foo.java
error: InvocationTargetException when invoking constructor for class org.checkerframework.checker.returnsrcvr.ReturnsRcvrVisitor; Underlying cause: InvocationTargetException when invoking constructor for class org.checkerframework.checker.returnsrcvr.ReturnsRcvrAnnotatedTypeFactory; Underlying cause: Cannot load annotation interface org.checkerframework.checker.returnsrcvr.qual.MaybeThis
  Exception: java.lang.reflect.InvocationTargetException; Stack trace: sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
  sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  java.lang.reflect.Constructor.newInstance(Constructor.java:423)
  org.checkerframework.common.basetype.BaseTypeChecker.invokeConstructorFor(BaseTypeChecker.java:274)
  org.checkerframework.common.basetype.BaseTypeChecker.createSourceVisitor(BaseTypeChecker.java:212)

But if the jars are placed in the classpath, the checker runs fine:

$ javac -classpath typesafe-builder-checker.jar:returnsrecv-checker-master-SNAPSHOT.jar:checker-2.8.1.jar:spring-expression-5.1.7.RELEASE.jar:lombok-1.18.8.jar:auto-value-annotations-1.6.5.jar Foo.java
warning: You do not seem to be using the distributed annotated JDK.  To fix the problem, supply javac an argument like:  -Xbootclasspath/p:.../checker/dist/ .  Currently using: jdk8.jar
1 warning

The checker is in typesafe-builder-checker.jar and the sub-checker is in returnsrecv-checker-master-SNAPSHOT.jar, and the checker is being run via processor auto-discovery (though I don't think that matters for the crash). Here is the code specifying the sub-checker:

https://github.com/kelloggm/typesafe-builder-checker/blob/7b61943a291b47bdb65689abd3b7bbd73c4c8f2f/src/main/java/org/checkerframework/checker/builder/TypesafeBuilderChecker.java#L17-L22

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.