[groovy-user] Goovy class implementing Generic interface

173 views
Skip to first unread message

Luciano Greiner

unread,
Sep 12, 2010, 11:00:50 AM9/12/10
to us...@groovy.codehaus.org
Hello everybody.

I am sorry if it was discussed before, but i have a doubt about
generics support on Groovy.

I have a Groovy class implementing a Java interface, in fact a Generic
Java Interface:

Java interface:
public interface Entity<T> {
T getId();
}

Groovy class:
class Car implements Entity<Long> {
Long id;
}

While the Entity interface wasn't generic (Object getId() signature),
the Groovy class was able to percept the auto-generated getter is
implementing the interface method.
Although, when code looks like the one i posted i have this error:
"Groovy:Can't have an abstract method in a non-abstract class.
The class 'br.com.greiner.webcasa.Car' must be declared abstract or
the method 'java.lang.Object getId()' must be implemented."

I am using 1.7.3 version.

Is this an expected behavior? Is there any plan when we should see
this limitation fixed?

Thank you!

Luciano Greiner

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


Roshan Dawrani

unread,
Sep 12, 2010, 11:15:12 AM9/12/10
to us...@groovy.codehaus.org
To me, it looks like something that groovy should support and I would ask you to create an issue for it.

Also, just to add the bit that the behavior is the same even if the interface is defined in groovy - so its implementation in java is not in the center of the issue.
-----------------------------------------------
interface GEntity<T> {
    T getId()
}
class Car implements GEntity<Long> {
    Long id
}
-----------------------------------------------

--
rgds,
Roshan
http://roshandawrani.wordpress.com/

Luciano Greiner

unread,
Sep 12, 2010, 4:48:31 PM9/12/10
to us...@groovy.codehaus.org
Hello Roshan.

Can you point me how to report this issue? I don't have access to
Jira, and i think it's needed.

Thank you

Luciano Greiner

Roshan Dawrani

unread,
Sep 12, 2010, 9:36:55 PM9/12/10
to us...@groovy.codehaus.org
Hi,

I think you need to register here first: http://xircles.codehaus.org/signup and then with the same credentials, you should be able to login to http://jira.codehaus.org/browse/GROOVY and then report the issue.

rgds,
Roshan
Reply all
Reply to author
Forward
0 new messages