I'm working on a plug-in for something and I'm trying to spawn a few threads, but I keep running into the problem of not being able to spawn them because of the SecurityManager. The software the plug-in runs under implements its own SecurityManager that does only two things: stop thread spawning and prevent the changing of the security manager.
It does not, however, prevent reflection, so I decided to try to reflect the System class to modify the manager that way.
Upon decompiling the System class, I found:
/* The security manager for the system.
*/
private static volatile SecurityManager security = null;
So, I tried to reflect it to a default security manager.
Class<System> systemClass = System.class;
Field securityManager = systemClass.getDeclaredField("security");
securityManager.setAccessible(true);
securityManager.set(securityManager, new SecurityManager());
However, this causes a NoSuchFieldExpception when I try to get the security field, even though it is clearly there. Why is this? Is there another way I can set the SecurityManager?
Note: The getDeclaredFields method returns an array not containing the security field.
Aucun commentaire:
Enregistrer un commentaire