wood burning stoves 2.0*
The moose likes Java in General and the fly likes got private variables :( Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "got private variables :(" Watch "got private variables :(" New topic
Author

got private variables :(

Chiranjeevi Kanthraj
Ranch Hand

Joined: Feb 18, 2008
Posts: 289

Hi all

By using reflection API we can access the private variable except inherited members.

then how can we protect the private member from the reflection API also.

regards
Chiru


-Chiru
santhosh.R gowda
Ranch Hand

Joined: Apr 06, 2009
Posts: 296
Chiranjeevi Kanthraj wrote:Hi all

By using reflection API we can access the private variable except inherited members.

then how can we protect the private member from the reflection API also.

regards
Chiru

HI chiru .. im not having idea regarding this issue....

Creativity is nothing but Breaking Rules
Duc Vo
Ranch Hand

Joined: Nov 20, 2008
Posts: 254
Chiranjeevi Kanthraj wrote:Hi all

By using reflection API we can access the private variable except inherited members.

then how can we protect the private member from the reflection API also.

regards
Chiru


Change the JVM security settings.


“Everything should be as simple as it is, but not simpler.” Albert Einstein
Chiranjeevi Kanthraj
Ranch Hand

Joined: Feb 18, 2008
Posts: 289

Change the JVM security settings.


any links please.
Adam Michalik
Ranch Hand

Joined: Feb 18, 2008
Posts: 128
Hi! Have a look at Sun's Security Guide (the last four bullets of 'General Security') and google for 'Security Manager' and 'security policy file'.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19651
    
  18

Chiranjeevi Kanthraj wrote:Hi all

By using reflection API we can access the private variable except inherited members.

then how can we protect the private member from the reflection API also.

regards
Chiru

Use Class.getSuperclass() in combination with Class.getDeclaredFields(), and loop until you've reached the end:


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37962
    
  22
More difficult a question than we expect on "beginners." Moving.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: got private variables :(
 
Similar Threads
Private methods in TDD
Reflection API
Reflection API
Reflection api
Serialization