Details
Description
public interface FooHolder {
public Foo getFoo();
}
public class FooHolderImpl {
private Foo foo = new Foo();
public Foo getFoo()
}
public class DerivedFooHolderImpl {
private Foo foo = new Foo();
public Foo getFoo() { return foo; }
}
OptimizerFactory.setDefaultOptimizer("reflective");
Serializable compiled = MVEL.compileExpression("foo.bar.name");
Object obj = executeExpression(compiled, new FooHolderImpl());
assertEquals("dog", obj);
obj = executeExpression(compiled, new DerivedFooHolderImpl());
assertEquals("dog", obj);
"dog" is the expected result both times. However, in the second call, Foo (the object) is returned.
The core issue here is that the cached Method call in GetterAccessor is derimed from FooHolderImpl rather than the FooHolder interface. As a result, FooHolderImpl.getFoo() cannot be applied to DerivedFooHolderImpl.getFoo() (you get an Exception since they are not instances of each other).
The work around/hack in GetterAccessor for this has a bug in it in that it does not work for nested property access.
fixed in trunk.