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

The method clone should be public as it implements the corresponding method from interface java.lang.Object

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.5.7
    • 2.5.8, 3.0.0-beta-2
    • Compiler
    • None

    Description

      I have a class like the following:

      @CompileStatic
      class MyClass implements Serializable, Cloneable {
        @Override
        protected Object clone() {
          super.clone()
        }
      }
      

      When trying to compile this class I get the following error from the Groovy compiler: The method clone should be public as it implements the corresponding method from interface java.lang.Object.

      Apart from the fact that java.lang.Object is not an interface it doesn't make sense. java.lang.Object.clone() is protected so why can't I override it and keep it protected?

      Attachments

        Issue Links

          Activity

            People

              daniel_sun Daniel Sun
              mauromol Mauro Molinari
              Votes:
              0 Vote for this issue
              Watchers:
              4 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 - 0.5h
                  0.5h