Looking for documentation on building com.google.errorprone:javac artifact

14 views
Skip to first unread message

Lazaro Clapp

unread,
Jan 15, 2021, 2:25:20 PMJan 15
to error-pro...@googlegroups.com
Hi everyone,

I was wondering if there are any instructions on how the javac.jar artifact for Error Prone (for compatibility with JDK 8 builds) is generated? Ideally, ones that make it easy for me to generate a new version from a later release of the JDK 9. Apologies in advance if I missed something obvious.

We are trying to debug an issue in our build, where we get the following error out of the Error Prone javac:9+181-r4173-1 compiler when using the EP @Var annotation (even with the actual Error Prone plugin fully disabled):

> stderr: : warning: unknown enum constant javax.lang.model.element.Modifier.FINAL
> reason: class file for javax.lang.model.element.Modifier not found

This is in a large Android build on JDK 8, and I have thus far been unable to generate a self-contained repro build project. 

One thing I'd like to try is to generate a version of EP javac.jar artifact based on a later JDK 9 build, to rule out issues like JDK-8187950. So, I was wondering if it's possible from me to build an updated version of "com.google.errorprone:javac:9+181-r4173-1" (which was last updated in January 2018) based on a more recent JDK like 9.0.1+11 or 9.0.4+11?

Thanks,

Lazaro

Liam Miller-Cushon

unread,
Jan 15, 2021, 2:34:37 PMJan 15
to error-pro...@googlegroups.com


We are trying to debug an issue in our build, where we get the following error out of the Error Prone javac:9+181-r4173-1 compiler when using the EP @Var annotation (even with the actual Error Prone plugin fully disabled):
> stderr: : warning: unknown enum constant javax.lang.model.element.Modifier.FINAL

My understanding is that android.jar doesn't contain javax.lang.model.element.Modifier. The definition of @Var has a meta-annotation that explicitly references that enum: https://github.com/google/error-prone/blob/4f69766fb4693baf089963c3221590c0705f960e/annotations/src/main/java/com/google/errorprone/annotations/Var.java#L23

So I think that javac diagnostic might be correct. Are you getting an error-level diagnostic, or just the warning? (Or maybe you're using -Werror?)

--
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-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/error-prone-discuss/CAE1NZyi2K6_J%2Bym%2Bh-qCk%2BGSTUtQV5muL5zPeROb4N%3Dko4TYrA%40mail.gmail.com.

Lazaro Clapp

unread,
Jan 15, 2021, 5:29:03 PMJan 15
to error-pro...@googlegroups.com
Hi Liam,

Actually, reading this response, I think you are right, and I went on an overly complicated tangent debugging this. 

Like you said, android.jar doesn't have javax.lang.model.element.Modifier enum. Now, in our build, we actually add a number of rt.jar classes to the -Xbootclasspath of the javac JVM. So, I was seeing it being loaded from custom Error Prone plugins and available to the compiler during debugging, and that caused me to become confused.

However, I just realized that - of course! - javac would be looking for it in the classpath of the code being compiled, not on the compiler's classpath, since the problem happens when processing an annotation (@Var) that is included with the compiled code. This is 100% unrelated to whether Modifier is available to the compiler and compiler plugins and related only to whether it's available to the compiled Java project.

Short term, we could possibly fix this by taking that enum into its own jar and adding it as a dependency, then removing it (and the annotations using it) before dexing. That said, would this be considered a bug on the Error Prone side?

By default, when running with -Werror, this breaks the Var checker for Android projects since at least 2.3.3, and it breaks LazyInit since 2.3.4 (see this line).
Thanks so much for these! As noted above, the actual issue might be unrelated, but it's not the first time I search for that.

> My understanding is that android.jar doesn't contain javax.lang.model.element.Modifier.

You are entirely correct. See above.

> So I think that javac diagnostic might be correct. Are you getting an error-level diagnostic, or just the warning? (Or maybe you're using -Werror?)

We build all targets with -Werror. I also looked for a way to suppress that diagnostic and only that diagnostic. Thus far, I haven't figured out how to do that.

Is this a case where it would be worth it to open an issue on EP for Android support for @Var/@LazyInit/etc out of the box?

Thanks again!

Lazaro


Liam Miller-Cushon

unread,
Jan 19, 2021, 7:28:30 PMJan 19
to error-pro...@googlegroups.com
On Fri, Jan 15, 2021 at 2:29 PM 'Lazaro Clapp' via error-prone-discuss <error-pro...@googlegroups.com> wrote:
Is this a case where it would be worth it to open an issue on EP for Android support for @Var/@LazyInit/etc out of the box?

SGTM, thanks for filing https://github.com/google/error-prone/issues/2122 :) I responded in the bug.
Reply all
Reply to author
Forward
0 new messages