Repository navigation
Closed
Description
hi,
java-profiler identifies the wrong JDK version on OpenJDK8. It is correct at JDK 11 and above.
java -version
openjdk version "1.8.0_412"
OpenJDK Runtime Environment (build 1.8.0_412-b08)
OpenJDK 64-Bit Server VM (build 25.412-b08, mixed mode)
(gdb) bt
#0 VM::init (vm=0x7ffff71781a0 <main_vm>, attach=true) at vmEntry.cpp:200
#1 0x00007fffd7407f68 in JNI_OnLoad (vm=0x7ffff71781a0 <main_vm>, reserved=0x0) at vmEntry.cpp:478
#2 0x00007ffff52c168e in Java_java_lang_ClassLoader_00024NativeLibrary_load () from /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.412.b08-1.el7_9.x86_64/jre/lib/amd64/libjava.so
#3 0x00007fffe1018427 in ?? ()
#4 0x00007fffdeb34380 in ?? ()
#5 0x0000000000000000 in ?? ()
(gdb) p prop
$1 = 0x7ffff0180120 "25.412-b08"
(gdb) p _java_version
$2 = 25
This will cause the async-profiler's workaround for https://bugs.openjdk.org/browse/JDK-8062116 to be skipped.
This may lead to serious performance issues.
void VMStructs::initJvmFunctions() {
...
if (VM::java_version() == 8) { // java_version == 25
_lock_func = (LockFunc)_libjvm->findSymbol(
"_ZN7Monitor28lock_without_safepoint_checkEv");
_unlock_func = (LockFunc)_libjvm->findSymbol("_ZN7Monitor6unlockEv");
}
...
}void VMStructs::resolveOffsets() {
...
_has_class_loader_data =
_class_loader_data_offset >= 0 &&
_class_loader_data_next_offset == sizeof(uintptr_t) * 8 + 8 &&
_methods_offset >= 0 && _klass != NULL && _lock_func != NULL && // _unlock_func == NULL
_unlock_func != NULL;
...
}void VM::loadMethodIDs(jvmtiEnv* jvmti, JNIEnv* jni, jclass klass) {
if (VMStructs::hasClassLoaderData()) { // <- the result is false, and the wordaround is skipped
VMKlass* vmklass = VMKlass::fromJavaClass(jni, klass);
int method_count = vmklass->methodCount();
if (method_count > 0) {
ClassLoaderData* cld = vmklass->classLoaderData();
cld->lock();
// Workaround for JVM bug: preallocate space for jmethodIDs
// at the beginning of the list (rather than at the end)
for (int i = 0; i < method_count; i += MethodList::SIZE) {
*cld->methodList() = new MethodList(*cld->methodList());
}
cld->unlock();
}
}
jint method_count;
jmethodID* methods;
if (jvmti->GetClassMethods(klass, &method_count, &methods) == 0) {
jvmti->Deallocate((unsigned char*)methods);
}
}Metadata
Metadata
Assignees
Labels
No labels
Activity
jbachorik commentedon Oct 29, 2024
Fixed in #142