Concurrency Analysis of Java RMI Using Source Transformation and Verisoft By Tim Cassidy Supervised...

Preview:

Citation preview

Concurrency Analysis of Java RMI Using

Source Transformation and Verisoft

By Tim Cassidy

Supervised by

Jim Cordy

Tom Dean

Special Thanks

My father My supervisors Juergen Dingel Dean Jin Debby Robertson

Motivation

Concurrency– Can improve performance– Can degrade performance

Expand the scope of Verisoft (a concurrency analysis tool)

Background

Modeling/Verification tools– Can provide useful insight into a model– But how to make the model

Concurrency Models– Threads and Processes (local and remote)

RMI – Remote Method Invocation

Source Transformation– What’s it good for?

Translation Rephrasing

Artifacts Used In My Solution

Why Verisoft?– Variety of problems inherent in Model

Checking/Verification – Model Construction Problem SOLVED!– State Space Explosion addressed up to a

predefined depth

Why Java RMI?– Flexible– Need to know basis

The Sequence Diagram for a Remote Method Invocation in Java RMI

Node2

RMIRegistry

Node3

RemoteObject

Node1

ClientProcess Naming

request remote object

returns ServerStub

Any Method Invocation

return value

returns ServerStub

request remote object

ServerStub

Any Method Invocation (marshalled)

return value (marshalled)

Overview of JCUV

Transform Java RMI (distributed) to C++ Using Verisoft on single machine (inter-process)

Three Step Process – First Step (powered by TXL)

Transform Java to C++

– Second Step (powered by TXL) Transform C++ to C++ using Verisoft

– Third Step Use Verisoft to analyze resultant/generated code

JavaClient Naming Stub (Proxy)

RMIRegistry

RemoteObject

C++Client

RemoteObject

C++ Using Verisoft Libraries

Naming and RMI RegistryStub (Proxy)

Verisoft RuntimeJava to

C++

Java toC

++

Client Naming and RMI RegistryRemoteObject

Stub (Proxy)

RMICompile

UserDefinedClass

User DefinedClass Implicit Class (provided by

the compiler vendor)

TransformationSource Transformation

No Transformation

LEGEND

Implicit Source Transformation(done by compiler vendor)

ImplicitTransformation

ImplicitClass

Step 1

Step 2

Step 3

UnicastRemoteObject

UnicastRemoteObject

UnicastRemoteObject

First Step

Semantic preserving transformation from Java to C++

Limitations– Unique Naming/Renaming – Constructors – Nested/Inner Classes – Inherent Weakness of Reference Counting

Memory Management Strategy – AND MORE!!!

Example of First Step Transform

JavaClient Naming Stub (Proxy)

RMIRegistry

RemoteObject

C++Client

RemoteObject

C++ Using Verisoft Libraries

Naming and RMI RegistryStub (Proxy)

Verisoft RuntimeJava to

C++

Java toC

++

Client Naming and RMI RegistryRemoteObject

Stub (Proxy)

RMICompile

UserDefinedClass

User DefinedClass Implicit Class (provided by

the compiler vendor)

TransformationSource Transformation

No Transformation

LEGEND

Implicit Source Transformation(done by compiler vendor)

ImplicitTransformation

ImplicitClass

Step 1

Step 2

Step 3

UnicastRemoteObject

UnicastRemoteObject

UnicastRemoteObject

Second Step

Generation of RMI related classes– Generation of Naming– Generation of Remote Object Stub (Proxy For

Remote Object)– Generation of UnicastRemoteObject

Limitations– Marshalling/Unmarshalling of Objects

JavaClient Naming Stub (Proxy)

RMIRegistry

RemoteObject

C++Client

RemoteObject

C++ Using Verisoft Libraries

Naming and RMI RegistryStub (Proxy)

Verisoft RuntimeJava to

C++

Java toC

++

Client Naming and RMI RegistryRemoteObject

Stub (Proxy)

RMICompile

UserDefinedClass

User DefinedClass Implicit Class (provided by

the compiler vendor)

TransformationSource Transformation

No Transformation

LEGEND

Implicit Source Transformation(done by compiler vendor)

ImplicitTransformation

ImplicitClass

Step 1

Step 2

Step 3

UnicastRemoteObject

UnicastRemoteObject

UnicastRemoteObject

Third Step

Necessary Steps– Compile and link C++ code– Configure system_file.VS prior to Verisoft run-

time– Execute Verisoft (manual, guided, automatic)

First Step Experiment

Over 14,000 lines of Java code (all associated with java.util.Hashtable) – Ran 100 C++ tests on the resultant code and it

functioned in an identical manner to the original Java code

JCUV Experiments

Two small Java RMI applications were analyzed– Trivial deadlock in one– Divergence was found in the other (with sufficient

clients and single server)

Future Work

Eventual goal would be to analyze any form of concurrency implemented in Java– More generalized use of the Java RMI framework– Internet communication without the use of RMI– Simple thread communication

Use JCUV on large and more realistic pieces of Java RMI code

Contributions

Concurrency can be a source of inconsistent problems and therefore debugging can be difficult or even impossible

Modelling/Verification tools - difficult and sometimes simply intractable to attempt a transformation from a programming language to a modelling language

Contributions (cont’d)

My approach attempts to simplify the creation of a model– Three step transformation– From Java code that makes use of RMI to C++

that uses Verisoft

Related Work

Java PathFinder and Bandera– Supports Linear Temporal Logic or Computation

Tree Logic (better solution to Requirement Specification problem)

– Poor support for Output Interpretation problem– Not capable of transforming/translating Java RMI

into a modelling language

Simple TXL Rule

rule putSemiColonAtEndOfClass replace [class_or_interface_type_declaration] ClassOrInterfaceHeader [class_or_interface_header] '{ ClassBodyDecl [repeat class_body_declaration] '} by ClassOrInterfaceHeader '{ ClassBodyDecl '} ';end rule

Realistic TXL RuleType out rule manually

Simple Deadlock Example Code

public class PeerA extends UnicastRemoteObject implements PeerAInterface, Serializable{

synchronized public void callBack () { //never make it into here }

synchronized public void run () { try { String name = "PeerB"; PeerBInterface peerB = (PeerBInterface) Naming.lookup(name); peerB.executeTask(); } catch (Exception exception_){ exception_.printStackTrace(); } }

public static void main(String args[]) { try { String name = "PeerA"; PeerAInterface peerA = new PeerA(); Naming.rebind(name, peerA); peerA.run(); } catch (Exception exception_){ exception_.printStackTrace(); } }}

public class PeerB extends UnicastRemoteObject implements PeerBInterface, Serializable{

public void executeTask(){ try { String name = "PeerA"; PeerAInterface peerA = (PeerAInterface) Naming.lookup(name); peerA.callBack(); } catch (Exception exception_){ exception_.printStackTrace(); } }

public static void main(String[] args) { String name = "PeerB"; try { PeerB peerB = new PeerB(); Naming.rebind(name, peerB); } catch (Exception exception_) { exception_.printStackTrace(); } }}