classloader
查看ClassLoader继承树,加载URL信息,类加载信息。
命令选项
命令选项 | 描述 |
---|---|
-a, --all | 列出所有被ClassLoader加载的类,请谨慎使用 |
-c, --classloader <hash> | 指定ClassLoader的哈希值 |
--classLoaderClass <name> | 指定ClassLoader的类名 |
-i, --include-reflection-classloader | 包含sun.reflect.DelegatingClassLoader |
-l, --list-classloader | 列出ClassLoader实例信息 |
--load <className> | 加载给定的类,必须指定ClassLoader,即-c |
-r, --resource <name> | 查找给定名字的资源,必须指定ClassLoader,即-c |
-t, --tree | 展示ClassLoader树 |
-u, --url-stat | 展示ClassLoader URL统计信息 |
-h, --help | 帮助 |
示例
bash
# 查看ClassLoader实例及加载类信息
[arthas@14064]$ classloader
name numberOfInstances loadedCountTotal
BootstrapClassLoader 1 3508
java.net.URLClassLoader 1 2020
com.taobao.arthas.agent.ArthasClassloader 1 1395
jdk.internal.loader.ClassLoaders$PlatformClassLoader 1 92
jdk.internal.reflect.DelegatingClassLoader 15 15
jdk.internal.loader.ClassLoaders$AppClassLoader 1 4
Affect(row-cnt:6) cost in 2 ms.
# 查看ClassLoader加载类、hash、父ClassLoader信息
[arthas@14064]$ classloader -l
name loadedCount hash parent
BootstrapClassLoader 3508 null null
com.taobao.arthas.agent.ArthasClassloader@435181e6 1393 435181e6 jdk.internal.loader.ClassLoaders$PlatformClassLoader@782458af
java.net.URLClassLoader@22a71081 2020 22a71081 jdk.internal.loader.ClassLoaders$AppClassLoader@2328c243
jdk.internal.loader.ClassLoaders$AppClassLoader@2328c243 4 2328c243 jdk.internal.loader.ClassLoaders$PlatformClassLoader@782458af
jdk.internal.loader.ClassLoaders$PlatformClassLoader@782458af 92 782458af null
Affect(row-cnt:5) cost in 2 ms.
# 查看ClassLoader树
[arthas@14064]$ classloader -t
+-BootstrapClassLoader
+-jdk.internal.loader.ClassLoaders$PlatformClassLoader@782458af
+-com.taobao.arthas.agent.ArthasClassloader@435181e6
+-jdk.internal.loader.ClassLoaders$AppClassLoader@2328c243
+-java.net.URLClassLoader@22a71081
Affect(row-cnt:5) cost in 3 ms.
# 查找指定名字的资源 必须是全路径且必须指定ClassLoader
[arthas@14064]$ classloader -c 435181e6 -r META-INF/MANIFEST.MF
jar:file:/C:/Users/A/.arthas/lib/3.6.7/arthas/arthas-core.jar!/META-INF/MANIFEST.MF
# 查找指定的Class
[arthas@14064]$ classloader -c 435181e6 -r java/lang/String.class
jrt:/java.base/java/lang/String.class
# 加载class
[arthas@14064]$ classloader -c 435181e6 --load com.alibaba.arthas.deps.ZZZ
load class success.
class-info com.alibaba.arthas.deps.ZZZ
code-source /C:/Users/A/.arthas/lib/3.6.7/arthas/arthas-core.jar
name com.alibaba.arthas.deps.ZZZ
isInterface false
isAnnotation false
isEnum false
isAnonymousClass false
isArray false
isLocalClass false
isMemberClass false
isPrimitive false
isSynthetic false
simple-name ZZZ
modifier public
annotation
interfaces
super-class +-java.lang.Object
class-loader +-com.taobao.arthas.agent.ArthasClassloader@435181e6
+-jdk.internal.loader.ClassLoaders$PlatformClassLoader@782458af
classLoaderHash 435181e6
# 加载已加载的类
[arthas@14064]$ classloader -c 435181e6 --load java.lang.String
load class success.
class-info java.lang.String
code-source
name java.lang.String
isInterface false
isAnnotation false
isEnum false
isAnonymousClass false
isArray false
isLocalClass false
isMemberClass false
isPrimitive false
isSynthetic false
simple-name String
modifier final,public
annotation
interfaces java.io.Serializable,java.lang.Comparable,java.lang.CharSequence,java.lang.constant.Constable,java.lang.constant.ConstantDesc
super-class +-java.lang.Object
class-loader
classLoaderHash null
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82