Groovy
  1. Groovy
  2. GROOVY-4415

Error implementing a Java or Groovy generic interface

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.7.3
    • Fix Version/s: 1.8.5, 2.0-beta-2, 1.7.11
    • Component/s: None
    • Labels:
      None
    • Environment:
      Groovy 1.7.3 - Eclipse

      Description

      Hello.

      I have an issue creating a Groovy class implementing an interface coded in Java with Generics:
      Here is the code:

      /* Java interface */
      public interface Entity<T> {
      	T getId();	
      }
      
      /* Groovy class */
      class Car implements Entity<Long> {
            Long id;
      }
      

      Car groovy class has a Long getId() method already, but it doesn't recognize it's enough to implement the interface method:
      "Can't have an abstract method in a non-abstract class. The class 'Car' must be declared abstract or the method 'java.lang.Object getId()' must be implemented."

      The same happens when the interface is coded in Groovy instead of Java.

      I believe it's an important thing to support.

      I am using Groovy 1.7.3.

      Thank you.

        Issue Links

          Activity

          Luciano Greiner created issue -
          Cédric Champeau made changes -
          Field Original Value New Value
          Link This issue is related to GROOVY-4645 [ GROOVY-4645 ]
          Hide
          Cédric Champeau added a comment -

          Formatting tags

          Show
          Cédric Champeau added a comment - Formatting tags
          Cédric Champeau made changes -
          Description Hello.

            I have an issue creating a Groovy class implementing an interface coded in Java with Generics:
          Here is the code:

          /* Java interface */
          public interface Entity<T> {
          T getId();
          }

          /* Groovy class */
          class Car implements Entity<Long> {
                Long id;
          }

          Car groovy class has a Long getId() method already, but it doesn't recognize it's enough to implement the interface method:
          "Can't have an abstract method in a non-abstract class. The class 'Car' must be declared abstract or the method 'java.lang.Object getId()' must be implemented."

          The same happens when the interface is coded in Groovy instead of Java.

          I believe it's an important thing to support.

          I am using Groovy 1.7.3.

          Thank you.
          Hello.

            I have an issue creating a Groovy class implementing an interface coded in Java with Generics:
          Here is the code:
          {code}
          /* Java interface */
          public interface Entity<T> {
          T getId();
          }

          /* Groovy class */
          class Car implements Entity<Long> {
                Long id;
          }
          {code}
          Car groovy class has a Long getId() method already, but it doesn't recognize it's enough to implement the interface method:
          "Can't have an abstract method in a non-abstract class. The class 'Car' must be declared abstract or the method 'java.lang.Object getId()' must be implemented."

          The same happens when the interface is coded in Groovy instead of Java.

          I believe it's an important thing to support.

          I am using Groovy 1.7.3.

          Thank you.
          Cédric Champeau made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Fix Version/s 2.0-beta-2 [ 18072 ]
          Fix Version/s 1.8.5 [ 18071 ]
          Resolution Fixed [ 1 ]
          Assignee Cedric Champeau [ melix ]
          Fix Version/s 1.7.11 [ 17244 ]
          Paul King made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Mark Thomas made changes -
          Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
          Mark Thomas made changes -
          Workflow jira [ 12733352 ] Default workflow, editable Closed status [ 12745169 ]
          Mark Thomas made changes -
          Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
          Mark Thomas made changes -
          Workflow jira [ 12970949 ] Default workflow, editable Closed status [ 12978724 ]
          Transition Time In Source Status Execution Times Last Executer Last Execution Date
          Open Open Resolved Resolved
          442d 14h 30m 1 Cédric Champeau 29/Nov/11 11:15
          Resolved Resolved Closed Closed
          24d 15h 52m 1 Paul King 24/Dec/11 03:08

            People

            • Assignee:
              Cédric Champeau
              Reporter:
              Luciano Greiner
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development