java 堆转储中那些奇怪的类名是什么意思?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1087177/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What do those strange class names in a java heap dump mean?
提问by itsadok
I'm trying to track down a memory leak in a java process, using jmapand jhat. Every time I do this I see those weird notation for specific object types, like [Sfor string arrays and [Cfor Character arrays. I never remember what means what, and it's very hard to google this stuff.
我正在尝试使用jmap和jhat跟踪 java 进程中的内存泄漏。每次我这样做时,我都会看到特定对象类型的奇怪符号,例如[S字符串数组和[C字符数组。我从不记得什么是什么意思,而且很难用谷歌搜索这些东西。
(EDIT: to prove my point, it turns out that [Sis array of short and [Cis array of char.)
(编辑:为了证明我的观点,结果[S是短[C数组和字符数组。)
Anyone care to make a table listing all the different class names and what they mean? Or point me to such table?
有人愿意制作一张列出所有不同类名称及其含义的表格吗?或者指向我这样的表?
Specifically I'd like to know what [Ljava.lang.Object;means.
具体我想知道是什么[Ljava.lang.Object;意思。
回答by kdgregory
You'll find the complete list documented under Class.getName():
您会在Class.getName()下找到记录的完整列表:
If this class object represents a reference type that is not an array type then the binary name of the class is returned, as specified by the Java? Language Specification, Second Edition.
If this class object represents a primitive type or void, then the name returned is a
Stringequal to the Java language keyword corresponding to the primitive type or void.If this class object represents a class of arrays, then the internal form of the name consists of the name of the element type preceded by one or more '[' characters representing the depth of the array nesting. The encoding of element type names is as follows:
Element Type Encoding boolean Z byte B char C class or interface Lclassname; double D float F int I long J short S
如果此类对象表示不是数组类型的引用类型,则返回类的二进制名称,如Java? 语言规范,第二版。
如果这个类对象表示一个原始类型或void,则返回的名称
String等于原始类型或void对应的Java语言关键字。如果此类对象表示一类数组,则名称的内部形式由元素类型的名称组成,前面有一个或多个代表数组嵌套深度的“[”字符。元素类型名称的编码如下:
Element Type Encoding boolean Z byte B char C class or interface Lclassname; double D float F int I long J short S
回答by dfa
it is an array of objects as specified by JVM Specificationsfor internal representation of class names:
它是JVM 规范指定的对象数组,用于类名的内部表示:
- a single [ means an array of
- L followed by a fully qualified class name (e.g. java/lang/Object) is the class nameterminated by semicolon ;
- 单个 [ 表示一个数组
- L 后跟一个完全限定的类名(例如 java/lang/Object)是以分号结尾的类名;
so [Ljava.lang.object;means Object[]
所以[Ljava.lang.object; 表示对象[]
回答by Michael Borgwardt
The rules are listed in the API doc of Class.getName().
这些规则列在Class.getName()的 API 文档中。
[Ljava.lang.Object;would be an instance of Object[]. Note that multidimensional arrays
are displayed with multiple opening braces.
[Ljava.lang.Object;将是Object[]. 请注意,多维数组显示时带有多个左大括号。
回答by omerkudat
Means Object[]
表示对象[]

