I have a TrirdParty API that contains a CLass [let's say A]. It has a bizarre static block similar to the following:
class A
{
static
{
try
{
System.loadLibrary("libraryName");
}
catch(UnsatisfiedLinkError ue)
{
System.exit(0);
}
}
//other stuff
}
I want to prevent the call to System.exit()
with a overridden SecurityManager
. However I want to override the SecurityManager
just before this static
block is executed and right after that I want to restore the original security manager.
I know how to replace/override/restore SecurityManager
.
My problem is how do I determine when the static
block will be called [basically when the class will be loaded] so that just before that I will use my own SecurityManager
to prevent the System.exit()
and after that restore the original SecurityManager
.
Please note that it is important to override the security manager only for the time duration when the static block is executed.
EDIT:
Changing the source is not an option for licensing reasons.