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

Fail to extend Java class with public final String getProperty(String s)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.7.6
    • None
    • Compiler
    • None

    Description

      Issue GROOVY-2837 reported a problem where Groovy compiler failed if you tried to extend a Java class with:

      public final Object getProperty(String s)

      It looks like that has been fixed but the following case still fails:

      public final String getProperty(String s)

      Unfortunately the Java class is within a third-party library so I can't change it.

      Code to Reproduce the problem

      $ head *.java
      ==> Java1.java <==
      public class Java1 {
        public final Object getProperty(String s) { return null; }
      }
      
      ==> Java2.java <==
      public class Java2 {
        public final String getProperty(String s) { return null; }
      }
      
      $ head *.groovy
      ==> Groovy1.groovy <==
      class Groovy1 extends Java1 { }
      
      ==> Groovy2.groovy <==
      class Groovy2 extends Java2 { }
      
      
      $ javac *.java
      $ groovyc *.groovy
      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      Groovy2.groovy: -1: You are not allowed to override the final method getProperty(java.lang.String) from class 'Java2'.
       @ line -1, column -1.
      1 error
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            paulcager Paul Cager
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: