From 6dfd2159fed62af9fef4aa52fff2915bb5a21ce0 Mon Sep 17 00:00:00 2001 From: Andrei Pangin Date: Wed, 3 May 2023 23:56:38 +0100 Subject: [PATCH] Fixed allocation profiling on JDK 20.0.1 --- src/profiler.cpp | 4 +--- src/vmEntry.cpp | 6 +++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/profiler.cpp b/src/profiler.cpp index a9b3351e..5d29c6e0 100644 --- a/src/profiler.cpp +++ b/src/profiler.cpp @@ -906,9 +906,7 @@ Engine* Profiler::selectEngine(const char* event_name) { } Engine* Profiler::selectAllocEngine(long alloc_interval, bool live) { - if (VM::canSampleObjects() && (alloc_interval > 0 || live || - VM::hotspot_version() == 0 || - !VMStructs::libjvm()->hasDebugSymbols())) { + if (VM::canSampleObjects()) { return &object_sampler; } else if (VM::isOpenJ9()) { return &j9_object_sampler; diff --git a/src/vmEntry.cpp b/src/vmEntry.cpp index 5a1caeb1..89fcf64a 100644 --- a/src/vmEntry.cpp +++ b/src/vmEntry.cpp @@ -119,11 +119,11 @@ bool VM::init(JavaVM* vm, bool attach) { } if (is_hotspot && _jvmti->GetSystemProperty("java.vm.version", &prop) == 0) { - if (strncmp(prop, "25.", 3) == 0) { + if (strncmp(prop, "25.", 3) == 0 && prop[3] > '0') { _hotspot_version = 8; - } else if (strncmp(prop, "24.", 3) == 0) { + } else if (strncmp(prop, "24.", 3) == 0 && prop[3] > '0') { _hotspot_version = 7; - } else if (strncmp(prop, "20.", 3) == 0) { + } else if (strncmp(prop, "20.", 3) == 0 && prop[3] > '0') { _hotspot_version = 6; } else if ((_hotspot_version = atoi(prop)) < 9) { _hotspot_version = 9;