groovy
  1. groovy
  2. GROOVY-5212

Compilation problem for java enums defined as groovy classes

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.8.5
    • Fix Version/s: 1.8.6, 2.0-beta-3
    • Component/s: Ant integration
    • Labels:
      None
    • Environment:
    • Number of attachments :
      0

      Description

      Hi, I have following groovy class TransactionStatus.groovy with code:

      package com.webbfontaine.twm.accounting.epaylog.emess.model.response

      public enum TransactionStatus

      { OK, ERROR }

      and compilation of this class using groovy 1.8.4 was ok but after migrating to 1.8.5 I have following:

      groovy.compile:
      [mkdir] Created dir: /home/sargis/projects/twm3.git/modules/accounting/Server/classes
      [groovyc] Compiling 186 source files to /home/sargis/projects/twm3.git/modules/accounting/Server/classes
      [groovyc] org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      [groovyc] Compile error during compilation with javac.
      [groovyc] warning: [options] bootstrap class path not set in conjunction with -source 1.6
      [groovyc] /tmp/groovy-generated-3682106614822967278-java-source/com/webbfontaine/twm/accounting/epaylog/emess/model/response/TransactionStatus.java:10: error: modifier final not allowed here
      [groovyc] public final enum TransactionStatus
      [groovyc] ^
      [groovyc] Note: Some input files use or override a deprecated API.
      [groovyc] Note: Recompile with -Xlint:deprecation for details.
      [groovyc] Note: Some input files use unchecked or unsafe operations.
      [groovyc] Note: Recompile with -Xlint:unchecked for details.
      [groovyc] 1 error
      [groovyc] 1 warning
      [groovyc]
      [groovyc]
      [groovyc] 1 error

      I am using

      <taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc">

      </taskdef>

      to compile groovy codes of my project.

        Activity

        Hide
        CÚdric Champeau added a comment -

        Enums cannot be extended, so the final modifier here is not allowed. Just remove the final modifier and it will be ok. Groovy now behaves like Java in that situation.

        Show
        CÚdric Champeau added a comment - Enums cannot be extended, so the final modifier here is not allowed. Just remove the final modifier and it will be ok. Groovy now behaves like Java in that situation.
        Hide
        Sargis Harutyunyan added a comment - - edited

        But in groovy code I dont have final its Groovy compiler generating for /tmp/groovy-generated-3682106614822967278-java-source/com/webbfontaine/twm/accounting/epaylog/emess/model/response/TransactionStatus.java:10, here is my groovy code:

        public enum TransactionStatus

        { OK, ERROR }
        Show
        Sargis Harutyunyan added a comment - - edited But in groovy code I dont have final its Groovy compiler generating for /tmp/groovy-generated-3682106614822967278-java-source/com/webbfontaine/twm/accounting/epaylog/emess/model/response/TransactionStatus.java:10, here is my groovy code: public enum TransactionStatus { OK, ERROR }
        Hide
        Sargis Harutyunyan added a comment -

        And the same code was ok with 1.8.4

        Show
        Sargis Harutyunyan added a comment - And the same code was ok with 1.8.4
        Hide
        CÚdric Champeau added a comment -

        Ok, this is a different issue from what I thought and must be related to the stub generator.

        Show
        CÚdric Champeau added a comment - Ok, this is a different issue from what I thought and must be related to the stub generator.
        Show
        CÚdric Champeau added a comment - Commit https://github.com/groovy/groovy-core/commit/5e2c99d43a9452564f28ebb28c611fb718fbfdd3
        Hide
        Evgeny Goldin added a comment -

        Is there any workaround that can be used before Groovy 1.8.6 is released?

        Show
        Evgeny Goldin added a comment - Is there any workaround that can be used before Groovy 1.8.6 is released?
        Hide
        Guillaume Laforge added a comment -

        If you can't wait for a week for the release, you can write that enum in Java, obviously.

        Show
        Guillaume Laforge added a comment - If you can't wait for a week for the release, you can write that enum in Java, obviously.

          People

          • Assignee:
            CÚdric Champeau
            Reporter:
            Sargis Harutyunyan
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: