Error Prone's integration with Bazel

287 views
Skip to first unread message

Manu Sridharan

unread,
Feb 27, 2018, 7:48:19 PM2/27/18
to error-prone-discuss
Hi all,

I had a couple questions about how Error Prone is integrated with Bazel that I was hoping I could get some help with.  For context, we've had Error Prone integrated with Buck for some time now, but it's hackish and we're trying to figure out a "proper" way to do things.

First, I'm wondering how Bazel deals with building using Error Prone on JDK 8, since some JDK 9 javac classes conflict with those in the JDK 8 rt.jar.  I'm guessing there is some classloader magic somewhere to make this work.  Could someone point me to the relevant code?

Second, a NullAway user noticed that on Bazel, the Guava library that Error Prone uses is not visible to annotation processors / plugin checks; see https://github.com/uber/NullAway/issues/119.  But with this isolation, I'm not sure what happens if an Error Prone plugin check needs to invoke an Error Prone API that mentions a Guava type.  I don't have a concrete bad example here, but I was just wondering how exactly this gets managed.

Thanks for the help!

Best,
Manu

Liam Miller-Cushon

unread,
Mar 1, 2018, 1:57:27 AM3/1/18
to error-pro...@googlegroups.com
Hi Manu,

On Tue, Feb 27, 2018 at 4:48 PM, Manu Sridharan <msri...@gmail.com> wrote:
First, I'm wondering how Bazel deals with building using Error Prone on JDK 8, since some JDK 9 javac classes conflict with those in the JDK 8 rt.jar.  I'm guessing there is some classloader magic somewhere to make this work.  Could someone point me to the relevant code?

We override the JDK 8 versions of those classes using -Xbootclasspath/p:

The JDK 9 equivalent is to use --patch-module on jdk.compiler and java.compiler, but Bazel is currently using JDK 8 by default, so that hasn't been productionized in Bazel yet.
 
Second, a NullAway user noticed that on Bazel, the Guava library that Error Prone uses is not visible to annotation processors / plugin checks; see https://github.com/uber/NullAway/issues/119.  But with this isolation, I'm not sure what happens if an Error Prone plugin check needs to invoke an Error Prone API that mentions a Guava type.  I don't have a concrete bad example here, but I was just wondering how exactly this gets managed.

The isolation is achieved by packaging Error Prone with the tool that wraps javac, so it's on the compiler classpath rather than the processor classpath, and there's some classloader magic to make sure that guava doesn't leak onto the processor classpath:

We don't have a solution to this, so we generally avoid using guava in Error Prone APIs consumed by plugins running in Bazel.

Manu Sridharan

unread,
Mar 1, 2018, 9:47:49 AM3/1/18
to error-prone-discuss
Thanks so much, Liam!  This is super helpful.  We actually made our own version of bootstrap_deploy.jar recently :-)  I think we'll try to re-use Bazel's now.  And thanks for the clarification on Guava and classloaders.

Best,
Manu

--
Googlers: This an external list. Please be careful when posting.
---
You received this message because you are subscribed to the Google Groups "error-prone-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to error-prone-discuss+unsub...@googlegroups.com.
Visit this group at https://groups.google.com/group/error-prone-discuss.
To view this discussion on the web visit https://groups.google.com/d/msgid/error-prone-discuss/CAL4Qsgst%3Dog7eZ7YMw8oxNaX4UNRiRC4BYcOFBQv%3D_-w7wboXg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages