Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0e5b5f9

Browse files
authoredMar 18, 2025··
Fix Java 24 support (#194)
1 parent 9b1ff48 commit 0e5b5f9

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed
 

‎ddprof-lib/src/main/cpp/vmEntry.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,12 @@ JavaFullVersion JavaVersionAccess::get_java_version(char* prop_value) {
129129
if (version.major < 9) {
130130
version.major = 9;
131131
}
132-
// format is 11.0.17+8
132+
char* peg_char = strchr(prop_value, '+');
133+
if (peg_char) {
134+
// terminate before the build specification
135+
*peg_char = '\0';
136+
}
137+
// format is 11.0.17
133138
// this shortcut for parsing the update version should hold till Java 99
134139
version.update = atoi(prop_value + 5);
135140
}

‎ddprof-lib/src/main/cpp/vmStructs.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,11 @@ void VMStructs::initOffsets() {
240240
if (strcmp(field, "_klass_offset") == 0) {
241241
_klass_offset_addr = *(int **)(entry + address_offset);
242242
}
243+
} else if (strcmp(type, "Thread") == 0) {
244+
// Since JDK 24, _osthread field belongs to Thread rather than JavaThread
245+
if (strcmp(field, "_osthread") == 0) {
246+
_thread_osthread_offset = *(int*)(entry + offset_offset);
247+
}
243248
} else if (strcmp(type, "JavaThread") == 0) {
244249
if (strcmp(field, "_osthread") == 0) {
245250
_thread_osthread_offset = *(int *)(entry + offset_offset);

‎ddprof-lib/src/test/cpp/ddprof_ut.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,17 @@
235235
EXPECT_EQ(9, hs_version1);
236236
}
237237

238+
TEST(JavaVersionAccess, testJavaVersionAccess_hs_24) {
239+
char runtime_prop_value_1[] = "24+36-FR";
240+
char vm_prop_value_1[] = "24+36-FR";
241+
242+
JavaFullVersion java_version1 = JavaVersionAccess::get_java_version(runtime_prop_value_1);
243+
int hs_version1 = JavaVersionAccess::get_hotspot_version(vm_prop_value_1);
244+
EXPECT_EQ(24, java_version1.major);
245+
EXPECT_EQ(0, java_version1.update);
246+
EXPECT_EQ(24, hs_version1);
247+
}
248+
238249
int main(int argc, char **argv) {
239250
::testing::InitGoogleTest(&argc, argv);
240251
return RUN_ALL_TESTS();

0 commit comments

Comments
 (0)
Please sign in to comment.