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

Compile error needed for illegal field modifier combination

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.0.5, 2.5.13
    • Fix Version/s: 4.0.0-alpha-1, 3.0.6
    • Component/s: None
    • Labels:
      None

      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

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

              Dates

              • Created:
                Updated:
                Resolved: