[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2901?page=c...
]
Wouter Lievens commented on HHH-2901:
-------------------------------------
I'd like to amend the description: there is not *always* a workaround because
sometimes you want to use return type covariance in your interface hierarchy, and in that
case you have to repeat the method declaration, with a different return type that is.
Repeating method declaration in interface hierarchy causes faulty
method lookup in proxies
------------------------------------------------------------------------------------------
Key: HHH-2901
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2901
Project: Hibernate3
Issue Type: Bug
Affects Versions: 3.2.5
Environment: Hibernate 3.2.5
DBMS: MySQL (probably irrelevant)
Reporter: Wouter Lievens
Consider the following two interfaces
interface A
{
public abstract void b();
}
interface B extends A
{
public abstract void b();
}
Note that B repeats the definition of "b", which is perfectly legal java code.
Now consider these two classes:
abstract class AImpl implements A
{
}
public class BImpl extends AImpl implements B
{
public final void b()
{
// implementation is irrelevant
}
}
Now consider that mappings have been created where interfaces A and B are given as the
"proxy" type for mapped entity types AImpl and BImpl, respectively, and that the
BImpl mapping "extends" the AImpl mapping.
Now, when an object is loaded by refering to the base type (AImpl), then invocations of
the method "b" will raise the following exception:
java.lang.IllegalArgumentException: object is not an instance of declaring class
A short time spent debugging suggested to me that the method that the proxy (a proxy for
A, not B!) selected to delegate the call to the "wrong" method somehow, causing
this error. The problem can be remedied by removing the declaration for "b" in
the B interface.
So, there is a workaround: don't repeat declarations. But still I would prefer to see
this issue solved.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira