This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

got private variables :(

 
Chiranjeevi Kanthraj
Ranch Hand
Posts: 290
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
santhosh.R gowda
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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....
 
Duc Vo
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Chiranjeevi Kanthraj
Ranch Hand
Posts: 290
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Change the JVM security settings.


any links please.
 
Adam Michalik
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20550
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
Campbell Ritchie
Sheriff
Pie
Posts: 49411
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
More difficult a question than we expect on "beginners." Moving.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic