So, I tried to reply to this thread this morning, but my ISP has totally screwed up my email over the last two days, and i think the response got eaten. At any rate, I have some good news.
I turned Andy's code into a simpler test case and then threw it into the debugger to determine exactly what's going on, and more specifically how to actually get at the type information that we want. As Taras pointed out, the PropertyDescriptor that gets returned in this case is, for practical purposes, incorrect.
From reading up it would appear that the compiler generates a bridge method for any concrete implementation of an interface method that involves a type variable that is parameterized in the class. E.g in Andy's case the XX interface has a type variable, and the class BB implements XX and provides the type parameter CC.
A bit of poking shows that you can actually get around this by basically doing:
Method m = pd.getReadMethod();
if (m.isBridge()) m = m.getDeclaringClass().getMethod(m.getName());
which returns the correct, non-bridge method. Doing the same for write-only properties is a little less tractable, but it would seem like looping through all the methods to find a non-bridge method of the same name with only a single parameter should be pretty safe.
I'm going to create a bug, and then check in my fixes and merge them onto the 1.4 branch so they'll be available in 1.4.2.
ps. I took a quick look at the linked bug earlier, but Sun's bug database is down for maintenance now. I can't quite decide if I think the above is a bug in the JDK or not. It would seem like you could make a good argument that the PropertyDescriptor *should* return the bridge methods since this is how type safety is enforced in these situations, but also that it should report the property type correctly...I guess we'll see.
On Oct 12, 2006, at 11:10 AM, Taras Puchko wrote:
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
Stripes-users mailing list
|Free forum by Nabble||Edit this page|