什么是Klass& KlassKlass [英] What is Klass & KlassKlass

查看:644
本文介绍了什么是Klass& KlassKlass的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是 Klass & JVM Hotspot Implementation中的 KlassKlass

What is Klass & KlassKlass in JVM Hotspot Implementation?

据我所知,呈现Perm生成 Klass 是Java类的内部表示(假设 A )&它将保存有关类结构的基本信息,包括字节码。它将作为对象本身存储。 A类的每个对象都有一个指向内部表示的指针 Klass 存在于PermGen中

As far as I understood from the article Presenting the Perm Generation, Klass is the internal representation of a Java class (let's say A) & it will hold the basic information about the structure of the class including the bytecode. It will be stored as an object itself. Every object of the class A will have a pointer to the internal representation Klass present in PermGen

KlassKlass是内部的表示 Klass 类本身。为什么需要 KlassKlass ?它存储了哪些额外信息?

KlassKlass is the internal representation of the Klass class itself. Why does KlassKlass is needed? What extra information is it storing?

另外, KlassKlass的 Klass 指针指向自身,我也不理解。

Also, a KlassKlass's Klass pointer points to itself, I didn't understand it either.

推荐答案

永久代又名permgen是指的存储所有类相关信息的位置。它有时被称为方法区域。

Permanent Generation a.k.a permgen is the referred to the place where all the class related information is stored. It is occasionally referred as method-area.

让我们举例说明以下代码:

Lets take an example of the following code:

public class Parent
{
    ...
}

这里:


  • new Parent()是一个对象 Parent class。

  • (new Parent())。getClass()指父的 Klass 。此对象的引用类型为 java.lang.Class< Parent> 。这将存储有关 Parent 的注释,构造函数,字段,方法,其继承(超类,接口)等的信息。

  • KlassKlass将是(new Parent())。getClass()。getClass()。该对象的引用类型是 java.lang.Class< java.lang.Class> 。这定义了有关 java.lang.Class 的注释,构造函数,字段,方法,它的继承(超类,接口)等的信息。

  • new Parent() is an object of Parent class.
  • (new Parent()).getClass() refers to Klass of Parent. The reference type for this object would be java.lang.Class<Parent>. This would store the information about Parent's annotations, constructors, fields, methods, its inheritance (superclass, interfaces) etc
  • KlassKlass would be (new Parent()).getClass().getClass(). The reference type for this object would be java.lang.Class<java.lang.Class>. This defines the information about java.lang.Class's annotations, constructors, fields, methods, its inheritance (superclass, interfaces), etc.

从理论上讲,这个链可以继续,但KlassKlassKlass与KlassKlass相同。

Theoretically, this chain could go on but KlassKlassKlass would be same as KlassKlass.

Inshort,KlassKlass意味着您将拥有一个 java.lang.Class 对象,该对象定义 java.lang.Class 本身的行为。

Inshort, KlassKlass means that you would have one java.lang.Class object which defines the behavior of java.lang.Class itself.

希望这有助于

这篇关于什么是Klass&amp; KlassKlass的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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