spotify / missinglink

Build time tool for detecting link problems in java projects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Spurious warnings for provided resources that redefine a class

pettermahlen opened this issue · comments

When using auto-value in scope provided and also using commons-lang 2.6, you get these warnings:

[WARNING] Category: FIELD NOT FOUND
[WARNING]   In artifact: com.google.auto.value:auto-value:1.0
[WARNING]     In class: org.apache.commons.lang.builder.ToStringStyle
[WARNING]       In method:  getRegistry():153
[WARNING]       Access to: org.apache.commons.lang.builder.ToStringStyle.registry
[WARNING]       Problem: Field not found: registry
[WARNING]       Found in: commons-lang:commons-lang:2.6
[WARNING]       --------
[WARNING]       In method:  <clinit>():136
[WARNING]       Access to: org.apache.commons.lang.builder.ToStringStyle.registry
[WARNING]       Problem: Field not found: registry
[WARNING]       Found in: commons-lang:commons-lang:2.6
[WARNING]       --------
[WARNING]     In class: org.apache.commons.lang.builder.HashCodeBuilder
[WARNING]       In method:  getRegistry():122
[WARNING]       Access to: org.apache.commons.lang.builder.HashCodeBuilder.registry
[WARNING]       Problem: Field not found: registry
[WARNING]       Found in: commons-lang:commons-lang:2.6
[WARNING]       --------
[WARNING]       In method:  <clinit>():105
[WARNING]       Access to: org.apache.commons.lang.builder.HashCodeBuilder.registry
[WARNING]       Problem: Field not found: registry
[WARNING]       Found in: commons-lang:commons-lang:2.6
[WARNING]       --------

Auto-value 1.0 includes unrelocated commons-lang classes.

For reference, updating the project in question to use auto-value 1.1 made those warnings go away. Even so, I don't think the warnings are correct.

auto-value:1.0 packages commons-lang:2.4 classes in it's JAR (via a dependency on org.apache.velocity:velocity:jar:1.7), presumably so they are available to the compiler annotation processor (there is an interesting note in auto-value's pom about why some packages are relocated by the shade plugin and Apache ones are not).

The implementation of ToStringStyle.getRegistry() is different between the 2.4 and 2.6 versions of the class - the static field registry was renamed to REGISTRY (and made final).

auto-value:1.1 got smarter about relocating classes - seems like they realized the classes that should not be relocated were only Velocity classes and not commons-lang.

So I think these warnings would actually be legitimate if they referred to methods that were different between commons-lang:2.4 and commons-lang:2.6, as a project could have code that referred to 2.4-only classes that disappeared in 2.6.

But it sounds like missinglink might be using the definition of org.apache.commons.lang.builder.ToStringStyle.registry from auto-value:1.0 in some places but considering the fields of that class to be defined by the version in commons-lang:2.6 - could there be places where classes defined in multiple jars overwrite/collide data from each other within missinglink?