perform narrowing in reflective property accessor read methods as well

This commit is contained in:
Keith Donald 2011-06-05 06:01:48 +00:00
parent c306afed63
commit 9ece4a88a9
1 changed files with 6 additions and 4 deletions

View File

@ -138,7 +138,8 @@ public class ReflectivePropertyAccessor implements PropertyAccessor {
if (method != null) {
try {
ReflectionUtils.makeAccessible(method);
return new TypedValue(method.invoke(target),invoker.typeDescriptor);
Object value = method.invoke(target);
return new TypedValue(value, invoker.typeDescriptor.narrow(value));
}
catch (Exception ex) {
throw new AccessException("Unable to access property '" + name + "' through getter", ex);
@ -158,7 +159,8 @@ public class ReflectivePropertyAccessor implements PropertyAccessor {
if (field != null) {
try {
ReflectionUtils.makeAccessible(field);
return new TypedValue(field.get(target),invoker.typeDescriptor);
Object value = field.get(target);
return new TypedValue(value, invoker.typeDescriptor.narrow(value));
}
catch (Exception ex) {
throw new AccessException("Unable to access field: " + name, ex);