![]() In a shared/hosted environment, the security is relative. Type-safety is also anyway threatened by run-time error because of downcast, so this point can also be argued. This is for instance what defensive copying try to protect against. Writing secure code is indeed extremely hard, and even without changing the access modifier you can subclass classes in an inappropriate way - unless they are final, or even better, sealed - and pass them around. The problem of access to private data and breaking encapsulation can be argued in practice. Is it the ReflectPermission only, or other permission of the security manager? One danger is clearly to get access to the file system and mess around. Also I don't know exactly what is disabled for Google App. I've read the link pointed by but it's mostly about. you can reveal sensible information of objects you don't ownįinally there are other mechanism that put security in jeopardy, notably which gives direct access to the memory - pointers are back.Ģ - Now, the question is whether reflection (in practice) leads to that many risks.strings are not immutable anymore and can be changed (see this question).It can lead to various malicious exploits, e.g. inspection and modification of internal data is possible. ![]() Reflection on private structures with tAccessible can however be disabled, because it breaks encapsulation. Reflection can not be turned off altogether it's always possible to reflect on its own public fields/methods. The article Dynamic class loading in the JVM, by Gilad Bracha, is insightful on such issues. For instance class loaders - which can be considered as reflective hook in the system - were not designed properly in the early version of Java leading to potential type replacement. Reflection defeat notably static typing and can lead to run-time errors.īut more subtle things can happen as well. You can read the interview of James Gosling in Masterminds of programming, which is interesting about that.īut the more reflective power you have the harder it is to ensure things are safe as they should. There was a big emphasis in the design of java to make it a safe platform, with static typing, security manager, disciplined usage of class loader, and no way to screw pointers/ memory. 1 - Reflection (as a concept) is indeed orthogonal to safety/security.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |