Formalising Java RMI with Explicit Code Mobility Alexander Ahern Nobuko Yoshida Department of Computing Imperial College London Motivation Distribution is important to modern object- (cid:132) oriented programming Yet, existing formalisms are insufficient: (cid:132) Single location (cid:133) No modelling of distributed runtime (cid:133) 2 DJ – Distributed Java First formalisation of Java RMI (cid:132) New primitives for type-safe code mobility (cid:132) A novel proof technique for type safety of (cid:132) distributed programs Proof of correctness of several RMI (cid:132) optimisations 3 Call Aggregation [Bogle & Liskov 1994, Yeung & Kelly 2003] int m1(RemoteObject r, int a) { int x = r.f(a); int y = r.g(a, x); int z = r.h(a, y); r nt e return z; e v r li e } C S x and y are dead from the client’s point of view 4 Call Aggregation [Bogle & Liskov 1994, Yeung & Kelly 2003] // Client int m1(RemoteObject r, int a) { (unit -> int) t = freeze() { int x = r.f(a); r nt e int y = r.g(a, x); e v r li e int z = r.h(a, y); C S return z; }; return r.run(t); } // Server int run((unit -> int) x) { return defrost(x); } 5 DJ – Model DJ = Java + distribution + new primitives and types Creates a closure e ::= freeze(T x) { e } | defrost(e, e) | … Evaluates a T ::= T -> T | … closure A new arrow type for closures 6 Runtime Syntax We require lots of syntax (cid:132) Don’t worry! You don’t need to remember this! 7 Networks consist Networks of zero or more JVMs executing in parallel JVM JVM Virtual machines Each machine communicate by Remote keeps a table of Method Invocations JVM classes, and has a JVM private memory 8 Remote Method Invocation Nature of parameters affects the nature of (cid:132) remote calls If a parameter is not a subtype of (cid:133) java.rmi.Remote, then it is passed by value For object parameters, this requires object (cid:132) serialisation This is the conversion of structured data into an array (cid:133) of bytes suitable for network transfer We model all of these features in DJ (cid:132) 9 Remote Method InvoByctesa artei on transferred to Deserialise the server 0 1 1 0 bytes into Serialise actual structured form parameters Network Network Evaluate local Deserialisation can trigger method call Bytes transferred to class downloading the client 1 0 1 0 Network Network Serialise Return value deserialised, returned return value to caller 10
Description: