java 堆转储中那些奇怪的类名是什么意思? [英] What do those strange class names in a java heap dump mean?

查看:21
本文介绍了java 堆转储中那些奇怪的类名是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 jmapjhat.每次我这样做时,我都会看到特定对象类型的奇怪符号,例如字符串数组的 [S 和字符数组的 [C.我从来不记得什么是什么意思,而且很难用谷歌搜索这些东西.

(EDIT:为了证明我的观点,事实证明 [S 是短数组,[C 是字符数组.)

有人愿意制作一个表格,列出所有不同的类名称及其含义吗?或者把我指向这样的表?

我特别想知道[Ljava.lang.Object;是什么意思.

解决方案

您会在 Class.getName():

<块引用>

如果这个类对象代表一个不是数组的引用类型然后输入类的二进制名称返回,如 Java™语言规范,第二版.

如果这个类对象代表一个原始类型或void,然后是名称返回一个 String 等于 Java对应的语言关键字原始类型或void.

如果这个类对象代表一个数组类,然后是内部名字的形式由名字组成元素类型的前面有一个或更多的 '[' 字符代表数组嵌套的深度.这元素类型名称的编码为如下:

<前>元素类型编码布尔值 Z字节B字符 C类或接口 Lclassname;双D浮点数国际我长J短裤

I'm trying to track down a memory leak in a java process, using jmap and jhat. Every time I do this I see those weird notation for specific object types, like [S for string arrays and [C for Character arrays. I never remember what means what, and it's very hard to google this stuff.

(EDIT: to prove my point, it turns out that [S is array of short and [C is array of char.)

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.

解决方案

You'll find the complete list documented under 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 String equal 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 堆转储中那些奇怪的类名是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆