Three types of classes are supported: standard, active and synchronized classes. As in Java there is no generic class in YAON. The class system of YAON is flat, i.e. there is no way to declare local classes inside a class nor anonymous classes, although Java provides syntactic constructs for them. The reason is quite easy. As is pointed out in [Fla97] some semantics problems arise by using the features mentioned above. Inner classes create quite a few special cases, and a confusing array of new rules. That is, one can write programs using these features where the intended semantics is violated by obscures and pathological cases. Also in Java 1.1 and Java 1.1.1, there are compiler bugs where the intended scope of some class modifiers is violated. Discussions about flat class systems versus hierarchic class systems have been done in different forums with different results. For example, in the standardization of Lisp only flat class systems were allowed.
The class name is written in the top part of the rectangle as indicated. The attributes of the class are described in the middle section of the icon, and the methods of the class in the lower section. This general arrangement of information is retained wherever properties of classes or methods are defined. The ellipses (...) appearing after the attributes and methods are significant, and are explained further in section 3.6. As a shortcut, the attributes and methods may be omitted. Two icons, as shown in figure 2, are used independently and with the same semantics.
Normally each YAON diagram has a root class, i.e. the class which will bootstrap the whole diagram. Thinking in Java, this corresponds to the class which contains the main method. Diagrams for distributed systems would have more than one root class, that is more than one bootstraper. This is the case of a client/server where both client and server have a root class. These classes, the root classes, will be depicted with a triangle in the left hand side of the icon class as depicted in figure 3.
If no modifier is used, the default visibility is assumed.
In addition, Java defines special modifiers applicable to classes,
methods and attributes. Table 4 gives
an overview.
|
These special modifiers are denoted by the appropriate keyword written in typewriter font, e.g. static method-name. The only exception is abstract, which may also be written abstract. The modifiers can be combined as for example:
+ static main (String [] args)
This specifies the public static method main of a given
class. An example, which shows the use of modifiers, is
depicted in Figure 4.
The icon for an active class is similar to the one used in ION. However, it is placed next to the class name to leave enough space for the attributes and methods. If the attributes and methods are omitted in the class icon, the active class icon may be placed inside the class icon as in ION (see figure 6).
A synchronized class is depicted by a circle with two crossed lines inside as in figure 7.
These classes are called protected in ION. But, the name protected is already used in Java as a visibility modifier. Therefore, the name synchronized was chosen. If the attributes and methods are omitted in the class icon, the synchronized class icon may be placed inside the class icon as in ION.
Synchronized classes are those whose methods are protected from concurrent invocation of their methods. Some ``synchronisation protocol'' exists in order to protect them. The synchronization of the methods is also depicted in the class box. Icons for the most common synchronization protocols, such as mutual exclusion, readers/writers, guarded, etc. are provided. Actually, the protocol icon must be interpreted as a shorthand of another diagram where the synchronization protocol is specified. Synchronization protocols can be specified using Petri nets, state-charts, etc. If the user would like to have a new one, he has to depict a new protocol icon and must give its specification using one of the formalisms mentioned above.
Now we give examples for the specification of the mutual exclusion and reader/writer protocol using the Petri net class place/transition systems without capacities. A place/transition system consists of places, transitions, arcs to connect places and transitions and a marking of the places. Places are represented as circles, transitions as rectangles and arcs as arrows. A transition may occur if its incoming places contain at least as much tokens as denoted on the incoming arcs with an empty arc meaning one token. If a transition occurs, it removes the needed tokens from its input places and marks it output places with the number of tokens specified by the inscriptions of its outgoing arcs.
Figure 8 shows a mutual exclusion protocol with a critical section modelled by a place and two jobs modelled as tokens on place In waiting to enter it. The rightmost place with an initial marking of one token ensures that only one job can enter the critical section at a time. In figure 9, the reader/writer protocol is shown. The synchronisation is achieved by the place between Reading and Writing. A writer can only enter the critical section modelled by place Writing if there are n tokens in the synchronisation place. This is only possible if no jobs are reading or writing because the total number of jobs is n, the initial marking of place Jobs. Of course, this model may lead to a starvation of a writer if there is always at least one reader reading. However, this issue will not be discussed here because the specifications are only examples.
The table 5 includes all the `built-in'' synchronization protocols of YAON which is similar to the one used in ION.
|
|
|