Hi Adeel, I am using Java 1.4 and I am not able to re-create the problem you are facing. Moreover, there are some differences in the Reflection API signatures. Please find the same below and investigate whether you are still facing exceptions:
//Super-class in package one package one;
public class ParentTest {
public String returnParam(String param){ return param; } }
I got you. This seems to be some kind of bug and can be seen in the sun bug list. The workaround is what you have done in the second method i.e, method.setAccessible(true);
Jim, thanks for your attempt. I tried it with Java 6 as well, but doesn't work. Have you tried it yourself? just curious.
I found a few matching threads in the Java 6 bugs list. Among those, this thread seems that this bug is not fixed, yet. I believe, you might, mistakenly, considered this one.
Adeel, yes I tested it using JDK 1.6.0_01 on Windows 2000 Pro, using the exact code that you provided in your first post. It prints
Hello! Hello! Hello!
But if I switch to JDK 1.5.0_11, I get the error you describe. Are you using a different JDK? Perhaps there is some subtle difference between my code and yours. Maybe there is a partial fix in place, but it doesn't work in all circumstances. Maybe it was fixed accidentally in JDK 1.6.0_01 in response to some other bug report, and they neglected to update the one you found. I don't know. I would agree with the earlier suggestions that if you're seeing this behavior, it's a bug. But I don't know why it seems to work for me and not you, unless it was fixed in _01 and you're using _00.
I am using jdk1.6.0_01 on SUSE Linux 10.0 and IDEA. Its working now. I have deleted the class files before recompiling with Java 6, that worked. Thanks for the help and sorry for disturbing you, the problem was on my end.
To avoid criticism do nothing, say nothing, be nothing. -Elbert Hubbard. Please critique this tiny ad:
a bit of art, as a gift, the permaculture playing cards