From 3313d41e005de45ecd408d34bd5f9ce28fb2337d Mon Sep 17 00:00:00 2001 From: Karm Michal Babacek Date: Thu, 19 Dec 2024 15:03:13 +0100 Subject: [PATCH] Delete native methods from java.lang.Thread 'getStackTrace0' is only used in asyncGetStackTrace() which is deleted as well. Thread.getStackTrace() is replaced by PlatformThreads.getStackTrace(). So it's not reachable. 'getNextThreadIdOffset()' is only used in ThreadIdentifiers private class which is substituted in JDKs better than JDK 19 (which includes 21). So won't be reachable either. Fixes: #28 This is a partial backport of: "Introudce a mode to unconditionally include classes" https://github.com/oracle/graal/commit/369f0ff8 to address https://github.com/oracle/graal/issues/9672 Only take the java.lang.Thread native method deletions as that's sufficient to fix the issue reported in #28. --- .../oracle/svm/core/thread/Target_java_lang_Thread.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Target_java_lang_Thread.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Target_java_lang_Thread.java index 4783cd3b2662..4b47d2009849 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Target_java_lang_Thread.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Target_java_lang_Thread.java @@ -623,6 +623,10 @@ private StackTraceElement[] getStackTrace() { return JavaThreads.getStackTrace(false, JavaThreads.fromTarget(this)); } + @Delete + @SuppressWarnings({"static-method"}) + private native Object getStackTrace0(); + /** @see com.oracle.svm.core.jdk.StackTraceUtils#asyncGetStackTrace */ @Delete @TargetElement(onlyWith = JDK19OrLater.class) @@ -798,6 +802,9 @@ boolean isTerminated() { @Alias @TargetElement(onlyWith = JDK19OrLater.class) native long threadId(); + + @Delete + static native long getNextThreadIdOffset(); } @TargetClass(value = Thread.class, innerClass = "Builder", onlyWith = JDK19OrLater.class)