Using Arthas ognl Command for Java Diagnostics
This article introduces the Arthas Java diagnostic tool, explains the powerful ognl command with basic usage examples for inspecting static fields and invoking static methods, and provides a sample Java code snippet illustrating how to apply these techniques in practice.
Arthas is an open‑source Java diagnostic tool. The article highlights the ognl command, noting its many advanced usages and focusing on basic scenarios such as viewing static field values and invoking static methods.
Two common use cases are described: (1) checking the value of a static field, and (2) calling a static method, with the latter often used to dump memory snapshots, reinitialize configurations, or modify settings, which is more useful than merely reading fields.
The article also lists a series of related video tutorials covering quick start, thread commands, JVM and system property commands, logger level adjustments, and the sc and sm commands.
Below is a sample Java class that can be inspected with Arthas, demonstrating static fields, a constructor, a loop that creates objects, and a static test method that logs a warning:
package com.fun;
import com.fun.frame.SourceCode;
class DeleteNull extends SourceCode {
public static String name = DEFAULT_STRING;
public int age;
public DeleteNull(int i) {
this.age = i;
}
public static void main(String[] args) {
int num = 0;
while (true) {
sleep(5000);
new DeleteNull(num++);
}
}
/**
* Test
* @return FunTester
*/
static String test() {
logger.warn(DEFAULT_STRING);
DEFAULT_STRING;
}
}The article concludes with a disclaimer that the "FunTester" content is original and should not be reposted without permission, and provides links to additional technical and non‑code articles covering topics such as Linux performance monitoring, HTTP concepts, JMeter performance testing, and automation engineering.
FunTester
10k followers, 1k articles | completely useless
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.