Change between 1.2 and 1.3 breaks task decoration with ClassFormatError

We recently discovered an issue with one of our plugins that as manifesting as a “Could not generate proxy class…” error whose root cause is a ‘ClassFormatError’ due to a duplicate method name and signature. This happens when creating the task.

This occurs in Gradle 1.3 or later (tested through 1.8), but works in Gradle 1.2.

To reproduce throw either of the following classes into ‘buildSrc’:

import java.util.Map;
import java.util.HashMap;
  import org.gradle.api.DefaultTask;
import org.gradle.api.tasks.TaskAction;
  public class JavaTask extends DefaultTask {
 private Map<String, String> environment = new HashMap<String, String>();
   public Map<String, String> getEnvironment() {
  return environment;
   public void setEnvironment(Map<String, String> environment) {
  this.environment = environment;
   public void environment(String varName) {
  this.environment.put(varName, null);
   public void environment(String varName, String varValue) {
  this.environment.put(varName, varValue);
 public void doWork() {
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.TaskAction
  class GroovyTask extends DefaultTask {
 Map fakeJellyBeans = [:]
     void fakeJellyBeans(String varName) {
  this.fakeJellyBeans[varName] = null
   void fakeJellyBeans(String varName, String varValue) {
  this.fakeJellyBeans[varName] = varValue
 void doWork() {

With a simple build file like below. You can swap the order depending on which one you want to test.

task groovy(type: GroovyTask)
task java(type: JavaTask)

It seems to be the combination of a property that has a getter, setter, and both the single and double arg method using the property name. I also tried this with a String property instead of a Map and had the same issue.

Can someone explain why this causes an issue? I’ve never looked into all of the voodoo Gradle is doing to decorate classes, so outside of bisecting through the 1005 commits between 1.2 and 1.3, I’m at a loss.

This has been posted on before on the forums. I can’t remember what the trigger was, but I think that post did get to the bottom of it.

Ah, I see the topic now. But they only have a workaround, not a solution: