mirror of
https://github.com/alibaba/arthas.git
synced 2024-04-21 10:21:39 +00:00
1.7 KiB
1.7 KiB
- It is recommended to use the [OGNL] (https://arthas.aliyun.com/doc/arthas-tutorials.html?language=en&id=ognl) command, which will be more flexible.
Use getstatic command to Check the static fields of classes conveniently, the usage is getstatic class_name field_name{{}} .
getstatic demo.MathGame random{{execute T2}}
- Specify classLoader
Note that the hashcode changes, you need to check the current ClassLoader information first, and extract the hashcode corresponding to the ClassLoader using
sc -d <ClassName>{{}} .
if you use-c{{}} , you have to manually type hashcode by-c <hashcode>{{}} .
For classloader with only one instance, it can be specified by--classLoaderClass{{}} using class name, which is more convenient to use.
getstatic --classLoaderClass jdk.internal.loader.ClassLoaders$AppClassLoader random{{execute T2}}
- PS: Here the classLoaderClass in java 8 is sun.misc.Launcher$AppClassLoader, while in java 11 it's jdk.internal.loader.ClassLoaders$AppClassLoader. Currently killercoda using java11.
The value of --classloaderclass{{}} is the class name of classloader. It can only work when it matches a unique classloader instance. The purpose is to facilitate the input of general commands. However, -c <hashcode>{{}} is dynamic.
Tip: if the static field is a complex class, you can even use OGNL{{}} to traverse, filter and access the inner properties of this class.