New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix compiler warnings #13410
Fix compiler warnings #13410
Conversation
We have a handful of compiler warnings, mostly because of passing an array to varargs methods. This change fixes these warnings and adds -Werror so we don't get anymore of these warnings. Note this does *not* enable deprecation or unchecked type warnings, so these remain "hidden". We should work towards removing those as well, but this is a first step.
Looks great!
Good, it at least prevents warnings of other types from stacking up. How bad is the unchecked situation? We should really open a followup for that one. Deprecation is more complicated, especially if we want to deprecate our own apis. That one is less important I think. |
Hundreds of warnings...well, at least 100 |
Can we also turn on -Xlint ? I don't care if we then have to add e.g. -Xlint:-serial to disable some of the stupid ones, or ones that need fixes, but it would be nice to know where we stand. |
I turned on -Xlint and disabled the frequent ones I found, and fixed a handful of easy ones. There are some tricky ones we should really look into... However, while core main/test now passes compile, I get a failure compiling tests for distribution/tar. But there is no warning, or any error at all... @dadoonet Could you try my branch and see if you understand why? I've run with -X but I don't see anything that explains why the failure occurred. |
this is likely your JVM / Compiler we had problems her with |
this is really weird if you run
creating |
hmm without |
Funny. The same is happening in plugins but not for all plugins...
Looking at this ATM. |
@rjernst Adding And BTW this is cool stuff because now we can see some cloud-azure code issues! :)
|
Just wondering if we should add a maven property like <lint.level>-Werror</lint.level> And then define instead of <arg>${xlint.level}</arg> So we could potentially run: |
@rjernst If you don't want to bypass path checks for each module, then add in parent pom:
And:
In distribution/pom.xml:
Same in cloud-azure (and may be some others)... |
No, I don't think we should do that, because the next step is "let's set the default back to warn". This PR fixes issues, we don't want to go backwards from there. And there are some we really need to investigate (see some of the TODOs I added in this). |
@dadoonet thanks for the suggestion on parameterizing -Xling:-path. I actually want to just be able to add additional compiler args within a child pom, eg core. This way the warning removals can be isolated to the modules that need them, instead of allowing leniency in all modules. |
@rjernst then add in parent pom: <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<fork>true</fork>
<maxmem>512m</maxmem>
<!-- REMOVE WHEN UPGRADE:
see https://jira.codehaus.org/browse/MCOMPILER-209 it's a bug where
incremental compilation doesn't work unless it's set to false causeing
recompilation of the entire codebase each time without any changes. Should
be fixed in version > 3.1
-->
<useIncrementalCompilation>false</useIncrementalCompilation>
<showWarnings>true</showWarnings>
<compilerArgs>
<arg>-XDignore.symbol.file</arg>
<arg>-Xlint:all</arg>
<arg>-Xlint:-path</arg>
<arg>-Werror</arg>
</compilerArgs>
</configuration>
</plugin> In core/pom.xml: <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgs>
<arg>-XDignore.symbol.file</arg>
<arg>-Xlint:all</arg>
<arg>-Xlint:-path</arg>
<arg>-Werror</arg>
<arg>-Xlint:-cast</arg>
<arg>-Xlint:-deprecation</arg>
<arg>-Xlint:-fallthrough</arg>
<arg>-Xlint:-overrides</arg>
<arg>-Xlint:-rawtypes</arg>
<arg>-Xlint:-serial</arg>
<arg>-Xlint:-try</arg>
<arg>-Xlint:-unchecked</arg>
</compilerArgs>
</configuration>
</plugin> But you don't really inherit from parent pom. You have to declare again all compilerArgs. |
Ok so here is a better solution. In <properties>
<xlint.options/>
</properties>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<fork>true</fork>
<maxmem>512m</maxmem>
<!-- REMOVE WHEN UPGRADE:
see https://jira.codehaus.org/browse/MCOMPILER-209 it's a bug where
incremental compilation doesn't work unless it's set to false causeing
recompilation of the entire codebase each time without any changes. Should
be fixed in version > 3.1
-->
<useIncrementalCompilation>false</useIncrementalCompilation>
<showWarnings>true</showWarnings>
<compilerArgs>
<arg>-XDignore.symbol.file</arg>
<arg>-Xlint:all</arg>
<arg>-Xlint:-path</arg>
<arg>${xlint.options}</arg>
<arg>-Werror</arg>
</compilerArgs>
</configuration>
</plugin> In
That said, there are also some deprecated classes in plugins, so I would also add in parent pom |
Pushing as this really hasn't changed other than limiting which xlint options are used. |
We have a handful of compiler warnings, mostly because of passing an
array to varargs methods. This change fixes these warnings and adds
-Werror so we don't get anymore of these warnings.
Note this does not enable deprecation or unchecked type warnings, so
these remain "hidden". We should work towards removing those as well,
but this is a first step.