Formal Semantics
and Interactive Environment
for Parallel Object-Oriented Programming

INRIA
CNRS
UNSA

Isabelle Attali and Denis Caromel
Marjorie Russo

Isabelle.Attali@sophia.inria.fr
Denis.Caromel@sophia.inria.fr
Marjorie.Russo@sophia.inria.fr


[Overview] [Language] [Example] [Semantics] [Environment] [Detailed Example Of Interpretation] [Documentation] [Contacts]

Overview

A formal definition of the Java semantics has been defined in the structural operational style of Natural Semantics. Using the Centaur system, this semantics permits to generate an interactive environment for parallel object-oriented programming and visualization. We provide features such as visualization of closure and semantic rules, and animation tools to show the concurrent activities of objects.
Another interest of a formal approach is to provide tools to ensure safety properties of Java programs, at the byte code level.
This work is part of a larger project on formal transformation and parallelization for object-oriented languages.

The Language

The Java language gathers two important concepts of the modern programming : object-orientation and concurrency.

An Example

As an illustration, the following Figure presents a Java program. This program is a well known producer-consumer program.



This program is using multi-threading : the main thread (the one which executes the main method) begins by creating a simple object (represented by c) and three others threads (represented by c1, p1 and c2) and then the three threads execute themselves with interleaving. Interleaving enables us to simulate the concurrent execution of several threads on a one-processor computer.

The Semantics

In order to specify our semantics, we use the Natural Semantics within the Centaur system, and the Typol formalism which provides us with executable specifications.
We need to define some structures which describe the state of a Java program. During its execution, this state is composed of objects. Each object has a configuration (type,attribute values). Moreover, threads which are special objects have one more characteristic : their activity. The list of all object (threads included) configurations is the configuration representing the state of the program.

The semantics of inheritance and dynamic binding is expressed in Natural Semantics (200 rules).
For example this next rule is dealing with the obtainment of the attribute list of an object and of the static variables of its type class.




The Operational Semantics simulates parallelism with a deterministic interleaving of (activities of) concurrent threads (this will change later).
So, the modules describing the actual execution of statements (loops, assignments, ...) are expressed in Structural Operational Semantics (200 rules).
We present here the two main Typol rules defining the evaluation of the assignment expression.



This first rule concerns the case "Var = Value1" where Var is a simple variable. In this case, the "assign" predicate deals with the assigment.



This second rule deals with the case "Name = Expr". Here "Expr" is evaluated in "exp" and, in the next step of execution the instruction to execute will be the first instruction of "instl1". When this instruction list will be executed, the next instruction to execute will be the evaluation of the expression "Name = exp".
We need these two rules in order to simulate interleaving between several threads. The assignment is not an atomic statement so we need to foresee a possibility of interleaving during its execution.

The Graphical Environment

We present a graphical environment for parallel object-oriented programming. It provides visual tools to develop and debug object-oriented programs as well as parallel or concurrent systems. This environment was derived from a structural operational semantics of Java.
The visualization is not obtained from code instrumentation but automatically, using the semantic description. The graphical environment focuses on objects and provides a set of primitives for controlling and probing the execution (execution speed, step-by-step execution...). All the updates are made by an incremental method...
The outcome of such an approach is twofold:
  • A pedagogic environment to demonstrate concepts of object-oriented programming, actor computation, and formal semantics.
  • A step towards environments for the formal study of parallel object-oriented programming.

  • The Textual Window

    The textual window enables people to see the object list. Each object is represented with its identifier (its element number in the object list), its type, its attribute list (a list of name-value pairs), its lock, its wait set and its activity (none in the case of a simple object).

    Here is an example which present one step of the execution of the above-mentioned example program.



    In this example, we can see that the identifiers of the objects (here two threads "#T0" and "#T2" and a simple object "#1") are in blue. The thread status appear in green.

    The Graphic Window

    The graphic window enables people to see quickly and easily the object topology, the cross references between objects and the object status by different colors. We can also zoom on an object with the middle button of the mouse in order to know the attribute and local variable values.

    Here is the caption window which shows all the different status of the objects.


    Here is the graphic window which corresponds to the textual window showed above.




    The Status Window

    This window shows the object list where the objects are classified by their status.

    Here is the status window which corresponds to the textual window showed above.




    The Path Window

    This window shows the cross reference list which exists between objects and threads.

    Here is the path window which corresponds to the textual window showed above.




    The Complete Environment

    Here is a view of the complete environment; we can see the program source, a textual view of objects, threads and their status, a graphical view, the status list as well as the cross reference list between objects and threads.




    Detailed Example Of Interpretation

    This example describes several steps of the interpretation of the example program presented above. To see the example, click Here

    Documentation

  • Vers une Sémantique Formelle de Java
    Actes des journées du PRC/GDR de Programmation , Novembre 1997.


  • Contacts

    Isabelle Attali
    Croap
    INRIA Sophia Antipolis BP 93
    06902 Sophia Antipolis - France
    (33) 4 92 38 79 10
    Isabelle.Attali@sophia.inria.fr
    Denis Caromel
    Sloop
    INRIA Sophia Antipolis BP 93
    06902 Sophia Antipolis - France
    (33) 4 92 38 76 31
    Denis.Caromel@sophia.inria.fr
    Marjorie Russo
    Croap
    INRIA Sophia Antipolis BP 93
    06902 Sophia Antipolis - France
    Marjorie.Russo@sophia.inria.fr

    Since November, 14, 1997, you are our    th   visitor.
    Thanks for visiting!