jastrachan | 22 Apr 12:43 2004
Picon

Re: Overriding final methods

This is a bug, could you raise it in JIRA please? Basically we should 
be able to check at verification stage that a method you're overloading 
is not final. Ditto deriving from final classes.

On 22 Apr 2004, at 10:58, Jim Downing wrote:

> Hi,
>
> If a groovy class overrides a final method then groovyc will compile 
> it fine,
> but the .class file generated will be invalid: -
>
> Base.java
> public class Base {
>     final int getCount() {
>     	return 1;
>     }
> }
>
> MyBase.groovy
> class MyBase extends Base {
>   int getCount() { return 2; }
> }
>
> These will both compile with groovyc without error. It's only when you
> try to compile: -
>
> MyBaseTest.groovy
> class MyBaseTest extends GroovyTestCase {
>   void testBasic() {
>       b = new MyBase()
>       assert b.count == 2
>   }
> }
>
> ... that groovyc throws a MissingClassException. Running javap on
> MyBase.class fails (it exposes a bug in javap that I think only happens
> for invalid class files).
>
> Could groovyc check for illegal overrides? In the same vein, could
> groovyc check that all abstract inherited methods had been implemented?
>
> cheers,
>
> jim
> _______________________________________________
> groovy-user mailing list
> groovy-user@...
> http://lists.codehaus.org/mailman/listinfo/groovy-user
>
>

James
-------
http://radio.weblogs.com/0112098/

Gmane