What do those strange class names in a java heap dump mean?

前端 未结 4 1224
故里飘歌
故里飘歌 2020-12-13 04:08

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

相关标签:
4条回答
  • 2020-12-13 04:35

    Means Object[]

    0 讨论(0)
  • 2020-12-13 04:43

    The rules are listed in the API doc of Class.getName().

    [Ljava.lang.Object; would be an instance of Object[]. Note that multidimensional arrays are displayed with multiple opening braces.

    0 讨论(0)
  • 2020-12-13 04:46

    it is an array of objects as specified by JVM Specifications for internal representation of class names:

    • a single [ means an array of
    • L followed by a fully qualified class name (e.g. java/lang/Object) is the class name terminated by semicolon ;

    so [Ljava.lang.object; means Object[]

    0 讨论(0)
  • 2020-12-13 04:52

    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 
    
    0 讨论(0)
提交回复
热议问题