dimanche 1 août 2021

How to prevent reflection only for some fields?

We all know that the keyword "private" in java for fields and methods works only in build time, while in runtime it takes 3 lines to bypass. I am making a plugin system for something, and these plugins are jars which are loaded in my process. So, i need a way to prevent plugins from accessing some fields of my game, which must not be accessed from outside. The problem is that the "private" keyword is useless and Reflection.registerFieldsToFilter is useless too. What i have tried:

making the field private (field.setAccessible() bypasses)

doing Reflection.registerFieldsToFilter (Class.getDeclaredFields0() bypasses)

Then what can i do to make some fields/methods/classes actually private?





Aucun commentaire:

Enregistrer un commentaire