groovy
  1. groovy
  2. GROOVY-4939

groovyc compilation problem for return values with generics

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.8.1
    • Fix Version/s: 1.8.2, 1.9-beta-3, 1.7.11
    • Component/s: Compiler
    • Labels:
      None
    • Environment:
    • Number of attachments :
      1

      Description

      Hi I have following code which was ok for groovy 1.8.0 but after updating to groovy 1.8.1 I have failed compilation

      MessagingTask.groovy
      class MessagingTask<T extends Serializable> {
      
        private static final long serialVersionUID = -5533069690405593263L;
      
        Long id
        String messageId
        String inDestination
        String outDestination
        MessagingTaskType messageType
        T messagePayload
      
        public String toString() {
          return "Task{" +
                  "id=" + id +
                  ", messageId='" + messageId + '\'' +
                  ", inDestination='" + inDestination + '\'' +
                  ", outDestination='" + outDestination + '\'' +
                  ", messageType='" + messageType + '\'' +
                  ", messagePayload=" + messagePayload +
                  '}';
        }
      }
      
      MessagingTaskDatabase.groovy
      class MessagingTaskDatabase {
      
          public List<MessagingTask<OutMessage>> loadOutMessage() {
              return new ArrayList<MessagingTask<OutMessage>>();
          }
      
      }
      
      SomeClient.java
      List<MessagingTask<OutMessage>> messagingTasks = taskDatabase.loadOutMessage();
      

      And the compile log:

          [mkdir] Created dir: /home/sargis/projects/twm_v3/trunk/twm_v3/accounting/Server/classes
        [groovyc] Compiling 185 source files to /home/sargis/projects/twm_v3/trunk/twm_v3/accounting/Server/classes
        [groovyc] org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
        [groovyc] Compile error during compilation with javac.
        [groovyc] /home/sargis/projects/twm_v3/trunk/twm_v3/accounting/Server/src/com/webbfontaine/twm/accounting/epaylog/scheduler/SendingScheduler.java:46: incompatible types
        [groovyc] found   : java.util.List<com.webbfontaine.twm.accounting.epaylog.emess.task.MessagingTask>
        [groovyc] required: java.util.List<com.webbfontaine.twm.accounting.epaylog.emess.task.MessagingTask<com.webbfontaine.twm.accounting.epaylog.emess.core.OutMessage>>
        [groovyc]         List<MessagingTask<OutMessage>> messagingTasks = taskDatabase.loadOutMessage();
        [groovyc]                                                                                     ^
        [groovyc] Note: Some input files use unchecked or unsafe operations.
        [groovyc] Note: Recompile with -Xlint:unchecked for details.
        [groovyc] 1 error
        [groovyc] 
        [groovyc] 
        [groovyc] 1 error
      

      But if I remove generic type parameters from return and compilation is ok

      public List loadOutMessage() {
          return new ArrayList<MessagingTask<OutMessage>>();
      }
      

        Activity

        Hide
        Sargis Harutyunyan added a comment - - edited

        I created some simple project with gradle to help you to reproduce compilation error

        Show
        Sargis Harutyunyan added a comment - - edited I created some simple project with gradle to help you to reproduce compilation error
        Hide
        Paul King added a comment -

        add code tags

        Show
        Paul King added a comment - add code tags
        Hide
        Paul King added a comment -

        Should be fixed - if you can try a snapshot jar, that would be great.

        Show
        Paul King added a comment - Should be fixed - if you can try a snapshot jar, that would be great.
        Hide
        Sargis Harutyunyan added a comment -

        I tried to build with snapshot jar and now everything is ok, issue solved. Thanks.

        Show
        Sargis Harutyunyan added a comment - I tried to build with snapshot jar and now everything is ok, issue solved. Thanks.

          People

          • Assignee:
            Paul King
            Reporter:
            Sargis Harutyunyan
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: