checkInstantiationByServiceLoader
Verifies that the current method is instantiated by java.util.ServiceLoader
.
This function checks the call stack to ensure that the class instantiating an object is java.util.ServiceLoader
. It prevents direct instantiation of the object outside of the expected context (i.e., via ServiceLoader
).
If the instantiation is not performed by ServiceLoader
, an IllegalStateException
is thrown with an appropriate error message, enforcing proper usage.
Throws
If the instantiation is not done by java.util.ServiceLoader
.