“This is the sixth day of my participation in the August More Text Challenge. For details, see: August More Text Challenge.”

The introduction

Today is day 6. Last time WE talked about what information is contained after an object is created, but what is the purpose of creating an object? (serious), of course it is for use, so the question is how we find it, hee hee, today we will talk about the object of the interview, are you happy, if you are not happy, I am happy, because tomorrow is Saturday, today is Friday. My attitude towards work is that everything can be moved to next Monday (my prince is having a nice weekend).

Object

In Java, we manipulate objects using references on the stack, and the Java Virtual Machine Specification defines two types: One is the basic type, the other is the reference type, but does not specify how the reference type is to access the location of the object, so the access mode is defined by the VIRTUAL machine itself, generally, there are the following two access modes:

  • Use the handle
  • Direct Pointers

Use the handle

If you use handle access, the Java heap allocates a special memory space for the handle pool. Reference is the direct address of the object, but it will be stored in the handle pool. I’m looking for an object, I’m looking for a reference on the stack, and then reference says, I only know the address in the handle pool, you go to the handle pool, and then I go to the handle pool, and the handle pool says, I know the address of the instance pool and the type pool, let’s see if that’s what you want, and I go to the instance pool and the type pool, and there it is.

Advantage: The advantage of this access is that no matter where the object is, even if it is on the tile, I don’t have to move my reference. I can just change the position in the handle pool.

Direct Pointers

You can simply store the address of the object in reference

Advantage: advantage is access speed is fast, save overhead. Since there are so many Java objects, this is a big cost savings, and no one likes a black sheep!

digression

I thought I wouldn’t write the article from the beginning, but now it’s day 6, I’ve grown up, how about you? Finally, thanks to the Nuggets, let’s go!