CSE647: Testing and Verification Homework 6 Solution (ver. 31 Oct) Due 26 Oct 2000 Scott Stoller 1. In lecture on 16 October, we mentioned two ways of organizing the class hierarchy in the wrapper approach to intercepting method invocations and method terminations: "one hierarchy" "separate hierarchies" C C CSS / \ / / C1 CSS C1 C1SS / \ / / C2 C1SS C2 C2SS \ C2SS Note: On the chalkboard, I wrote C' instead of CSS. Compare the advantages and disadvantages of these two organizations. Consider the effects on how method calls and field accesses are intercepted. Remember that the same piece of code (e.g., a method invocation or field access) might sometimes be executed on an unshared object and sometimes on a shared object. Answer: An advantage of "separate hierarchies" is that each stub class CiSS needs to declare wrappers only for methods declared by Ci, not for methods inherited by Ci. A disadvantage of "separate hierarchies" is that Ci and CiSS are not related (by inheritance), so the same code cannot be used for both shared and unshared instances. For example, consider "invokevirtual Ci.m". If we leave this unchanged, it can't be used for shared objects. If we change this to "invokevirtual CiSS.m", it can't be used for unshared objects. 2. In lecture, we proposed to use the wrapper approach to intercept method invocations and method terminations for call sites of the form "invokevirtual C.m" (i.e., we introduce a wrapper class CSS and a wrapper method CSS.m. and we do not modify the call site or the body of C.m). This approach does not quite work for call sites of the form "invokespecial C.m". Describe how to transform such call sites using the outside approach (mentioned in lecture). Be reasonably detailed about what the transformed bytecode looks like. Don't forget about method arguments and exceptions. Answer: See section 9.5.1 of "Design of Java Checker", available from the web page. That section is relatively self-contained. You don't need to read that entire document.