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

No compiler error for invalid transient method modifier

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.5.14, 3.0.8, 4.0.0-alpha-3
    • 4.0.6
    • None

    Description

      Consider the following:

      class C {
        transient void m() {
          println 'should not compile'
        }
      }
      new C().m()
      

      Groovy happily compiles and executes this code. It should emit and error for the invalid modifier "transient" on the method declaration. Similar code in Java produces the following error:

      Illegal modifier for the method m; only public, protected, private, abstract, static, final, synchronized, native & strictfp are permitted
      

      transient overlaps the modifier bit for varargs so this can cause difficulties in joint compilation scenarios. Also the modifier printing code leveraged from MethodNode#getText does not consider the method context and prints "transient" for "def foo(... args) {}".

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              emilles Eric Milles
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 2.5h
                  2.5h