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
        Sargis Harutyunyan made changes -
        Field Original Value New Value
        Attachment groovyc-test.tar.gz [ 56090 ]
        Hide
        Paul King added a comment -

        add code tags

        Show
        Paul King added a comment - add code tags
        Paul King made changes -
        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 I have:


        groovy.compile:
            [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>>();
            }
        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

        {code:title=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 +
                    '}';
          }
        }
        {code}
        {code:title=MessagingTaskDatabase.groovy}
        class MessagingTaskDatabase {

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

        }
        {code}
        {code:title=SomeClient.java}
        List<MessagingTask<OutMessage>> messagingTasks = taskDatabase.loadOutMessage();
        {code}
        And the compile log:
        {noformat}
            [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
        {noformat}

        But if I remove generic type parameters from return and compilation is ok
        {code}
        public List loadOutMessage() {
            return new ArrayList<MessagingTask<OutMessage>>();
        }
        {code}
        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.
        Paul King made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Assignee Paul King [ paulk ]
        Fix Version/s 1.7.11 [ 17244 ]
        Fix Version/s 1.8.2 [ 17495 ]
        Fix Version/s 1.9-beta-2 [ 17494 ]
        Resolution Fixed [ 1 ]
        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.
        Paul King made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

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

            Dates

            • Created:
              Updated:
              Resolved: