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

Generated Java stub for enum with abstract method is invalid

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.4.6
    • Component/s: None
    • Labels:
      None
    • Environment:
      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

            People

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

              Dates

              • Created:
                Updated:
                Resolved: