Runtime Trace Method Calls Removed

ID

java.runtime_trace_method_calls_removed

Severity

info

Remediation Complexity

trivial

Remediation Risk

low

Remediation Effort

low

Resource

Reliability

Language

Java

Tags

best-practice

Description

Reports calls to Runtime.traceMethodCalls(boolean) and Runtime.traceInstructions(boolean). These methods have been no-ops since early JDK versions and were formally deprecated. Calling them has no effect.

Rationale

These tracing methods were part of an early JVM debugging facility that was never fully implemented in most JVMs. They do nothing at runtime, so any code relying on them for diagnostics is silently broken. Their presence also confuses maintainers who may believe tracing is active.

// Bad - no-op call that misleads readers
Runtime.getRuntime().traceMethodCalls(true);
Runtime.getRuntime().traceInstructions(true);

Remediation

Remove the calls entirely. For method tracing, use a profiler, Java Flight Recorder, or a bytecode instrumentation agent instead.

// Good - use proper profiling tools instead
// e.g., -XX:StartFlightRecording=duration=60s,filename=recording.jfr