Gradle 4.0-milestone-2 - AbstractMethodError with SingleFileReport

Hey guys,

When we use Gradle 4.0-milestone-2 we get AbstractMethodError with our custom implementations of org.gradle.api.reporting.SingleFileReport:

Caused by: java.lang.AbstractMethodError: com.linkedin.ligradle.quality.findbugs.LiFindBugsPlugin$RichXmlReport.setDestination(Ljava/io/File;)V

There were some changes in SingleFileReport interface: (see SingleFileReport.setDestination in 3.5 and SingleFileReport.setDestination in 4.0.

It looks like we need to recompile our plugin code with Gradle 4.0 to resolve the problem (and tweak the implementation to add new methods). However, we cannot do it right now because this would effectively force everybody at LinkedIn to use Gradle 4.0.

Questions:

  1. Is this a known incompatible change that is intended to go out with 4.0 and we need to resolve it by recompiling our plugins?
  2. Any workarounds we can use? Can I use some Groovy magic to create instances of SingleFileReport that would work with Gradle 3 and Gradle 4?

We are looking forward to using Gradle 4.0 at LinkedIn!

Hi Szczepan,

The interface ConfigurableReport has changed as follows:

  1. The method setDestination(Object) has been deprecated. It’s going to be removed in Gradle 5.0.
  2. Two new methods have been introduced as a replacement: setDestination(File) and setDestination(Provider<File>).

My guess is that you’ll need to implement the new methods in your plugin implementation. Can you describe the need for wanting to have your own implementation of SingleFileReport?

Any workarounds we can use? Can I use some Groovy magic to create instances of SingleFileReport that would work with Gradle 3 and Gradle 4?

You might want to try casting your Object to a File explicitly or using a File instance instead. If that doesn’t help I can ping the Groovy experts in our team.

Cheers,

Ben

1 Like

This error is thrown when an application tries to call an abstract method without actual implementation. Abstract methods have no body and cannot be executed. This error can only occur at run time if the definition of some class has incompatibly changed since the currently executing method was last compiled. It usually happens after some library is upgraded while some is not. The dependencies are missing somehow. This means that you are using an old java version of an interface implementation which is missing a new interface method. For example java.sql.Connection interface got a new getSchema method in 1.7. If you have 1.6 JDBC driver and call Connection.getSchema you will get AbstractMethodError. So, make sure you have the latest jar file in your class path not a older copy.