Systemoutprintln here in foo this systemoutprintln

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ew Exception();! !}! }! •  What happens if we do (new C()).foo();? CIS120 / Spring 2012 Abstract Stack Machine Workspace (new C()).foo();! CIS120 / Spring 2012 Stack Heap Abstract Stack Machine Workspace (new C()).foo();! CIS120 / Spring 2012 Stack Heap Abstract Stack Machine Workspace Stack ().foo();! Allocate a new instance of C in the heap. (Skipping details of trivial Constructor.) CIS120 / Spring 2012 Heap C! Abstract Stack Machine Workspace ().foo();! CIS120 / Spring 2012 Stack Heap C! Abstract Stack Machine Workspace this.bar();! System.out.println(
 “here in foo”);! Stack _;! Heap C! this! Save a copy of the current workspace in the stack, leaving a “hole”, wriren _, where we return to. Push the this pointer, followed by arguments (in this case none) onto the stack. Use the dynamic class to lookup the method body from the class table. CIS120 / Spring 2012 Abstract Stack Machine Workspace this.bar();! System.out.println(
 “here in foo”);! CIS120 / Spring 2012 Stack _;! this! Heap C! Abstract Stack Machine Workspace this.baz();! System.out.println(
 “here in bar”);! Stack _;! this! _;! System.out.println(
 “here in foo”);! this! CIS120 / Spring 2012 Heap C! Abstract Stack Machine Workspace this.baz();! System.out.println(
 “here in bar”);! Stack _;! this! _;! System.out.println(
 “here in foo”);! this! CIS120 / Spring 2012 Heap C! Abstract Stack Machine Workspace throw new Exception();! Stack _;! this! _;! System.out.println(
 “here in foo”);! this! _;! System.out.println(
 “here in bar”);! this! CIS120 / Spring 2012 Heap C! Abstract Stack Machine Workspace throw new Exception();! Stack _;! this! _;! System.out.println(
 “here in foo”);! this! _;! System.out.println(
 “here in bar”);! this! CIS120 / Spring 2012 Heap C! Abstract Stack Machine Workspace throw ();! Stack _;! Heap C! this! _;! System.out.println(
 “here in foo”);! this! _;! System.out.println(
 “here in bar”);! this! CIS120 / Spring 2012 Exception! Abstract Stack Machine Workspace throw ();! Stack _;! Heap C! this! Discard the current workspace. Then, pop s...
View Full Document

This document was uploaded on 11/24/2013.

Ask a homework question - tutors are online