16

How to suppress "warning: Ignoring InnerClasses attribute for an anonymous inner class" with Gradle?

  • This not a duplicate question
  • This not during Proguard nor do I want to suppress using Proguard
  • I would like to suppress doing normal ./gradlew assembleDebug (since this is assertj-core - ./gradlew testDebug)

Dependency:

dependencies {
   testCompile "org.assertj:assertj-core:1.7.1"
}

Warning:

Dex: warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.assertj.core.internal.cglib.reflect.FastClassEmitter$3) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.

Something like:

tasks.withType(JavaCompile) {
    sourceCompatibility = JavaVersion.VERSION_1_7
    targetCompatibility = JavaVersion.VERSION_1_7

    configure(options) {
        compilerArgs << "-Xlint:-options"    // Turn off "missing" bootclasspath warning
    }
}

What compilerArgs can I add to suppress this warning?

References:

Jared Burrows
  • 54,294
  • 25
  • 151
  • 185

2 Answers2

1

I had the same issue when I tried to use a third party lib a while ago. That lib was compiled for Java 1.3. I was able to fix it by getting the source of that lib and build a jar file on my own. This works only, of course, if the sources to that lib are available and ready for build.

  • Alright. I rather not compile and repackage of `assertj-core`. I just want to "silence" Gradle. – Jared Burrows May 11 '17 at 06:21
  • By chance I stumbled upon another, similar question. Maybe this answer to that question is of help: http://stackoverflow.com/a/40173052/5956451 –  May 11 '17 at 06:32
  • I use `assertj-core` for unit tests. This does not get compiled into the app and so I will not run proguard against it. – Jared Burrows May 11 '17 at 06:36
0

@SuppressWarnings("unchecked") with replacing the unchecked does not help? More examples are here: http://www.codejava.net/java-core/the-java-language/suppresswarnings-annotation-examples

Baum mit Augen
  • 49,044
  • 25
  • 144
  • 182
tom3008
  • 100
  • 9