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

Compile error needed for illegal field modifier combination

    XMLWordPrintableJSON

Details

    Description

      The JLS (recent versions at least) states:

      It is a compile-time error if a final variable is also declared volatile.

      Compiling this class:

      public class Foo {
          final volatile String foo = "bar";
      }
      

      in Java gives the following compilation error:

      error: illegal combination of modifiers: final and volatile
      

      Groovy currently passes compilation but then gives the following error at runtime when trying to create an instance of such a class:

      java.lang.ClassFormatError: Illegal field modifiers in class Foo: 0x52
      

      Groovy should also have a compilation error for this case.

      Attachments

        Activity

          People

            paulk Paul King
            paulk Paul King
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: