mojohaus / animal-sniffer

https://www.mojohaus.org/animal-sniffer/animal-sniffer-maven-plugin/
MIT License
84 stars 43 forks source link

`@IgnoreJRERequirement` annotated class keeps getting "Undefined reference " #249

Closed oldergod closed 1 year ago

oldergod commented 1 year ago

I have a class with only member methods like

internal class JvmFileSystemFileHandle(
  readWrite: Boolean,
  private val seekableByteChannel: SeekableByteChannel,
) : FileHandle(readWrite) {

Animal sniffer would give me violations like:

JvmFileSystemFileHandle.class: Undefined reference: java.nio.channels.SeekableByteChannel
JvmFileSystemFileHandle.class:35: Undefined reference: java.nio.channels.SeekableByteChannel java.nio.channels.SeekableByteChannel.truncate(long)
.....
JvmFileSystemFileHandle.class:83: Undefined reference: void java.nio.channels.SeekableByteChannel.close()

After having annotated the class as follows:

@org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
internal class JvmFileSystemFileHandle(
  readWrite: Boolean,
  private val seekableByteChannel: SeekableByteChannel,
) : FileHandle(readWrite) {

all violations are gone except one:

JvmFileSystemFileHandle.class: Undefined reference: java.nio.channels.SeekableByteChannel

Does this need a specific configuration to get ignore of this violation as well?

oldergod commented 1 year ago

We think it's because our class exposes a field which AnimalSniffer would not allow us to ignore? Is it because it can be class loaded?

Marcono1234 commented 1 year ago

Might be #131 which was fixed in version 1.23. Which version are you using?

oldergod commented 1 year ago

It looks like I was on 1.22.

@xvik maybe the Gradle plugin could have been released when it bumped to 1.23? https://github.com/xvik/gradle-animalsniffer-plugin/blob/5275015d68abee811b4ce2b41d6d994de9427da9/build.gradle#L24C59-L24C59

xvik commented 1 year ago

My bad, sorry. I was checking this issue on sample project using animalsniffer 1.22 (forget to verify). Now I tried with 1.23 and, indeed, everything works.

You can already test with 1.23 by applying additional gradle plugin configuration: animalsniffer.toolVersion = '1.23'. And, I'll release new plugin version today to avoid such issues in the future.

oldergod commented 1 year ago

Great we were able to sort it out! Thank you both.