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

Generated Java stub for enum with abstract method is invalid

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 2.4.6
    • None
    • None
    • Groovy 2.4.5

    Description

      When generating Java stub for enum with an abstract method results in invalid Java source. The generated source class is defined as "abstract enum".

      EnumWithAbstractMethod.groovy
      enum EnumWithAbstractMethod {
          ONE {
              @Override
              int getInt() {
                  return 1
              }
          },
          TWO {
              @Override
              int getInt() {
                  return 2
              }
          }
      
          abstract int getInt()
      }
      
      Driver.groovy
      class Driver {
      
          public static void main(String[] args) {
              def stubCompiler = new JavaStubCompilationUnit(
                  new CompilerConfiguration(),
                  new GroovyClassLoader(),
                  new File('tmp')
              )
      
              stubCompiler.addSource(new File('EnumWithAbstractMethod.groovy'))
      
              stubCompiler.compile()
          }
      }
      
      EnumWithAbstractMethod.java
      public abstract enum EnumWithAbstractMethod
        implements
          groovy.lang.GroovyObject {
      ...
      

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            paulk Paul King
            jonpeterson Jonathan Peterson
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment