import{_ as o,o as i,c as l,a as s,b as e,e as n,d as t,r as c}from"./app.391b0e4e.js";const p={},r=s("h1",{id:"getstatic",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#getstatic","aria-hidden":"true"},"#"),n(" getstatic")],-1),u={href:"https://arthas.aliyun.com/doc/arthas-tutorials.html?language=en&id=command-getstatic",target:"_blank",rel:"noopener noreferrer"},d=s("code",null,"getstatic",-1),m=n(" online tutorial"),k=t(`

Check the static fields of classes conveniently, the usage is getstatic class_name field_name.

$ getstatic demo.MathGame random
field: random
@Random[
    serialVersionUID=@Long[3905348978240129619],
    seed=@AtomicLong[120955813885284],
    multiplier=@Long[25214903917],
    addend=@Long[11],
    mask=@Long[281474976710655],
    DOUBLE_UNIT=@Double[1.1102230246251565E-16],
    BadBound=@String[bound must be positive],
    BadRange=@String[bound must be greater than origin],
    BadSize=@String[size must be non-negative],
    seedUniquifier=@AtomicLong[-3282039941672302964],
    nextNextGaussian=@Double[0.0],
    haveNextNextGaussian=@Boolean[false],
    serialPersistentFields=@ObjectStreamField[][isEmpty=false;size=3],
    unsafe=@Unsafe[sun.misc.Unsafe@2eaa1027],
    seedOffset=@Long[24],
]

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

$ getstatic -c 3d4eac69 demo.MathGame random

For classloader with only one instance, it can be specified by --classLoaderClass using class name, which is more convenient to use.

getstatic --classLoaderClass demo.MathGame random

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.

`,11),v=n("Tip: if the static field is a complex class, you can even use "),h={href:"https://commons.apache.org/proper/commons-ognl/language-guide.html",target:"_blank",rel:"noopener noreferrer"},b=s("code",null,"OGNL",-1),g=n(" to traverse, filter and access the inner properties of this class."),f={href:"https://commons.apache.org/proper/commons-ognl/language-guide.html",target:"_blank",rel:"noopener noreferrer"},_=n("OGNL official guide"),y={href:"https://github.com/alibaba/arthas/issues/71",target:"_blank",rel:"noopener noreferrer"},L=n("Special usages"),x=t(`

E.g. suppose n is a Map and its key is a Enum, then you can achieve this if you want to pick the key with a specific Enum value:

$ getstatic com.alibaba.arthas.Test n 'entrySet().iterator.{? #this.key.name()=="STOP"}'
field: n
@ArrayList[
    @Node[STOP=bbb],
]
Affect(row-cnt:1) cost in 68 ms.


$ getstatic com.alibaba.arthas.Test m 'entrySet().iterator.{? #this.key=="a"}'
field: m
@ArrayList[
    @Node[a=aaa],
]
`,2);function N(S,w){const a=c("ExternalLinkIcon");return i(),l("div",null,[r,s("p",null,[s("a",u,[d,m,e(a)])]),k,s("p",null,[v,s("a",h,[b,e(a)]),g]),s("ul",null,[s("li",null,[s("a",f,[_,e(a)])]),s("li",null,[s("a",y,[L,e(a)])])]),x])}var B=o(p,[["render",N],["__file","getstatic.html.vue"]]);export{B as default};