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

Provide better error message in case of misspelled enum constant

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.8-beta-1
    • 1.7.4, 1.8-beta-1
    • Compiler
    • None

    Description

      This code...

      import java.lang.annotation.*
      
      @Retention(RetentionPolicy.Runtime) // should be 'RUNTIME'
      @interface MyAnn {
        String foo()	
      }
      

      ... produces the following groovyc error message:

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      General error during class generation: No enum const class java.lang.annotation.RetentionPolicy.Runtime
      
      java.lang.IllegalArgumentException: No enum const class java.lang.annotation.RetentionPolicy.Runtime
      	at java.lang.Enum.valueOf(Enum.java:196)
      	at java.lang.annotation.RetentionPolicy.valueOf(RetentionPolicy.java:19)
      	at org.codehaus.groovy.vmplugin.v5.Java5.configureAnnotationFromDefinition(Java5.java:186)
      	at org.codehaus.groovy.vmplugin.v5.Java5.configureAnnotation(Java5.java:209)
      	at org.codehaus.groovy.classgen.AnnotationVisitor.visit(AnnotationVisitor.java:76)
      	at org.codehaus.groovy.classgen.ExtendedVerifier.visitAnnotation(ExtendedVerifier.java:153)
      	at org.codehaus.groovy.classgen.ExtendedVerifier.visitAnnotations(ExtendedVerifier.java:114)
      	at org.codehaus.groovy.classgen.ExtendedVerifier.visitClass(ExtendedVerifier.java:51)
      	at org.codehaus.groovy.control.CompilationUnit$11.call(CompilationUnit.java:736)
      	at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:971)
      	at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:519)
      	at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:497)
      	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:474)
      	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:458)
      	at org.codehaus.groovy.tools.FileSystemCompiler.compile(FileSystemCompiler.java:57)
      	at org.codehaus.groovy.tools.FileSystemCompiler.doCompilation(FileSystemCompiler.java:170)
      	at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompile(FileSystemCompiler.java:138)
      	at org.codehaus.groovy.tools.FileSystemCompiler.main(FileSystemCompiler.java:152)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      	at java.lang.reflect.Method.invoke(Method.java:597)
      	at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:108)
      	at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:130)
      
      1 error
      

      Might be better to show the user sth. other than an IllegalArgumentException (which looks like a compiler crash).

      Attachments

        1. Patch2_4273_v17x.patch
          6 kB
          Roshan Dawrani
        2. Patch1_4273_v17x.patch
          2 kB
          Roshan Dawrani

        Activity

          People

            roshandawrani Roshan Dawrani
            pniederw Peter Niederwieser
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: