The caller class is used in the warning message but it may throw NPE when invoked via JNI code with no caller frame and when -Djava.security.manager=allow is set when it accesses its code source and its name.
Comments
Discussed with [~mullan]. It's believed that it's unlikely a real use case calling System::setSecurityManager in JNI code with no caller frame and also set -Djava.security.manager=allow. Close this issue as WNF.
04-02-2022
System::setSecurityManager was made a caller-sensitive method in JDK 17 for JDK-8268349 to add a warning message that includes the caller class and protection domain.