|
|
Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
In the Java virtual machine, memory is allocated on the garbage-collected heap only as objects. There is no way to allocate
memory for a primitive type on the heap, except as part of an object. If you want to use a primitive type where an Object reference is needed, you can allocate a wrapper object for the type from the java.lang package. For example, there is an Integer class that wraps an int type with an object. Only object references and primitive types can reside on the Java stack as local variables. Objects
can never reside on the Java stack.
The architectural separation of objects and primitive types in the JVM is reflected in the Java programming language, in which
objects cannot be declared as local variables. Only object references can be declared as such. Upon declaration, an object
reference refers to nothing. Only after the reference has been explicitly initialized -- either with a reference to an existing
object or with a call to new -- does the reference refer to an actual object.
In the JVM instruction set, all objects are instantiated and accessed with the same set of opcodes, except for arrays. In
Java, arrays are full-fledged objects, and, like any other object in a Java program, are created dynamically. Array references
can be used anywhere a reference to type Object is called for, and any method of Object can be invoked on an array. Yet, in the Java virtual machine, arrays are handled with special bytecodes.
As with any other object, arrays cannot be declared as local variables; only array references can. Array objects themselves
always contain either an array of primitive types or an array of object references. If you declare an array of objects, you
get an array of object references. The objects themselves must be explicitly created with new and assigned to the elements of the array.
new opcode. Two one-byte operands follow the new opcode. These two bytes are combined to form a 16-bit index into the constant pool. The constant pool element at the specified
offset gives information about the class of the new object. The JVM creates a new instance of the object on the heap and pushes
the reference to the new object onto the stack, as shown below.| Opcode | Operand(s) | Description |
|---|
new |
indexbyte1, indexbyte2 | creates a new object on the heap, pushes reference |
The next table shows the opcodes that put and get object fields. These opcodes, putfield and getfield, operate only on fields that are instance variables. Static variables are accessed by putstatic and getstatic, which are described later. The putfield and getfield instructions each take two one-byte operands. The operands are combined to form a 16-bit index into the constant pool. The constant pool item at that index contains information about the type, size, and offset of the field. The object reference is taken from the stack in both the putfield and getfield instructions. The putfield instruction takes the instance variable value from the stack, and the getfield instruction pushes the retrieved instance variable value onto the stack.