# SPO Exercise Session Lecture 15 ## Exercise 2.5 (p. 414, Crafting a Compiler) Tjek typefejl > The description of each instruction is always given in the context of Java Virtual Machine code that satisfies the static and structural constraints of [§4](https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html "Chapter 4. The class File Format"). In the description of individual Java Virtual Machine instructions, we frequently state that some situation "must" or "must not" be the case: "The _value2_ must be of type `int`." The constraints of [§4](https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html "Chapter 4. The class File Format") guarantee that all such expectations will in fact be met. If some constraint (a "must" or "must not") in an instruction description is not satisfied at run time, the behavior of the Java Virtual Machine is undefined. ## Exercise 2.6 (p. 414, Crafting a Compiler) Performance wise, it would take longer time to search for the value among all the values in the relevant scope. Having an address would be quicker than looking up the name with a hash table. A getarbitrary instruction would be "unsecure", since it would allow for accessing data that may otherwise be inaccessible (p. 403). This is only true, if "getarbitrary" was implemented without type checking. ## Exercise 2.10 (p. 415, Crafting a Compiler) It will use what is at the top of the stack, so it duplicates the reference, so it is still there when the first is consumed