my dog learned polymorphism
The moose likes Beginning Java and the fly likes Reflection Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Reflection Problem" Watch "Reflection Problem" New topic

Reflection Problem

V Vijay Veeraraghavan

Joined: Apr 06, 2008
Posts: 21

dear all
i am using reflection to invoke particular methods to fetch the values from them. i have a class structure like this

//the above code works for all the methods... but for getValue and setValue exception is thrown....
java.lang.IllegalAccessException: Class MyClass can not access a member of class MyPackage.C with modifiers "public"

i am able to understand that the problem is with the protected package which i try to access from outside. but how do i solve this problem roundabout way...


Vijay Veeraraghavan


[Nitesh: Added code tags: Please UseCodeTags]
[ November 24, 2008: Message edited by: Nitesh Kant ]
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

Not really an advanced question. Have a read of the JavaDocs for java.lang.reflect.AccessibleObject; you should be able to work out the way round this from there.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
I agree. Here's the link:
subject: Reflection Problem
It's not a secret anymore!