未定义类型 Runtime 的方法 traceMethodCalls(boolean)

The method traceMethodCalls(boolean) is undefined for the type Runtime

我收到错误:
线程“main”中的异常java.lang.Error:未解决的编译问题: 未为类型 Runtime)
定义方法 traceMethodCalls(boolean) 当我 运行 下面的代码时。

    public static void main(String[] args) {
        //Start tracing for instructions
        System.out.println("Enabling...");

        Runtime.getRuntime().traceMethodCalls(true);
        System.out.println("Enabled");
    }
}

此方法已在 Java 13.

中删除

查看发行说明:https://www.oracle.com/java/technologies/javase/13-relnote-issues.html

The obsolete methods traceInstructions(boolean) and traceMethodCalls(boolean) have been removed from the java.lang.Runtime class. These methods have been non-functional for many releases, and their intended functions are provided by the Java Virtual Machine Tool Interface (JVMTI).

自 Java 1.2.1 !!

以来,traceInstructionstraceMethodCall 方法没有做任何有用的事情

https://bugs.openjdk.java.net/browse/JDK-4623283

这些方法在 Java 9 中被标记为已弃用(删除),并最终在 Java 13 中删除。