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

CLONE -Groovy objects trying to override final methods

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.5.6, 1.6-beta-1
    • 1.5.7, 1.6-beta-2
    • None
    • Windows XP
      Groovy Version: 1.0 JVM: 1.6.0-b105
      Groovy Version: 1.1-rc-2 JVM: 1.6.0-b105

    Description

      Using a java framework that defines a class like this

      public class FrameworkComponent {
      // lots of fields
      // lots of methods
      public final Object getProperty(String name)

      { return frameworkStuff.get(name); }

      // lots of other fields
      // lots of other methods
      }

      If one tries to create a Groovy class that extends this
      FrameworkComponent like the following:

      class MyComponent extends FrameworkComponent {
      def size = 10
      }

      the groovy compiler raises an error saying that MyComponent
      overrides final method getProperty(String name) from
      FrameworkComponent.

      Attached to this issue follows bug.zip containing a mockup of this
      framework and a Groovy class that extends the framework class.

      To reproduce the error just unzip the file, navigate to the unzipped folder
      and fire:

      groovyc -cp framework.jar MyComponent.groovy

      it will raise the following error lines

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, MyComponent.groovy: -1: You are not allowed to overwrite the final method getProperty(java.lang.String) from class 'FrameworkComponent'.
      @ line -1, column -1.
      1 error

      Attachments

        1. GROOVY-2837.patch
          2 kB
          Paul King

        Issue Links

          Activity

            People

              blackdrag Jochen Theodorou
              gunnar Gunnar Wagenknecht
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: