Stop compilation after N warnings with -Werror?

Dawid Weiss dawid.weiss at gmail.com
Fri Sep 4 07:59:21 UTC 2020


Hello folks,

Is there any way to have both -Werror (error on warnings) *and* more
than *one* warning emitted during compilation? When running on a CI
it'd be good to see a number of warnings causing the final error - not
just the first one. I thought something like this may work:

-Werror -Xmaxerrs 10 -Xmaxwarns 10

but this still stops after the first warning, saying - somewhat
misleadingly (because there are a number more errors/warnings during
full compile cycle):

error: warnings found and -Werror specified
1 error
1 warning

I looked at the code in [1] but couldn't pinpoint why it doesn't work, exactly.

Dawid

[1] https://hg.openjdk.java.net/jdk-updates/jdk11u/file/95da35fd7597/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java#l576


More information about the compiler-dev mailing list