Does the bytecode/JVM execution model impacts the decision of not having pointers like C/C++ in Java?
Well, One of the main features of JVM is Garbage collection so to answer this question, yes it does. As Java does not support pointers but references, which gives JVM the liberty of moving around objects in the memory and that takes place possibly during garbage collection. When the objects are moved in the memory, JVM updates all the references. The convenience of moving the objects around in the memory while a program is running permits it to recycle the memory with ease. If there are chunks of unused memory, then those should be released by a program. “Internally computers use pages of memory, which are quite large. If a sparsely used page of memory could have the few used bits moved into another page, then a page of memory can be freed. This increases the density of data to memory, improving cache performance. Sometimes this translates into performance improvements that can be quite dramatic.” (Buck, 2016)
Buck (2016) further states “Java’s Garbage Collector takes advantage of the use of references by temporarily blocking access to the data for a set of references. During that blockage of access, it moves the data around (to compact it). After the blockage, the reference to address table has the new memory addresses. Since the “functional” layer of the code never knew the addresses in the first place, this operation will not break a running Java program.”
References:
Buck, E. (2016). Does Java have Pointers? Available at: https://stackoverflow.com/questions/2629357/does-java-have-pointers (Accessed: 8 July 2017)