lastnpe / external-annotations-esperanto

Tooling to convert different representations of externalized Java annotations to & fro' each other
http://www.lastnpe.org
Eclipse Public License 1.0
2 stars 0 forks source link

Hack NullAway LibraryModels generator MVP POC #2

Open vorburger opened 3 weeks ago

vorburger commented 3 weeks ago

The goal of this issue would be to explore hacking a converter from annotated Java sources to a NullAway LibraryModels generator MVP POC.

Use case / application would be for / driven by https://github.com/enola-dev/enola/issues/845 (and possibly also using NullAway e.g. for my https://github.com/vorburger/ch.vorburger.exec or https://github.com/vorburger/ch.vorburger.fswatch or https://github.com/MariaDB4j/MariaDB4j).

Approach/steps planned would be to:

https://github.com/javaparser/javaparser, and/or it's apparent (?) fork https://github.com/eisop/stubparser, used by (?) https://github.com/typetools/annotation-tools may be of interest - although I don't yet fully understand if any of that is even needed... what's wrong with plain simple Java reflection?!

Re. https://github.com/uber/NullAway/issues/1024

/CC @cpovirk FYI

cpovirk commented 3 weeks ago

FWIW, the Checker Framework groups (EISOP + Typetools) are trying to move off JavaParser IIUC, as they've had issues:

Their likely replacement is https://github.com/plume-lib/javac-parse/blob/main/src/main/java/org/plumelib/javacparse/JavacParse.java, which contains the same basic boilerplate as various similar tools use (example).

As for reflection: If you can actually compile the annotated Java sources, then that could work fine AFAIK. (Maybe bugs around type annotations are more likely for reflection than for build tools, but I don't know. I at least doubt you'd have significant issues for annotations on "root" locations (e.g., fields and method return types, as opposed to type arguments inside those).) I think we ended up with our approach in part because we were interested in annotations for the JDK, which might be trickier to build? I don't actually remember the details of that discussion, if even I heard most of them in the first place. (I do think that trying to do the job with only a "parser" is a bit sketchy: You really want the deps of the classes to be available, I think. But apparently they mostly get away with it.)

msridhar commented 3 weeks ago

A couple of thoughts / questions.