[ 
https://issues.apache.org/jira/browse/GROOVY-4744?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

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

    {code}public final Object getProperty(String s){code}

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

    {code}public final String getProperty(String s){code}

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

h4. Code to Reproduce the problem
{code}
$ 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; }
}
{code}
{code}
$ head *.groovy
==> Groovy1.groovy <==
class Groovy1 extends Java1 { }

==> Groovy2.groovy <==
class Groovy2 extends Java2 { }
{code}
{code}

$ 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
{code}

  was:
Issue [http://jira.codehaus.org/browse/GROOVY-2837] reported a problem where 
Groovy compiler failed if you tried to extend a Java class with:

    {code}public final Object getProperty(String s){code}

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

    {code}public final String getProperty(String s){code}

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

h4. Code to Reproduce the problem
{code}
$ 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; }
}
{code}
{code}
$ head *.groovy
==> Groovy1.groovy <==
class Groovy1 extends Java1 { }

==> Groovy2.groovy <==
class Groovy2 extends Java2 { }
{code}
{code}

$ 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
{code}


> Fail to extend Java class with public final String getProperty(String s)
> ------------------------------------------------------------------------
>
>                 Key: GROOVY-4744
>                 URL: https://issues.apache.org/jira/browse/GROOVY-4744
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 1.7.6
>            Reporter: Paul Cager
>            Priority: Major
>
> Issue GROOVY-2837 reported a problem where Groovy compiler failed if you 
> tried to extend a Java class with:
>     {code}public final Object getProperty(String s){code}
> It looks like that has been fixed but the following case still fails:
>     {code}public final String getProperty(String s){code}
> Unfortunately the Java class is within a third-party library so I can't 
> change it.
> h4. Code to Reproduce the problem
> {code}
> $ 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; }
> }
> {code}
> {code}
> $ head *.groovy
> ==> Groovy1.groovy <==
> class Groovy1 extends Java1 { }
> ==> Groovy2.groovy <==
> class Groovy2 extends Java2 { }
> {code}
> {code}
> $ 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
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to