简体   繁体   中英

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. 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).

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. 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.

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. 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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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