Access checks are performed at the method handle creation time via the Lookup object against its lookup class.
If MethodHandles::lookup is invoked via JNI code with no caller frame, two possible options:
1. throw IllegalCallerException as no caller is available
2. return a public lookup (MethodHandles::publicLookup)
While it may look that returning a public lookup is JNI-friendly, I think the caller should call the proper API, i.e. MethodHandles::publicLookup, if public lookup is what they want. Throwing IllegalCallerException would help the existing code to call the right API.