August 11, 2011

Accessing Private Members of a Java Class using Reflection

Java Reflection API provides a feature to access private members of a Java Class.

java.lang.reflect package provides the AccessibleObject class that is parent class of Constructor, Method, and Field class. Using the AccessibleObject class, we can change the access control flags of a Reflection Object

Lets understand how to achieve this with below example.

Class Having Private Members[]

Class to Access the private members of the above class using Reflection[]

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.