SlideShare a Scribd company logo
1 of 27
Download to read offline
1
No Java without Caffeine
A Tool for Dynamic Analysis of Java Programs
Yann-Gaël Guéhéneuc
Rémi Douence
Narendra Jussien
{guehene, douence, jussien}@emn.fr
École des Mines
de Nantes, France
Object Technology
International, Inc., Canada
Ladies and gentlemen…
My name is Yann-Gaël Guéhéneuc.
I present today our work on Caffeine, a tool for the dynamic analysis of Java programs.
We develop Caffeine with Rémi Douence and Narendra Jussien from the EMN.
My work is partly funded by Object Technology International, Inc.
2
2/23
Software understanding is about…
… Understanding!
n Do not hesitate to interrupt!
n Questions are most welcome!
Today, we are all attending a session on software understanding.
We should not forget that software understanding is first and foremost about
understanding.
Being from France, my accent might be a bit of a problem, so please, do not hesitate to
interrupt me, questions are most welcome.
3
3/23
Objectives
n Motivate the need for dynamic analysis
n Present the prototype models
n Detail the prototype implementation
n Describe a more complex example
n Summarize limitations and future work
Today, in my presentation:
First, I motivate the need for dynamic analysis, using on a verysimple example: The
analysis of a n-queens algorithm.
Second, I present the models used in our prototype.
Third, I detail our prototype implementation. I put the emphasis on issues and
limitations.
Fourth, I introduce a real-life example that (I hope) highlights the usefulness of dynamic
analyses and presents the integration of our tool with other tools for software
understanding.
Finally, I summarize the usefulness and the limitations of our tools and present some
future work.
4
4/23
Motivation
n Software understanding:
[Soloway et al., 1988]
– Code structure
– Conjecture
n Assistant
n Dynamic behaviour of Java programs
n Least modifications (source code, JVM)
Our motivation is software understanding.
Soloway et al. characterized software understanding as composed of inquiry episodes.
The maintainer, who tries to understand a program, first reads some code, asks a
question about this code, conjectures an answers, and searches the code and the
documentation for a confirmation of the conjecture.
Our goal is to develop an assistant which the maintainer uses to verify conjectures on the
runtime behaviour of the program with respect to the program structure.
We want our assistant to work with Java.
We need to analyze the dynamic behaviour of Java programs.
(I hope that I will convince you of the need for dynamic analyses in Java, in contrast
with the results presented in the Nokia experience report yesterday…)
5
5/23
Simple example (1/2)
n The n-queens problem:
– A n×n chessboard
– n queens
– An algorithm to place the n queens
Take for example a simple Java program to solve the n-queens problem.
This program declares a board of n×n cells and puts n queens on that board using a
simple algorithm with backtrack.
This is a very simple example… I present a more complex example at the end of this
presentation.
6
6/23
Simple example (2/2)
How many
backtracks?
Count the number
of calls to the
removeQueen()
method
boolean placeNextQueen(final int column) {
…
int row = 0;
while (row < this.n) {
if (!this.attack(row, column)) {
// Place a queen.
this.setQueen(row, column);
// Attempt to place the next queen.
if (this.placeNextQueen(column + 1)) {
return true;
}
else {
// Backtrack.
this.removeQueen(row, column);
}
}
row++;
}
return false;
…
How many immediate
backtracks?
Count the number of times the program
execution matches the sequence of
method calls:
• setQueen()
• placeNextQueen()
• removeQueen()
The algorithm is presented here.
Now, let’s imagine the maintainer who gets that program wants to know the number of
time the algorithm backtracks and the number of time the algorithm does an immediate
backtracks, i.e., remove a queen just after having placed her.
The maintainer needs to analyze the behaviour of the program…
We could then replace immediate backtracks with, for example, a propagation
algorithm.
7
7/23
Models (1/2)
n Trace model:
– History of execution events
n Execution model:
– Object model
– Prolog predicates
n Analysis
– Prolog (pattern matching, high level)
[Ducassé, 1999]
To perform the dynamic analysis of Java programs we need both a trace model, which
model the process of program execution, and an execution model, which models what
happens during the execution.
A trace is an history of execution events. We assume that the trace is built on the fly and
that there is not storage mechanism (but it is possible to store execution events).
Our execution model is based on the object model of the Java programming language.
This means that we have execution events related to operations performed on and by
classes and their instances.
We describe these execution events as Prolog predicates.
We use Prolog to perform analyses on traces of program executions.
We chose Prolog because it is powerful, it has pattern matching capabilities, and we can
express queries in a quite natural way. Prolog has already been chosen to perform trace
analysis: For example in Mireille Ducassé’s work on Opium and Coca.
8
8/23
Execution model (2/2)
class A {
String s;
A(String s) {
…
}
String foo() {
…
return "Happy" + s;
}
protected void finalize() {
…
}
}
classLoad
+ classUnload
programEnd
fieldAccess
fieldModification
constructorEntry
constructorExit
methodEntry
methodExit
finalizerEntry
finalizerExit
This list presents the different execution events defined by our execution model.
Remember that these execution events are modelled as Prolog predicates.
We have execution events for almost everything that can happens to classes and their
instances.
We have field accesses and modification…
We have class load and unload…
We have…
We have method exit execution event, including the returned value.
We have…
9
9/23
boolean placeNextQueen(final int column) {
…
int row = 0;
while (row < this.n) {
if (!this.attack(row, column)) {
// Place a queen.
this.setQueen(row, column);
// Attempt to place the next queen.
if (this.placeNextQueen(column + 1)) {
return true;
}
else {
// Backtrack.
this.removeQueen(row, column);
}
}
row++;
}
return false;
…
Simple example (2/3)
query(N, M) :-
nextMethodEntryEvent(removeQueen),
!,
N1 is N + 1,
query(N1, M).
query(N, N).
So, let’s get back to our simple example.
Remember we wanted to count the number of backtracks?
We write the following Prolog query on the program execution.
The nextMethodEntryEvent/1 predicate requests the program to run until
method removeQueen() is called. When the removeQueen() method is
called, the program execution stops and the control flow goes to the Prolog
engine, which then increases a counter and loops.
10
10/23
boolean placeNextQueen(final int column) {
…
int row = 0;
while (row < this.n) {
if (!this.attack(row, column)) {
// Place a queen.
this.setQueen(row, column);
// Attempt to place the next queen.
if (this.placeNextQueen(column + 1)) {
return true;
}
else {
// Backtrack.
this.removeQueen(row, column);
}
}
row++;
}
return false;
…
Simple example (3/3)
query(N, M) :-
nextMethodEntryEvent(setQueen),
nextPlaceNextQueen,
nextMethodEntryEvent(removeQueen),
!, N1 is N + 1, query(N1, M).
query(N, N).
nextPlaceNextQueen :-
nextMethodEntryEvent(NAME),
isPlaceNextQueen(NAME).
isPlaceNextQueen(placeNextQueen) :- !.
isPlaceNextQueen(removeQueen) :- !, fail.
isPlaceNextQueen(setQueen) :- !, fail.
isPlaceNextQueen(_) :- nextPlaceNextQueen.
We also wanted to count the number of immediate backtracks.
We write the following query, base on the same principles as for counting backtracks.
The query is a bit more complicated and I do not detail it here,but you can find in the
paper the details that prove that we obtain the number of immediate backtracks quite
nicely.
11
11/23
Design
Caffeine
Virtual
machine
Local computer
Event manager
Local
OS
Virtual
machine
Remote computer
Remote
OS
Front-end
JDI
Back-end
JVMDIJDWP
JIProlog
engine
Next
required
event Events
Program
being
analyzed
JPDA
Okay, so far I gave you a flavour of what our tool, Caffeine, is all about.
I now detail the tool implementation of our tool.
Basically, we have a Prolog engine, JIProlog, which runs as a co-routine of the program
being analyzed.
The Prolog engine controls and receives execution events from the program through the
Java Debug Interface (JDI) of the Java Debug Platform Architecture (JPDA).
We chose to use the JPDA because it seems quite natural to use the debug architecture
to analyze, programmatically though, program executions; It alsoreduces the need for
modifications of both the source code and the JVM.
This is quite simple to implement at first sight.
However, some issues quickly show up. In particular with the following five points.
12
12/23
Implementation
n Issues:
– Returned values
• Parameter values
• Instrument return statements
– return CaffeineWrapper(<previously
returned value>);
– Finalizers
• System.runFinalizersOnExit(boolean)
• Instrument class files to add finalize()
methods and to call the GC
Here are implementation techniques we use to overcome the limitations of the JDI.
To obtain returned value, we instrument the class files at load-time, to replace any return
statement by a return statement with a call to a special method with a single parameter
(the returned value), which in turn we can monitor to obtain its parameter and thus the
returned value.
To obtain execution events related to finalizers, we use the deprecated method
System.runFinalizersOnExit(boolean). We also add finalize() method to all
loaded class and add calls to the garbage collector. All these manipulations dramatically
slow down the program execution.
13
13/23
Implementation
n Issues:
– Program end
• Instrument System.exit(int)
• Count user thread starts/ends
– Assumption about the thread group
– Unique identifiers
• Instrument hierarchy root
To obtain program ends, we need to monitor calls to the System.exit(int) method,
which we replace by our own wrapper method. We also count the number of user
threads that start and terminate. We need to count user threads only because the JVM
starts its own threads.
To obtain unique identifiers, we instrument the loaded class to insert our own super-
class which holds a unique identifier for each class and instances created.
All these tricks solve most of the problem we met when developing Caffeine. It’s all fun
and good. However, a last issue remains, and this issue is of most importance.
14
14/23
Performances
n A real
problem:
1142
26 169 211
656
5647
0
1000
2000
3000
4000
5000
6000
3.8 4.1 4.3 6.2 7.0 10.7
Number of events per seconds
Increasefactor
The performance of our tool is way to low!
On this table, for two different programs, we show that the performances are
dramatically decreased. The main slow down factor is the event generation.
We perform some measurements, and we notice a exponential increase of execution
time according to the number of execution events. That sounds reasonable, nothing
comes free. However, the increase is of many orders of magnitude.
This performance issue is very bad and impedes the use of our analysis tool.
15
15/23
More complex example
n Object-oriented programs:
– Classes (and their instances)
– Relationships among classes
(and among their instances)
n Two binary class relationships:
– Aggregation: (structural)
– Composition: (behavioural)A B
A B
I present now a real-life example of software understanding.
We all know that object-oriented programs are about classes (and their instances) and
about relationships among classes (and among instances).
There are two famous binary class relationships: The aggregation and the composition
relationships. There are no consensual definitions of those relationships, so I give my
own:
-An aggregations relationship between two classes A and B expresses that class A
declares a field (or a collection) of instances of class B.
-A composition relationship between two classes A and B expresses that an aggregation
relationship links those two classes and that the lifetime of instances of B is shorter that
(and exclusive to) the lifetime of instances of A.
16
16/23
Architecture of JUnit v3.7
n Subset from Ptidej
[Albin-Amiot et al., 2001]:
– static analysis
(structure)
n Aggregations:
n Compositions?
A B
A B
Let’s consider the following subset of JUnit v3.7 architecture.
We extract this architecture using our tool Ptidejand a static (structural) analysis.
We presented Ptidej last year at ASE.
We notice there are some aggregation relationships found.
We would like to have more information about this architecture. In particular, we would
like to know if there are any composition relationships among classes of the JUnit.
17
17/23
Composition relationship
n Static (structure):
–A declares a collection (field) of B
–A declares handling methods
n Dynamic (behaviour):
– Instances of B must belong exclusively to
instances of A (exclusivity)
– Lifetime of instances of B must not exceed
the lifetime of instances of A (lifetime)
A composition relationship has two aspects:
-A structure (static), a field (a collection, generally) and some methods to handle adding
and removing of instances of B.
-A behaviour (dynamic), instances of…
18
18/23
Execution events
n Assignations of instances of B to any
field in class A
n Assignation of instances of B to any
collection in class A
n Finalization of instances of B and A
Using Caffeine, our dynamic analysis tool, we can monitor assignations of instances of B
in any field or collection of class A.
We can also monitor the finalizations of instances of A and B and their ordering.
19
19/23
Composition analysis
n About 50 predicates:
– About 300 lines of Prolog
– Mostly lists handling
– Complexity n2
n Analysis written once and for all
– Exclusivity property
– Lifetime property
We wrote Prolog predicates to monitor and analyze the composition relationships
between classes. It is not that complex, the Prolog file is about 50 predicates, 300 lines
of Prolog, and is mostly about list handling.
This analysis is written once and for all, it can be reused for other Java programs. It
decomposes into the two properties Exclusivity and Lifetime.
20
20/23
Composition analysis, example
n MoneyTest from JUnit v3.7:
–TestResult u TestFailure?
–TestRunner (AWT) u Throwable?
–TestRunner (Swing) u TestRunView?
–TestSuite u Test?
–TestRunner (AWT) u Test?
–TestTreeModel u Test?
We apply Caffeine and our composition relationship analysis on JUnit v3.7, using the
provided MoneyTest class.
We monitored the following classes because they all have aggregation relationships.
21
21/23
Composition analysis, results
n MoneyTest from JUnit v3.7:
–TestResult u TestFailure
–TestRunner (AWT) u Throwable
–TestRunner (Swing) u TestRunView
–TestSuite u Test
–TestRunner (AWT) u Test
–TestTreeModel u Test
ü
û
ü
ü
û
û
The results are as follow…
22
22/23
Detailed architecture
n Subset from Ptidej:
– Static analysis
– Dynamic analysis
n Some aggregations
n Some compositions
Finally, from the static and dynamic analyses, we can improve our understanding of the
architecture of JUnit.
We have now a better understanding of JUnit architecture. On one hand, we know that
the TestResult and TestFailure classes are tightly coupled, through a
composition relationships: Instances of class TestFailure live and die with instances
of class TestResult. On the other hand, instances of class Test are shared among
several classes and have lives on their own.
23
23/23
Conclusion and future work
n Useful!
n Limitations:
– Performances
– Code coverage
n Future work:
– Implementation rework
– More analyses
– Runtime description language
To conclude, dynamic analysis is a useful thing to have and to do!
I presented Caffeine, a tool for the dynamic analysis of Java programs.
I gave some examples of our use of dynamic analyses.
However, our tool, as it is, is too limited with respect to performances and to code
coverage analysis.
Future work includes:
-Implementation rework, we would like to obtain only interesting events, no all events
of a certain kind, and we would like to remove the dependency onthe debug architecture
that decreases performances.
-We also want to add more analyses to the current library. In particular, we want to
develop more properties.
-We plan to implement a runtime description language to express properties and to
compose easily properties into complete analyses. We consider using temporal logic or
logic programming.
24
24/23
Future work
JDI (JPDA)
Caffeine
N-queens
algorithm
Binary class
relationships
Design pattern
behaviors
Interaction
diagrams
Runtime
description language
N-queens
algorithm
Binary class
relationships
Design pattern
behaviors
Interaction
diagrams
Low-level
Intermediate
Middle-level
High-level
Protocols ...
Prolog
JVM
25
25/23
Exclusivity property
checkEXProperty(
assignation(_, A, AID, B, BID),
LIST,
NLIST) :-
updateEXProperties(A, AID, B, BID, LIST, NLIST, true).
checkEXProperty(_, LIST, LIST).
updateEXProperties(
A, AID, B, BID,
[],
[exclusivityProperty(A, AID, B, BID, true)],
true).
updateEXProperties(
A, AID, B, BID,
[],
[exclusivityProperty(A, AID, B, BID, false)],
false).
…
26
26/23
Lifetime property
checkLTProperty(
assignation(_, A, AID, B, BID),
LIST,
NLIST) :-
append(LIST, [pendingAssignation(A, AID, B, BID, [])], NLIST).
checkLTProperty(
finalization(EID, A, AID),
LIST,
NLIST) :-
doesLTPropertyHold(finalization(EID, A, AID), LIST, NLIST).
checkLTProperty(
programEnd(_),
LIST,
NLIST) :-
convertPendingAssignations(LIST , NLIST).
checkLTProperty(_, LIST, LIST).
27
27/23
Composition analysis
checkComposition([], [], []).
checkComposition([], _, []) :-
write ('Problem! Lists of properties have different size!'), nl, false.
checkComposition(_, [], []) :-
write ('Problem! Lists of properties have different size!'), nl, false.
checkComposition(
[exclusivityProperty(A, AID, B, BID, OKAY) | EXPREST],
[lifetimeProperty(A, AID, B, BID, OKAY) | LTPREST],
[composition(A, AID, B, BID, OKAY) | NLIST]) :-
checkComposition(EXPREST , LTPREST, NLIST).
checkComposition(
[exclusivityProperty(A, AID, B, BID, _) | EXPREST],
[lifetimeProperty(A, AID, B, BID, _) | LTPREST],
[composition(A, AID, B, BID, false) | NLIST]) :-
checkComposition(EXPREST , LTPREST, NLIST).

More Related Content

What's hot

Hotspot & hotswap, who and who are best freinds
Hotspot & hotswap, who and who are best freindsHotspot & hotswap, who and who are best freinds
Hotspot & hotswap, who and who are best freinds
亚军 汪
 
Cs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUALCs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUAL
Prabhu D
 
Java session13
Java session13Java session13
Java session13
Niit Care
 

What's hot (20)

Javascript
JavascriptJavascript
Javascript
 
Google lme4
Google lme4Google lme4
Google lme4
 
Basics of reflection in java
Basics of reflection in javaBasics of reflection in java
Basics of reflection in java
 
Hotspot & hotswap, who and who are best freinds
Hotspot & hotswap, who and who are best freindsHotspot & hotswap, who and who are best freinds
Hotspot & hotswap, who and who are best freinds
 
Java lab1 manual
Java lab1 manualJava lab1 manual
Java lab1 manual
 
Ch 6 randomization
Ch 6 randomizationCh 6 randomization
Ch 6 randomization
 
Strategy and Template Pattern
Strategy and Template PatternStrategy and Template Pattern
Strategy and Template Pattern
 
Java- Concurrent programming - Synchronization (part 1)
Java- Concurrent programming - Synchronization (part 1)Java- Concurrent programming - Synchronization (part 1)
Java- Concurrent programming - Synchronization (part 1)
 
Java Exception Handling, Assertions and Logging
Java Exception Handling, Assertions and LoggingJava Exception Handling, Assertions and Logging
Java Exception Handling, Assertions and Logging
 
Java programming-examples
Java programming-examplesJava programming-examples
Java programming-examples
 
Java- Concurrent programming - Synchronization (part 2)
Java- Concurrent programming - Synchronization (part 2)Java- Concurrent programming - Synchronization (part 2)
Java- Concurrent programming - Synchronization (part 2)
 
Advanced Reflection in Java
Advanced Reflection in JavaAdvanced Reflection in Java
Advanced Reflection in Java
 
Comparing different concurrency models on the JVM
Comparing different concurrency models on the JVMComparing different concurrency models on the JVM
Comparing different concurrency models on the JVM
 
Heap and stack space in java
Heap and stack space in javaHeap and stack space in java
Heap and stack space in java
 
Cs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUALCs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUAL
 
Ch01 basic-java-programs
Ch01 basic-java-programsCh01 basic-java-programs
Ch01 basic-java-programs
 
Java - Concurrent programming - Thread's basics
Java - Concurrent programming - Thread's basicsJava - Concurrent programming - Thread's basics
Java - Concurrent programming - Thread's basics
 
Introduction to Java 11
Introduction to Java 11 Introduction to Java 11
Introduction to Java 11
 
Questions of java
Questions of javaQuestions of java
Questions of java
 
Java session13
Java session13Java session13
Java session13
 

Similar to Ase02.ppt

9781111530532 ppt ch05
9781111530532 ppt ch059781111530532 ppt ch05
9781111530532 ppt ch05
Terry Yoast
 
9781111530532 ppt ch05
9781111530532 ppt ch059781111530532 ppt ch05
9781111530532 ppt ch05
Terry Yoast
 

Similar to Ase02.ppt (20)

Introduction To Programming IP5
Introduction To Programming IP5Introduction To Programming IP5
Introduction To Programming IP5
 
Java introduction
Java introductionJava introduction
Java introduction
 
java
javajava
java
 
SMI - Introduction to Java
SMI - Introduction to JavaSMI - Introduction to Java
SMI - Introduction to Java
 
Java Enterprise Edition
Java Enterprise EditionJava Enterprise Edition
Java Enterprise Edition
 
Knowledge of Javascript
Knowledge of JavascriptKnowledge of Javascript
Knowledge of Javascript
 
Ase02 dmp.ppt
Ase02 dmp.pptAse02 dmp.ppt
Ase02 dmp.ppt
 
Dutch PHP Conference 2013: Distilled
Dutch PHP Conference 2013: DistilledDutch PHP Conference 2013: Distilled
Dutch PHP Conference 2013: Distilled
 
Java 101
Java 101Java 101
Java 101
 
Week1 programming challenges
Week1 programming challengesWeek1 programming challenges
Week1 programming challenges
 
P&MSP2012 - Unit Testing
P&MSP2012 - Unit TestingP&MSP2012 - Unit Testing
P&MSP2012 - Unit Testing
 
Java multi thread programming on cmp system
Java multi thread programming on cmp systemJava multi thread programming on cmp system
Java multi thread programming on cmp system
 
Java For beginners and CSIT and IT students
Java  For beginners and CSIT and IT studentsJava  For beginners and CSIT and IT students
Java For beginners and CSIT and IT students
 
Feature extraction for classifying students based on theirac ademic performance
Feature extraction for classifying students based on theirac ademic performanceFeature extraction for classifying students based on theirac ademic performance
Feature extraction for classifying students based on theirac ademic performance
 
Problem solving using computers - Chapter 1
Problem solving using computers - Chapter 1 Problem solving using computers - Chapter 1
Problem solving using computers - Chapter 1
 
Proyect of english
Proyect of englishProyect of english
Proyect of english
 
Jay Yagnik at AI Frontiers : A History Lesson on AI
Jay Yagnik at AI Frontiers : A History Lesson on AIJay Yagnik at AI Frontiers : A History Lesson on AI
Jay Yagnik at AI Frontiers : A History Lesson on AI
 
9781111530532 ppt ch05
9781111530532 ppt ch059781111530532 ppt ch05
9781111530532 ppt ch05
 
9781111530532 ppt ch05
9781111530532 ppt ch059781111530532 ppt ch05
9781111530532 ppt ch05
 
Java introduction
Java introductionJava introduction
Java introduction
 

More from Yann-Gaël Guéhéneuc

Evolution and Examples of Java Features, from Java 1.7 to Java 22
Evolution and Examples of Java Features, from Java 1.7 to Java 22Evolution and Examples of Java Features, from Java 1.7 to Java 22
Evolution and Examples of Java Features, from Java 1.7 to Java 22
Yann-Gaël Guéhéneuc
 
Consequences and Principles of Software Quality v0.3
Consequences and Principles of Software Quality v0.3Consequences and Principles of Software Quality v0.3
Consequences and Principles of Software Quality v0.3
Yann-Gaël Guéhéneuc
 
On Reflection in OO Programming Languages v1.6
On Reflection in OO Programming Languages v1.6On Reflection in OO Programming Languages v1.6
On Reflection in OO Programming Languages v1.6
Yann-Gaël Guéhéneuc
 

More from Yann-Gaël Guéhéneuc (20)

Advice for writing a NSERC Discovery grant application v0.5
Advice for writing a NSERC Discovery grant application v0.5Advice for writing a NSERC Discovery grant application v0.5
Advice for writing a NSERC Discovery grant application v0.5
 
Ptidej Architecture, Design, and Implementation in Action v2.1
Ptidej Architecture, Design, and Implementation in Action v2.1Ptidej Architecture, Design, and Implementation in Action v2.1
Ptidej Architecture, Design, and Implementation in Action v2.1
 
Evolution and Examples of Java Features, from Java 1.7 to Java 22
Evolution and Examples of Java Features, from Java 1.7 to Java 22Evolution and Examples of Java Features, from Java 1.7 to Java 22
Evolution and Examples of Java Features, from Java 1.7 to Java 22
 
Consequences and Principles of Software Quality v0.3
Consequences and Principles of Software Quality v0.3Consequences and Principles of Software Quality v0.3
Consequences and Principles of Software Quality v0.3
 
Some Pitfalls with Python and Their Possible Solutions v0.9
Some Pitfalls with Python and Their Possible Solutions v0.9Some Pitfalls with Python and Their Possible Solutions v0.9
Some Pitfalls with Python and Their Possible Solutions v0.9
 
An Explanation of the Unicode, the Text Encoding Standard, Its Usages and Imp...
An Explanation of the Unicode, the Text Encoding Standard, Its Usages and Imp...An Explanation of the Unicode, the Text Encoding Standard, Its Usages and Imp...
An Explanation of the Unicode, the Text Encoding Standard, Its Usages and Imp...
 
An Explanation of the Halting Problem and Its Consequences
An Explanation of the Halting Problem and Its ConsequencesAn Explanation of the Halting Problem and Its Consequences
An Explanation of the Halting Problem and Its Consequences
 
Are CPUs VMs Like Any Others? v1.0
Are CPUs VMs Like Any Others? v1.0Are CPUs VMs Like Any Others? v1.0
Are CPUs VMs Like Any Others? v1.0
 
Informaticien(ne)s célèbres (v1.0.2, 19/02/20)
Informaticien(ne)s célèbres (v1.0.2, 19/02/20)Informaticien(ne)s célèbres (v1.0.2, 19/02/20)
Informaticien(ne)s célèbres (v1.0.2, 19/02/20)
 
Well-known Computer Scientists v1.0.2
Well-known Computer Scientists v1.0.2Well-known Computer Scientists v1.0.2
Well-known Computer Scientists v1.0.2
 
On Java Generics, History, Use, Caveats v1.1
On Java Generics, History, Use, Caveats v1.1On Java Generics, History, Use, Caveats v1.1
On Java Generics, History, Use, Caveats v1.1
 
On Reflection in OO Programming Languages v1.6
On Reflection in OO Programming Languages v1.6On Reflection in OO Programming Languages v1.6
On Reflection in OO Programming Languages v1.6
 
ICSOC'21
ICSOC'21ICSOC'21
ICSOC'21
 
Vissoft21.ppt
Vissoft21.pptVissoft21.ppt
Vissoft21.ppt
 
Service computation20.ppt
Service computation20.pptService computation20.ppt
Service computation20.ppt
 
Serp4 iot20.ppt
Serp4 iot20.pptSerp4 iot20.ppt
Serp4 iot20.ppt
 
Msr20.ppt
Msr20.pptMsr20.ppt
Msr20.ppt
 
Iwesep19.ppt
Iwesep19.pptIwesep19.ppt
Iwesep19.ppt
 
Icsoc20.ppt
Icsoc20.pptIcsoc20.ppt
Icsoc20.ppt
 
Icsoc18.ppt
Icsoc18.pptIcsoc18.ppt
Icsoc18.ppt
 

Recently uploaded

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 

Recently uploaded (20)

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
Pharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodologyPharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodology
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide Deck
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 

Ase02.ppt

  • 1. 1 No Java without Caffeine A Tool for Dynamic Analysis of Java Programs Yann-Gaël Guéhéneuc Rémi Douence Narendra Jussien {guehene, douence, jussien}@emn.fr École des Mines de Nantes, France Object Technology International, Inc., Canada Ladies and gentlemen… My name is Yann-Gaël Guéhéneuc. I present today our work on Caffeine, a tool for the dynamic analysis of Java programs. We develop Caffeine with Rémi Douence and Narendra Jussien from the EMN. My work is partly funded by Object Technology International, Inc.
  • 2. 2 2/23 Software understanding is about… … Understanding! n Do not hesitate to interrupt! n Questions are most welcome! Today, we are all attending a session on software understanding. We should not forget that software understanding is first and foremost about understanding. Being from France, my accent might be a bit of a problem, so please, do not hesitate to interrupt me, questions are most welcome.
  • 3. 3 3/23 Objectives n Motivate the need for dynamic analysis n Present the prototype models n Detail the prototype implementation n Describe a more complex example n Summarize limitations and future work Today, in my presentation: First, I motivate the need for dynamic analysis, using on a verysimple example: The analysis of a n-queens algorithm. Second, I present the models used in our prototype. Third, I detail our prototype implementation. I put the emphasis on issues and limitations. Fourth, I introduce a real-life example that (I hope) highlights the usefulness of dynamic analyses and presents the integration of our tool with other tools for software understanding. Finally, I summarize the usefulness and the limitations of our tools and present some future work.
  • 4. 4 4/23 Motivation n Software understanding: [Soloway et al., 1988] – Code structure – Conjecture n Assistant n Dynamic behaviour of Java programs n Least modifications (source code, JVM) Our motivation is software understanding. Soloway et al. characterized software understanding as composed of inquiry episodes. The maintainer, who tries to understand a program, first reads some code, asks a question about this code, conjectures an answers, and searches the code and the documentation for a confirmation of the conjecture. Our goal is to develop an assistant which the maintainer uses to verify conjectures on the runtime behaviour of the program with respect to the program structure. We want our assistant to work with Java. We need to analyze the dynamic behaviour of Java programs. (I hope that I will convince you of the need for dynamic analyses in Java, in contrast with the results presented in the Nokia experience report yesterday…)
  • 5. 5 5/23 Simple example (1/2) n The n-queens problem: – A n×n chessboard – n queens – An algorithm to place the n queens Take for example a simple Java program to solve the n-queens problem. This program declares a board of n×n cells and puts n queens on that board using a simple algorithm with backtrack. This is a very simple example… I present a more complex example at the end of this presentation.
  • 6. 6 6/23 Simple example (2/2) How many backtracks? Count the number of calls to the removeQueen() method boolean placeNextQueen(final int column) { … int row = 0; while (row < this.n) { if (!this.attack(row, column)) { // Place a queen. this.setQueen(row, column); // Attempt to place the next queen. if (this.placeNextQueen(column + 1)) { return true; } else { // Backtrack. this.removeQueen(row, column); } } row++; } return false; … How many immediate backtracks? Count the number of times the program execution matches the sequence of method calls: • setQueen() • placeNextQueen() • removeQueen() The algorithm is presented here. Now, let’s imagine the maintainer who gets that program wants to know the number of time the algorithm backtracks and the number of time the algorithm does an immediate backtracks, i.e., remove a queen just after having placed her. The maintainer needs to analyze the behaviour of the program… We could then replace immediate backtracks with, for example, a propagation algorithm.
  • 7. 7 7/23 Models (1/2) n Trace model: – History of execution events n Execution model: – Object model – Prolog predicates n Analysis – Prolog (pattern matching, high level) [Ducassé, 1999] To perform the dynamic analysis of Java programs we need both a trace model, which model the process of program execution, and an execution model, which models what happens during the execution. A trace is an history of execution events. We assume that the trace is built on the fly and that there is not storage mechanism (but it is possible to store execution events). Our execution model is based on the object model of the Java programming language. This means that we have execution events related to operations performed on and by classes and their instances. We describe these execution events as Prolog predicates. We use Prolog to perform analyses on traces of program executions. We chose Prolog because it is powerful, it has pattern matching capabilities, and we can express queries in a quite natural way. Prolog has already been chosen to perform trace analysis: For example in Mireille Ducassé’s work on Opium and Coca.
  • 8. 8 8/23 Execution model (2/2) class A { String s; A(String s) { … } String foo() { … return "Happy" + s; } protected void finalize() { … } } classLoad + classUnload programEnd fieldAccess fieldModification constructorEntry constructorExit methodEntry methodExit finalizerEntry finalizerExit This list presents the different execution events defined by our execution model. Remember that these execution events are modelled as Prolog predicates. We have execution events for almost everything that can happens to classes and their instances. We have field accesses and modification… We have class load and unload… We have… We have method exit execution event, including the returned value. We have…
  • 9. 9 9/23 boolean placeNextQueen(final int column) { … int row = 0; while (row < this.n) { if (!this.attack(row, column)) { // Place a queen. this.setQueen(row, column); // Attempt to place the next queen. if (this.placeNextQueen(column + 1)) { return true; } else { // Backtrack. this.removeQueen(row, column); } } row++; } return false; … Simple example (2/3) query(N, M) :- nextMethodEntryEvent(removeQueen), !, N1 is N + 1, query(N1, M). query(N, N). So, let’s get back to our simple example. Remember we wanted to count the number of backtracks? We write the following Prolog query on the program execution. The nextMethodEntryEvent/1 predicate requests the program to run until method removeQueen() is called. When the removeQueen() method is called, the program execution stops and the control flow goes to the Prolog engine, which then increases a counter and loops.
  • 10. 10 10/23 boolean placeNextQueen(final int column) { … int row = 0; while (row < this.n) { if (!this.attack(row, column)) { // Place a queen. this.setQueen(row, column); // Attempt to place the next queen. if (this.placeNextQueen(column + 1)) { return true; } else { // Backtrack. this.removeQueen(row, column); } } row++; } return false; … Simple example (3/3) query(N, M) :- nextMethodEntryEvent(setQueen), nextPlaceNextQueen, nextMethodEntryEvent(removeQueen), !, N1 is N + 1, query(N1, M). query(N, N). nextPlaceNextQueen :- nextMethodEntryEvent(NAME), isPlaceNextQueen(NAME). isPlaceNextQueen(placeNextQueen) :- !. isPlaceNextQueen(removeQueen) :- !, fail. isPlaceNextQueen(setQueen) :- !, fail. isPlaceNextQueen(_) :- nextPlaceNextQueen. We also wanted to count the number of immediate backtracks. We write the following query, base on the same principles as for counting backtracks. The query is a bit more complicated and I do not detail it here,but you can find in the paper the details that prove that we obtain the number of immediate backtracks quite nicely.
  • 11. 11 11/23 Design Caffeine Virtual machine Local computer Event manager Local OS Virtual machine Remote computer Remote OS Front-end JDI Back-end JVMDIJDWP JIProlog engine Next required event Events Program being analyzed JPDA Okay, so far I gave you a flavour of what our tool, Caffeine, is all about. I now detail the tool implementation of our tool. Basically, we have a Prolog engine, JIProlog, which runs as a co-routine of the program being analyzed. The Prolog engine controls and receives execution events from the program through the Java Debug Interface (JDI) of the Java Debug Platform Architecture (JPDA). We chose to use the JPDA because it seems quite natural to use the debug architecture to analyze, programmatically though, program executions; It alsoreduces the need for modifications of both the source code and the JVM. This is quite simple to implement at first sight. However, some issues quickly show up. In particular with the following five points.
  • 12. 12 12/23 Implementation n Issues: – Returned values • Parameter values • Instrument return statements – return CaffeineWrapper(<previously returned value>); – Finalizers • System.runFinalizersOnExit(boolean) • Instrument class files to add finalize() methods and to call the GC Here are implementation techniques we use to overcome the limitations of the JDI. To obtain returned value, we instrument the class files at load-time, to replace any return statement by a return statement with a call to a special method with a single parameter (the returned value), which in turn we can monitor to obtain its parameter and thus the returned value. To obtain execution events related to finalizers, we use the deprecated method System.runFinalizersOnExit(boolean). We also add finalize() method to all loaded class and add calls to the garbage collector. All these manipulations dramatically slow down the program execution.
  • 13. 13 13/23 Implementation n Issues: – Program end • Instrument System.exit(int) • Count user thread starts/ends – Assumption about the thread group – Unique identifiers • Instrument hierarchy root To obtain program ends, we need to monitor calls to the System.exit(int) method, which we replace by our own wrapper method. We also count the number of user threads that start and terminate. We need to count user threads only because the JVM starts its own threads. To obtain unique identifiers, we instrument the loaded class to insert our own super- class which holds a unique identifier for each class and instances created. All these tricks solve most of the problem we met when developing Caffeine. It’s all fun and good. However, a last issue remains, and this issue is of most importance.
  • 14. 14 14/23 Performances n A real problem: 1142 26 169 211 656 5647 0 1000 2000 3000 4000 5000 6000 3.8 4.1 4.3 6.2 7.0 10.7 Number of events per seconds Increasefactor The performance of our tool is way to low! On this table, for two different programs, we show that the performances are dramatically decreased. The main slow down factor is the event generation. We perform some measurements, and we notice a exponential increase of execution time according to the number of execution events. That sounds reasonable, nothing comes free. However, the increase is of many orders of magnitude. This performance issue is very bad and impedes the use of our analysis tool.
  • 15. 15 15/23 More complex example n Object-oriented programs: – Classes (and their instances) – Relationships among classes (and among their instances) n Two binary class relationships: – Aggregation: (structural) – Composition: (behavioural)A B A B I present now a real-life example of software understanding. We all know that object-oriented programs are about classes (and their instances) and about relationships among classes (and among instances). There are two famous binary class relationships: The aggregation and the composition relationships. There are no consensual definitions of those relationships, so I give my own: -An aggregations relationship between two classes A and B expresses that class A declares a field (or a collection) of instances of class B. -A composition relationship between two classes A and B expresses that an aggregation relationship links those two classes and that the lifetime of instances of B is shorter that (and exclusive to) the lifetime of instances of A.
  • 16. 16 16/23 Architecture of JUnit v3.7 n Subset from Ptidej [Albin-Amiot et al., 2001]: – static analysis (structure) n Aggregations: n Compositions? A B A B Let’s consider the following subset of JUnit v3.7 architecture. We extract this architecture using our tool Ptidejand a static (structural) analysis. We presented Ptidej last year at ASE. We notice there are some aggregation relationships found. We would like to have more information about this architecture. In particular, we would like to know if there are any composition relationships among classes of the JUnit.
  • 17. 17 17/23 Composition relationship n Static (structure): –A declares a collection (field) of B –A declares handling methods n Dynamic (behaviour): – Instances of B must belong exclusively to instances of A (exclusivity) – Lifetime of instances of B must not exceed the lifetime of instances of A (lifetime) A composition relationship has two aspects: -A structure (static), a field (a collection, generally) and some methods to handle adding and removing of instances of B. -A behaviour (dynamic), instances of…
  • 18. 18 18/23 Execution events n Assignations of instances of B to any field in class A n Assignation of instances of B to any collection in class A n Finalization of instances of B and A Using Caffeine, our dynamic analysis tool, we can monitor assignations of instances of B in any field or collection of class A. We can also monitor the finalizations of instances of A and B and their ordering.
  • 19. 19 19/23 Composition analysis n About 50 predicates: – About 300 lines of Prolog – Mostly lists handling – Complexity n2 n Analysis written once and for all – Exclusivity property – Lifetime property We wrote Prolog predicates to monitor and analyze the composition relationships between classes. It is not that complex, the Prolog file is about 50 predicates, 300 lines of Prolog, and is mostly about list handling. This analysis is written once and for all, it can be reused for other Java programs. It decomposes into the two properties Exclusivity and Lifetime.
  • 20. 20 20/23 Composition analysis, example n MoneyTest from JUnit v3.7: –TestResult u TestFailure? –TestRunner (AWT) u Throwable? –TestRunner (Swing) u TestRunView? –TestSuite u Test? –TestRunner (AWT) u Test? –TestTreeModel u Test? We apply Caffeine and our composition relationship analysis on JUnit v3.7, using the provided MoneyTest class. We monitored the following classes because they all have aggregation relationships.
  • 21. 21 21/23 Composition analysis, results n MoneyTest from JUnit v3.7: –TestResult u TestFailure –TestRunner (AWT) u Throwable –TestRunner (Swing) u TestRunView –TestSuite u Test –TestRunner (AWT) u Test –TestTreeModel u Test ü û ü ü û û The results are as follow…
  • 22. 22 22/23 Detailed architecture n Subset from Ptidej: – Static analysis – Dynamic analysis n Some aggregations n Some compositions Finally, from the static and dynamic analyses, we can improve our understanding of the architecture of JUnit. We have now a better understanding of JUnit architecture. On one hand, we know that the TestResult and TestFailure classes are tightly coupled, through a composition relationships: Instances of class TestFailure live and die with instances of class TestResult. On the other hand, instances of class Test are shared among several classes and have lives on their own.
  • 23. 23 23/23 Conclusion and future work n Useful! n Limitations: – Performances – Code coverage n Future work: – Implementation rework – More analyses – Runtime description language To conclude, dynamic analysis is a useful thing to have and to do! I presented Caffeine, a tool for the dynamic analysis of Java programs. I gave some examples of our use of dynamic analyses. However, our tool, as it is, is too limited with respect to performances and to code coverage analysis. Future work includes: -Implementation rework, we would like to obtain only interesting events, no all events of a certain kind, and we would like to remove the dependency onthe debug architecture that decreases performances. -We also want to add more analyses to the current library. In particular, we want to develop more properties. -We plan to implement a runtime description language to express properties and to compose easily properties into complete analyses. We consider using temporal logic or logic programming.
  • 24. 24 24/23 Future work JDI (JPDA) Caffeine N-queens algorithm Binary class relationships Design pattern behaviors Interaction diagrams Runtime description language N-queens algorithm Binary class relationships Design pattern behaviors Interaction diagrams Low-level Intermediate Middle-level High-level Protocols ... Prolog JVM
  • 25. 25 25/23 Exclusivity property checkEXProperty( assignation(_, A, AID, B, BID), LIST, NLIST) :- updateEXProperties(A, AID, B, BID, LIST, NLIST, true). checkEXProperty(_, LIST, LIST). updateEXProperties( A, AID, B, BID, [], [exclusivityProperty(A, AID, B, BID, true)], true). updateEXProperties( A, AID, B, BID, [], [exclusivityProperty(A, AID, B, BID, false)], false). …
  • 26. 26 26/23 Lifetime property checkLTProperty( assignation(_, A, AID, B, BID), LIST, NLIST) :- append(LIST, [pendingAssignation(A, AID, B, BID, [])], NLIST). checkLTProperty( finalization(EID, A, AID), LIST, NLIST) :- doesLTPropertyHold(finalization(EID, A, AID), LIST, NLIST). checkLTProperty( programEnd(_), LIST, NLIST) :- convertPendingAssignations(LIST , NLIST). checkLTProperty(_, LIST, LIST).
  • 27. 27 27/23 Composition analysis checkComposition([], [], []). checkComposition([], _, []) :- write ('Problem! Lists of properties have different size!'), nl, false. checkComposition(_, [], []) :- write ('Problem! Lists of properties have different size!'), nl, false. checkComposition( [exclusivityProperty(A, AID, B, BID, OKAY) | EXPREST], [lifetimeProperty(A, AID, B, BID, OKAY) | LTPREST], [composition(A, AID, B, BID, OKAY) | NLIST]) :- checkComposition(EXPREST , LTPREST, NLIST). checkComposition( [exclusivityProperty(A, AID, B, BID, _) | EXPREST], [lifetimeProperty(A, AID, B, BID, _) | LTPREST], [composition(A, AID, B, BID, false) | NLIST]) :- checkComposition(EXPREST , LTPREST, NLIST).