Transformation rules from AO4AADL to AspectJ

Size: px
Start display at page:

Download "Transformation rules from AO4AADL to AspectJ"

Transcription

1 Transformation rules from AO4AADL to AspectJ 1 Introduction We define a set of transformation rules to map AO4AADL aspects into AspectJ aspects. These transformation rules are based on the RTSJ generator ones in order to ensure the consistency between the RTSJ code and the generated AspectJ code. In this way, a complete Java prototype can be obtained by integrating automatically the generated AspectJ aspects in the RTSJ code. In the following, we present some examples of the transformation rules from AO4AADL to AspectJ. 2 Transformation of Keywords Table1. Transformation of keywords AO4AADL AspectJ aspect aspect pointcut pointcut call inport call outport call inoutport call call subprogram execution inport execution outport execution inoutport call execution subprogram args args advice advice before before after after around void around AO4AADL AspectJ proceed proceed if if else else for for while while variables - initially - applies - to - precedence Declare precedence : in - count - thread - process - subprogram - 3 Transformation of Data Since the data used in the AO4AADL description are already declared in the basic AADL model, we simply use generated classes from this model using the

2 2 RTSJ code generator. In other words, there will be no new transformation rules of data generation for aspect-oriented model. 4 Transformation of identifiers In AO4AADL, identifiers still unchanged in AspectJ. If a name conflict can be generated in the AspectJ code, this collision is resolved by prefixing the generated name using an underscore ( ). Identifiers of ports and subprograms they are transformed using the following rules and taking into consideration the rules of the RTSJ generator : Table2. Transformation rule of a joinpoint intercepting an input port AO4AADL <Port Identifier> Generated Activity.<PORT IDENTIFIER> AspectJ code For example, considering a port called RestoreCode out V, the identifier of this port will be in AspectJ Activity.RESTORECODE OUT V. Table3. Transformation rule of a joinpoint intercepting an input port AO4AADL <Subprogram Identifier> Generated SubPrograms.<Subprogram Identifier>Impl AspectJ code For example, considering a subprogram called CheckValidity, the identifier of this subprogram will be in AspectJ SubPrograms.CheckValidityImpl. 5 Transformation of parameters In AO4AADL, the declaration of the list of parameters used in the pointcuts and the advices have always the following structure : <Parameter_Identifier> : <Parameter_Type> In AspectJ, the order of declaration will be reversed by not reporting the two points separating the identifier of its type. For the type of parameter, it obeys the transformation rules of the RTSJ generator. Thus, the declaration of variables in AspectJ has the following structure : GeneratedTypes.<Parameter_Type> <PARAMETER_IDENTIFIER>

3 Transformation rules from AO4AADL to AspectJ 3 6 Transformation of precedence subclause In AO4AADL, the declaration of the priority of aspects is performed in the precedence subclause. This subclause has always the following structure : precedence <Aspect_Identifier> {, <Aspect_Identifier> The precedence subclause is mapped to AspectJ while keeping the same structure. We have just to replace the keyword precedence by Declare precedence :. Thus the generated AspectJ code has the structure as follows : Declare precedence : <Aspect_Identifier> {, <Aspect_Identifier> 7 Transformation of pointcuts A pointcut consists of one or a combination of a set of joinpoints using logical operators (&&) and ( ). The transformation of a pointcut returns then to the combination of the transformations of each joinpoint using the same logical operators. 8 Transformation of joinpoints The main concepts that we catch in the of a joinpoint are ports and subprograms. In the following, we present how all the joinpoint types (inport outport and subprogram) with a call or execution primitive are translated into AspectJ to obtain a valid code. The inoutport joinpoints are not yet treated as the inout port type is rarely used in AADL models and because it can easily switch ports by using in and out ports. For the args primitive, it is kept unchanged in AspectJ when it is combined with a subprogram joinpoint. Otherwise, it follows the transformation rules that we present in this section. Joinpoint intercepting a subprogram Table 4 presents the rule which translate a joinpoint intercepting a subprogram. As shown in Table 4, the interception of a subprogram at architectural level in AO4AADL returns to intercept, in AspectJ, the right method of the Subprograms class (SubPrograms.<Subprogram Identifier>Impl) already generated by the RTSJ generator. According to the syntax of AspectJ, we have to specify the returning type of the intercepted method. As it was mentioned, all the generated methods are public static void. So we are not interested in the generation of the returning type of the intercepted method. That s why, we use here the wildcard * in the generated AspectJ code. For the parameter types used in AO4AADL, they obey to the transformation rules of the data types defined by the RTSJ generator. Listing 1.2 presents an example of the generated AspectJ code from a pointcut described in AO4AADL which intercepts the execution of the

4 4 Table4. Transformation rule of a joinpoint intercepting a subprogram AO4AADL call/execution subprogram (<Subprogram Identifier> (<Paramerter types>)) Generated call/execution (* SubPrograms.<Subprogram Identifier>Impl AspectJ code (<Generated Parameter Types>)) Ping Spg subprogram taking a Simple Type parameter. The AO4AADL is presented in Listing aspect AspectName { 2 pointcut PointcutName () : execution subprogram (PingSpg (Simple_Type)); Listing 1.1. Example of an AO4AADL pointcut intercepting a subprogram 1 aspect AspectName { 2 pointcut PointcutName () : execution (* SubPrograms.PingSpgImpl (GeneratedTypes.Simple_Type)); Listing 1.2. Generated AspectJ code from Listing 1.1 We have to note that no changes are applied neither to the aspect and the pointcut names nor to the keywords aspect, pointcut and call/execution. When the designer wants to intercept the values of the parameters defined in the considered subprogram he aught to use the following transformation rule : Table5. Transformation rule of a joinpoint intercepting the type of the data to send through an output port AO4AADL call/execution subprogram (<Subprogram Identifier> (<Paramerter Types>)) && args (<Parameter Identifiers>) Generated call/execution (* SubPrograms. Subprogram Identifier Impl AspectJ code (<Generated Paramerter Types>)) && args (<PARAMETER IDENTIFIERS>) Listing 1.3 presents a joinpoint described in AO4AADL intercepting the call of a subprogram called spg tanking two parameters. Listing 1.4 the corresponding generated AspectJ code. 1 pointcut P (i:integer_type, j:integer_type) : 2 call subprogram spg (..) && args (i,j); Listing 1.3. Transformation d un joinpoint interceptant un sous programme

5 Transformation rules from AO4AADL to AspectJ 5 1 pointcut P (GeneratedTypes.IntegerType I,GeneratedTypes.IntegerType J): 2 call Subprogram.spgImpl (..) && args (I,J); Listing 1.4. Generated AspectJ code from Listing 1.4 Joinpoint intercepting an output port In this case, the designer can intercept either the event of sending a message or the type and/or the value of the data to send. Joinpoint intercepting the event of sending a message In the case of intercepting the event of sending a message through an output port (call/execution outport (<Output Port Identifier> (..))) at architectural level, we have to look for the methods (or subprograms) that carry out the exchange of messages through this port at the implementation level. We suppose in this case that we are not interested in the type of the data to send (the wildcard.. ). According to the RTSJ generator, these methods are defined in the Activity class. The study of these methods shows that the interception of an output port in AO4AADL returns to intercept, in AspectJ, the method sendoutput() of the Activity class. This is illustrated in Table 6. Table6. Transformation rule of a joinpoint intercepting an output port AO4AADL call/execution outport (<Output Port Identifier> (..)) Generated call/execution (* Activity.sendOutput(..)) AspectJ code Since all the used methods are public static void, we are not then interested in its returning type. We use therefore the wildcard * in the generated code. As an example of this transformation rule, we present in Listing 1.6 the AspectJ code generated from the pointcut of the aspect defined in Listing aspect CheckCode { 3 pointcut Verification(): call outport (Restore_Code_out_V (..)); Listing 1.5. Example of AO4AADL pointcut intercepting an output port 1 aspect CheckCode{ 2 pointcut Verification(): call (* Activity.sendOutput(..)); Listing 1.6. Generated AspectJ pointcut from listing 1.5

6 6 Joinpoint intercepting the type and/or the value of the data to send If the designer is interested in intercepting the type or the value of the data to send through an output port, then the corresponding method at implementation level is the public static void putvalue of the Activity class. This method has the following structure : public static void putvalue (int entity, OutPort outport, GeneratedType value) where entity presents the identifier of the intercepted thread, the Outport object refers to the intercepted port while value is the value of the data to send. When intercepting only the type of the data to send (call/execution outport (<Output Port Identifier>(<Data Type>))), the used rule in this case is presented in Table 7. While, the interception of the value of this data is translated as shown in Table 8. Table7. Transformation rule of a joinpoint intercepting the type of the data to send through an output port AO4AADL call/execution outport (<Output Port Identifier> (<Data Type>)) Generated call/execution (* Activity.putValue(..,.., AspectJ code GeneratedTypes.<Data Type>)) The first and second types of the arguments of the method putvalue() are not specified because we are not interested in these arguments. In addition, these two types of arguments are always fixed. Table8. Transformation rule of a joinpoint intercepting the value of the data to send through an output port AO4AADL call/execution outport (<Output Port Identifier>(..)) && args (<Data Identifier>) Generated call/execution (* Activity.putValue(..)) && args (..,.., AspectJ code <DATA IDENTIFIER>) In the generated AspectJ code, the first and the second arguments of the args primitive, corresponding to the first and the second parameters of the method putvalue(), are not specified because they are constant and can be deducted easily from the generated RTSJ code. In the case of intercepting both the type and the value of the data to send, we have simply to combine the rules presented in Table 7 and Table 8. Listing 1.7 presents a joinpoint intercepting the value of the data to send through an output port described in AO4AADL. The corresponding AspectJ code is presented in Listing 1.8.

7 Transformation rules from AO4AADL to AspectJ 7 1 pointcut catchoutportdata(value: Integer_Type): 2 call outport (Port_out(..))&& args (value); Listing 1.7. Transformation d un joinpoint interceptant un port de sortie 1 pointcut catchoutportdata (GeneratedTypes.IntegerType VALUE): 2 call(* Activity.putValue(..)) && args (..,..,VALUE); Listing 1.8. Transformation d un joinpoint interceptant un port de sortie As shown in the transformation rules presented in Tables 6, 7 and 8, the identifier of the intercepted port is not specified in the generated AspectJ code. To deal with this limitaion and to specify that the code of the advice is executed only when the port specified at the architectural joinpoint is really catched, the generated advice code should be inserted under a condition that verifies the port s identifier. This condition is used to check if the OutPort parameter of the intercepted method in the generated AspectJ code corresponds to the identifier of the intercepted port specified in the AO4AADL code. Therefore, the generated advice code (more specifically the advice action subclause) has the following structure : For a before or after advice if ((OutPort)(thisJoinPoint.getArgs([1]))).getPortNumber()== Deployment.<Out_PORT_ID>){ //Generated advice action code thisjoinpoint is an AspectJ object which refers to the intercepted joinpoint. The method getargs([1]) applied to this object refers to the second parameter of the intercepted joinpoint. The returned object is casted to the type OutPort to apply the method getportnumber() which returns the number of the intercepted port. The <Out PORT ID> is defined in the Deployment class. Each port has an identification number which has the format : <NODE IDENTIFIER> <THREAD IDENTIFIER> <PORT IDENTIFIER> K. For example the identification number of the output port RestoreCode out V of the Validation thread instance of the ValidationTh thread defined in the process Node Customer is Node Customer Validation RestoreCode out V K. If the identifier of the port is not specified in the joinpoint specified in the AO4AADL code (we use the wildcard * ), this condition will not be generated since this aspect is applied to every output port. For an around advice when intercepting the event of sending a data through an output port if ((OutPort) (thisjoinpoint.getargs([1]))).getportnumber()== Deployment.<Out_PORT_ID>) { //Generated advice action code else{ proceed(<parameter_profile>);

8 8 The else condition is used here to define the executed code when the intercepted output port in the AspectJ aspect is different from the one intercepted in the AO4AADL aspect. We call then the proceed() action to carry on with the execution of the basic RTSJ code. when intercepting the type and/or the value of the data to send, an additional pointcut will be generated in the aspect. Actually, the intercepted method putvalue() is associated with the method sendoutput(). If the first method is not executed by calling a proceed() action then the second method should not be executed. So the second pointcut is supposed to intercept the second method (sendoutput). The name of this pointcut is the combination of the first pointcut name and the suffix sendoutput. Moreover, two advices are generated in this case. The first advice, which is associated to the first pointcut, includes the advice code generated from the AO4AADL advice code. We add to this code a static boolean variable put OK initialized to false. This variable takes the value true whenever the method put- Value() is executed by calling the proceed() action, otherwise it takes the value false. Concerning the second advice, it is associated to the second pointcut and has the following structure : if ((OutPort) (thisjoinpoint.getargs([1]))).getportnumber()== Deployment.<Out_PORT_ID>) { if (put_ok){ proceed(); else{ proceed(); Listing 1.9 shows an example of an AO4AADL aspect intercepting the value of information to send via an output port. An around advice is applied to the pointcut. Listing 1.10 shows the generated AspectJ code from Listing aspect Example{ 2 pointcut catchoutportdata(argument: Integer_Type): 3 call outport(port_out(..))&& args (argument); 4 advice around (argument: Integer_Type): catchoutportdata(argument){ 5 if (condition_1){ 6 proceed(argument); 7 argument:=argument+1; 8 9 else{ //instructions_else 10 Listing 1.9. Aspect interceptant un port de sortie avec un advice around 1 aspect Example{ 2 pointcut catchoutportdata (GeneratedTypes.IntegerType ARGUMENT): 3 call(* Activity.putValue(..)) && args (..,..,ARGUMENT); 4 5 pointcut catchoutportdata_sendoutput ():call(* Activity.sendOutput(..)); 6 7 public static boolean put_ok = false;

9 Transformation rules from AO4AADL to AspectJ void around (GeneratedTypes.IntegerType ARGUMENT): catchoutportdata(argument){ if ((OutPort)(thisJoinPoint.getArgs([1])).getPortNumber()== 12 Deployment.NODE_Customer_VALIDATION_PORT_OUT_K){ 13 if (condition_1){ 14 proceed(argument); 15 put_ok = true; 16 ARGUMENT.value=ARGUMENT.value+1; else{ 19 //instructions_else else{ proceed(argument); void around ():catchoutportdata_sendoutput (){ if ((OutPort)(thisJoinPoint.getArgs([1])).getPortNumber()== 26 Deployment.NODE_CUSTOMER_VALIDATION_PORT_OUT_K){ 27 if (put_ok){ 28 proceed(); else{ proceed(); Listing Code AspectJ gnr partir de l exemple 1.9 Joinpoint intercepting an input port For the joinpoints which intercept an input port, we follow the same reasoning made in the case of intercepting an output port. Actually, the study of the methods of the Activity class has proofed that the interception of an input port at architectural level returns to intercept, at implementation level, two main methods which are : (1) the method public static void storereceivedmessage which enables the designer to know if there is a new incoming message to the input port, and (2) public static void getvalue allowing to intercept the type and/or the value of the received data. As a result, three transformation rules are used to translate a joinpoint intercepting an input port from AO4AADL to AspectJ. Joinpoint intercepting the event of receiving a message Table 9 presents the rule applied in the the case of intercepting the event of receiving a message. Table9. Transformation rule of a joinpoint intercepting an input port AO4AADL call/execution inport (<Input Port Identifier> (..)) Generated call/execution (* Activity.storeReceivedMessage(..)) AspectJ code Listing 1.11 shows an AO4AADL joinpoint intercepting the event of receiving a data on an input port called Port in. The corresponding AspectJ code is presented in Listing 1.12.

10 10 1 pointcut catchinport():call inport (Port_in(..)); Listing Transformation d un joinpoint interceptant un port d entre 1 pointcut catchinport():call (* Activity.storeReceivedMessage(..)); Listing Transformation d un joinpoint interceptant un port d entre Joinpoint intercepting the type and/or the value of the received data In this case, two transformation rules are defined. Table 10 specifies the rule used to intercept the type of the incoming data while the rule presented in Table 11 is used when intercepting the value of the incoming data. Table10. Transformation rule of a joinpoint intercepting the type of the incoming data to an input port AO4AADL call/execution inport (<Input Port Identifier> (<Data Type>)) Generated call/execution (* Activity.getValue(..,.., AspectJ code GeneratedTypes.<Data Type>)) The types of the first and the second arguments of the method put- Value() are not specified for the same reasons as in the case of output ports. Table11. Transformation rule of a joinpoint intercepting the value of the incoming data to an input port AO4AADL call/execution inport (<Input Port Identifier>(..)) && args (<Data Identifier>) Generated call/execution (* Activity.getValue(..)) && args (..,.., AspectJ code <DATA IDENTIFIER>) The first two arguments of the args primitive are not specified for the same reasons as in the case of output ports. The combination of the two last rules leads to the interception of both the type and the value of the incoming data. Listing 1.13 presents an AO4AADL joinpoint intercepting the type and the value of the received data on an input port. The corresponding AspectJ code is presented in Listing pointcut catchinporttypedata(argument: Integer_Type):

11 Transformation rules from AO4AADL to AspectJ 11 3 call inport (Port_in(Integer_Type)) && args (argument); Listing Transformation d un joinpoint interceptant un port d entre 1 2 pointcut catchinporttypedata (GeneratedTypes.IntegerType ARGUMENT): 3 call(* Activity.getValue(..,..,GeneratedTypes.IntegerType)) 4 && args(..,..,argument); Listing Transformation d un joinpoint interceptant un port d entre As we mentioned in the case of intercepting an output port, the generated advice should be inserted under a condition that verifies the port s identifier. Therefore, the generated advice code has the following structure : For a before or after advice when intercepting the event of receiving a data if ((InPort)(thisJoinPoint.getArgs([0]))).getPortNumber()== Deployment.<In_PORT_ID>){ //Generated advice action code when intercepting the type and/or the value of the received data if ((InPort)(thisJoinPoint.getArgs([1]))).getPortNumber()== Deployment.<In_PORT_ID>){ //Generated advice action code The difference here between these two cases consists in the position of the InPort parameter in the intercepted method. For the public static void storereceivedmessage (InPort inport, Message msg, long timestamp), this parameter takes the position 0 ; while for the public static void getvalue (int entity, InPort inport, GeneratedType destination) the InPort parameter takes the position 1. For an around advice when intercepting the event of receiving a data if ((InPort) (thisjoinpoint.getargs([0]))).getportnumber()== Deployment.<In_PORT_ID>) { //Generated advice action code else{ proceed(<parameter_profile>); when intercepting the type and/or the value of the received data if ((InPort) (thisjoinpoint.getargs([1]))).getportnumber()== Deployment.<In_PORT_ID>) { //Generated advice action code else{ proceed(<parameter_profile>); If the identifier of the port is not specified in the joinpoint specified in the AO4AADL code (we use the wildcard * ), this condition will not be generated since this aspect is applied to every input port.

12 12 9 Transformation rules of the advice We present in this part the transformation rules used to translate the instructions used in the advice subclause from AO4AADL to AspectJ. 9.1 Transformation rules of the advice declaration and the pointcut reference For the generated advice declaration and the pointcut reference parts, they keep the same structure used in AO4AADL. We have only omitted the keyword advice and applied the transformation rules defined by the RTSJ generator to translate the declared parameters. Concerning the variables and the initially parts, they will be combined in the generated AspectJ code. For each variable declared in the variables subclause, the transformation rule presented in Table 12 is applied. Table12. Transformation rule of a variable declared in the variables subclause AO4AADL <Variable Identifier> : <Variable Type> ; Generated public static final GeneratedTypes.<Variable Type> AspectJ code <VARIABLE IDENTIFIER> = new Generated- Types.<Variable Type>(<Variable Value>) ; where <Variable Value> corresponds to the initial value of the variable defined in the initially subclause. If this variable is not initialized then a default value is attributed depending on the type of the variable. For example, the default value of an integer type is 0. Listing 1.15 presents the generated AspectJ code for a declared and initialized integer variable. Listing 1.16 shows the generated code for a declared and not initialized integer variable. //AO4AADL variables { counter : Integer_Type; initially { counter := 1; //Generated AspectJ code public static final GeneratedTypes.IntegerType COUNTER = new GeneratedTypes.IntegerType (1); Listing Generated AspectJ code for a declared and initialized integer variable //AO4AADL variables { counter : Integer_Type; //Generated AspectJ code public static final GeneratedTypes.IntegerType COUNTER = new GeneratedTypes.IntegerType (0);

13 Transformation rules from AO4AADL to AspectJ 13 Listing Generated AspectJ code for a declared and not initialized integer variable 9.2 Transformation rules of the action subclause What about the action subclause, we present the main defined transformation rules to obtain an AspectJ code from an AO4AADL. Transformation of identifiers In this subclause, the identifiers of the variables and parameters are translated according to the transformation rule presented in Table 13. Table13. Transformation rule of the identifiers of variables and parameters used in the action subclause AO4AADL <Variable or Parameter Identifier> Generated <VARIABLE OR PARAMETER IDENTIFIER>.value AspectJ code This rule is applied for all the identifiers except those used in the communication and the proceed() actions. In this case, the generated identifiers have the following structure : <VARIABLE OR PARAMETER IDENTIFIER>. Transformation des constants Constants used in AO4AADL are the numerical values, the number of messages in the queue for an entry port and the boolean values. For the numerical and the boolean values, they are kept without modification. For the second type of constant, the transformation rule is presented in table 14 : Table14. Transformation rule of the number of messages in the queue for an entry port Acti- AO4AADL <Input Port Identifier> count Generated Activity.getCount(Deployment.<THREAD ID>, AspectJ code vity.<input PORT IDENTIFIER>)

14 14 Transformation of the assignment operation In AO4AADL, the structure of the assignment operation is : <Variable_or_Parameter_Identifier> := <Expression> ; In AspectJ, this structure is kept as it is replacing the assignment sign ( :=) by the equal sign (=) while respecting the rules of transformation is presented in table 15 : Table15. Transformation rule of the number of messages in the queue for an entry port AO4AADL <Variable or Parameter Identifier> := <Expression> ; Generated <VARIABLE OR PARAMETER IDENTIFIER>.value = AspectJ code <Generated Expression> ; Transformation of conditions Conditions used in AO4AADL are projected in AspectJ keeping the same structure and respecting the transformation rules presented in table 16 : Table16. Transformation rules of the operators AO4AADL AspectJ or and && not! = == > > < <!=!= Transformation of the arithmetic operators Arithmetic operations used in AO4AADL are mapped into AspectJ without modification. Arithmetic operation has always the following structure : <Left_Expression> <operator> <Right_Expression> where <operator> belongs to the following set of operators : {*, /, +, -

15 Transformation rules from AO4AADL to AspectJ 15 Transformation of the communication operations For the communication actions presented in lines of Listing 1.19, we followed the transformation rules used by the RTSJ generator. In AO4AADL, communication operations can be summarized in three main operations namely (1) the execution of a subprogram (2) reading data from an input port and (3) writing data on an output port. The structures of these various operations are respectively : 1. <Required Subprogram Identifier>! (<Parameter Profile>) 2. <Input Port Identifier>? (<Data Identifier>) 3. <Output Port Identifier>! (<Data Identifier>) According to this generator, for a given node, the generated Subprograms class includes only the subprograms called by a thread forming this node. Unfortunately, a subprogram can be used inside the advice action without being called by any thread. Our idea is then to extend this class by generating, for each node, the methods that correspond to the called subprograms in the AO4AADL aspects. Therefore, calling a subprogram inside the advice action in the AO4AADL returns to call the corresponding method in the Subprograms class for the generated AspectJ code. Transformation rules applied to the three types of the communication operations are presented in tables 17, 18 and 19 respectively : Table17. Transformation rule of the number of messages in the queue for an entry port AO4AADL <Required Subprogram Identifier>! (<Parameter Profile>) Generated SubPrograms.<Required Subprogram Identifier>Impl AspectJ code (PARAMETER PROFILE) According to the RTSJ generator, the operation of receiving a message by an input port is translated into two other methods from the Activity class which are : (1) the getvalue() method which enables to get the data on the port and (2) the nextvalue() method to dequeue one entry from the input port s queue. Table 19 presents the transformation rule of the operation of sending a message through an output port. As shown in Table 19, this operation is translated into two methods : (1) the putvalue() method which enables to put the data on the port and (2) the sendoutput() method to send the data to the corresponding destination. Transformation of the proceed operations Concerning the proceed() action, it keeps the same structure presented in AO4AADL respecting the transformation rules applied to the identifiers. Transformations of conditions and loops

16 16 Table18. Transformation rule of the operation of receiving a message by an input port AO4AADL <Input Port Identifier>? (<Data Identifier>) Generated AspectJ code try { Activity.getValue (Deploymet.<THREAD ID>, Activity.<INPUT PORT IDENTIFIER>, <DATA IDENTIFIER>) ; catch (ProgramException e) { Debug.debugMessage ( error while performing get value in port + Deployment.<INPUT PORT IDENTIFIER>.getPortNumber () + from thread + Deployment.<THREAD ID>) ; throw e ; try { Activity.nextValue (Deploymet.<THREAD ID>, Activity.<INPUT PORT IDENTIFIER>) ; catch (ProgramException e) { Debug.debugMessage ( Error while performing next value in port + Deployment.<INPUT PORT IDENTIFIER>.getPortNumber ()+ from thread + Deployment.<THREAD ID>) ; throw e ;

17 Transformation rules from AO4AADL to AspectJ 17 Table19. Transformation rule of the operation of sending a message through an output port AO4AADL <Output Port Identifier>! (<Data Identifier>) Generated AspectJ code try { Activity.putValue (Deploymet.<THREAD ID>, Activity.<OUTPUT PORT IDENTIFIER>, <DATA IDENTIFIER>) ; catch (ProgramException e) { Debug.debugMessage ( error while putting value in port + Deployment.<OUTPUT PORT IDENTIFIER>.getPortNumber () + from entity + Deployment.<THREAD ID>) ; throw e ; try { Activity.sendOutput (Deploymet.<THREAD ID>, Activity.<OUTPUT PORT IDENTIFIER>) ; catch (ProgramException e) { Debug.debugMessage ( Error while sending output in port + Deployment.<OUTPUT PORT IDENTIFIER>.getPortNumber ()+ from entity + Deployment.<THREAD ID>) ; throw e ;

18 18 Transformation of if conditions In AspcetJ, the if condition keeps the same structure used in AO4AADL while respecting the transformation rules presented above. Transformation of the while loop The while loop keeps the same structure used in AO4AADL while respecting the transformation rules presented above. Transformation of the for loop The transformation of the for loop from AO4AADL to AspectJ is performed according to the rule presented in table 20 : Table20. Transformation rule of the for loop AO4AADL for (<Loop Variable Identifier> in <Integer Range>) Generated for (<LOOP VARIABLE IDENTIFIER>.value = AspectJ code <Min Value> ; <LOOP VARIABLE IDENTIFIER>.value < <Max Value> ; <LOOP VARIABLE IDENTIFIER>.value++) where <Integer Range> is the interval in which varies the loop counter (<loop variable identifier>). It has always the following form : Integer_Range ::= Min_Value.. Max_Value For the for loop in AO4AADL, we specify the identifier of the counter <Loop Variable Identifier> and the interval in which varies the counter <Integer Range>. When transforming the for loop to the AspectJ language, the part between brackets will be divided into three parts : 1. initialization : The loop counter is initialized to the minimum value of the specified interval. 2. condition : Boolean expression that controls the passages in the loop that are as long as it is true. This expression is generally of the form : counter maximum value of the specified interval. 3. transition : instruction executed before each new pass through the loop. It increments the counter by 1. Listing 1.17 presents a complete example of AO4AADL aspect. Listing 1.18 presents the generated AspectJ code. 1 aspect CheckCode{ 2 pointcut Verification(): call outport (Restore_Code_out_V (..)); 3 4 advice around():verification(){ 5 6 variables { counter : Integer_Type; message : String_Type 7 initially { counter:=1; message:= "Card Rejected!"; 8 9 if(counter=3){ 10 Rejected_Card_out_V!(message); 11 counter := 1; 12

19 Transformation rules from AO4AADL to AspectJ else{ 14 proceed(); 15 counter := counter; 16 Listing Complete example of AO4AADL aspect 1 //List of import instructions generated in every AspectJ file 2 import fr.enst.ocarina.polyorb_hi_runtime.outport; 3 import fr.enst.ocarina.polyorb_hi_runtime.inport; 4 import fr.enst.ocarina.polyorb_hi_runtime.programexception; 5 import fr.enst.ocarina.polyorb_hi_runtime.debug; 6 import fr.enst.ocarina.polyorb_hi_runtime.message; 7 8 aspect CheckCode{ 9 //The generated AspectJ pointcut 10 //In our case, we intercept the event of sending a data through an output port 11 pointcut Verification(): call (* Activity.sendOutput (..)); //The variables generated from the variables and initially sections 14 public static final GeneratedTypes.IntegerType COUNTER = 15 new GeneratedTypes.IntegerType(1); public static final GeneratedTypes.StringType MESSAGE = 18 new GeneratedTypes.StringType("Card Rejected!"); 19 //The generated Advice code 20 void around():verification(){ //Advice declaration //The condition that checks the intercepted port 23 //In our case the identification number of the output port is 24 //NODE_CUSTOMER_VALIDATION_RESTORECODE_OUT_K 25 if (((OutPort)(thisJoinPoint.getArgs()[1])).getPortNumber()== 26 Deployment.NODE_CUSTOMER_VALIDATION_RESTORECODE_OUT_K){ //The generated advice action part 29 if(counter.value==3){ 30 // Set the call sequence OUT port values 31 try { 32 Activity.putValue(Deployment.NODE_CUSTOMER_VALIDATION_K, 33 Activity.REJECTEDCARD_OUT_V, MESSAGE); catch (ProgramException e) { 36 Debug.debugMessage("Error while putting value in port " 37 +Deployment.NODE_CUSTOMER_VALIDATION_REJECTEDCARD_OUT_K 38 + " from entity " + Deployment.NODE_CUstomer_VALIDATION_K); // Send the call sequence OUT port values 41 try { 42 Activity.sendOutput(Deployment.NODE_CUSTOMER_VALIDATION_K, 43 Activity.REJECTEDCARD_OUT_V); 44 catch (ProgramException e) { 45 Debug.debugMessage("Error while sending output in port " 46 + Deployment.NODE_CUSTOMER_VALIDATION_REJECTEDCARD_OUT_K 47 + " from entity " + Deployment.NODE_CUSTOMER_VALIDATION_K); 48 COUNTER.value=1; else{ 51 //The proceed action 52 proceed(); //The generated code from the assignment action 55 //In this case, the operator ":=" used in AO4AADL is transformed 56 //to the operator "=" 57 //For the arithmetic operations, no changes are applied to 58 //the operators {*, /, +, - 59 COUNTER.value=COUNTER.value+1;

20 //This code will be executed if the intercepted port is not RestoreCode_Out_V. 62 else{proceed(); Listing Generated AspectJ code from listing 1.17 In Listing 1.18, lines 2 6 shows the list of the imported files that should be present in every generated AspectJ file. Line 11 corresponds to the generated pointcut. Lines presents the list of the generated local variables. The generated advice code is presented in lines Notes : In order to have a valid code, the following imports must be added to each generated aspect : import fr.enst.ocarina.polyorb_hi_runtime.outport; import fr.enst.ocarina.polyorb_hi_runtime.inport; import fr.enst.ocarina.polyorb_hi_runtime.programexception; import fr.enst.ocarina.polyorb_hi_runtime.debug; import fr.enst.ocarina.polyorb_hi_runtime.message; The transformation rules presented here are applicable to aspects that are reported as an annex in a thread or a subprogram. In the case where the aspect affects several architectural components, it is declared in an external package visible to all the system. The transformation rules presented here remain valid ; we have just to generate this aspect for each node of the application while applying the following rules : If the aspect uses a subprogram, it will be generated in all Subprograms classes of all nodes of the application. If the Subprograms class already contains the corresponding method to this subprogram then the generation will be ignored for this class. For the code of the advice and in the case of the interception of ports, we have simply to combine the condition of checking the identifier of the port generated in the case of an aspect applied to a single thread with the conditions of verification of the identifiers of the treads intercepted in a node with a logical operator (&&). These conditions are separate by a logical operator (&&). Identifiers are deduced easily from the list of the specified components in section applies to of the aspect and using the Deployment class. The conditions of verifying identifiers of the intercepted threads are generated using the following rules. : If we intercept the event of receiving a message on an input port, the generated verification condition has the following form : (Message)(thisJoinPoint.getArgs([1])).getmydestination()== Deployment.<THREAD_ID> For all other cases, the generated verification condition has the following form : (int)(thisjoinpoint.getargs([0]))== Deployment.<THREAD_ID>

21 Transformation rules from AO4AADL to AspectJ 21 Example : We suppose an application composed of two processes : A process called Node A composed of three threads TA1, TA2 and TA3. A process called Node B composed of two threads TB1 et TB2. The snippet code 1.19 presents a complete example of AO4AADL aspect declared in an external package. 1 aspect Logging { 2 applies to thread TA1, thread TA2, process Node_B; 3 pointcut count() : execution outport (* (..)); 4 advice after (): count(){ 5 variables{counter:integer_type; 6 initially{counter:=1; 7 counter:=counter+1; Listing Example of AO4AADL aspect affecting several components Since the aspect intercepts the threads TA1 and TA2 of the process Node A and all threads of the process Node B, then there will be generation of two aspects for each process. Listing 1.20 shows the AspectJ code generated for the process Node A and listing 1.21 corresponds to the AspectJ code generated for the process Node B. 1 import fr.enst.ocarina.polyorb_hi_runtime.outport; 2 import fr.enst.ocarina.polyorb_hi_runtime.inport; 3 import fr.enst.ocarina.polyorb_hi_runtime.programexception; 4 import fr.enst.ocarina.polyorb_hi_runtime.debug; 5 import fr.enst.ocarina.polyorb_hi_runtime.message; 6 7 aspect Logging { 8 9 pointcut count () : execution (* Activity.sendOutput (..)); 10 public static final GeneratedTypes.IntegerType COUNTER = 11 new GeneratedTypes.IntegerType(1); 12 after ():count (){ 13 if(((int)(thisjoinpoint.getargs([0]))== Deployment.NODE_A_TA1_K) 14 (((int)(thisjoinpoint.getargs([0]))== 15 Deployment.NODE_A_TA2_K)){ 16 COUNTER.value=COUNTER.value+1; Listing Generated AspectJ code for Node A of the application 1 import fr.enst.ocarina.polyorb_hi_runtime.outport; 2 import fr.enst.ocarina.polyorb_hi_runtime.inport; 3 import fr.enst.ocarina.polyorb_hi_runtime.programexception; 4 import fr.enst.ocarina.polyorb_hi_runtime.debug; 5 import fr.enst.ocarina.polyorb_hi_runtime.message; 6 7 aspect Logging { 8 9 pointcut count () : execution (* Activity.sendOutput (..)); 10 public static final GeneratedTypes.IntegerType COUNTER = 11 new GeneratedTypes.IntegerType(1); 12 after ():count (){ 13 if(((int)(thisjoinpoint.getargs([0]))== Deployment.NODE_B_TB1_K) 14 (((int)(thisjoinpoint.getargs([0]))== Deployment.NODE_B_TB2_K)){ 15 COUNTER.value=COUNTER.value+1; Listing Generated AspectJ code for Node B of the application

22 22 10 Conclusion we presented here one of our main contributions.it consists in the definition of a set of transformation rules that enables the designer to translate the AO4AADL into AspectJ code. These transformation rules are based on the RTSJ generator ones. Actually, the transformation from AO4AADL to AspectJ is not so hard since the syntax and semantics of our language is very close to the AspectJ ones.

AO4AADL Compiler. Sihem Loukil. June 2011

AO4AADL Compiler. Sihem Loukil. June 2011 AO4AADL Compiler Sihem Loukil June 2011 We present in this report the main tools used in our work. Then, we detail one of our main contributions. Finally, we present the several steps to implement our

More information

CS111: PROGRAMMING LANGUAGE II

CS111: PROGRAMMING LANGUAGE II CS111: PROGRAMMING LANGUAGE II Computer Science Department Lecture 1(c): Java Basics (II) Lecture Contents Java basics (part II) Conditions Loops Methods Conditions & Branching Conditional Statements A

More information

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

Operators. Java operators are classified into three categories:

Operators. Java operators are classified into three categories: Operators Operators are symbols that perform arithmetic and logical operations on operands and provide a meaningful result. Operands are data values (variables or constants) which are involved in operations.

More information

3. Java - Language Constructs I

3. Java - Language Constructs I Educational Objectives 3. Java - Language Constructs I Names and Identifiers, Variables, Assignments, Constants, Datatypes, Operations, Evaluation of Expressions, Type Conversions You know the basic blocks

More information

1 Lexical Considerations

1 Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2013 Handout Decaf Language Thursday, Feb 7 The project for the course is to write a compiler

More information

CS313D: ADVANCED PROGRAMMING LANGUAGE

CS313D: ADVANCED PROGRAMMING LANGUAGE CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science Department Lecture 3: C# language basics Lecture Contents 2 C# basics Conditions Loops Methods Arrays Dr. Amal Khalifa, Spr 2015 3 Conditions and

More information

Operators and Expressions

Operators and Expressions Operators and Expressions Conversions. Widening and Narrowing Primitive Conversions Widening and Narrowing Reference Conversions Conversions up the type hierarchy are called widening reference conversions

More information

CS111: PROGRAMMING LANGUAGE II

CS111: PROGRAMMING LANGUAGE II 1 CS111: PROGRAMMING LANGUAGE II Computer Science Department Lecture 1: Introduction Lecture Contents 2 Course info Why programming?? Why Java?? Write once, run anywhere!! Java basics Input/output Variables

More information

Programming in C++ 5. Integral data types

Programming in C++ 5. Integral data types Programming in C++ 5. Integral data types! Introduction! Type int! Integer multiplication & division! Increment & decrement operators! Associativity & precedence of operators! Some common operators! Long

More information

Java Primer 1: Types, Classes and Operators

Java Primer 1: Types, Classes and Operators Java Primer 1 3/18/14 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser, Wiley, 2014 Java Primer 1: Types,

More information

Control Flow. COMS W1007 Introduction to Computer Science. Christopher Conway 3 June 2003

Control Flow. COMS W1007 Introduction to Computer Science. Christopher Conway 3 June 2003 Control Flow COMS W1007 Introduction to Computer Science Christopher Conway 3 June 2003 Overflow from Last Time: Why Types? Assembly code is typeless. You can take any 32 bits in memory, say this is an

More information

Programming with Java

Programming with Java Programming with Java Data Types & Input Statement Lecture 04 First stage Software Engineering Dep. Saman M. Omer 2017-2018 Objectives q By the end of this lecture you should be able to : ü Know rules

More information

Getting started with Java

Getting started with Java Getting started with Java Magic Lines public class MagicLines { public static void main(string[] args) { } } Comments Comments are lines in your code that get ignored during execution. Good for leaving

More information

ASML Language Reference Manual

ASML Language Reference Manual ASML Language Reference Manual Tim Favorite (tuf1) & Frank Smith (fas2114) - Team SoundHammer Columbia University COMS W4115 - Programming Languages & Translators 1. Introduction The purpose of Atomic

More information

Lecture 2: Variables and Operators. AITI Nigeria Summer 2012 University of Lagos.

Lecture 2: Variables and Operators. AITI Nigeria Summer 2012 University of Lagos. Lecture 2: Variables and Operators AITI Nigeria Summer 2012 University of Lagos. Agenda Variables Types Naming Assignment Data Types Type casting Operators Declaring Variables in Java type name; Variables

More information

Sequence structure. The computer executes java statements one after the other in the order in which they are written. Total = total +grade;

Sequence structure. The computer executes java statements one after the other in the order in which they are written. Total = total +grade; Control Statements Control Statements All programs could be written in terms of only one of three control structures: Sequence Structure Selection Structure Repetition Structure Sequence structure The

More information

CS1622. Semantic Analysis. The Compiler So Far. Lecture 15 Semantic Analysis. How to build symbol tables How to use them to find

CS1622. Semantic Analysis. The Compiler So Far. Lecture 15 Semantic Analysis. How to build symbol tables How to use them to find CS1622 Lecture 15 Semantic Analysis CS 1622 Lecture 15 1 Semantic Analysis How to build symbol tables How to use them to find multiply-declared and undeclared variables. How to perform type checking CS

More information

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

Weiss Chapter 1 terminology (parenthesized numbers are page numbers) Weiss Chapter 1 terminology (parenthesized numbers are page numbers) assignment operators In Java, used to alter the value of a variable. These operators include =, +=, -=, *=, and /=. (9) autoincrement

More information

Lexical Considerations

Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2010 Handout Decaf Language Tuesday, Feb 2 The project for the course is to write a compiler

More information

LECTURE 2 (Gaya College of Engineering)

LECTURE 2 (Gaya College of Engineering) LECTURE 2 (Gaya College of Engineering) 1) CHARACTERISTICS OF OBJECTS: Object is an instance of a class. So, it is an active entity. Objects have three basic characteristics. They are- State: An object

More information

Chapter 4 Defining Classes I

Chapter 4 Defining Classes I Chapter 4 Defining Classes I This chapter introduces the idea that students can create their own classes and therefore their own objects. Introduced is the idea of methods and instance variables as the

More information

Index COPYRIGHTED MATERIAL

Index COPYRIGHTED MATERIAL Index COPYRIGHTED MATERIAL Note to the Reader: Throughout this index boldfaced page numbers indicate primary discussions of a topic. Italicized page numbers indicate illustrations. A abstract classes

More information

MATLIP: MATLAB-Like Language for Image Processing

MATLIP: MATLAB-Like Language for Image Processing COMS W4115: Programming Languages and Translators MATLIP: MATLAB-Like Language for Image Processing Language Reference Manual Pin-Chin Huang (ph2249@columbia.edu) Shariar Zaber Kazi (szk2103@columbia.edu)

More information

Lexical Considerations

Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Fall 2005 Handout 6 Decaf Language Wednesday, September 7 The project for the course is to write a

More information

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS PAUL L. BAILEY Abstract. This documents amalgamates various descriptions found on the internet, mostly from Oracle or Wikipedia. Very little of this

More information

CS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University

CS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University CS5000: Foundations of Programming Mingon Kang, PhD Computer Science, Kennesaw State University Overview of Source Code Components Comments Library declaration Classes Functions Variables Comments Can

More information

Sir Muhammad Naveed. Arslan Ahmed Shaad ( ) Muhammad Bilal ( )

Sir Muhammad Naveed. Arslan Ahmed Shaad ( ) Muhammad Bilal ( ) Sir Muhammad Naveed Arslan Ahmed Shaad (1163135 ) Muhammad Bilal ( 1163122 ) www.techo786.wordpress.com CHAPTER: 2 NOTES:- VARIABLES AND OPERATORS The given Questions can also be attempted as Long Questions.

More information

Accelerating Information Technology Innovation

Accelerating Information Technology Innovation Accelerating Information Technology Innovation http://aiti.mit.edu Cali, Colombia Summer 2012 Lesson 02 Variables and Operators Agenda Variables Types Naming Assignment Data Types Type casting Operators

More information

Getting started with Java

Getting started with Java Getting started with Java by Vlad Costel Ungureanu for Learn Stuff Programming Languages A programming language is a formal constructed language designed to communicate instructions to a machine, particularly

More information

FRAC: Language Reference Manual

FRAC: Language Reference Manual FRAC: Language Reference Manual Justin Chiang jc4127 Kunal Kamath kak2211 Calvin Li ctl2124 Anne Zhang az2350 1. Introduction FRAC is a domain-specific programming language that enables the programmer

More information

DM550 / DM857 Introduction to Programming. Peter Schneider-Kamp

DM550 / DM857 Introduction to Programming. Peter Schneider-Kamp DM550 / DM857 Introduction to Programming Peter Schneider-Kamp petersk@imada.sdu.dk http://imada.sdu.dk/~petersk/dm550/ http://imada.sdu.dk/~petersk/dm857/ OBJECT-ORIENTED PROGRAMMING IN JAVA 2 Programming

More information

AADL Generative Implementation Annex

AADL Generative Implementation Annex Institut Supérieur de l Aéronautique et de l Espace AADL Generative Implementation Annex Jérôme Hugues, ISAE Key question answered by the annex How to implement a subprogram, and bind it to an AADL model?

More information

AspectC++ A Language Overview

AspectC++ A Language Overview AspectC++ A Language Overview c 2005 Olaf Spinczyk Friedrich-Alexander University Erlangen-Nuremberg Computer Science 4 May 20, 2005 This is an overview about the AspectC++ language, an

More information

So, What is an Aspect?

So, What is an Aspect? Introduction to AspectJ Aspect-oriented paradigm AspectJ constructs Types of Join Points Primitive Lexical designators Type designators Control flow Types of Advice Before After Around Receptions Join

More information

Aspect-Oriented Programming with C++ and AspectC++

Aspect-Oriented Programming with C++ and AspectC++ Aspect-Oriented Programming with C++ and AspectC++ AOSD 2007 Tutorial University of Erlangen-Nuremberg Computer Science 4 Presenters Daniel Lohmann dl@aspectc.org University of Erlangen-Nuremberg, Germany

More information

UNIT- 3 Introduction to C++

UNIT- 3 Introduction to C++ UNIT- 3 Introduction to C++ C++ Character Sets: Letters A-Z, a-z Digits 0-9 Special Symbols Space + - * / ^ \ ( ) [ ] =!= . $, ; : %! &? _ # = @ White Spaces Blank spaces, horizontal tab, carriage

More information

School of Computer Science CPS109 Course Notes 5 Alexander Ferworn Updated Fall 15

School of Computer Science CPS109 Course Notes 5 Alexander Ferworn Updated Fall 15 Table of Contents 1 INTRODUCTION... 1 2 IF... 1 2.1 BOOLEAN EXPRESSIONS... 3 2.2 BLOCKS... 3 2.3 IF-ELSE... 4 2.4 NESTING... 5 3 SWITCH (SOMETIMES KNOWN AS CASE )... 6 3.1 A BIT ABOUT BREAK... 7 4 CONDITIONAL

More information

Java 2 Programmer Exam Cram 2

Java 2 Programmer Exam Cram 2 Java 2 Programmer Exam Cram 2 Copyright 2003 by Que Publishing International Standard Book Number: 0789728613 Warning and Disclaimer Every effort has been made to make this book as complete and as accurate

More information

MID TERM MEGA FILE SOLVED BY VU HELPER Which one of the following statement is NOT correct.

MID TERM MEGA FILE SOLVED BY VU HELPER Which one of the following statement is NOT correct. MID TERM MEGA FILE SOLVED BY VU HELPER Which one of the following statement is NOT correct. In linked list the elements are necessarily to be contiguous In linked list the elements may locate at far positions

More information

M/s. Managing distributed workloads. Language Reference Manual. Miranda Li (mjl2206) Benjamin Hanser (bwh2124) Mengdi Lin (ml3567)

M/s. Managing distributed workloads. Language Reference Manual. Miranda Li (mjl2206) Benjamin Hanser (bwh2124) Mengdi Lin (ml3567) 1 M/s Managing distributed workloads Language Reference Manual Miranda Li (mjl2206) Benjamin Hanser (bwh2124) Mengdi Lin (ml3567) Table of Contents 1. Introduction 2. Lexical elements 2.1 Comments 2.2

More information

1/16/2013. Program Structure. Language Basics. Selection/Iteration Statements. Useful Java Classes. Text/File Input and Output.

1/16/2013. Program Structure. Language Basics. Selection/Iteration Statements. Useful Java Classes. Text/File Input and Output. Program Structure Language Basics Selection/Iteration Statements Useful Java Classes Text/File Input and Output Java Exceptions Program Structure 1 Packages Provide a mechanism for grouping related classes

More information

Some language elements described in this text are not yet supported in the current JAsCo version (0.8.x). These are: Multiple hook constructors

Some language elements described in this text are not yet supported in the current JAsCo version (0.8.x). These are: Multiple hook constructors !IMPORTANT! Some language elements described in this text are not yet supported in the current JAsCo version (0.8.x). These are: Multiple hook constructors Gotchas when migrating to 0.8.5 from an earlier

More information

CSC 1214: Object-Oriented Programming

CSC 1214: Object-Oriented Programming CSC 1214: Object-Oriented Programming J. Kizito Makerere University e-mail: jkizito@cis.mak.ac.ug www: http://serval.ug/~jona materials: http://serval.ug/~jona/materials/csc1214 e-learning environment:

More information

CS 231 Data Structures and Algorithms, Fall 2016

CS 231 Data Structures and Algorithms, Fall 2016 CS 231 Data Structures and Algorithms, Fall 2016 Dr. Bruce A. Maxwell Department of Computer Science Colby College Course Description Focuses on the common structures used to store data and the standard

More information

Chapter 3: Operators, Expressions and Type Conversion

Chapter 3: Operators, Expressions and Type Conversion 101 Chapter 3 Operators, Expressions and Type Conversion Chapter 3: Operators, Expressions and Type Conversion Objectives To use basic arithmetic operators. To use increment and decrement operators. To

More information

SMURF Language Reference Manual Serial MUsic Represented as Functions

SMURF Language Reference Manual Serial MUsic Represented as Functions SMURF Language Reference Manual Serial MUsic Represented as Functions Richard Townsend, Lianne Lairmore, Lindsay Neubauer, Van Bui, Kuangya Zhai {rt2515, lel2143, lan2135, vb2363, kz2219}@columbia.edu

More information

CS313D: ADVANCED PROGRAMMING LANGUAGE. Lecture 3: C# language basics II

CS313D: ADVANCED PROGRAMMING LANGUAGE. Lecture 3: C# language basics II CS313D: ADVANCED PROGRAMMING LANGUAGE Lecture 3: C# language basics II Lecture Contents 2 C# basics Methods Arrays Methods 3 A method: groups a sequence of statement takes input, performs actions, and

More information

Object Oriented Programming. Java-Lecture 6 - Arrays

Object Oriented Programming. Java-Lecture 6 - Arrays Object Oriented Programming Java-Lecture 6 - Arrays Arrays Arrays are data structures consisting of related data items of the same type In Java arrays are objects -> they are considered reference types

More information

CA4003 Compiler Construction Assignment Language Definition

CA4003 Compiler Construction Assignment Language Definition CA4003 Compiler Construction Assignment Language Definition David Sinclair 2017-2018 1 Overview The language is not case sensitive. A nonterminal, X, is represented by enclosing it in angle brackets, e.g.

More information

Computational Expression

Computational Expression Computational Expression Variables, Primitive Data Types, Expressions Janyl Jumadinova 28-30 January, 2019 Janyl Jumadinova Computational Expression 28-30 January, 2019 1 / 17 Variables Variable is a name

More information

Array. Prepared By - Rifat Shahriyar

Array. Prepared By - Rifat Shahriyar Java More Details Array 2 Arrays A group of variables containing values that all have the same type Arrays are fixed length entities In Java, arrays are objects, so they are considered reference types

More information

Introduction to C++ Introduction. Structure of a C++ Program. Structure of a C++ Program. C++ widely-used general-purpose programming language

Introduction to C++ Introduction. Structure of a C++ Program. Structure of a C++ Program. C++ widely-used general-purpose programming language Introduction C++ widely-used general-purpose programming language procedural and object-oriented support strong support created by Bjarne Stroustrup starting in 1979 based on C Introduction to C++ also

More information

VALLIAMMAI ENGINEERING COLLEGE

VALLIAMMAI ENGINEERING COLLEGE VALLIAMMAI ENGINEERING COLLEGE SRM Nagar, Kattankulathur 603 203 DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING QUESTION BANK B.E. - Electrical and Electronics Engineering IV SEMESTER CS6456 - OBJECT ORIENTED

More information

Syntax Syntax for file I/O error detection system function (not in Annex A)

Syntax Syntax for file I/O error detection system function (not in Annex A) writes any buffered output to the file(s) specified by mcd, to the file specified by fd, or if $fflush is invoked with no arguments, to all open files. 21.3.7 I/O error status file_error_detect_function

More information

DM550 Introduction to Programming part 2. Jan Baumbach.

DM550 Introduction to Programming part 2. Jan Baumbach. DM550 Introduction to Programming part 2 Jan Baumbach jan.baumbach@imada.sdu.dk http://www.baumbachlab.net COURSE ORGANIZATION 2 Course Elements Lectures: 10 lectures Find schedule and class rooms in online

More information

Use the scantron sheet to enter the answer to questions (pages 1-6)

Use the scantron sheet to enter the answer to questions (pages 1-6) Use the scantron sheet to enter the answer to questions 1-100 (pages 1-6) Part I. Mark A for True, B for false. (1 point each) 1. Abstraction allow us to specify an object regardless of how the object

More information

The Architecture Analysis and Design Language and the Behavior Annex: A Denotational Semantics

The Architecture Analysis and Design Language and the Behavior Annex: A Denotational Semantics The Architecture Analysis and Design Language and the Behavior Annex: A Denotational Semantics Stefan Björnander, Cristina Seceleanu, Kristina Lundqvist, and Paul Pettersson School of School of Innovation,

More information

CS4215 Programming Language Implementation. Martin Henz

CS4215 Programming Language Implementation. Martin Henz CS4215 Programming Language Implementation Martin Henz Thursday 26 January, 2012 2 Chapter 4 The Language simpl In this chapter, we are exting the language epl in order to provide a more powerful programming

More information

What does this program print?

What does this program print? What does this program print? Attempt 1 public class Rec { private static int f(int x){ if(x

More information

Computer Science II (20082) Week 1: Review and Inheritance

Computer Science II (20082) Week 1: Review and Inheritance Computer Science II 4003-232-08 (20082) Week 1: Review and Inheritance Richard Zanibbi Rochester Institute of Technology Review of CS-I Syntax and Semantics of Formal (e.g. Programming) Languages Syntax

More information

Introduction to C++ with content from

Introduction to C++ with content from Introduction to C++ with content from www.cplusplus.com 2 Introduction C++ widely-used general-purpose programming language procedural and object-oriented support strong support created by Bjarne Stroustrup

More information

Computers Programming Course 6. Iulian Năstac

Computers Programming Course 6. Iulian Năstac Computers Programming Course 6 Iulian Năstac Recap from previous course Data types four basic arithmetic type specifiers: char int float double void optional specifiers: signed, unsigned short long 2 Recap

More information

2/3/2018 CS313D: ADVANCED PROGRAMMING LANGUAGE. Lecture 3: C# language basics II. Lecture Contents. C# basics. Methods Arrays. Dr. Amal Khalifa, Spr17

2/3/2018 CS313D: ADVANCED PROGRAMMING LANGUAGE. Lecture 3: C# language basics II. Lecture Contents. C# basics. Methods Arrays. Dr. Amal Khalifa, Spr17 CS313D: ADVANCED PROGRAMMING LANGUAGE Lecture 3: C# language basics II Lecture Contents 2 C# basics Methods Arrays 1 Methods : Method Declaration: Header 3 A method declaration begins with a method header

More information

Fall 2017 CISC124 9/16/2017

Fall 2017 CISC124 9/16/2017 CISC124 Labs start this week in JEFF 155: Meet your TA. Check out the course web site, if you have not already done so. Watch lecture videos if you need to review anything we have already done. Problems

More information

Java How to Program, 10/e. Copyright by Pearson Education, Inc. All Rights Reserved.

Java How to Program, 10/e. Copyright by Pearson Education, Inc. All Rights Reserved. Java How to Program, 10/e Copyright 1992-2015 by Pearson Education, Inc. All Rights Reserved. Data structures Collections of related data items. Discussed in depth in Chapters 16 21. Array objects Data

More information

CISC-124. This week we continued to look at some aspects of Java and how they relate to building reliable software.

CISC-124. This week we continued to look at some aspects of Java and how they relate to building reliable software. CISC-124 20180129 20180130 20180201 This week we continued to look at some aspects of Java and how they relate to building reliable software. Multi-Dimensional Arrays Like most languages, Java permits

More information

Introduction to Programming (Java) 2/12

Introduction to Programming (Java) 2/12 Introduction to Programming (Java) 2/12 Michal Krátký Department of Computer Science Technical University of Ostrava Introduction to Programming (Java) 2008/2009 c 2006 2008 Michal Krátký Introduction

More information

Object oriented programming. Instructor: Masoud Asghari Web page: Ch: 3

Object oriented programming. Instructor: Masoud Asghari Web page:   Ch: 3 Object oriented programming Instructor: Masoud Asghari Web page: http://www.masses.ir/lectures/oops2017sut Ch: 3 1 In this slide We follow: https://docs.oracle.com/javase/tutorial/index.html Trail: Learning

More information

Multiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible)

Multiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible) Name Closed notes, book and neighbor. If you have any questions ask them. Notes: Segment of code necessary C++ statements to perform the action described not a complete program Program a complete C++ program

More information

Aspect-Oriented Programming and AspectJ

Aspect-Oriented Programming and AspectJ What is Aspect-Oriented Programming? Many possible answers: a fad Aspect-Oriented Programming and AspectJ Aspect-oriented programming is a common buzzword lately Papers from ECOOP 1997 (early overview

More information

Numerical Data. CS 180 Sunil Prabhakar Department of Computer Science Purdue University

Numerical Data. CS 180 Sunil Prabhakar Department of Computer Science Purdue University Numerical Data CS 180 Sunil Prabhakar Department of Computer Science Purdue University Problem Write a program to compute the area and perimeter of a circle given its radius. Requires that we perform operations

More information

do fifty two: Language Reference Manual

do fifty two: Language Reference Manual do fifty two: Language Reference Manual Sinclair Target Jayson Ng Josephine Tirtanata Yichi Liu Yunfei Wang 1. Introduction We propose a card game language targeted not at proficient programmers but at

More information

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types

More information

CSCI 136 Data Structures & Advanced Programming. Fall 2018 Instructors Bill Lenhart & Bill Jannen

CSCI 136 Data Structures & Advanced Programming. Fall 2018 Instructors Bill Lenhart & Bill Jannen CSCI 136 Data Structures & Advanced Programming Fall 2018 Instructors Bill Lenhart & Bill Jannen Administrative Details Lab 1 handout is online Prelab (should be completed before lab): Lab 1 design doc

More information

2.8. Decision Making: Equality and Relational Operators

2.8. Decision Making: Equality and Relational Operators Page 1 of 6 [Page 56] 2.8. Decision Making: Equality and Relational Operators A condition is an expression that can be either true or false. This section introduces a simple version of Java's if statement

More information

Java is an objet-oriented programming language providing features that support

Java is an objet-oriented programming language providing features that support Java Essentials CSCI 136: Spring 2018 Handout 2 February 2 Language Basics Java is an objet-oriented programming language providing features that support Data abstraction Code reuse Modular development

More information

LESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are:

LESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are: LESSON 1 FUNDAMENTALS OF C The purpose of this lesson is to explain the fundamental elements of the C programming language. C like other languages has all alphabet and rules for putting together words

More information

General Syntax. Operators. Variables. Arithmetic. Comparison. Assignment. Boolean. Types. Syntax int i; float j = 1.35; int k = (int) j;

General Syntax. Operators. Variables. Arithmetic. Comparison. Assignment. Boolean. Types. Syntax int i; float j = 1.35; int k = (int) j; General Syntax Statements are the basic building block of any C program. They can assign a value to a variable, or make a comparison, or make a function call. They must be terminated by a semicolon. Every

More information

Announcements. Lab Friday, 1-2:30 and 3-4:30 in Boot your laptop and start Forte, if you brought your laptop

Announcements. Lab Friday, 1-2:30 and 3-4:30 in Boot your laptop and start Forte, if you brought your laptop Announcements Lab Friday, 1-2:30 and 3-4:30 in 26-152 Boot your laptop and start Forte, if you brought your laptop Create an empty file called Lecture4 and create an empty main() method in a class: 1.00

More information

Pace University. Fundamental Concepts of CS121 1

Pace University. Fundamental Concepts of CS121 1 Pace University Fundamental Concepts of CS121 1 Dr. Lixin Tao http://csis.pace.edu/~lixin Computer Science Department Pace University October 12, 2005 This document complements my tutorial Introduction

More information

Computer Components. Software{ User Programs. Operating System. Hardware

Computer Components. Software{ User Programs. Operating System. Hardware Computer Components Software{ User Programs Operating System Hardware What are Programs? Programs provide instructions for computers Similar to giving directions to a person who is trying to get from point

More information

PROGRAMMING FUNDAMENTALS

PROGRAMMING FUNDAMENTALS PROGRAMMING FUNDAMENTALS Q1. Name any two Object Oriented Programming languages? Q2. Why is java called a platform independent language? Q3. Elaborate the java Compilation process. Q4. Why do we write

More information

Programming Assignment 5 Interpreter and Static Analysis

Programming Assignment 5 Interpreter and Static Analysis Lund University Computer Science Niklas Fors, Görel Hedin, Christoff Bürger Compilers EDAN65 2016-09-24 Programming Assignment 5 Interpreter and Static Analysis The goal of this assignment is to implement

More information

Java How to Program, 9/e. Copyright by Pearson Education, Inc. All Rights Reserved.

Java How to Program, 9/e. Copyright by Pearson Education, Inc. All Rights Reserved. Java How to Program, 9/e Copyright 1992-2012 by Pearson Education, Inc. All Rights Reserved. Copyright 1992-2012 by Pearson Copyright 1992-2012 by Pearson Before writing a program to solve a problem, have

More information

MIDTERM EXAMINATION Spring 2010 CS301- Data Structures

MIDTERM EXAMINATION Spring 2010 CS301- Data Structures MIDTERM EXAMINATION Spring 2010 CS301- Data Structures Question No: 1 Which one of the following statement is NOT correct. In linked list the elements are necessarily to be contiguous In linked list the

More information

SEMANTIC ANALYSIS TYPES AND DECLARATIONS

SEMANTIC ANALYSIS TYPES AND DECLARATIONS SEMANTIC ANALYSIS CS 403: Type Checking Stefan D. Bruda Winter 2015 Parsing only verifies that the program consists of tokens arranged in a syntactically valid combination now we move to check whether

More information

THE CONCEPT OF OBJECT

THE CONCEPT OF OBJECT THE CONCEPT OF OBJECT An object may be defined as a service center equipped with a visible part (interface) and an hidden part Operation A Operation B Operation C Service center Hidden part Visible part

More information

By the end of this section you should: Understand what the variables are and why they are used. Use C++ built in data types to create program

By the end of this section you should: Understand what the variables are and why they are used. Use C++ built in data types to create program 1 By the end of this section you should: Understand what the variables are and why they are used. Use C++ built in data types to create program variables. Apply C++ syntax rules to declare variables, initialize

More information

COP 3330 Final Exam Review

COP 3330 Final Exam Review COP 3330 Final Exam Review I. The Basics (Chapters 2, 5, 6) a. comments b. identifiers, reserved words c. white space d. compilers vs. interpreters e. syntax, semantics f. errors i. syntax ii. run-time

More information

Chapter 7 Control I Expressions and Statements

Chapter 7 Control I Expressions and Statements Chapter 7 Control I Expressions and Statements Expressions Conditional Statements and Guards Loops and Variation on WHILE The GOTO Controversy Exception Handling Values and Effects Important Concepts in

More information

Question 1a) Trace of program

Question 1a) Trace of program Question 1a) What is printed by the following Java program? int s; int r; int i; int [] x = 4, 8, 2, -9, 6; s = 1; r = 0; i = x.length - 1; while (i > 0) s = s * -1; i = i - 1; r = r + s * x[i]; System.out.println(r);

More information

An Implementation of Hybrid A Concurrent, Object-Oriented Language

An Implementation of Hybrid A Concurrent, Object-Oriented Language An Implementation of Hybrid A Concurrent, Object-Oriented Language D. Konstantas O. Nierstrasz M. Papathomas Abstract This paper is a report on a prototype implementation of Hybrid, a strongly-typed, concurrent,

More information

Microsoft. Microsoft Visual C# Step by Step. John Sharp

Microsoft. Microsoft Visual C# Step by Step. John Sharp Microsoft Microsoft Visual C#- 2010 Step by Step John Sharp Table of Contents Acknowledgments Introduction xvii xix Part I Introducing Microsoft Visual C# and Microsoft Visual Studio 2010 1 Welcome to

More information

Loops. CSE 114, Computer Science 1 Stony Brook University

Loops. CSE 114, Computer Science 1 Stony Brook University Loops CSE 114, Computer Science 1 Stony Brook University http://www.cs.stonybrook.edu/~cse114 1 Motivation Suppose that you need to print a string (e.g., "Welcome to Java!") a user-defined times N: N?

More information

News and information! Review: Java Programs! Feedback after Lecture 2! Dead-lines for the first two lab assignment have been posted.!

News and information! Review: Java Programs! Feedback after Lecture 2! Dead-lines for the first two lab assignment have been posted.! True object-oriented programming: Dynamic Objects Reference Variables D0010E Object-Oriented Programming and Design Lecture 3 Static Object-Oriented Programming UML" knows-about Eckel: 30-31, 41-46, 107-111,

More information

Data Structure using C++ Lecture 04. Data Structures and algorithm analysis in C++ Chapter , 3.2, 3.2.1

Data Structure using C++ Lecture 04. Data Structures and algorithm analysis in C++ Chapter , 3.2, 3.2.1 Data Structure using C++ Lecture 04 Reading Material Data Structures and algorithm analysis in C++ Chapter. 3 3.1, 3.2, 3.2.1 Summary Infix to Postfix Example 1: Infix to Postfix Example 2: Postfix Evaluation

More information

The format for declaring function templates with type parameters

The format for declaring function templates with type parameters UNIT 3 Function and class templates - Exception handling try-catch-throw paradigm exception specification terminate and Unexpected functions Uncaught exception. Templates Function templates Function templates

More information

1007 Imperative Programming Part II

1007 Imperative Programming Part II Agenda 1007 Imperative Programming Part II We ve seen the basic ideas of sequence, iteration and selection. Now let s look at what else we need to start writing useful programs. Details now start to be

More information

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of

More information