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; } }
Nope you wouldn't get it after modifying your parent class as public. Please note my parent class Test is not public. Thanks.
Amit Biswas
Ranch Hand
Joined: Jun 01, 2006
Posts: 52
posted
0
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);
Adeel Ansari
Ranch Hand
Joined: Aug 15, 2004
Posts: 2874
posted
0
I don't think it would be bug. There must be some rational reason behind it.
Well, it seems that the code works fine under JDK 6, but not JDK 5. So I'd say yes, it's a bug, and it's been fixed, but only very recently.
"I'm not back." - Bill Harding, Twister
Adeel Ansari
Ranch Hand
Joined: Aug 15, 2004
Posts: 2874
posted
0
Sound. Thanks Jim.
Adeel Ansari
Ranch Hand
Joined: Aug 15, 2004
Posts: 2874
posted
0
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.
Thanks.
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18670
posted
0
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.
Adeel Ansari
Ranch Hand
Joined: Aug 15, 2004
Posts: 2874
posted
0
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.