Static Analysis of Object References in RMIbased Java

Static Analysis of Object References in RMI-based Java Software Mariana Sharp Atanas (Nasko) Rountev Ohio State University

Reference Analysis for Java § § Which objects may variable x refer to? Builds a points-to graph x = new A(); x f y = new B(); x. f = y; o 1 y o 2 Nasko Rountev - ICSM'05 2

Uses of Reference Information § § Clients: SE tools and compilers Object read-write information § Side-effect analysis, dependence analysis Call graph construction § For interprocedural static analyses § De-virtualization and inlining Escape analysis § Object lifetime for dependence analysis; synchronization removal; stack allocation Nasko Rountev - ICSM'05 3

RMI-Based Distributed Java Applications § § Java Remote Method Invocation (RMI) § Object references that cross JVM boundaries § Invocations of remote methods § Parameter passing for entire object graphs Open questions § Correct semantic definition of reference analysis for RMI-based Java applications § Practical analysis algorithms Nasko Rountev - ICSM'05 4

Contributions § Theoretical definition of reference analysis for distributed RMI-based Java applications § § Analysis algorithm § § Generalizes an algorithm for non-distributed Java programs Static analyses for program understanding § § § Foundation for many other analyses Inter-component dependencies Reducing the cost of serialization at RMI calls Analysis implementation and evaluation Nasko Rountev - ICSM'05 5

RMI Basics § Code for a set of components C 1, C 2, …, Cn § Each Ci executes on a different JVM § Remote class: implements java. rmi. Remote § Remote object: instance of a remote class § Remote reference: pointer to a remote object § Remote call: x. m( ), x is a remote reference interface Listener extends java. rmi. Remote { void update(Event b); } update class My. Listener implements Listener extends … { void update(Event b) { … } } update Nasko Rountev - ICSM'05 6

Component “Channel” interface Channel extends java. rmi. Remote { void add(Listener c); add void notify(Event d); notify } class My. Channel implements Channel extends … { private Listener[ ] LST = new Listener[100]; void add(Listener c) { LST[n++] = c; } add void notify(Event d) { … } notify static void main() main { Channel e = new My. Channel(); Naming. bind(“foo”, e); } …} Nasko Rountev - ICSM'05 7

Adding a Listener Component C 1 My. Channel LST array c RMI Registry “foo” Component C 2 f g My. Listener Channel f = (Channel) Naming. lookup(“foo”); Listener g = new My. Listener(); f. add(g); add LST[n++] = c; Nasko Rountev - ICSM'05 8

Component “Channel” class Event implements Serializable { … private Date dt = new Date(); } interface Listener extends java. rmi. Remote { void update(Event b); } update class My. Channel implements Channel extends … { void notify(Event d) { notify for (…) LST[i]. update(d); update } …} Nasko Rountev - ICSM'05 9

Announcing an Event Component C 1 Component C 2 My. Channel LST My. Listener b array d Eventcopy dt Date notify(new Event()); LST[i]. update(d); update Nasko Rountev - ICSM'05 10

Theoretical Model § § Names for locals and formals: v 1, v 2, v 3, … § Label with the component id Names for site s “new X()” – s 1, s 2, s 3, … Names for de-serialized objects: s k, i § Exists in the JVM of Ci, but the original object was created inside the JVM of Ck Local points-to edges in component Ci § ( v i , s x )L or ( s 1 y , fld, s 2 x )L § x = i or x = k, i ; y = i or y = k, i Nasko Rountev - ICSM'05 11

Theoretical Model (cont) § § Remote points-to edges in component Ci § ( v i , s x )R or ( s 1 y , fld, s 2 x )R § the target object is a remote object Effects of v 1 = v 2 in Ci § § For ( v 2 i , s y )L/R create ( v 1 i , s y )L/R Effects of v 1 = v 2. fld in Ci § For ( v 2 i , s 2 y )L and ( s 2 y , fld, s 1 x )L/R create ( v 1 i , s 1 x )L/R Nasko Rountev - ICSM'05 12

Theoretical Model (cont) § § Effects of v. m(w) in Ci for ( v i , s x )R § Remote call to method m in Cx Create ( m. this x , s x )L For ( w i , s 2 y )L/R if s 2 y is a remote object § Create ( p x , s 2 y )R formal p For ( w i , s 2 y )L if s 2 y is a non-remote serializable object § Take the graph of serializable objects starting at s 2 y and create a copy of the graph in Cx § Create ( p x , s 2 z )L formal p Nasko Rountev - ICSM'05 13
![Analysis Algorithm § Pointer Assignment Graph [Lhotak. Hendren. CC 03] § Nodes are variables Analysis Algorithm § Pointer Assignment Graph [Lhotak. Hendren. CC 03] § Nodes are variables](http://slidetodoc.com/presentation_image_h2/6515f8f8290735744a90f721da92af9f/image-14.jpg)
Analysis Algorithm § Pointer Assignment Graph [Lhotak. Hendren. CC 03] § Nodes are variables and object fields § Edges represent the flow of values § Each node has a local points-to set Pt. L and a remote points-to set Pt. R § v 1 = v 2 in Ci : edge node(v 2 i ) node(v 1 i ) § Represents the subset relationships Pt. L(v 2 i ) Pt. L(v 1 i ) and Pt. R(v 2 i ) Pt. R(v 1 i ) Nasko Rountev - ICSM'05 14

Analyses for Program Understanding § § § Inter-component dependencies between § a remote call from Ci to Ck § some statement in Ck § due to a memory location in Ck Inter-component dependencies between § a remote call from Ci to Ck § a remote call from Cj to Ck § due to a memory location in Ck Specialized serialization at remote calls § Acyclic object graph; unique types Nasko Rountev - ICSM'05 15

Experimental Study § § § 11 RMI applications § Between 12 and 125 methods § Analysis includes ~7000 library methods Implementation: Soot 2. 1 (Mc. Gill U. ) § Generalized the points-to analysis in Soot Analysis running time § 2. 8 GHz PC with 1 GB memory § Time: ~ 5 -6 minutes per application § Special handling of libraries – no replication § Open issue: pre-computed summary info Nasko Rountev - ICSM'05 16

Remote Call Sites § § § Passing of remote references and serialization are common High precision of the call graph at remote calls All remote call sites with serialization: used acyclic and uniquely-typed object graphs Nasko Rountev - ICSM'05 17

Conclusions and Future Work § § Theoretical foundations for reference analysis Practical algorithm § Needs more work on handling of the libraries Initial precision results are promising Open questions § Theoretical definitions of other analyses for RMI software (e. g. , for slicing) § More experimental results § § Additional RMI applications Precision for other analyses (e. g. , analysis of inter-component dependencies) Nasko Rountev - ICSM'05 18

Questions? Nasko Rountev - ICSM'05 19
- Slides: 19