Install instructions
Requires
Java 1.6 (or later).
The archive already contains all used external libraries (
JDOM,
Jetty and
dk.brics.automaton).
To install simply extract the contents of the archive. There's a "Quick User Guide" in
[1] which contains instructions on how to run the examples.
A more detailed description...
This is an on-going project and for now the most important aspect of this prototype is the behavioral type system which checks the correct use of an object's behavior. This behavior is related to the valid sequence of method calls specified in a class' usage protocol. The protocol is a regular expression like description which tells the type system which methods can be called and in what context. Our typing rules cover all normal
sequential programming constructions (if-else, while), exceptions (try-catch/throw) as well as guarantee the termination of a protocol.
A more complete presentation and additional examples (with more interesting constructions) are given in
[1], therefore the following examples are only intended as a short and simple introduction to some of the prototype's features.
1. Simple example
In this very simple example the usage of the Travel class follows a simple sequential order. Therefore its use reaches a valid stop position at the end the main method.
class Travel{
usage flight;hotel;order
flight(){}
hotel(){}
order(){}
}
class Main{
main(){
Travel t = new Travel();
t.flight();
t.hotel();
t.order();
}
}
2. If-Else
This construction causes a branch by spliting the program flow in two different slices which are then merged back to obtain the correct shared behavior at its end.
method(A#a;((b;c)+(d;c*)) a){
if( a.a() ){
a.b();
}
else{
a.d();
};
a.c();
a.c(); Error: illegal call
}
3. While
This cycle requires special attention on all possible behaviors that can occur at run-time.
method(A#a*+b v){
while( ){
v.a();
};
v.b(); Error: illegal call
v.a();
}
4. Exceptions
Exceptions may cause a jump from an undetermined throw point to the appropriate catch branch based on the type of the raised object.
method(A#a[Error: b];aa v){
try{
v.a();
}catch(Error error){
v.b();
return;
};
v.aa();
}
See the documentation provided in
[1] for a more formal and detailed information on how each rule is checked as well as other features like subtyping, protocol recursion, assignment rules, class consistency check, behavioral argument passing.