Alan Burlison wrote:
> The more I read the code in question, the less I understand it. I can
> understand why the code would have to traverse up the class hierarchy to
> determine the real type of a Type Variable, but why does it need to scan
> back along the NodeEvaluation chain? Surely the type of a value depends
> only on its class and not the rest of the expression that it is a part of?
And the algorithm used in code in question doesn't seem to work properly
in any case, certainly not when you've got inherited generic classes, as
follows:
----------
class One<A> {
public A a;
}
class Two<C> extends One<B> {
}
class Three extends Two<Integer> {
}
----------
If we traverse the class hierarchy from an instance of Three trying to
resolve the type information in the same fashion as the Stripes code
(PropertyExpressionEvaluation.getTypeVariableValue()), we see the following:
Resolving type A for member a
searching class ref.Three
Param B = type class java.lang.Integer
searching class ref.Two
Param A = type B
searching class ref.One
searching class java.lang.Object
So we can determine (via getGenericType()) on the Field that represents
'a' that its TypeVariable type is 'A' - and that comes from the
definition of class One. As we traverse the class hierarchy via
Class.getGenericSuperclass(), we can map TypeVariable A onto
TypeVariable C (from class Two). However, due to the way the Stripes
code scans the hierarchy (upwards) we have already 'passed' the
subsequent mapping of C to the final type of Integer, so the mapping fails.
What actually needs to happen is that we remember the mappings as we
traverse the hierarchy, say in a hash, and we then do the mappling
lookups after traversing the hierarchy, when we have all the type
information available.
I'm willing to try to straighten this code out, but I'm struggling to
find any code that actually exercises this area of Stripes. Is there
any sort of regression test harness for Stripes?
--
Alan Burlison
--
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development