JVM Link Type

In some Java literature, the statement

Link Type Virtual Java machine smarter named Link

widely popular. However, authors, as a rule, do not explain why such a statement is valid. Another thing that will make me understand this is

What does JVM reference type mean? Does the JVM contain itself on the heap?

Would thank for this explanation.

Thanks,

Ashmawy

+4
source share
4 answers

The word you are looking for is irony :

using words to convey a meaning that is opposite to its literal meaning

Using smart in this sentence is clearly ironic. "The figurative type of the Java virtual machine is given the obviously really stupidly obvious name" link "- this is another way to read this sentence.

+10
source

I think the part is cleverly related to the fact that the reference type is usually called pointer , which requires the reader to learn two terms. JVM terminology simply uses the term reference for this.

There is also a historical context.

When Java was introduced, its biggest competitor was C ++. The main problem with C ++ was that it was too complicated. Java initially positioned itself as a lightweight alternative to C ++. It had syntax very close to C ++, but all complex things (operator overloading, templates, multiple pass mechanisms) were removed from this language, etc.

And now the catch is coming ...

Java was originally sold as without pointers . The rationale for saying this was that pointers were considered the most difficult task of C ++, therefore, if Java did not have them, it would be a simpler language.

The clever part, therefore, stems from the simple invention of another term for “pointer”. Call them with a link, and you can declare that Java has no pointers (but no links).

This led to a lot of debate and caused a lot of confusion, especially since C ++ already had the term “link” and uses it for something else (although it is conceptually slightly related). The discussion usually focuses on two camps, where one of them claims that Java really does not have pointers, since you cannot do pointer arithmetic with them, and they do not directly represent the memory address, while the other camp indicates that you have not to be able to do arithmetic with a pointer, to call it a pointer.

In other words, whether it was reasonable to use the term reference is still open for discussion.

+5
source

This becomes clearer when the entire paragraph is taken into context:

The link type of a Java virtual machine is tricked into being called a link. Reference type values ​​refer to three options: class type, interface type, and array type. All three types have values ​​that are references to dynamically created objects. Class type values ​​are references to class instances. Array type values ​​are references to arrays that are fully functional objects in the Java virtual machine. Interface type values ​​are references to class instances that implement the interface. Another reference value is a null value, which indicates that the reference variable does not apply to any object.

(taken from http://javadeveloper-jayaprakash-m.blogspot.com/ )

I would suggest that the “smart name” bit refers to the fact that links are of three different types, and the JVM can distinguish each of them.

0
source

Or maybe only the concept expresses a different approach developed by JVM designers for memory management.

If you recall in C / C ++, you will have the freedom to allocate memory for the variable either on the local stack or on the global heap. In C ++, it is possible to allocate memory for an object in the local method stack, and then pass the entire object as a parameter to other methods.

Java designers have taken this freedom from developers. You simply cannot create objects on the local stack, only on the global heap. Therefore, each variable of type Class / Interface / Array is really a reference to some memory address on the heap. And you cannot pass an object by value only by reference.

If you don’t have a choice, you don’t even need to think about what type of variable you have - a value type or a reference type.

-1
source

Source: https://habr.com/ru/post/1336569/


All Articles