lundi 29 août 2022

Is it safe to modify private variables using ReflectionUtils

Java ReflectionUtils gives us a way to make private variables accessible and modifiable. I just wrote some code which intercepts a process and modifies some private variables of an object.

How safe is this? My doubt is, What if in future, the person who owns this object decides to rename it to something else ? Since its a private var, he is completely entitled to.

If this is unsafe, then what is the point of ReflectionUtils allowing us to set private variables at all ?

Thanks in advance.





Aucun commentaire:

Enregistrer un commentaire