One property of a java program that is checked by the


Java Bytecode Analysis

One property of a Java program that is checked by the veri?er is that each object must be properly initialized before it is used. This property is fairly dif?cult to check. One relatively simple part of the analysis, however, is to guarantee that each subclass constructor must call the superclass constructor. The reason for this check is to guarantee that the inherited parts of every object will be initialized properly. If we were designing our own bytecode veri?er, there are two ways we might consider designing this check:

(i) The veri?er can analyze the bytecode program to make sure that on every ex- ecution of a subclass constructor, there is some call to a superclass constructor.

(ii) The veri?er can check that the ?rst few bytecode instructions of a subclass constructor contain a call to the superclass constructor, before any loop or jump inside the subclass constructor.

In design (i), the veri?er should accept every bytecode program that satis?es this condition and reject every bytecode program that allows some subclass constructor to complete without calling the superclass constructor. In design (ii), some subclass constructors that would be acceptable according to condition (i) will be rejected by the bytecode veri?er. However, it may be possible to design the Java source code compiler so that every correct Java source code program is compiled to bytecode that meets the condition described in design (ii).

(a) If you were writing a Java compiler and another person on your team was writing the bytecode veri?er, which design would you prefer? Explain brie?y.

(b) If you were writing a Java compiler and your manager told you that the standard veri?er used design (ii) instead of (i), could you still write a decent compiler? Explain brie?y.

(c) If you were writing a bytecode veri?er and your manager offered to double your salary if you satis?ed design condition (i) instead of (ii) but would ?re you if you failed, would you accept the offer? Explain in one sentence.

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: One property of a java program that is checked by the
Reference No:- TGS01270009

Expected delivery within 24 Hours