Static Extraction of Hierarchical Runtime Object Graphs...
Transcript of Static Extraction of Hierarchical Runtime Object Graphs...
Static Extraction of Hierarchical Runtime Object Graphs –Tool Demonstration
Marwan Abi-Antoun Jonathan Aldrich
School of Computer Science
Carnegie Mellon University
2
Object-Oriented Code vs. Runtime Structure
“An object-oriented program's runtime structureoften bears little resemblance to its code structure.
The code structure [...] consists of classes in fixed inheritance relationships.
A program's runtime structure consists of [...]
networks of communicating objects [...]
Trying to understand one from the other is like trying
to understand the dynamism of living ecosystems from the static taxonomy of plants and animals, and
vice versa.” (Gamma et al., 1994)
3
Object Diagram: a diagram of object structures which shows object instances exclusively.
Source: E. Gamma, R. Helm, R. Johnson, and J. Vlissides. Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley, 1994. (CD-ROM edition)
[…]
[…]
4
ToolButton
ToolButton
SelectionTool
fTool
JavaDrawApp
fListener
PaletteIcon
fIcon
ToolButton
SelectionTool
fTool
JavaDrawApp
fListener
fIcon
ToolButton
SelectionTool
fTool
JavaDrawApp
fListener
fIcon
ToolButton
ToolButton
Main
app
Undoable
SelectionTool
SelectionTool
myUndoActivity
JavaDrawApp
myDrawingEditor
Tool
fChild
AbstractTool$EventDispatchermyEventDispatcher
Object
SelectionTool
myUndoActivity
myDrawingEditorfChild
AbstractTool$EventDispatchermyEventDispatcher
SelectionTool
SelectionTool
myUndoActivity
JavaDrawApp
myDrawingEditor
Tool
fChild
AbstractTool$EventDispatcher
myEventDispatcher
SelectionTool
myUndoActivity
myDrawingEditor
ToolfChild
AbstractTool$EventDispatchermyEventDispatcher
myUndoActivitymyDrawingEditor
fChild
AbstractTool$EventDispatcher
myEventDispatcher
myUndoActivity
JavaDrawApp
myDrawingEditor
fChild
myEventDispatcher
JavaDrawApp
JavaDrawApp
fSelectedToolButton
fDefaultToolButton
fTool
Animator
fAnimator
DrawingView
fView
Vector
mdiListeners
JComponent
desktop
JTextField
fStatusLine
EventListenerListlistenerList
fView
AnimatablefAnimatable
fDefaultToolButton
fSelectedToolButton
fTool
fAnimator
fView
Vector
mdiListeners
desktop
fStatusLine
listenerList
fSelectedToolButton
fDefaultToolButton
fTool
fAnimator
fView
Vector
mdiListeners
desktop
fStatusLine
listenerList
fSelectedToolButton
fDefaultToolButton
fTool
mdiListeners::elts
fAnimator
fView
desktop
fStatusLine
listenerList
fSelectedToolButton
fDefaultToolButton
fTool
mdiListeners::elts
fAnimator
fView
desktop
fStatusLine
listenerList
fSelectedToolButton
fDefaultToolButton
fTool
fAnimator
fView
mdiListeners
desktop
fStatusLine
listenerList
Rectangle
UndoableHandle
Image
DrawingEditor
Tool
fSelectGroup
fAnchorHandle
myDrawingEditor
AbstractTool$EventDispatcher
myEventDispatcher
DragTrackermyWrappedTool
fSelectGroup
fAnchorHandle
myDrawingEditor
AbstractTool$EventDispatchermyEventDispatcher
myWrappedTool
fSelectGroup
fAnchorHandle
myDrawingEditor
AbstractTool$EventDispatcher
myEventDispatcher DragTracker
myWrappedTool
fSelected
fNormal
fPressed
DimensionfSize
Vector
Object[]elementData
AbstractTool$EventDispatcher
myRegisteredListeners
myObservedTool
myObservedTool
myRegisteredListeners
myObservedTool
myRegisteredListeners
myObservedTool
myRegisteredListeners
myObservedTool
ToolListener
myRegisteredListeners::elts
myObservedTool
myRegisteredListeners
myUndoActivity
myDrawingEditor
myEventDispatcher
Figure
fAnchorFigure
listenerList[]
NULL_ARRAY[]
Tool support to extract runtime structure less mature
• Low-level objects
• No architectural abstraction
• Some analyses incorrectlyhandle aliasing
JavaDrawApp,
DrawingEditor,
represent one
runtime object.
Output of Womble on JHotDraw (15 KLOC)
Key Insight
Ownership domain annotations enable the extraction of sound hierarchical object graphs using static analysis.
6
Extracting sound hierarchical object graphs using static analysis
• Why static analysis?• Dynamic analysis shows object graphs for
a few program runs, not all
• Why sound?• To be most useful, show all objects and
relations that could exist at runtime
7
Model
View
Controller
figureChangeEvent(+):DrawingChangeEvent
fPoly(+):Shape
textFigure1(+):Drawing
myBorderOffset(+):Point2D
polyLineConnector(+):Connector
fStartDecoration(+):AbstractLineDecoration
fLocator(+):Locator
undoableHandle(+):Handle
myDrawingView(+):DrawingView
myUndoableActivity(+):UndoableAdapter
myAlignment(+):Alignment
myUndoManager(+):UndoManager
fStorageFormatManager(+):StorageFormatManager
myDefaultStorageFormat(+):StorageFormat
fAnimator(+):Thread
autoscrollInsets(+):Insets
app(+):DrawingEditor
fDefaultToolButton(+):ToolListener
textTool(+):Tool
bufferedUpdateStrategy(+):Painter
constrainer(+):PointConstrainer
menu(+):CommandListener
cmd(+):Command
system:Main
Extracting sound hierarchical object graphs using static analysis
• Hierarchical graphs• Flat graphs do not
provide architectural abstraction or scale
ToolButton
ToolButton
SelectionTool
fTool
JavaDrawApp
fListener
PaletteIcon
fIcon
ToolButton
SelectionTool
fTool
JavaDrawApp
fListener
fIcon
ToolButton
SelectionTool
fTool
JavaDrawApp
fListener
fIcon
ToolButton
ToolButton
Main
app
Undoable
SelectionTool
SelectionTool
myUndoActivity
JavaDrawApp
myDrawingEditor
Tool
fChild
AbstractTool$EventDispatchermyEventDispatcher
Object
SelectionTool
myUndoActivity
myDrawingEditorfChild
AbstractTool$EventDispatchermyEventDispatcher
SelectionTool
SelectionTool
myUndoActivity
JavaDrawApp
myDrawingEditor
Tool
fChild
AbstractTool$EventDispatcher
myEventDispatcher
SelectionTool
myUndoActivity
myDrawingEditor
ToolfChild
AbstractTool$EventDispatchermyEventDispatcher
myUndoActivitymyDrawingEditor
fChild
AbstractTool$EventDispatcher
myEventDispatcher
myUndoActivity
JavaDrawApp
myDrawingEditor
fChild
myEventDispatcher
JavaDrawApp
JavaDrawApp
fSelectedToolButton
fDefaultToolButton
fTool
Animator
fAnimator
DrawingView
fView
Vector
mdiListeners
JComponent
desktop
JTextField
fStatusLine
EventListenerListlistenerList
fView
AnimatablefAnimatable
fDefaultToolButton
fSelectedToolButton
fTool
fAnimator
fView
Vector
mdiListeners
desktop
fStatusLine
listenerList
fSelectedToolButton
fDefaultToolButton
fTool
fAnimator
fView
Vector
mdiListeners
desktop
fStatusLine
listenerList
fSelectedToolButton
fDefaultToolButton
fTool
mdiListeners::elts
fAnimator
fView
desktop
fStatusLine
listenerList
fSelectedToolButton
fDefaultToolButton
fTool
mdiListeners::elts
fAnimator
fView
desktop
fStatusLine
listenerList
fSelectedToolButton
fDefaultToolButton
fTool
fAnimator
fView
mdiListeners
desktop
fStatusLine
listenerList
Rectangle
UndoableHandle
Image
DrawingEditor
Tool
fSelectGroup
fAnchorHandle
myDrawingEditor
AbstractTool$EventDispatcher
myEventDispatcher
DragTrackermyWrappedTool
fSelectGroup
fAnchorHandle
myDrawingEditor
AbstractTool$EventDispatchermyEventDispatcher
myWrappedTool
fSelectGroup
fAnchorHandle
myDrawingEditor
AbstractTool$EventDispatcher
myEventDispatcher DragTracker
myWrappedTool
fSelected
fNormal
fPressed
DimensionfSize
Vector
Object[]elementData
AbstractTool$EventDispatcher
myRegisteredListeners
myObservedTool
myObservedTool
myRegisteredListeners
myObservedTool
myRegisteredListeners
myObservedTool
myRegisteredListeners
myObservedTool
ToolListener
myRegisteredListeners::elts
myObservedTool
myRegisteredListeners
myUndoActivity
myDrawingEditor
myEventDispatcher
Figure
fAnchorFigure
listenerList[]
NULL_ARRAY[]
8
Demonstration Outline
• Ownership annotations• Adding annotations
• Typechecking annotations
• Runtime structure• Extraction tool
• Real-World Example• JHotDraw
• Additional material• Static analysis
Ownership Domains
10
Ownership domains[Aldrich and Chambers, ECOOP’04]
• Each object defines conceptual groups (ownership domains) to hold its state
• Separate object’s internals from object’s boundary (accessible to outside)
• Ensure private state not leaked
• Distinguish different “subsystems” within object
11
Example: Sequence
head iterator
@Domains@Domains@Domains@Domains({“ownedownedownedowned”, “itersitersitersiters”})
classclassclassclass Sequence {
@Domain@Domain@Domain@Domain(“ownedownedownedowned”) Cons head;
public public public public @Domain@Domain@Domain@Domain(“itersitersitersiters”)
Iterator iterator() {return new return new return new return new Iterator(head);
}
}
Object
LEGEND
• Sequence has private state (head)• Should not be accessible to outside
• Sequence has iterators that are accessible to outside• Can also access private state
seq: Sequence
12
Sequence Code Structure
13
Sequence: Private Domain
• Each object has one or more domains• E.g., Sequence declares domains owned and iters
• Each object is in exactly one domain• E.g., head in domain owned; iterator in domain iters
head
owned
@Domains@Domains@Domains@Domains({“ownedownedownedowned”, “itersitersitersiters”})
classclassclassclass Sequence {
@Domain@Domain@Domain@Domain(“ownedownedownedowned”) Cons head;
public public public public @Domain@Domain@Domain@Domain(“itersitersitersiters”)
Iterator iterator() {return new return new return new return new Iterator(head);
}
}
seq: Sequence
Object
LEGEND
Domain
14
Sequence: Public Domain
• Each object has one or more domains• E.g., Sequence declares domains owned and iters
• Each object is in exactly one domain• E.g., head in domain owned; iterator in domain iters
head iterator
owned iters
@Domains@Domains@Domains@Domains({“ownedownedownedowned”, “itersitersitersiters”})
classclassclassclass Sequence {
@Domain@Domain@Domain@Domain(“ownedownedownedowned”) Cons head;
public public public public @Domain@Domain@Domain@Domain(“itersitersitersiters”)
Iterator iterator() {return new return new return new return new Iterator(head);
}
}
seq: Sequence
Object
Domain
LEGEND
15
Sequence Runtime Structure
state
list
iters
owned
object:Object
it:Iterator
cons:Cons
seq:Sequence
system:SequenceClient
16
Sequence Runtime Structure
• Collapse Sequence’s sub-structure
statelist
object:
Object
seq(+):
Sequencesystem:
SequenceClient
17
Encapsulation and Containment
(1) Strict encapsulation(private domain)
(2) Logical containment(public domain)
OWNED
seq:Sequence
head:ConsX
seq:Sequence
it:Iterator
ITERS
18
Annotation Tool Support
• Use Java 1.5 annotations
• Typechecker uses Eclipse JDT
• Warnings in Eclipse’s problem window
19
Demo: Checking Sequence
• Cannot return head of list• Head of list in private domain
• Stronger than making field private
• Cannot nullify head of list• Stronger than Java visibility (e.g., private)
• Iterate over list• Iterator in public domain
20
Ownership Domain Parameters
@DomainParams@DomainParams@DomainParams@DomainParams({“elemselemselemselems”})classclassclassclass Sequence {@Domain@Domain@Domain@Domain(“ownedownedownedowned<elemselemselemselems>”)Cons head;
…………}
@DomainParams@DomainParams@DomainParams@DomainParams({“elemselemselemselems”})classclassclassclass Cons {
@@@@DomainDomainDomainDomain(“elemselemselemselems”) Object obj; @@@@DomainDomainDomainDomain(“ownerownerownerowner<elemselemselemselems>”) Cons next;
}
• To share objects across domains• Add domain parameter to hold elements in list• Implicit domain parameter “owner”
(Same as me, a.k.a. “peer” or “same”)
ownedclientobjects
elems
seq : Sequence
:Cons
owner
Demo: Annotating Listeners
(Iteration 1)
22
Listeners Example
• Listeners tricky in object-oriented code
• Reuse annotated Sequence• Disguised as ArrayList
23
Listeners Code Structure
interfaceinterfaceinterfaceinterface Listener { }
classclassclassclass BaseChart implementsimplementsimplementsimplements Listener {
List< Listener> listeners;}classclassclassclass BarChart extendsextendsextendsextends BaseChart { }
classclassclassclass PieChart extendsextendsextendsextends BaseChart { }
classclassclassclass Model implementsimplementsimplementsimplements Listener {List<Listener> listeners;}
classclassclassclass Main {Model model;BarChart barChart;PieChart pieChart;
}
Class diagram by Eclipse UML.
24
Demo: Listeners example
• Tool to add default annotations• Declare owned private domain• Private field à place in domain owned
• owned: object fully encapsulated
• String à mark shared• shared: shared persistently or globally
• Method parameter à mark lent• lent: temporary alias within method
• Not a smart inference tool!
25
Standard and third-party libraries
• Annotate external code• Ideally, library provider adds annotations• Annotations shared amongst authors
• Only annotate parts of library in use
• Wizard to generate skeleton XML file
26
Listeners Runtime Structure (version 1)
• Listeners at the top-level
DOCUMENT VIEW
model:
Model
listeners:
List<Listener>
barChart:
BarChart
pieChart:
PieChart
listeners:
List<Listener>
Runtime Structure
28
Code Structure – Take 1
interfaceinterfaceinterfaceinterface Listener { }
classclassclassclass BaseChart implementsimplementsimplementsimplements Listener {
List< Listener> listeners;}classclassclassclass BarChart extendsextendsextendsextends BaseChart { }
classclassclassclass PieChart extendsextendsextendsextends BaseChart { }
classclassclassclass Model implementsimplementsimplementsimplements Listener {List<Listener> listeners;}
classclassclassclass Main {Model model;BarChart barChart;PieChart pieChart;
}
Class diagram extracted by Eclipse UML.
29
Code Structure – Take 2
interfaceinterfaceinterfaceinterface Listener { }
classclassclassclass BaseChart implementsimplementsimplementsimplements Listener {
List< Listener> listeners;}classclassclassclass BarChart extendsextendsextendsextends BaseChart { }
classclassclassclass PieChart extendsextendsextendsextends BaseChart { }
classclassclassclass Model implementsimplementsimplementsimplements Listener {List<Listener> listeners;}
classclassclassclass Main {Model model;BarChart barChart;PieChart pieChart;
}Class diagram by AgileJ.
30
• Who points to who?
• Do not distinguish between conceptually different instances of same class
• Extra details: abstract classes, interfaces, etc.
• No hierarchy
Code vs. Runtime Structure
DOCUMENT
VIEW
Class diagram extracted by AgileJ.
Demo: Annotating Listeners
(Iteration 2)
32
Change annotations
• Instance encapsulation
• May require changing code to avoid representation exposure, e.g., • Return copy instead of alias to internal List• Pass object linearly
33
Listeners Runtime Structure (version 2)
DOCUMENT
OWNED
VIEW
OWNED
OWNED
listeners:List<Listener>
barChart:BarChart
pieChart:PieChart
model:Model
listeners:List<Listener>
listeners:List<Listener>
X
pieChart.OWNED != barChart.OWNED
34
Abstraction by Ownership Hierarchy
• Push secondary objects underprimary objects using
(1) Strict encapsulation(private domain)
(2) Logical containment(public domain)
OWNED
seq:Sequence
head:ConsX
seq:Sequence
it:Iterator
ITERS
35
Hierarchy Provides Abstraction
• Can collapse object sub-structure
• Summary edges account for hidden objects
DOCUMENT
VIEW
model(+):Model
barChart(+):BarChart
pieChart(+):PieChart
36
Tool Features
• Control projection depth
• Collapse/expand substructure• Selected domain or • Selected object
• Summary edges
• Elide private domains
• Control object labeling
Case Study: JHotDraw
38
Extract As-BuiltRuntime Graph
Extract As-BuiltRuntime Graph
AnnotationsAnnotations
1. Add
3. Refine and iterate
CodeCode
Annotation/Extraction Process
2. Control Display4. (Optional) Change
code and refine
39
Annotation/Extraction Process
1. Choose top-level domains
2. Achieve desired number of objects in top-level domainsa) Push secondary objects under primary objectsb) Use abstraction by types to merge objects
3. Achieve appropriate visual detaila) Collapse or expand substructure of objectsb) Change projection depth across all objects
40
ConnectionFigure
Connector
DecoratorFigure
Handle
NullHandle TrackHandle
Locator
0..*
0..*
0..*2
Painter
PointConstrainer
Tool
DrawingEditor
DrawingView
CreationTool SelectionToolHandleTracker
Figure
Drawing
0..*
CompositeFigure
JHotDraw: Code Structure
Manually generated UML Class Diagram for JHotDraw [Riehle, Thesis 2000].
41
View
Model
Controller
ConnectionFigure
Connector
DecoratorFigure
Handle
NullHandle TrackHandle
Locator
0..*
0..*
0..*2
Painter
PointConstrainer
Tool
DrawingEditor
DrawingView
CreationTool SelectionToolHandleTracker
Figure
Drawing
0..*
CompositeFigure
JHotDraw: Model-View-Controller (MVC)
42
JHotDraw: Adding Annotations to Code
File: Main.java
43
JHotDraw: “30-second Architecture”
• Hide contents of domains• Dotted edges summarize field references
• Interestingly: no callback from M to C
Model
View
Controller
Main
44
JHotDraw: “30-minute Architecture”
Model
View
Controller
figureChangeEvent(+):DrawingChangeEvent
fPoly(+):Shape
textFigure1(+):Drawing
myBorderOffset(+):Point2D
polyLineConnector(+):Connector
fStartDecoration(+):AbstractLineDecoration
fLocator(+):Locator
undoableHandle(+):Handle
myDrawingView(+):DrawingView
myUndoableActivity(+):UndoableAdapter
myAlignment(+):Alignment
myUndoManager(+):UndoManager
fStorageFormatManager(+):StorageFormatManager
myDefaultStorageFormat(+):StorageFormat
fAnimator(+):Thread
autoscrollInsets(+):Insets
app(+):DrawingEditor
fDefaultToolButton(+):ToolListener
textTool(+):Tool
bufferedUpdateStrategy(+):Painter
constrainer(+):PointConstrainer
menu(+):CommandListener
cmd(+):Command
system:Main
Showing top-
level domains
and objects
LEGEND
formal_domain
domain1
domain2
Object:DeclaredType
Object1_with_Substructure (+):DeclaredType1
Object2:DeclaredType2
domain link
RootObject:Type
field reference
45
Model
owned
owned
View
Controller
figureChangeEvent(+):DrawingChangeEvent
fPoly(+):Shape
fFigures:Vector<Figure>
textFigure1:Drawing
_theQuadTree(+):QuadTree
fMap:MapfAttributes:
FigureAttributes
fDisplayBox:Shape
fPoints:Vector<Point>
myBorderOffset(+):Point2D
fListeners:Vector<DrawingChangeListener>
myDrawingView(+):DrawingView
fDrawingLockHolder:Runnable
polyLineConnector(+):Connector
fStartDecoration(+):AbstractLineDecoration
fLocator(+):Locator
undoableHandle(+):Handle
myUndoableActivity(+):UndoableAdapter
myAlignment(+):Alignment
myUndoManager(+):UndoManager
fStorageFormatManager(+):StorageFormatManager
myDefaultStorageFormat(+):StorageFormat
fAnimator(+):Thread
autoscrollInsets(+):Insets
app(+):DrawingEditor
fDefaultToolButton(+):ToolListener
textTool(+):Tool
bufferedUpdateStrategy(+):Painter
constrainer(+):PointConstrainer
menu(+):CommandListener
cmd(+):Command
system:Main
JHotDraw: “30-minute Architecture”
Showing Drawing’s sub-
structure
ToolButton
ToolButton
SelectionTool
fTool
JavaDrawApp
fListener
PaletteIcon
fIcon
ToolButton
SelectionTool
fTool
JavaDrawApp
fListener
fIcon
ToolButton
SelectionTool
fTool
JavaDrawApp
fListener
fIcon
ToolButton
ToolButton
Main
app
Undoable
SelectionTool
SelectionTool
myUndoActivity
JavaDrawApp
myDrawingEditor
Tool
fChild
AbstractTool$EventDispatchermyEventDispatcher
Object
SelectionTool
myUndoActivity
myDrawingEditorfChild
AbstractTool$EventDispatchermyEventDispatcher
SelectionTool
SelectionTool
myUndoActivity
JavaDrawApp
myDrawingEditor
Tool
fChild
AbstractTool$EventDispatcher
myEventDispatcher
SelectionTool
myUndoActivity
myDrawingEditor
ToolfChild
AbstractTool$EventDispatchermyEventDispatcher
myUndoActivitymyDrawingEditor
fChild
AbstractTool$EventDispatcher
myEventDispatcher
myUndoActivity
JavaDrawApp
myDrawingEditor
fChild
myEventDispatcher
JavaDrawApp
JavaDrawApp
fSelectedToolButton
fDefaultToolButton
fTool
Animator
fAnimator
DrawingView
fView
Vector
mdiListeners
JComponent
desktop
JTextField
fStatusLine
EventListenerListlistenerList
fView
AnimatablefAnimatable
fDefaultToolButton
fSelectedToolButton
fTool
fAnimator
fView
Vector
mdiListeners
desktop
fStatusLine
listenerList
fSelectedToolButton
fDefaultToolButton
fTool
fAnimator
fView
Vector
mdiListeners
desktop
fStatusLine
listenerList
fSelectedToolButton
fDefaultToolButton
fTool
mdiListeners::elts
fAnimator
fView
desktop
fStatusLine
listenerList
fSelectedToolButton
fDefaultToolButton
fTool
mdiListeners::elts
fAnimator
fView
desktop
fStatusLine
listenerList
fSelectedToolButton
fDefaultToolButton
fTool
fAnimator
fView
mdiListeners
desktop
fStatusLine
listenerList
Rectangle
UndoableHandle
Image
DrawingEditor
Tool
fSelectGroup
fAnchorHandle
myDrawingEditor
AbstractTool$EventDispatcher
myEventDispatcher
DragTrackermyWrappedTool
fSelectGroup
fAnchorHandle
myDrawingEditor
AbstractTool$EventDispatchermyEventDispatcher
myWrappedTool
fSelectGroup
fAnchorHandle
myDrawingEditor
AbstractTool$EventDispatcher
myEventDispatcher DragTracker
myWrappedTool
fSelected
fNormal
fPressed
DimensionfSize
Vector
Object[]elementData
AbstractTool$EventDispatcher
myRegisteredListeners
myObservedTool
myObservedTool
myRegisteredListeners
myObservedTool
myRegisteredListeners
myObservedTool
myRegisteredListeners
myObservedTool
ToolListener
myRegisteredListeners::elts
myObservedTool
myRegisteredListeners
myUndoActivity
myDrawingEditor
myEventDispatcher
Figure
fAnchorFigure
listenerList[]
NULL_ARRAY[]
Output of Womble
JHotDraw Runtime Object Graph
Static Analysis
47
Static analysis
• Build TypeGraph from program’s AST
• Convert to ObjectGraph that soundly approximates all runtime object graphs (ROG)
ROG: graph where nodes represent runtime objects, edges represent reference or usage relations
● Problem ● Approach ● Analysis ● Evaluation ● Conclusion
48
…
TypeGraph: show types, domains inside types, and objects in domains
BarChart
OWNED
listeners: List<Listener>
…
Main
DOCUMENT
VIEW
pieChart: PieChart
barChart:BarChart
model:Model List<Listener>
OWNED
head
ELTS
obj: Listener
M
Is-Aobj: Type
Object
Type Type
F
A
Formal Domain
Actual Domain
● Problem ● Approach ● Analysis ● Evaluation ● Conclusion
49
…
ObjectGraph: instantiate types, starting with root
BarChart
OWNED
listeners: List<Listener>
…
Main
DOCUMENT
VIEW
pieChart: PieChart
barChart:BarChart
model:Model List<Listener>
OWNED
head
ELTS
obj: Listener
M
Is-Aobj: Type
Object
Type Type
F
A
Formal Domain
Actual Domain
● Problem ● Approach ● Analysis ● Evaluation ● Conclusion
50
…
ObjectGraph: instantiate types, starting with root
BarChart
OWNED
listeners: List<Listener>
…
main: Main
DOCUMENT
VIEW
pieChart: PieChart
barChart:BarChart
model:Model List<Listener>
OWNED
head
ELTS
obj: Listener
M
Is-Aobj: Type
Object
Type Type
F
A
Formal Domain
Actual Domain
● Problem ● Approach ● Analysis ● Evaluation ● Conclusion
51
BarChart
OWNED
listeners: List<Listener>
…
ObjectGraph: instantiate types, show domains and objects inside domains
…
main: Main
DOCUMENT
VIEW
pieChart: PieChart
barChart:BarChart
model:Model List<Listener>
OWNED
head
ELTS
obj: Listener
M
Is-Aobj: Type
Object
Type Type
F
A
Formal Domain
Actual Domain
● Problem ● Approach ● Analysis ● Evaluation ● Conclusion
52
…
ObjectGraph: instantiate types, show domains and objects inside domains
…
main: Main
DOCUMENT
VIEW
pieChart: PieChart
barChart:BarChart
model:Model List<Listener>
OWNED
head
ELTS
obj: Listener
BarChart
OWNED
listeners: List<Listener>
M
Is-Aobj: Type
Object
Type Type
F
A
Formal Domain
Actual Domain
● Problem ● Approach ● Analysis ● Evaluation ● Conclusion
53
main: Main
VIEW
pieChart: PieChart…
ObjectGraph: instantiate types, show domains and objects inside domains
barChart: BarChart
OWNED
listeners: List<Listener>
List<Listener>
OWNED
head
ELTS
obj: Listener
MIs-A
obj: Type
Object
Type Type
F
A
Formal Domain
Actual Domain
DOCUMENT
model: Model…
● Problem ● Approach ● Analysis ● Evaluation ● Conclusion
54
main: Main
VIEW
pieChart: PieChart…
ObjectGraph: instantiate types, show domains and objects inside domains
barChart: BarChart
OWNED
listeners: List<Listener>
List<Listener>
OWNED
head
ELTS
obj: Listener
MIs-A
obj: Type
Object
Type Type
F
A
Formal Domain
Actual Domain
DOCUMENT
model: Model…
● Problem ● Approach ● Analysis ● Evaluation ● Conclusion
55
main: Main
VIEW
pieChart: PieChart…
ObjectGraph: instantiate types, show domains and objects inside domains
barChart: BarChart
OWNED
listeners: List<Listener>
List<Listener>
OWNED
head
ELTS
obj: Listener
MIs-A
obj: Type
Object
Type Type
F
A
Formal Domain
Actual Domain
DOCUMENT
model: Model…
● Problem ● Approach ● Analysis ● Evaluation ● Conclusion
56
main: Main
VIEW
pieChart: PieChart…
DOCUMENT
ObjectGraph: instantiate types, show domains and objects inside domains
model: Model…
barChart: BarChart
OWNED
M
listeners: List<Listener>
OWNED
head
ELTS
obj: Listener obj:
TypeObject
F
A
Formal Domain
Actual Domain
● Problem ● Approach ● Analysis ● Evaluation ● Conclusion
57
main: Main
VIEW
pieChart: PieChart…
DOCUMENT
ObjectGraph: pull objects from formal domains to actual domains
model: Model…
barChart: BarChart
OWNED
M
listeners: List<Listener>
OWNED
head
ELTS
obj: Listener obj:
TypeObject
F
A
Formal Domain
Actual Domain
● Problem ● Approach ● Analysis ● Evaluation ● Conclusion
58
main: Main
VIEW
pieChart: PieChart…
DOCUMENT
ObjectGraph: pull objects from formal domains to actual domains
model: Model…
barChart: BarChart
OWNED
M
listeners: List<Listener>
OWNED
head
ELTS
obj: Listener obj:
TypeObject
F
A
Formal Domain
Actual Domain
obj: Listener
● Problem ● Approach ● Analysis ● Evaluation ● Conclusion
59
main: Main
VIEW
pieChart: PieChart…
DOCUMENT
ObjectGraph: pull objects from formal domains to actual domains
model: Model…
barChart: BarChart
OWNED
M
listeners: List<Listener>
OWNED
head
ELTS
obj: Listener obj:
TypeObject
F
A
Formal Domain
Actual Domain
obj: Listener
obj: Listener
● Problem ● Approach ● Analysis ● Evaluation ● Conclusion
60
main: Main
VIEW
pieChart: PieChart…
DOCUMENT
ObjectGraph: merge objects, in one domain, that may alias, based on types
{model: Model, obj:Listener}…
barChart: BarChart
OWNED
M
listeners: List<Listener>
OWNED
head
ELTS
obj: Listener obj:
TypeObject
F
A
Formal Domain
Actual Domain
obj: Listener
class Model implements Listener {…}
● Problem ● Approach ● Analysis ● Evaluation ● Conclusion
61
main: Main
VIEW
pieChart: PieChart…
DOCUMENT
ObjectGraph: add edges to represent field references
{model: Model, obj:Listener}…
barChart: BarChart
OWNED
M
listeners: List<Listener>
OWNED
head
ELTS
obj: Listener obj:
TypeObject
F
A
Formal Domain
Actual Domain
obj: Listener
● Problem ● Approach ● Analysis ● Evaluation ● Conclusion
62
Conclusion
• Ownership domain annotationsenable extraction of hierarchicalruntime object graphs using static analysis
• Provide architectural abstraction by ownership hierarchy and by types