concurrency analysis of java rmi using source transformation and verisoft by tim cassidy supervised...

24
Concurrency Analysis of Java RMI Using Source Transformation and Verisoft By Tim Cassidy Supervised by Jim Cordy Tom Dean

Upload: ada-small

Post on 25-Dec-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Concurrency Analysis of Java RMI Using Source Transformation and Verisoft By Tim Cassidy Supervised by Jim Cordy Tom Dean

Concurrency Analysis of Java RMI Using

Source Transformation and Verisoft

By Tim Cassidy

Supervised by

Jim Cordy

Tom Dean

Page 2: 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

Page 3: Concurrency Analysis of Java RMI Using Source Transformation and Verisoft By Tim Cassidy Supervised by Jim Cordy Tom Dean

Motivation

Concurrency– Can improve performance– Can degrade performance

Expand the scope of Verisoft (a concurrency analysis tool)

Page 4: Concurrency Analysis of Java RMI Using Source Transformation and Verisoft By Tim Cassidy Supervised by Jim Cordy Tom Dean

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

Page 5: Concurrency Analysis of Java RMI Using Source Transformation and Verisoft By Tim Cassidy Supervised by Jim Cordy Tom Dean

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

Page 6: Concurrency Analysis of Java RMI Using Source Transformation and Verisoft By Tim Cassidy Supervised by Jim Cordy Tom Dean

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)

Page 7: Concurrency Analysis of Java RMI Using Source Transformation and Verisoft By Tim Cassidy Supervised by Jim Cordy Tom Dean

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

Page 8: Concurrency Analysis of Java RMI Using Source Transformation and Verisoft By Tim Cassidy Supervised by Jim Cordy Tom Dean

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

Page 9: Concurrency Analysis of Java RMI Using Source Transformation and Verisoft By Tim Cassidy Supervised by Jim Cordy Tom Dean

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!!!

Page 10: Concurrency Analysis of Java RMI Using Source Transformation and Verisoft By Tim Cassidy Supervised by Jim Cordy Tom Dean

Example of First Step Transform

Page 11: Concurrency Analysis of Java RMI Using Source Transformation and Verisoft By Tim Cassidy Supervised by Jim Cordy Tom Dean

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

Page 12: Concurrency Analysis of Java RMI Using Source Transformation and Verisoft By Tim Cassidy Supervised by Jim Cordy Tom Dean

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

Page 13: Concurrency Analysis of Java RMI Using Source Transformation and Verisoft By Tim Cassidy Supervised by Jim Cordy Tom Dean

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

Page 14: Concurrency Analysis of Java RMI Using Source Transformation and Verisoft By Tim Cassidy Supervised by Jim Cordy Tom Dean

Third Step

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

time– Execute Verisoft (manual, guided, automatic)

Page 15: Concurrency Analysis of Java RMI Using Source Transformation and Verisoft By Tim Cassidy Supervised by Jim Cordy Tom Dean

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

Page 16: Concurrency Analysis of Java RMI Using Source Transformation and Verisoft By Tim Cassidy Supervised by Jim Cordy Tom Dean

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)

Page 17: Concurrency Analysis of Java RMI Using Source Transformation and Verisoft By Tim Cassidy Supervised by Jim Cordy Tom Dean

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

Page 18: Concurrency Analysis of Java RMI Using Source Transformation and Verisoft By Tim Cassidy Supervised by Jim Cordy Tom Dean

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

Page 19: Concurrency Analysis of Java RMI Using Source Transformation and Verisoft By Tim Cassidy Supervised by Jim Cordy Tom Dean

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

Page 20: Concurrency Analysis of Java RMI Using Source Transformation and Verisoft By Tim Cassidy Supervised by Jim Cordy Tom Dean
Page 21: Concurrency Analysis of Java RMI Using Source Transformation and Verisoft By Tim Cassidy Supervised by Jim Cordy Tom Dean

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

Page 22: Concurrency Analysis of Java RMI Using Source Transformation and Verisoft By Tim Cassidy Supervised by Jim Cordy Tom Dean

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

Page 23: Concurrency Analysis of Java RMI Using Source Transformation and Verisoft By Tim Cassidy Supervised by Jim Cordy Tom Dean

Realistic TXL RuleType out rule manually

Page 24: Concurrency Analysis of Java RMI Using Source Transformation and Verisoft By Tim Cassidy Supervised by Jim Cordy Tom Dean

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(); } }}