As per understanding its possible to manipulate the general notion of final
keyword using reflection.
Also its possible to prevent the same using a security manager.
Is it possible to enable the security manager by default (at the jdk-installation level ) ?
References :
- Change private static final field using Java reflection
- Running Java Security Manager without the default java.policy file
Update 1:
Given that its required to be enabled in order to work, its unlikely that its possible.
The closest I got was by placing System.setSecurityManager(new SecurityManager())
in the static block of a class, bundling it as a jar and placing it in the 'jre/lib/ext', only to find that its not loaded by default and we still need to use Class.forName.
So even otherwise the only options are to either use the -Djava.security.manager
flag or add programatically.