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

706 Views Asked by At

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");
    }
}
2

There are 2 best solutions below

0
On BEST ANSWER

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).

0
On

The traceInstructions and traceMethodCall methods have not done anything useful since Java 1.2.1 !!

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

The methods were marked as deprecated (for removal) in Java 9 and finally removed in Java 13.