简体   繁体   English

“java.lang.Class”类的对象在哪里

[英]Where do objects of "java.lang.Class" class reside

I searched a lot but I couldn't find the answer for where do objects of java.lang.Class class reside - is it the Heap or Metaspace/PermGen.我搜索了很多但找不到java.lang.Class类的对象所在位置的答案 - 是堆还是元空间/永久代。 My own understanding is that objects of java.lang.Class represents the class metadata so they should reside on Metaspace (or PermGen for pre-Java8).我自己的理解是java.lang.Class的对象代表类元数据,因此它们应该驻留在 Metaspace(或 PermGen for pre-Java8)上。

Could someone please confirm, and I need some official documentation which clearly mentions the same.有人可以确认一下吗,我需要一些明确提到相同内容的官方文件。

IMHO, objects of java.lang.Class class can't be considered as class metadata.恕我直言, java.lang.Class类的对象不能被视为类元数据。 Class metadata is nothing but JVM's internal representation of Java classes - basically when JVM loads .class file then it doesn't store all the bytecode present in that .class file, but creates an internal data structure that holds everything which is needed from that .class file and that gets stored in Metaspace or PermGen.类元数据只不过是 JVM 对 Java 类的内部表示——基本上,当 JVM 加载.class文件时,它不会存储该.class文件中存在的所有字节码,而是创建一个内部数据结构来保存该 .class 文件所需的所有内容.class文件,并将其存储在 Metaspace 或 PermGen 中。

So, based on my knowledge I would say objects of java.lang.Class class will reside on heap and class metadata of java.lang.Class class will reside on Metaspace or PermGen.因此,根据我的知识,我会说java.lang.Class类的对象将驻留在堆上,而java.lang.Class类的类元数据将驻留在 Metaspace 或 PermGen 上。 However, I can't give any official doc about first part of my statement, and offical doc for second part can be read over here .但是,我无法提供关于我声明第一部分的任何官方文档,第二部分的官方文档可以在此处阅读。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM