Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion ddprof-lib/src/main/cpp/vmEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,12 @@ JavaFullVersion JavaVersionAccess::get_java_version(char* prop_value) {
if (version.major < 9) {
version.major = 9;
}
// format is 11.0.17+8
char* peg_char = strchr(prop_value, '+');
if (peg_char) {
// terminate before the build specification
*peg_char = '\0';
}
// format is 11.0.17
// this shortcut for parsing the update version should hold till Java 99
version.update = atoi(prop_value + 5);
}
Expand Down
5 changes: 5 additions & 0 deletions ddprof-lib/src/main/cpp/vmStructs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,11 @@ void VMStructs::initOffsets() {
if (strcmp(field, "_klass_offset") == 0) {
_klass_offset_addr = *(int **)(entry + address_offset);
}
} else if (strcmp(type, "Thread") == 0) {
// Since JDK 24, _osthread field belongs to Thread rather than JavaThread
if (strcmp(field, "_osthread") == 0) {
_thread_osthread_offset = *(int*)(entry + offset_offset);
}
} else if (strcmp(type, "JavaThread") == 0) {
if (strcmp(field, "_osthread") == 0) {
_thread_osthread_offset = *(int *)(entry + offset_offset);
Expand Down
11 changes: 11 additions & 0 deletions ddprof-lib/src/test/cpp/ddprof_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,17 @@
EXPECT_EQ(9, hs_version1);
}

TEST(JavaVersionAccess, testJavaVersionAccess_hs_24) {
char runtime_prop_value_1[] = "24+36-FR";
char vm_prop_value_1[] = "24+36-FR";

JavaFullVersion java_version1 = JavaVersionAccess::get_java_version(runtime_prop_value_1);
int hs_version1 = JavaVersionAccess::get_hotspot_version(vm_prop_value_1);
EXPECT_EQ(24, java_version1.major);
EXPECT_EQ(0, java_version1.update);
EXPECT_EQ(24, hs_version1);
}

int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
Expand Down
Loading