Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A static reference has the following two components in the JVM: The type of the

ID: 3800933 • Letter: A

Question

A static reference has the following two components in the JVM:

The type of the reference;

The fully qualified name of the reference, including its host class.

From a security perspective for the JVM, investigate why static references are as described above.

Why is the type of the reference included with each get static instruction?

It might be more efficient to use the relative offset of a static field within a class in lieu of its name. Why are offsets not used in the JVM get static instruction?

Explanation / Answer

Static methods are stored in the PermGen section of the heap.

Only the variables and technical values are stored in PermGen space.

If your static variable is a reference to an object then that object is stored in the normal sections of the heap but not inPERMGEN space.

2) A call to a static method generates a call instruction. but a call to an instance method generates a callvirt instruction, which also checks for a null object references. A static constructor must be called before the class is referenced for the first time in your program. A static constructor is only called one time, and a static class remains in memory for the lifetime of the application domain in which your program resides.

3) when the compilation is done in JVM there are two additional bytes associated with the static instruction, namely the "branch bytes". These bytes are composed to a single short value to determine the offset - namely, how far the instruction pointer should "jump" when the condition is satisfied.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote