Is there any way to suppress notes printed by javac from Bazel?

444 views
Skip to first unread message

Erik Kuefler

unread,
Jul 1, 2015, 3:21:53 AM7/1/15
to bazel-...@googlegroups.com
When javac encounters uses of deprecated APIs or raw types, it prints a line after it's done telling you what flag you can pass to see more details on the error. As far as I can tell there's no way to disable this behavior in javac itself. Unfortunately, this doesn't play very nicely with the Bazel structure of using fine-grained packages and invoking javac for each. On a build that touches anything of significance in my system, I tend to get hundreds of repetitions of the following lines in my terminal:

INFO: From Building src/main/java/mypackage.jar (5 files):
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

This makes for a lot of spam to scroll through trying to find the actual errors. Does Bazel provide any way to filter the javac output, or could it be made to? I'm guessing there's no way to do this right now, but I don't recall ever seeing this problem when I was using Blaze inside Google.

Kristina Chodorow

unread,
Jul 1, 2015, 10:03:25 AM7/1/15
to Erik Kuefler, bazel-...@googlegroups.com
You might want to use http://bazel.io/docs/bazel-user-manual.html#flag--output_filter to just get output from the top-level target you're building.

--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/CANK5_0pFyG_WdGtBw4JWPC_BpqmG82SQsbrGoARoxQWshpdomQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Liam Miller-Cushon

unread,
Jul 1, 2015, 1:34:21 PM7/1/15
to Kristina Chodorow, Erik Kuefler, bazel-...@googlegroups.com
There are a few lint errors that javac makes it impossible to suppress. I think the full list is sunapi, deprecation, and unchecked/rawtypes. If they aren't enabled, you're stuck with the 'note' diagnostics.

Those notes are disabled in our internal copy of javac, so that might be what you're remembering.

The default behaviour of --output_filter is supposed to only show output for the targets explicitly listed in the build invocation. That doesn't sound like what you're seeing. Are you setting a custom --output_filter? If not, something might be broken.

Erik Kuefler

unread,
Jul 1, 2015, 1:57:48 PM7/1/15
to Liam Miller-Cushon, Kristina Chodorow, bazel-...@googlegroups.com
Too bad. Yeah, I was kind of hoping that it was Error-Prone that made them go away and they'd magically vanish when Bazel switched to using it, but no such luck.

--output_filter is a bit heavy-handed - I don't want to suppress errors from other targets, I just don't want to see 4 lines of Note for basically every single target that gets built.

I don't think anything's broken - sounds like Bazel and javac are both working as intended, I just think javac's intention is dumb (and interacts poorly with Bazel in a way that might not be visible to you if your javac suppresses those messages). Really javac should provide a flag to silence these messages, but that not being possible would it be feasible for Bazel or Error-Prone to have an option to filter the javac output?

Liam Miller-Cushon

unread,
Jul 1, 2015, 7:20:25 PM7/1/15
to Erik Kuefler, Kristina Chodorow, bazel-...@googlegroups.com
On Wed, Jul 1, 2015 at 10:57 AM, Erik Kuefler <ekue...@gmail.com> wrote:
Too bad. Yeah, I was kind of hoping that it was Error-Prone that made them go away and they'd magically vanish when Bazel switched to using it, but no such luck.

--output_filter is a bit heavy-handed - I don't want to suppress errors from other targets, I just don't want to see 4 lines of Note for basically every single target that gets built.

If other targets produce errors and fail the build, the output should always be printed. It's only if they succeed with warnings that --output_filter takes effect.

It would still be nice to silence the notes, though.
 
I don't think anything's broken - sounds like Bazel and javac are both working as intended, I just think javac's intention is dumb (and interacts poorly with Bazel in a way that might not be visible to you if your javac suppresses those messages). Really javac should provide a flag to silence these messages, but that not being possible would it be feasible for Bazel or Error-Prone to have an option to filter the javac output?

Filtering the notes after they're emitted by javac is do-able, but changing javac was the simplest option. The alternatives are brittle - you either have to use internal javac APIs, or post-process the diagnostics as text.
Reply all
Reply to author
Forward
0 new messages