oracle/graal · error

GetJavaVM: Passed JNIEnv* is NULL

Error message

GetJavaVM: Passed JNIEnv* is NULL

What it means

Error "GetJavaVM: Passed JNIEnv* is NULL" thrown in oracle/graal.

Source

Thrown at espresso/src/com.oracle.truffle.espresso.native/src/nespresso.c:462

  jint ret = JNI_OK;
  jint i;
  for (i = 0; i < nMethods; ++i) {
    ret = nespresso_env->RegisterNative(env, clazz, methods[i].name, methods[i].signature, methods[i].fnPtr);
    if (ret != JNI_OK) {
        break;
    }
  }
  return ret;
}

jint GetJavaVM(JNIEnv *env, JavaVM **vmPtr) {
  MokapotEnv* moka_env = NULL;
  JavaVM* vm = NULL;
  if (vmPtr == NULL) {
    return JNI_ERR;
  }
  if (env == NULL) {
    fprintf(stderr, "GetJavaVM: Passed JNIEnv* is NULL" OS_NEWLINE_STR);
    return JNI_ERR;
  }

  moka_env = (MokapotEnv*) (*env)->reserved1;
  if (moka_env == NULL) {
    fprintf(stderr, "GetJavaVM: Passed JNIEnv* has no MokapotEnv* associated" OS_NEWLINE_STR);
    return JNI_ERR;
  }

  vm = (*moka_env)->vm;

  // If there's an isolate-aware JavaVM, find it.
  if ((*vm)->reserved1 == MOKA_AMERICANO) {
    vm = (JavaVM*) (*vm)->reserved2;
    // MOKA_AMERICANO JavaVM can only point to a MOKA_LATTE.
    if ((*vm)->reserved1 != MOKA_LATTE) {
      fprintf(stderr, "GetJavaVM: not a MOKA_LATTE" OS_NEWLINE_STR);
      return JNI_ERR;

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Fix the condition reported by the error: GetJavaVM: Passed JNIEnv* is NULL
  2. Check the throwing call site and ensure its documented preconditions (argument values, types, environment, or configuration) are satisfied before the call.

Example fix

Validate inputs and environment so that the failing condition does not occur: GetJavaVM: Passed JNIEnv* is NULL

When it happens

Trigger: Thrown at espresso/src/com.oracle.truffle.espresso.native/src/nespresso.c:462 when the library encounters an invalid state.

Common situations: Occurs when a caller violates the contract guarded by this check: GetJavaVM: Passed JNIEnv* is NULL


AI-assisted analysis of oracle/graal@a66e9ccd1d (2026-08-14). Data as JSON: /api/errors/1cf31976bb75b6a5. Report an issue: GitHub.