Enabling proper Error Prone integration with Buck
See original GitHub issueWe wanted to have a discussion on the best way to “upstream” our technique for using using Error Prone with Buck, which would primarily consist of adding documentation.
For the most part, our integration uses the available javac_jar
and compiler_class_name
options, where the javac jar is the Error Prone Ant artifact. Error Prone is packaged with a version of the JDK 9 javac compiler, whereas we currently build on JDK 8. This makes integration slightly tricky, as the JDK 9 javac includes updated versions of certain javax.tools
and javax.lang.model.type
classes as compared to what is in the JDK 8 rt.jar
. To work around this issue, we have extracted the relevant classes from the EP javac jar into a small new jar tiny_tools.jar
that we place in Buck’s bootclasspath via .buckjavaargs
. (Placing the full EP Ant artifact in the bootclasspath is risky; see google/error-prone#934.) With this change, everything seems to work well, including plugin checks. One downside is that the EP Ant artifact exposes some third-party libraries like Guava to annotation processors; we opened google/error-prone#950 to relocate the classes most likely to cause conflicts.
An alternative integration point would be to use Error Prone as a Javac plugin, which is supported by Error Prone (see the docs). However, this integration requires Java 9, and we are still building on JDK 8; we have not yet tried it in the context of Buck builds.
In terms of upstreaming, one question is where the tiny_tools.jar
file should live. We could create a separate Maven artifact for it, or add it to the Buck repo. It was created via a fairly manual process, and it could requiring updating when Error Prone uses a new javac version. We could also add some scripting around this to auto-generate the jar.
Other feedback / comments welcome. Thanks!
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:8 (8 by maintainers)
Top GitHub Comments
Some further clarity on classloader stuff. My understanding of
bootstrap_deploy.jar
was way off in the above comment. What actually happens is:-bootclasspath
parameter and calling the file manager APIs, e.g., here and here. This makes sense, as for example if you’re targeting 1.6, you want the bootclasspath seen by the compiler to match a 1.6 JVM.Anyway, wanted to clarify that. Still thinking about the right integration for Buck; will post back when I have something.
FYI, we have documented how we got Error Prone to work with Buck builds on JDK 8 at Uber:
https://github.com/uber/okbuck/wiki/Using-Error-Prone-with-Buck-and-OkBuck
Feedback welcome and I’m happy to help with upstreaming docs or scripts if desired