The JNI GetEnv function is supposed to return JNI error codes which
are all negative numbers. Thus,
if ((jvm->GetEnv((void **)&interface, version)) < 0) {
... error processing ...
is the standard usage pattern. For JVMDI,
if ((jvm->GetEnv((void **)&jvmdi, JVMDI_VERSION_1)) < 0) {
... error processing ...
the error test will fail and an uninitialized interface pointer
will be returned if debugging is not enabled,
} else if (version == JVMDI_VERSION_1) {
if (jvmdi::enabled()) {
*penv = (void *)jvmdi::GetInterface_1(vm);
return JNI_OK;
} else {
return JVMDI_ERROR_ACCESS_DENIED;
}
since the code returns a JVMDI error code which is a positive
number and is not a JNI error code as specified. Note also that
current versions (JVMDI_VERSION_1, JVMDI_VERSION_1_1, ...) cannot
be specified (see how JNI and JVMPI handle this).
are all negative numbers. Thus,
if ((jvm->GetEnv((void **)&interface, version)) < 0) {
... error processing ...
is the standard usage pattern. For JVMDI,
if ((jvm->GetEnv((void **)&jvmdi, JVMDI_VERSION_1)) < 0) {
... error processing ...
the error test will fail and an uninitialized interface pointer
will be returned if debugging is not enabled,
} else if (version == JVMDI_VERSION_1) {
if (jvmdi::enabled()) {
*penv = (void *)jvmdi::GetInterface_1(vm);
return JNI_OK;
} else {
return JVMDI_ERROR_ACCESS_DENIED;
}
since the code returns a JVMDI error code which is a positive
number and is not a JNI error code as specified. Note also that
current versions (JVMDI_VERSION_1, JVMDI_VERSION_1_1, ...) cannot
be specified (see how JNI and JVMPI handle this).