Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-4320

Joint compiler + @Delegate fail to recognize method signature with default value



    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.7.4
    • 4.0.0-beta-1, 2.5.16, 3.0.10
    • Compiler
    • None
    • MacOSX Snow Leopard, Groovy 1.7.4, Java 1.6.0_17


      Spotted this problem when upgrading Griffon to Groovy 1.7.4.

      Start with a base contract defined in java

      import java.util.List;
      public interface IApp {
          void event(String name);
          void event(String name, List params);

      Implement said contract in Groovy

      class BaseApp implements IApp {
          private IApp appDelegate
          BaseApp(IApp app) {
              this.appDelegate = app
          void event(String name, List params = []) {
              // empty

      Now create a Groovy class where the previous will be used as delegate

      class RealApp {
          @Delegate BaseApp _base
          RealApp() {
              _base = new BaseApp(this)

      Compile the code

      groovyc IApp.java BaseApp.groovy RealApp.groovy

      With Groovy 1.7.3 you get the following method signatures

      $ javap BaseApp | grep event
          public void event(java.lang.String, java.util.List);
          public void event(java.lang.String);
      $ javap RealApp | grep event
          public void event(java.lang.String);
          public void event(java.lang.String, java.util.List);

      However 1.7.4 fails to recognize that the second argument to event() has a default value

      $ groovy -version
      Groovy Version: 1.7.4 JVM: 1.6.0_17
      $ groovyc IApp.java BaseApp.groovy RealApp.groovy 
      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      RealApp.groovy: 1: Can't have an abstract method in a non-abstract class. The class 'RealApp' must be declared abstract or the method 'void event(java.lang.String)' must be implemented.
       @ line 1, column 1.
         class RealApp {
      1 error


        1. GROOVY-4320.patch
          3 kB
          Guillaume Sauthier

        Issue Links



              emilles Eric Milles
              aalmiray Andres Almiray
              1 Vote for this issue
              4 Start watching this issue