#define CHECK_CALL_SUCCESS(c) \ do { \ if ((c) != JNI_OK) { \
printf("call "#c" did not succeed\n"); \ return -1; \
} \
} while (false)
CHECK_CALL_SUCCESS(vm->GetEnv(reinterpret_cast<void**>(&env), JVMTI_VERSION_1_0));
CHECK_CALL_SUCCESS(vm->GetEnv(reinterpret_cast<void**>(&env2), JVMTI_VERSION_1_0)); if (env == env2) {
printf("GetEnv returned same environment twice!\n"); return -1;
} unsignedchar* local_data = nullptr;
CHECK_CALL_SUCCESS(env->Allocate(8, &local_data));
strcpy(reinterpret_cast<char*>(local_data), "hello!!");
CHECK_CALL_SUCCESS(env->SetEnvironmentLocalStorage(local_data)); unsignedchar* get_data = nullptr;
CHECK_CALL_SUCCESS(env->GetEnvironmentLocalStorage(reinterpret_cast<void**>(&get_data))); if (get_data != local_data) {
printf("Got different data from local storage then what was set!\n"); return -1;
}
CHECK_CALL_SUCCESS(env2->GetEnvironmentLocalStorage(reinterpret_cast<void**>(&get_data))); if (get_data != nullptr) {
printf("env2 did not have nullptr local storage.\n"); return -1;
}
CHECK_CALL_SUCCESS(env->Deallocate(local_data));
jint version = 0;
CHECK_CALL_SUCCESS(env->GetVersionNumber(&version)); if ((version & JVMTI_VERSION_1) != JVMTI_VERSION_1) {
printf("Unexpected version number!\n"); return -1;
}
if (vm->GetEnv(reinterpret_cast<void**>(&jvmti_env), JVMTI_VERSION_1_0)) {
printf("Unable to get jvmti env!\n"); return1;
}
SetStandardCapabilities(jvmti_env);
jvmtiPhase current_phase;
jvmtiError phase_result = jvmti_env->GetPhase(¤t_phase); if (phase_result != JVMTI_ERROR_NONE) {
printf("Could not get phase"); return1;
} if (current_phase != JVMTI_PHASE_ONLOAD) {
printf("Wrong phase"); return1;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.