javaexceptionruntimeexceptionjava-runtime-compiler

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


I get the error:
(Exception in thread "main" java.lang.Error: Unresolved compilation problem: The method traceMethodCalls(boolean) is undefined for the type Runtime)
when I run the code Below.

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

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

Solution

  • This method was removed in Java 13.

    See the release notes: 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).