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

Groovy compiler allows overriding final methods but class loading fails with java.lang.VerifyError

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 1.7.0
    • 1.6.8, 1.7.1, 1.8-beta-1
    • Compiler
    • None

    Description

      The following script compiles but when run, class loading fails saying "java.lang.VerifyError: class B overrides final method"

      class A {
          def foo() {}
          final def bar() {}
      }
      class B extends A {
          def foo() {}
          def bar() {}
      }
      B
      

      If I swap the order of method definitions in class B as:

      class A {
          def foo() {}
          final def bar() {}
      }
      class B extends A {
          def bar() {}
          def foo() {}
      }
      B
      

      then it correctly gives the error message "You are not allowed to overwrite the final method bar() from class 'A'."

      Attachments

        Activity

          People

            roshandawrani Roshan Dawrani
            roshandawrani Roshan Dawrani
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: