<<

A Framework for Dynamic Evolution of Distributed Systems Specifications*

Mohammed Erradi, Gregor v. Bochmann and Rachida Dssouli

UniversitédeMontréal,Département'Informatiqueet deRechercheOpérationnelle,CP.6128,Succ.“A” Montréal,(Québec)CanadaH3C3J7 Email :{erradi,dssouli,bochmann}@iro.umontreal.ca Tel :(514)3437484 Fax :(514)3435834

RÉSUMÉ. Récemment, les spécifications orientées objets des systèmes distribués ont suscité beaucoup d'interêt. L'approche orientée objet offre beaucoup de flexibilité pour la construction des systèmes. Cependant, un des problèmes culminant est d'effectuer des modifications de façon dynamique durant le processus de développement d’exploitation et de maintenance. Nous nous intéressons dans cet article, aux techniques de description formelle qui permettent le développement et la modification dynamique des spécifications exécutables. Nous introduisons un modèle à deux niveaux pour l'évolution des spécifications orientées objets. Le premier niveau concerne la modification dynamique des types (classes), alors que le second niveau est consacré à la modification dynamique des modules. Pour chacun des niveaux, nous définissons un ensemble de contraintes, structurelles et comportementales, qui assurent la consistence de la spécification après sa modification. Pour effectuer les modifications de façon dynamique, nous avons développé un langage réflexif de spécification orientée objet. Ce langage permet de définir les opérations de modifications à un meta-niveau en utilisant des meta-objets. Dans ce langage, les types et les modules sont des objets.

MOTSCLES. Spécification orientée objet, évolution de logiciel, modification des types, compatibilité des modules, réflection, modification dynamique.

ABSTRACT. Recently, object-oriented specifications of distributed systems has gained more attention. The object-oriented approach is known by its flexibility for system construction. However, one of the major challenges is to provide facilities for the dynamic modifications of such specifications during the development and maintenance process. Yet, current work has not addressed the dynamic modifications of specifications of distributed systems. In this paper, we are concerned with formal description techniques that allow for the development and the dynamic modification of executable specifications. A two-level model for the evolution of large object-oriented specifications is introduced. The first level deals with the dynamic modification of types (classes), while the second level deals with the modification of modules. We have defined a of structural and behavioral constraints to ensure the specification consistency after its modification at both levels. To allow for dynamic modification of types and modules, we have developed a reflective object-oriented specification language which uses meta-objects to support the modification operations. In this language, types and modules are objects.

KEYWORDS:Object-oriented specifications, software evolution, type modification, modules compatibility, reflection, dynamic modifications.

*RevueRéseauxetInformatiqueRépartie,Vol.4,No.2

1 1. Introduction and motivations

Inanysoftwaresystem,especiallydistributedsystems,thatexistsforlongperiodoftime,it becomesnecessarytoperiodicallychangevariouscomponentsofthesystem.Whileithaslong beenunderstoodthatsupportforsoftwareevolutionandmaintenanceisanimportantpartof programmingmethodology,thepropertechniquesandtoolsforperformingthatevolutionand maintenanceeasilyandcorrectlyareoftennotavailable.Thereareanumberofreasonsthat mightnecessitateevolutionarychange.Onepossiblereasonistheusers’requirementschange overtime.Anotheristoimproveefficiency.Finally,systemsneedtoevolveastheapplication environmentchanges.Allthesecasesareexamplesofchangeandevolutionproblemsfaced withlargesoftwaresystems.

Inlargedistributedsoftwaresystems,itmaynotbepossibletostoptheentiresystemto allowmodificationtopartofit.Amajorchallengeistoprovidefacilitiesforthedynamic modificationsofanevolvingsystemwithoutinterruptingtheprocessingofthosepartsofthe systemwhicharenotdirectlyaffected.Ingeneral,evolutionarychangesaredifficultto accommodatebecausetheycannotbepredictedatthetimethesystemisdesigned.Systems shouldbesufficientlyflexibletopermitarbitrary,incrementalchanges.Inaddition,when systemsarelarge,theirmanipulation,understanding,andmaintenancebecomedifficult.The importanceofdecomposinglargesystemsintomodulesiswidelyrecognizedwithinthe softwareengineeringcommunity[Brin89],[Webe86],[Parn72].Therefore,theavailability ofmodulesisofgreatpracticalusefortheproductionofstructuredsystemsthatareeasierto manipulate,understand,analyzeandmaintain.Systemmodularityisessential,andpermitsthe useofcompositiontoformasystemfromreusableandindependentmodules.Theuseofwell definedmoduleinterfacesallowsforthevalidationofmoduleinterconnections.

Webelievethatsoftwaresystemmodificationsaremostofthetimeincremental.Therefore, theyconsistofaddingnewfunctionalitiesorextendingsomeexistingones.Inthispaper,we considerthatanexecutablespecificationofasystemisanimplementationmodelofsuch system.Therefore,weexamineamethodofsupportingdynamicextensionsofdistributed systemsspecificationsinthecontextoftheobjectorientedspecificationlanguageMondel [Boch90].Mondelhasimportantconceptsasaspecificationlanguagetobeappliedinthearea ofdistributedsystems.ThemotivationsbehindMondelare:(a)writingsystemdescriptionsat thespecificationanddesignlevel,(b)supportingconcurrencyasrequiredfordistributed systems,()supportingpersistentobjectsandtransactionfacilities,and(d)supportingthe

2 objectconcept.Presently,Mondelhasbeenusedforthespecificationofproblemsrelatedto networkmanagement[Boch91]andOSIdirectorysystem[Boch92].Theobjectoriented approachisknownbyitsflexibilityforsystemconstruction.Thisispartlyduetothe inheritanceproperty.However,therehasbeenlittlesuggestionstoprovidefacilitiesforthe dynamicmodificationofobjectorientedsystems.

Inthispaper,atwolevelgenericmodelformanaginglargespecificationsevolutionis introduced.Thismodelconsistsofthein-the-smallandthein-the-largelevels.Thein-the-small leveldealswiththedynamicmodificationofclasseswithinanobjectorientedspecification. Thein-the-largeleveldealswiththedynamicmodificationofmoduleswithinlargeobject orientedspecifications.Thedistinctionbetweenthetwolevelsismadebecausemodulesare differentfromclassesusedbytheobjectorientedapproach.Theconstructionofmodulesis differentfromthecompositionofobjects.Modulesmaybeconstructedinmanydifferentways anddonotalwaysfollowtheinheritancerelationshipwhichexistsbetweenclassesand subclasses.Inaddition,classesareprimarilyaimedatsupporting“programminginthesmall”, whilemodulesareusedfor“programminginthelarge”.

Inourmodel,modificationsareexplicitlyspecifiedbyanagentexternaltothespecification. Thespecificationmaybemodifiedbytheapplicationofmodificationtransactions.Inaddition tothemeansforspecifyingandperformingchanges,itisalsonecessarytoprovidefacilitiesfor controllingchangeinordertopreservespecificationconsistency.Modificationsmaybe performedonthestructureaswellasonthebehaviorofthespecification.Therefore,we considerbothstructuralandbehavioralconsistenciesrequirements.Structuralconsistencydeals withpreservingtheconsistencyofthestructureofthespecificationafteritsmodification.This concernsmainlythecompilingconstraints(i.e.,checkingdynamicallythestaticsemanticsrules ofthelanguageinuse).Behavioralconsistencydealswithpreservingtheconsistencyofthe behaviorofthespecificationafteritsmodification.Thisconcernsmainlysomepropertiesof distributedsystemssuchasblocking.Theconsistencyrequirementsareaddressedatthein-the- smallandatthein-the-largelevels.

InthecontextofMondel,largespecificationsareconstructedfromunits (calledmodulesin otherlanguages)whicharecomposedof types(calledclassesinmostobjectoriented languages).Inordertoallowfortheconstructionofdynamicallymodifiablespecifications,we needtohaveaccess,andtobeabletomodifyunitsandtypesduringexecutiontime.Therefore, wedevelopedRMondel,anewversionofMondel,wheretypesareobjects,andmetaobjects

3 areusedtoprovidefacilitiesforthedynamicmodificationsoftypes[Erra92c].Inasimilar way,metaobjectsarealsousedtoallowforthedynamicmodificationsofunits.

Thepaperisstructuredasfollows:Section2introducesthetwolevelgenericmodelforlarge specificationsevolution.Thefirstleveldescribestheevolutionofobjectorientedspecifications byconsideringclassesasthebasicunitsofspecificationconstruction.Theneededrequirements tomaintaintheconsistencyatthislevelarealsoaddressed.Then,wedescribethesecondlevel thatpresentsthemoduleconceptastheunitoflargespecificationscomposition,andtheneeded requirementstomaintainconsistencyatthemoduleboundaries.InSection3,afteranoverview oftheMondelspecificationlanguageandRMondel,weshowhowthetwolevelsof modification,introducedbythegenericmodel,aresupportedintheRMondellanguage. Thereafter,weintroducetheconstraintswhichpreservethestructuralandthebehavioral consistenciesforbothlevels,andwediscusshowmodificationsmaybeperformed dynamicallyinthesetwolevels.ConclusionsaredrawninSection4.

2. A generic model at two levels

Inthissectionwediscussagenericmodelfortheevolutionofobjectorientedspecifications. Thismodelconsistsoftwolevelsofspecificationevolutionwhicharetheclasslevelandthe modulelevel,calledin-the-smallandin-the-large,respectively.Figure1givesaglobalviewof thesetwolevels.The in-the-largeleveldealswiththespecificationmodulesandtheir interconnectionswhilethein-the-smallleveldealswithclassesandtheirrelationships.

Inthelargelevel Modul1 userelation

Modul2 Modul3

c1

Inthesmalllevel c2 c5 Inheritance c3 relation c4

Figure1.Twolevelview

4 2.1. The in-the-small level

Forobjectorientedspecificationstofulfilltheirpromiseasvehiclesforfastprototyping,ease ofmaintenance,andeaseofmodification,awelldefinedandconsistentmethodologyforclass modificationmustbedeveloped.Aclassisasetofobjectscalleditsinstances.Aclass definitionspecifiesthefeatures(afeaturecanbeaninstancevariableoramethod)andthe allowablebehaviorofitsinstances.Atthein-the-smalllevelaspecificationconsistsofaclass lattice.Anodeinthelatticerepresentsaclassandanedgebetweenapairofnodesrepresents theinheritancerelationship.Inheritanceallowsanewclasstobederivedfromanexistingclass. Thenewclass,calledasubclass,inheritsallthefeaturesoftheexistingclass.Onemayalso specifyadditionalfeaturesforthesubclass.Inthefollowingweenumeratetheallowed modificationsatthe in-the-smalllevel,andwediscusstheconsistencyrequirementsatthis level.

2.1.1. Class modifications

Classmodificationsaretypicallyachievedbyaddingorremovinginstancevariables, reimplementingmethods,rearranginginheritancelinks,etc.Suchmodificationsindicatethat theexistingclassesarenotentirelysatisfactory.Intheareaofobjectorienteddatabases,these modificationshavebeenextensivelystudiedintherecentliterature[Bane87],[Penn87],[Skar 87],and[Delc91].Theavailablemethodsdeterminetheconsequencesofclasschangeson otherclassesandontheexistinginstances,sothatpossibleviolationsoftheintegrity constraintscanbeavoided.Itisimportanttonotethattheexistingapproachesdealmainlywith sequentialsystemsanddonotaddressbehaviormodifications.Anacuteproblemindesigninga methodologyforclassmodificationishowtobringexistingobjectsinlinewithamodified class.Thisproblembecomesmoreacuteinthecaseofdistributedsystemssuchasour environmentwhereobjectbehaviorsimposeadditionalconstraints.

Classupdatesmaybeclassifiedintothreecategories[Bane87]:(1)updatestothecontents ofanodeintheclasslattice,(2)updatestoanedgeintheclasslattice,and(3)updatestoa nodeintheclasslattice.Inthefollowingweenumeratethemostimportantupdateoperations onclasses. (1)Modificationstothecontentsofanodeintheclasslattice. (i)Modificationstoaninstancevariableofaclass.

5 - Add an instance variableV to a class C. - Drop an existing instance variable V from a class C. - Change the class C of an instance variable V. (ii)Modificationstoanoperationofaclass. - Add the operation O to the class C. - Drop the existing operation O from the class C. Change the signature S of the operation O. (2)Modificationstoanedgeofthelattice. (i)MakeaclassSasuperclassofclassC. (ii)DeleteaparentS(superclass)oftheclassC. (3)Modificationstoanodeofthelatticestructure. (i)AddanewclassC. (ii)DeleteanexistingclassC.

2.1.2. Kinds of consistency

Atthe in-the-smalllevelthreekindsofconsistenciesmustbeaddressedw.r.t.class evolution:thestructuralconsistency,thesemanticalconsistency,andtheinstanceof relationshipconsistency. The structural consistency:Itensuresthatthestructureofthespecification(classlattice)is maintainedaccordingtotheinheritancerelation.Thisofconsistencyiswidely investigatedinobjectorienteddatabasesareawheresomeinvariantsareusedtodefinethe consistencyrequirementsoftheclasslattice[Bane87],[Penn87](e.g.,thedistinctname invariant,ensuresthatallinstancevariableandmethodnamesofaclasswhetherexplicitly definedorinherited,aredistinct). The semantical consistency:Whilemostexistingapproaches[Bane87],[Penn87],and[Delc 91]havefocusedonpreservingstructuralconsistency,webelievethatthesemantical consistencywhichdealswithobjectbehaviorsmustbeaddressed.Themethodologyof SkarraandZdonik[Skar87]goesalongwaytowardpreservingbehaviorinsequential systems.Theirmethodologyimplementsclassmodificationbytheuseofversions. However,weareexploringsolutionstoclassmodificationthatdonotrequireversioning. Ourdefinitionofthesemanticalconsistency,thatwecallbehaviorextension,willbegivenin Section3.3.1.

6 The instance-of relationship consistency:Whileclassesevolve,theirexistinginstancesmust bechangedinordertoremaininlinewiththeirclasses.Thiskindofconsistencycanbe definedaccordingtotheallowedclassmodificationswhich,inadistributedenvironment, dealswithbothstructuralandbehavioralaspectsofobjects.Forinstancetheadditionofan instancevariablewithinaclassinvolvestherestructurationoftheexistingobjectsofthis class.

2.2. The in-the-large level

Beforeaddressingtheproblemofspecificationmodificationsandtheconsistency requirementsattheinthelargelevel,weneedtounderstandwhatarethecomponentsofa specificationandtheirrelationships.Alargespecificationconsistsofalatticeofinterconnected modules.Anodeinthelatticerepresentsamodule,andanedgebetweenapairofnodesmeans thattheupperlevelmoduleusesthemoduleofthelevelbelow.Thehierarchicorganizationof modularspecificationsdoesnotpredeterminethewaytheyaredevelopedi.e.,topdown, bottomup,orinaniterativemanner.

2.2.1. Constituent parts of modules

Amoduleconsistofthreeparts:anexport,animportinterface,andamodulebody. The export interfaceisthevisiblepartwhichmustbeknownforusingthismodulein connectionwithothermodules.Itallowsdifferentaspectsofinformationhidingsuchas: Itpreventsauserfromlookingintotheinternalstructureofamodule. Itprotectssomeoftheresourcesthatexistinternallyfromtheirusefromoutsidethemodule. The import interfacecontainsreferencestooneormoreothermodules.Modulesmaynot importeachothercyclically. The module bodyisintendedtodefinetheconstructionoftheexportinterfaceusingtheimport interface,andmaycontainauxiliaryhiddenresourcessuchasclassesandobjects,whichdonot belongtoanyotherpartofthemodule.

2.2.2. Module interconnections

7 Forlargespecifications,thedevelopmentprocessconsistsofasequenceofalternating incrementalcompletionsofincompletelydevelopedmodulesandrefinementsthrough successivedecompositionsandcompositionsforthetopdownorbottomupcontinuationof thedevelopmentprocess.Forthis,asetoffundamentaloperationsonmodulespecifications hasbeenprovided[Blum87].Theseincludehorizontalstructuringoperationssuchas compositionandunion,andverticaldevelopmentsteps,suchasrefinement. .ThecompositionoftwomodulesM1andM2connectstheimportinterfaceofM2withthe exportinterfaceofM1.Thecompositemodule(M1compM2)willhavethesameimport interfaceasM1,thesameexportinterfaceasM2,whilethebodyof(M1compM2)isgiven bytheunionofthebodypartsinM1andM2(seeFigure2.(a)). .TheunionM1UM2oftwomodulesM1andM2isthedisjointunionofM1andM2.The constituentpartsoftheresultingmodule(M1UM2)aretheunionofthecorrespondingparts oftheoriginalmodules(seeFigure2.(b)). .TheextensionextE(M)ofamoduleMistheresultofextendingsomeorallconstituentparts ofthemoduleMbyadditionalitems,whereEdenotesthecollectionofallextendeditems. Theextensionconstructionisusedtoaugmentagivenmodulebyaddingitemsintheexport, importorbodypartofamodule(seeFigure2.(c)).Thisconstructionisimportanttobuildup modulesstepbystep.

2.2.3. Module modifications

Sinceeachmoduleformsasmallandindependentpieceofthewholespecification,then modulescanbedeveloped,implemented,andmodifiedindividually.Asspecificationsevolve, designerscanbeledtomodifymodulessothattheysuittheirneeds.Thisistypicallyachieved bymodifyingmoduleconstituentparts(e.g.,addingorremovingaresourceto/fromanimport orexportinterface).Weclassifymodulemodificationsintothefollowingcategories: (1)modificationoftheexportinterface:Addingand/orremovinganamedobjectoraclass to/fromtheexportinterfaceofthemodule. (2)modificationoftheimportinterface:Addingand/orremovinganamedobjectoraclass to/fromtheimportinterfaceofthemodule. (3)modificationofthebodypartofamodule:Asaconsequenceoftheimportand/ortheexport interfacemodifications,thebodyofthemodulemaybechanged.Sometimes,oneneedsto modifythebodyofamodulewithoutmodifyingtheinterface(e.g.,performance enhancement).

8 (4)Additionand/ordeletionofamodule.

Aparticularaspectofmodulemodificationinobjectorientedsystemsistospecializeobjects orclassesbymeansofinheritance.Thisaspectwillbediscussedfurtherinrelationwithour environmentinSection3.4.

Exp2 Exp2 M2 Bod2 M2 Bod2 Imp2 Imp2

Exp1 Exp1 M1 Bod1 M1 Bod1 Imp1 Imp1

(a)composition,M1compM2

Exp M Bod Imp Exp1UExp2

Bod1UBod2 Exp' M' Bod' Imp1UImp2 Imp'

(b)Union,M1UM2 (c)Extension,M'isanextensionofM. Exp'=extensionofExp Imp'=extensionofImp Bod'=extensionofBod

Figure2.Operationsonmodules

2.2.4. Kinds of consistency in the in-the-large level

Accordingtotheallowedmodificationsofmodules,therearetwokindsofconsistenciesto beconsidered.First,thestructuralconsistencydealsmainlywithtypecheckingatthemodule boundaries.Forexample,theextensionofamoduleshouldensuretypecompatibility,atthe importandexportinterfaces,betweentheoriginalmoduleanditsextendedversion.Second,

9 thesemanticalconsistencydealswiththebehavioraspectofmodules.Thatis,anextended moduleshouldprovidethebehaviorrequiredbythewholespecification.Theextendedmodule shouldprovideatleastwhattheoriginalmoduleprovides.

Thesetwokindsofconsistencymustbeaddressedatthemodulelevelandatthewhole specificationlevel.Atthemodulelevelweshouldensurethattheallowedmodifications,ofthe importandtheexportinterfacesofamodule,willnotviolatethestaticsemanticsrules,e.g.,an objectoraclassnamemustnotbeimportedandexportedbythesamemodule.Moreover,the modificationsofthebodypartofamodulemustbedonewithoutresultinginruntimeerrors, blocking,oranyuncontrollablesituation.Atthewholespecificationlevel,oneneedstocheck theimpactofthemodulemodificationontheothermodules.Thisshouldpreservethe specificationinaconsistentstateafterthemodificationofoneormoremodules.Accordingto ourgoalwhichisthedynamicmodificationofarunningspecification,itshouldnotbe necessarytostoptheexecutionofthespecificationtomodifypartsofit.Oneshoulddefinea mechanismtodeterminethepartofthespecificationwhichareaffectedbythechange.Therest ofthespecificationshouldbeabletocontinueitsexecutionnormally.InSection3.4,we addresstheseproblemsinthecontextofRMondel.

3. Specification Evolution in RMondel

AccordingtothegenericmodelpresentedinSection2,wewillshowhowthefeaturesof suchamodelaresupportedbyRMondel.RMondelisanobjectorientedspecification language,suitableforthespecificationandmodelingofdistributedsystems.Itprovides facilitiesforbuildingdynamicallymodifiablespecifications.Afteranoverviewoftheoriginal languageMondel,weintroducethemaincharacteristicsofRMondellanguage.Thenwe describeevolutionatthe in-the-smalllevelandatthe in-the-largelevelassupportedinthis language.

10 3.1. Mondel overview

WehavedevelopedMondelanobjectorientedspecificationlanguage[Boch90]withcertain particularfeatures,suchasmultipleinheritance,typechecking,rendezvouscommunication betweenobjects,thepossibilityofconcurrentactivitiesperformedbyasingleobject,object persistenceandtheconceptoftransaction.Anobjectisaninstanceofatype(i.e.,calledclass inmostobjectorientedlanguages)thatspecifiesthepropertiesthataresatisfiedbyallits instances.EachMondelobjecthasanidentity,acertainnumberofnamedattributeswhichmay befixedreferencestootherobjects,andoperationswhichareexternallyvisible.

AMondelspecificationcorrespondstoatypelattice.Insuchalattice,typesarelinkedby meanoftheinheritancerelation.Theexecutionofaspecification consistsofasetofobjectsthat runinparallel.Eachobjecthasitsindividualbehaviorwhichprovidescertaindetailsas constraintsontheorderoftheexecutionofoperationsbytheobject,anddeterminesproperties ofthepossiblereturnedresultsoftheseoperations.Amongtheactionsrelatedtotheexecution ofanoperation,theobjectmayalsoinvokeoperationsonotherobjects.Basically, communicationbetweenobjectsissynchronous,basedontherendezvousmechanism.Mondel hasaformalsemanticswhichassociatesameaningtothevalidlanguagesentences.The behaviorofobjectsisformallyspecifiedbyatranslationtolabeledtransitionsystems.The Mondel formalsemanticswasthebasisfortheverificationofMondelspecifications[Barb91], andhasbeenusedfortheconstructionofaninterpreter[Will90].

3.1.1. Example of a Mondel specification

InthefollowingweshowanexampleusingtheMondellanguage.Letusconsideravending machinewhichreceivesacoinanddeliverscandiestoitsuser.Thespecificationofthevending machinesystemconsistsofonemodulecomposedoftwotypes:thetypeMachineandthetype User,asshowninFigure3.TherootofthetypelatticeinMondelisthemostgeneraltype object (calledtopinotherlanguages).Therefore,thetypes Machineand Userinheritfrom objectasshowninlines1and21ofFigure3.TherelationbetweenthetypeUserandthetype Machineisrepresentedbytheattributem,oftypeMachine(seeline22ofFigure3),defined withintheUser type.Theoperations,InsertCoinandPushAndGetCandy,arespecifiedwithin theoperationclauseasshowninlines2to4ofFigure3.Notethattheseoperationsarewithout

11 parametersandresult.Theuserisinitiallyina Thinkingstate,andwhenhedecidestobuya candyheinsertsacoin.Afterthecoinhasbeenaccepted,theuserentersthe GetCandystate. Thentheuserpushesthemachine'sbuttontogetacandy.ThemachineisinitiallyintheReady state,readytoacceptacoin.Onceacoinisinserted,themachineacceptsthecoinandthen enterstheDeliverCandystate.Aftertheuserhaspushedthebuttonofthemachine,thelatter deliversacandyandbecomes Readytoacceptanothercoin.Thebehaviorofthevending machinesystemisdefinedasthecompositionoftwointeractingobjects(i.e., Machineand Userobjects)(seelines35to38ofFigure3.).Thetypesarespecifiedusingastateoriented style[Viss88]whereinternalstatesaremodeledasMondelprocedures.

0unit VMsystem= 21type User=object with 22 m:Machine; 1type Machine=object with 23behavior 2operation 24Thinking 3InsertCoin; 25where 4PushAndGetCandy; 26procedureThinking= 5behavior 27m!InsertCoin; 6Ready 28 GetCandy; 7where 29endproc Thinking 8procedureReady= 9acceptInsertCoindo 30procedure GetCandy= 10return; 31 m!PushAndGetCandy; 11end; 32Thinking; 12 DeliverCandy; 33endproc GetCandy 13endproc Ready 34endtype User 14procedure DeliverCandy = 15 accept PushAndGetCandydo {thevendingmachinesystembehavior} 16return; 35 behavior 17end; 36defineAmachine=new(Machine)in 18Ready; 37eval new(User(Amachine)); 19endproc DeliverCandy 38end;

20 endtype Machine 39endunit VMsystem

Figure3.Mondelspecificationofthevendingmachinesystem

3.2. RMondel facilities

IntheformalismusedtodefinethesemanticsofMondel,typesarestaticandusedas templatesforinstancecreation.Onlytheinstancesofatypeareconsideredasobjects.To supporttheconstructionofdynamicallymodifiablespecificationsweneedtohaveaccessto typesduringexecutiontime.Forthispurpose,reflectionisapromisingchoice.

12 Recently,inobjectorientedlanguages,reflectionhasgainedwiderattentionasconfirmedby thefirstandsecondworkshopsonreflectionandmetalevelarchitecturesinobjectoriented programming[Work91]heldinconjunctionwithOOPSLA'90and91.Alanguageiscalled reflectiveifitusesthesamestructurestorepresentdataandprograms.Inconventional systems,computationisperformedonlyondatathatrepresententitiesofanapplication domain.Incontrast,areflectivesystemcontainsanothertypeofdatathatrepresentthe structuralandcomputationalaspectsofitself.Theoriginalmodelofreflectionwasproposedin [Maes87]followingSmith'searlierwork[Smit82],whereametaobjectisassociatedwith eachobjectinthesystemtorepresentinformationabouttheimplementationandthe interpretationoftheobject.

Todefineareflectivearchitecture,onehastodefinethenatureofmetaobjectsandtheir structureandbehavior.Inaddition,onehastoshowhowthehandlingofobjects communicationsandoperationslookuparedescribedatthemetalevel[Ferb89].InRMondel, typesareusedforstructuraldescription(i.e.,forthedefinitionofthestructureofobjectsand ofapplicableoperations),andinterpretersareusedforthebehavioraldescription(i.e.,howthe rendezvouscommunicationisinterpretedandtheoperationsareapplied)oftheirassociated objectscalledreferents.Onecansaythattypesarestructuralmetaobjects,whileinterpreters arebehavioralmetaobjects.

MoredetailsonthedefinitionofRMondel andofotherkernelobjects,aregivenin[Erra 92d].LetusnowintroducethefundamentalfeaturesofreflectionassupportedinRMondel. Wedistinguishtwomainfeatures:Structuralreflection(SR)andbehavioralreflection(BR). Thestructural reflectionissupportedinasimilarmannerasinObjVlisp[Coin87].Themost importantaspectofSRinRMondel,isthateachobjectisaninstanceofatype,andtypesare objects. AnotheraspectofSRisthattheRMondelstatementsandexpressionsareobjects.The structureofRMondelissupportedbyinstantiationandinheritancegraphs.Theinstantiation graphrepresentstheinstance-ofrelationship,andtheinheritancegraphrepresentsthesubtype- ofrelationship. TYPEandOBJECTaretherespectiverootsofthesetwographs[Erra90]. Figure4givesasubsetofthedefinitionsofthestructuresusedtocreatenewtypesandto detecttheinconsistenciesinthetypelatticeinducedbymodifications.

Thebehavioral reflection(BR)dealswithobjectbehaviors.Therefore,aninterpreterobject isassociatedtoeachobject.Aninterpreterobjectdealswiththecomputationalaspectofits associatedobjectcalled referent.Interpreterobjectsaredefinedasinstancesofthetype

13 INTERPRETER.Alsoaninterpreterobjectmayhaveitsowninterpreterobject;thusthe numberofinterpreterobjectsisvirtuallyinfinite.Specializedinterpreterscanbedefinedfor monitoringthebehaviorofobjects,orfordynamicallymodifyingtheirbehaviors.Apossible specificationofthetype INTERPRETERisgivenin[Erra92d].

Typesandinterpretersareinstancesofthekerneltypes Modifiable-Type,asubtypeof TYPE,andINTERPRETER,respectively.Thisapproachshowsmanyadvantages: typesareobjects,instancesoftheModifiable-Type,whichisdefinedatametalevel. operationsfortypemodificationsmaybedefinedatthemetalevel(i.e.,within Modifiable- TypeasshowninFigure4). anobjectbehaviorcanbemonitoredand/ormodifiedbyitsinterpreter. newcommunicationstrategiescanbedefinedbycreatingsubtypesofINTERPRETER.

typeTYPE=OBJECT with TypeName :string; BehaviorDef :var[Statement]; DirectSuperTypes:set[TYPE]; Attributes :set[AttributeDef]; Operations :set[Operation]; Procedures :set[Procedure]; ... operation ... {theoperation Newcreatesanobjectaccordingto RMondelobjectstructure} New:OBJECT; {theoperation LookUpchecksiftheoperation“OpName”isdefinedforanobject’stypeorfor oneofitssupertypes;thenreturnstheassociatedstatements} LookUp(OpName:string):Statement; Behavior {thesemanticsdefinitionsoftheaboveoperationsּ} endtype TYPE

{thetypeModifiableTypeisdefinedasasubtypeofTYPEasfollows} typeModifiableType=TYPE with operation AddStat(S:Statement); AddAttr(A:Attribute); AddOper(O:Operation); AddProc(P:Procedure); ... behavior {Thesemanticsdefinitionsofthemodificationoperationsabove .} endtype ModifiableType

Figure4.TYPEandModifiableTypespecificationswiththemodificationoperators

14 ThereflectionfacilitiesofRMondeltogetherwiththeprinciplesintroducedbythegeneric modelinSection2,formthebasisofthedynamicevolutionoflargespecificationswrittenin RMondel.

3.3. In-the-small modifications in RMondel

WearemainlyinterestedinthemodificationsofaspecificationSwhichleadtoaconsistent specificationS'usinganincrementalapproach.Theincrementalapproachconsistsof dynamicallyextendingthespecificationStogetaconsistentspecificationS'suchthatthelater conformstotheformer.ThetypemodificationsinRMondel maybeseenasaspecializationof thein-the-smalllevelintroducedinthegenericmodelofSection2.

InRMondelspecifications,whichmainlydescribedistributedapplications,thedynamic behaviorofobjectsisofextremeimportance.Therefore,ourinterpretationoftype modificationstakesintoaccountthedynamicbehaviorofobjects.Accordingtothegeneric model,the in-the-smalllevelinRMondelisconcernedabouttypemodificationsandthe consistencyrequirementswhichensurebothstructuralandbehavioralconsistencies.The structuralconsistencydealswiththecompilingconstraints(e.g.,typechecking),while behavioralconsistencydealswiththedynamicbehaviorofobjects(e.g.,possibilityof blocking).

3.3.1. Definition of consistency constraints

BeforeaddressingtheinthesmallmodificationsofRMondelspecifications,an understandingoftypesandtheirrelationshipsisrequired.

Definition 1: AtypetconsistsofaninterfaceItandabehaviorBt,t=. It=<At,Opt>whereA tisthesetofattributesandOp tisthesetofoperations.B tisthe behaviorspecificationoftheobjectsoftypet. J

Types'interfacesareusedasabasisforthetraditionalinheritanceschemeofobjectoriented languages.Thus,atypehasatleastallattributesandoperationsdefinedforthemoregeneral type,wherethetypesoftheoperationsresultmustbeconformingandthetypesoftheinput

15 parametersmustbeinverselyconforming(seeforinstance[Blac87]).Basedonthisaspectof inheritance,wegivearecursivedefinitionofthestructuralconsistencyrelationasfollows.

Definition 2: Thetypet’=<<At',Opt'>,Bt’>is structurally consistentwiththetype t=<<At,Opt>,Bt>if: 1.At'⊇ At.t'hasatleastalltheattributesoft. 2.ForeachoperationoinOptthereisacorrespondingoperationo’inOpt'suchthat: oando’havethesamename oando’havethesamenumberofparameters. Theresulttypeofo’,ifany,isstructurallyconsistentwiththeresulttypeofo. Thetypeoftheithparameterofoisstructurallyconsistentwiththetype oftheithparameterofo’. J

Thefollowingdefinitionintroducesournotionofbehaviorextension.AccordingtoMondel formalsemantics,thebehaviorofobjectsisformallyspecifiedbyatranslationtolabeled transitionsystems[Erra92a].BothRMondelandLotoshavetheirformalsemanticsdefined basedonlabeledtransitionsystems.Therefore,Ifweignoreoperationsparameters,our definitionofthebehaviorextensioncorrespondstothe extensionrelationdefinedforLotos specifications[Brin86].

Definition 3: Thetypet’=extends thetypet=,ifthefollowing propertiesaresatisfied: property 1.Bt’doeswhatisexplicitlyallowedaccordingtoBt(butitmaydomore). property 2.WhatBt’refusestodo(i.e.,blocking),canberefusedaccordingtoB t (Bt’maynotrefusemorethanBt). J

Itisimportanttonotethatformanyauthorstheconceptofinheritanceisonlyconcernedwith thenamesandparametertypesoftheoperationsthatareofferedbythespecifiedtype,e.g.in Emerald[Blac87]and Eiffel[Meye88].However,thereareotherimportantaspectsto inheritancerelatedtothedynamicbehaviorofobjects[Amer90],includingconstraintsonthe resultsofoperations,theorderingofoperationexecution,andthepossibilitiesofblocking [Boch89].Therefore,ourdefinitionofinheritancetakesintoaccountthedynamicbehaviorof objectsasfollows:

16 Definition 4:Atypet’=conforms toatypet=if: t’isstrcturally consistentwitht. and t’extends t. J

Iftypet'conformstotypetthenwesaythatt'isasubtypeoftandtisasupertypeoft'.

3.3.2. Structure modifications

Inthefollowingwegiveaclassificationoftypeinterfacesmodificationsthataresupportedin RMondel,andweprovidethedescriptionoftheirsemantics.Asweareconcernedbythe incrementalapproachforspecificationevolution,wewillconsiderthosetypemodificationsthat leadtonewtypeswhicharestructurallyconsistentwiththeoldones.

Add an attributeA to a type T:Thisupdateallowstheusertoappendanattributedefinition toagiventypedefinition.WesupposethattheaddedattributeAcausesnonameconflictsin thetypeToranyofitssubtypes. Change the type T of an attribute A by the type T1: ThisupdateisallowedonlyifT1inherits fromT. Add the operation O to the type T:ThisupdateallowstheusertoappendtheoperationOto thetypeT.WesupposethattheaddedoperationOcausesnooperationsnameconflictsinthe typeToranyofitssubtypes. Change the signature S of the operation O: (i)ChangethetypeToftheparameterpinS:ThisupdateallowsthechangeofthetypeTof theparameterpinS,tobecomeT’.ThisupdateisallowedonlyifTinheritsfromT’. (ii)ChangethetypeToftheresult,ifany,oftheoperationO:Thisupdateallowsthechangeof thetypeToftheresulttobecomeoftypeT’.ThisupdateisallowedonlyifT’inheritsfromT. Make a type S a supertype of type T:Thismodificationisallowedonlyifitdoesnot introduceacycleintheinheritancelattice.TheattributesandoperationsprovidedbyS,are inheritedbyTandbythesubtypesofT. Add a new type T:IfnosupertypesofTarespecified,thenthetypeOBJECT(i.e.therootof thetypelattice)isthedefaultsupertypeofT.Ifsupertypesarespecified,thenallattributesand operationsfromthesupertypesareinheritedbyT.ThenameoftheaddedtypeTmustnotbe usedbyanalreadydefinedtype.ThespecifiedsupertypesofTmusthavebeenpreviously defined.

17 InRMondel,typesareobjects(e.g.,instancesofModifiableTypewhichisdefinedata metalevel).TheModifiableTypeprovidestheprimitiveoperationsfortypemodifications definedabove(seeFigure4.).

3.3.3. Behavior modifications

Forthemodificationofthebehavior,weconsiderthosemodificationswhichextendthe existingbehavior.Thisissimilartothenotionofincrementalspecificationsproposedfora subsetofbasicLotoslanguage[Ichi90].Thebehaviorofobjectsistosomedegreedependent uponpreservingstructural consistency.Forinstance,whenanoperationiscalledonanobject, theassociatedcodetobeexecutedisdeterminedbytheobject’stypeorsupertypes. Additionally,oncetheoperationcodeislocated,itsimplementationisdependentonthecalled object’sstructure.Thisstructurehastobepresentinallobjectsthatareinstancesofthetype wheretheoperationisdefined.So,changestothetypeinterfacemaylead,inmostcases,to changesinthebehavior,accordingly.

Thepossibilitiesofbehaviormodificationsarebasedonthelanguageconstructswhichcan beinvolvedinsuchmodifications.Thebehaviorobtainedaftermodification,shouldbean extensionoftheoldbehavior.Amodifiedbehaviorconsistsofthecompositionofanold behaviorwithanewone.Thiscompositionisbasedonthesequential,thechoice,orthe parallelcompositionoperatorsofRMondel.Furtherdetailsonthebehaviormodificationsare givenin[Erra92b].Analgorithmforbehaviorscompositionisgivenin[Khen92].

3.3.4. Invariant definitions

Inthissectionwedefineasetofinvariantswhicharededucedfromthedefinitionsof Section3.3.1.Suchinvariantsmustbesatisfiedbyeachtypeanditsrelatedtypesinthetype lattice.Theinvariantsarecheckedwhenanobjectoratypeiscreatedandaftertypeupdates.In RMondel,theinvariantsarecheckeddynamically.Therefore,theyaredefinedatthemetalevel withintheinvariantclauseoftheModifiableTypeasshowninFigure5.

18 Type Lattice Invariant:Thetypelatticeisseenasadirectedacyclicgraph,wheretherootisa systemdefinedtypecalledOBJECT,andeachnode(i.e.,atype)isreachablefromtheroot. Eachtypeinthelatticehasauniquename.

Distinct Name Invariant:Allattributeandoperationnamesofatype,whetherexplicitlydefined orinherited,aredistinct.

Object Representation Invariant:Theobject’sstructuremustbeasspecifiedbyitstype.

Full Inheritance Invariant:Atypeinheritsallattributesandoperationsfromeachofits supertypes.Nameconflictsarenotaddressedhere,butmaybeavoidedusingthenameconflict detectionalgorithmsinasimilarwayasin[Delc91].

Type Compatibility Invariant:IfatypeTdefinesanattributewiththesamenameasanattribute itwouldotherwiseinheritfromasupertypeS,thetypeofT'sattributemustbethesameora subtypeofS'sattribute.

{theclassofmodifiabletypesisdefinedasasubclassofTYPEasfollows} typeModifiableType=TYPE with AddStat(S:Statement); AddAttr(A:Attribute); AddOper(O:Operation); AddProc(P:Procedure); ... invariant {Wedefinehere,theinvariantsdescribedabove,whichcorrespondtothestaticsemanticsrules ofthelanguage.Aformaldefinition,inMondel,oftheseinvariantsisgivenin [Erra92a]} behavior {Thesemanticsdefinitionsofthemodificationoperationsabove .} endtype ModifiableType

Figure5.ModifiableTypespecificationwiththeinvariants

3.3.5. Consistency checking of a specification

Inthissectionwediscusstheconsistencycheckingofaspecificationaftertype modifications.Ontheonehand,ifwereplaceatypetbyt'insomespecificationS,wheret'is structurally consistentwitht,doestheresultingspecificationS'remainstructurallyconsistent w.r.t.S?RecallthattypesareobjectsinRMondel.Ourstrategyfortypemodificationallows themodificationoftypeswithoutchangingtheiridentities.Thisimpliesthatthewhole specificationremainsconsistentfromthestructuralpointofview,i.e.,wedonotneedto

19 recompilethewholespecification.Thismaybeprovedaccordingtotwosituations,whichare assignmentandparameterpassing,wheretypecheckingisimportant.

Ontheotherhand,ifwereplaceatypetbyt'insomespecificationS,wheret' extends t, doestheresultingspecificationS' extends S?Theanswerisingeneralno,anillustrative exampleisgivenin[Erra92b].Therefore,weneedtocheckdynamicallythatthemodification ofthebehaviorofanobjectdoesnotintroducenewdeadlocksintheoverallspecification. Amongtheexistingapproachesfordeadlockdetection(e.g.,programtransformation, simulation,reachabilityanalysis)weuseadependencygraphandthereachabilityanalysis techniqueswidelyusedforthevalidation(e.g.,deadlockdetection)ofcommunication protocols[Zafi78],[Zhao86].Adependencygraphisconstructedbasedontherelationof dependencybetweentypes.Atypet1dependsonatypet2iftheformerusesoneormore operationsofthelater.Ifthe extension relationisviolated,e.g.,adeadlockisdetected,then thesystemreportstheinconsistenciesandthetypemustberevisedagain.

Inordertoensuretheconsistencyofthewholespecificationafteritsmodification,weuse theconceptoftransactionwhichiswellknownfordatabasesystems.Theuserformulateshis requirementswithinatransactionwhichconsistsofoneorseveraltypeupdateoperations.In ordertoallowfordynamicmodificationsofagivenspecificationwithoutinterruptingthe processingofthosepartsofthespecificationwhicharenotdirectlyaffectedbythechange,we definealockingprotocoltoisolatethosepartsofthespecificationwhichareaffectedbythe modifications.Thisprotocolalsoensuresthemutualexclusionofconcurrenttransactions.The otherpartsofthespecificationcontinuetobehavenormally.Thisprotocolisincorporated withinourtransactionmechanism.Adetaileddescriptionofthetransactionmechanismandthe lockingprotocol,assupportedinRMondel,isgivenin[Erra92d].

3.4. In-the-large modifications in RMondel

Forlargespecifications,theavailabilityofmodulesisofgreatpracticaluseforthe productionofstructuredspecificationsthatareeasiertomanipulate,understand,analyzeand maintain.Modulescanbedevelopedindependently,andtheycanbeanalyzedorevencompiled separately.Moreover,modulesofgeneralpurposecanbereusedwithinseveralspecifications. Inordertorealizethesefeatures,amodularspecificationlanguagehastofulfillseveral requirements.First,toenhancetheindependentdevelopment,analysis,andcompilationof

20 modules,theyshouldberepresentedassyntacticalcomponentsinthelanguage.Second,the compositionofmodulestobuildacompletespecificationshouldbesimple,e.g.,thisaspect canberealizedbymeansoftheimport/exportmechanism.

Inthefollowing,wewillshowhowthesefeaturesaresupportedinRMondel usingunits. Thenweintroducethestructuralandbehavioralconsistencyrequirementswhichallowforthe constructionofvalidspecifications.Afterwards,weintroducetheunitmodificationsandtheir semanticsasdefinedinRMondel.

3.4.1. The unit concept in RMondel

Aunitconsistsofthefollowingconstituentparts:animportinterface,anexportinterface, types,andaunitbody.Therearetwoformsoftheimportinterface: (1)UseU1,U2,....,Un (2)FromUjUseN1,N2,...,Nm WheretheUiareunitidentifiersandtheNiarenamedobjectsortypenamesdefinedwithin theUi.ThefirstformmakesthenamesoftheunitsUi(i=1,...,n)visible.Thisimpliesthatthe exportedobjectsandthetypesofUiarevisible.ThesecondformmakesonlythenamesN1, N2,...,NmvisiblefromtheunitUj.ThisassumesthatthenamesNiareavailableinUj.

Theexportinterfacehastheform: ExportN1,N2,...,Nm wheretheNiarenamedobjectsortypenames.Theexportinterfaceisintendedtobethevisible partofthemodule.Thetypesofaunitconstituteatypelatticewheretypesarelinkedbymeans oftheinheritancerelation.Thebodypartofaunitmustincludethedefinitionoftheexported objects.Itcanincludesalsoacollectionoftypesthatcanbeusedonlywithintheunit.

Therearecertainsemanticalrequirementsthathavetobefulfilledbeforeseveralunitsmaybe consideredtoformacorrectspecification. .Aspecificationconsistsofanumberof units.Oneunitmaydependonobjectsandtypes giveninotherunits.Agivenspecificationisexecutedbyexecutingsequentiallythe behaviorsinthedifferentunits.TheunitsshouldbeexecutedinsuchanorderthatifaunitA usesaunitBthentheunitBisexecutedbeforetheunitA.

21 . Thetypesandthoseobjectsthatareexportedcanbeusedbyotherunitsifthelaterexplicitly indicatethattheyusetheformer. . Unitsmaynotimporteachothercyclically. . Theexportedobjectsandtypesshouldbeuniquelyidentifiedtoavoidnameconflicts.

3.4.2. Notion of configuration

Alargespecificationisadirectedacyclicgraphwheretheleafnodesareunits,andthe internalnodesaresubspecifications.Eachsubspecificationisrealizedbyaconfigurationofits successornodeswhichmay,inturn,beothersubspecificationsormodules.Aconfiguration maybeacombinationoftwoormoreunitsbymeansofthe compositionand/orthe union operationsintroducedinSection2.2.2.Thecharacteristicsofmeaningfulconfigurationsare embodiedintheconceptofwellformedconfigurationsintroducedbyTichy[Tich82]. However,Tichy’sapproachispurelysyntactic.Hedoesnotconsiderthedynamicbehavior aspectofmodules.Ourapproachconsidersthedynamicbehavioraspectandtheinheritance relationassupportedbytheRMondellanguage.

Theunitconstructisdefinedinaccordancewithasetofconstraintsinordertohavea structurallycorrectconfiguration.Astructurallycorrectconfigurationmustensurethatthesame objectand/ortypecannotbeimportedandexportedwithinsuchconfiguration.Itisalso importanttoensurethatthetypesandthoseobjectsthatareexportedbyaunitarenotexported byotherunitswithinthesameconfiguration.

LetaspecificationconfigurationC=<C1,C2,...,Cn>whereeachCimaybeaunitor anotherconfiguration.Accordingtoourdefinitionoftheunitweintroducethefollowing notations:

EO(U)isthesetofobjectsexportedbytheunitU, ET(U)isthesetoftypesexportedbytheunitU, IO(U)isthesetofobjectsimportedbytheunitU,and IT(U)isthesetoftypesimportedbytheunitU.

22 Definition 5: Aspecificationconfigurationiswellformedifitsatisfiesthefollowing conditions: (1)EverytypeandobjectthatisexportedbyCisexportedbysomeCi. (EO(C) " ET(C))⁄"i (EO(Ci) " ET(Ci))fori=1,..,n. (2)CimportsthosetypesandobjectsimportedbyalltheCiexceptforthetypesandobjects alreadyexportedbysomeothercomponentintheconfiguration. IO(C)"IT(C)⊇ ("i (IO(Ci)"IT(Ci)))("i (EO(Ci)" ET(Ci))fori=1,..,n. (3)Cdoesnotexportandimportthesametypesandobjects IO(C)∩EO(C)=∅ andIT(C)∩ ET(C))=∅ (4)Notypeorobjectisexportedbymorethanonecomponent. EO(Ci)∩ EO(Cj)=∅ and ET(Ci)∩ET(Cj)=∅ forallCi,Cj ofC,i≠j. (5)Theconditions(1)to(4)aresatisfiedbyallCi(fori=1,..,n). J

3.4.3. Consistency constraints for modifications

Asmodificationscanbecarriedoutoncomponentsofaconfiguration,itisimportantto ensureacontinuedvalidityofthespecificationasitevolves.Inthefollowing,wedefinethe constraintsthatmustholdtomaintainthestructuralandbehavioralconsistenciesofa specificationafteritsmodification.

Definition 6 [Tich82]:AunitU2is UpWardCompatibletotheunitU1ifandonlyif:U2 exportsatleastwhatU1exports,andimportsnotmorethanwhatU1does.Thatmeansthat U2canbeusedinsteadofU1,butnotviceversa: (EO(U2) " ET(U2))¤(EO(U1) " ET(U1)) and (IO(U2) " IT(U2))⁄(IO(U1) " IT(U1))J

Thisdefinitionisbasedonlyonimportedandexportedobjectsandtypes.Howeverour interpretationoftheupwardcompatibilityrelationisnotsatisfiedbythisdefinition.Weneedto takeintoaccounttheconforms-to relationdefinedfortypesinSection3.3.1,andconsiderthe dynamicbehavioroftheunits.Therefore,wedefinetheUpWardConformrelationasfollows:

23 Definition 7: AunitU2isUpWardConformtoU1ifthefollowingconditionsaresatisfied: (1)U2isUpWardCompatiblewithU1. (2)ThetypeofanobjectexportedbyU2conforms-tothetypeofanobjectexportedbyU1. ¢ O1[EO(U1),¡ O2[EO(U2)suchthat(type(O2)conforms-totype(O1)) (3)ThetypeofanobjectimportedinU1conforms-tothetypeofanobjectimportedinU2. ¢O2[IO(U2),¡ O1[IO(U1)suchthat:(type(O1)conforms-totype(O2)) (4)EverytypeexportedbyU2conforms-toatypeexportedbyU1 ¢ t1[ET(U1),¡t2[ET(U2)suchthat:(t2conforms-tot1) (5)EverytypeimportedinU1conforms-toatypeimportedbyU2 ¢ t2[IT(U2),¡ t1[ IT(U1)suchthat:(t1conforms-tot2) (6)ThebehaviorofU2(specifiedbyitsbodypart)conforms-tothebehaviorofU1.J

3.4.4. Semantics of the unit modifications

WeclassifytheunitmodificationsthatwesupportinRMondelanddefinetheirsemantics. Wedistinguishthefollowingcategories: (1)modificationoftheexportinterface:Addinga namedobjectoratypetotheexportinterfaceoftheunit.(2)modificationoftheimport interface:Removinganamedobjectoratypefromtheimportinterfaceoftheunit.(3) modificationofthetypes:thesearethesameasthoseallowedbytheinthesmalllevel,ashas beenshowninSection3.3.(4)modificationofthebodypartofaunit:similartothebehavior modificationsoftypes.

(1)Addanamedobjectoratypetotheexportinterfaceofaunit:thisupdateshouldnotcausea nameconflict,andtheaddedobjectortypemustbedefinedwithintheunit.Thismodification hasnoimpactontheexistingmodules. (2)Deleteanamedobjectoratypefromtheimportinterfaceofaunit:Thisisthecasewherea unitcanproducethesameservicewithlessresources.Thisimpliesthattheunitbehavior and/orthetypes,wheretheremovedobjectortypeisused,mustbechangedaccordingly. (3)themodificationsoftypesandoftheunitbodyareperformedbyusingthosemodification operationsdefinedforthemodificationoftypes. (4)Addaunit:Theaddedunitmustbepreviouslycreated,andcanimporttheexistingunits.It canalso,exportsnamedobjectsortypeswhichshouldbeeventuallyusedbyotheradded units.

24 Thedeletionofanexportedobjectortype,theadditionofanobjectortypetotheimport interfaceofagivenunit,andthedeletionofaunitmaybeusefulforchangingthe configurationofthespecification.

3.4.5. Dynamic modification of a modular specification

Inordertoallowtheconstructionofdynamicallymodifiablelargespecifications,weneedto haveaccess,andtobeabletomodifyunitsduringthespecificationexecution.Modifications shouldbesupporteddynamically,withoutinterruptingtheprocessingofthosepartsofthe specificationwhicharenotdirectlyaffected.Inasimilarwayasourreflectionbasedmodel usedtosupportdynamictypemodifications,aunitisanobjectoftypeUNITwhichisdefined atthemetalevel.ThetypeUNITprovidessomeprimitiveoperationsforunitmodificationsas showninFigure6.

Theunitcomponentsaredefinedasvariableattributes(UnitName,Import,Export,Types, andBody)withintheUNITtype(seeFigure6.).TheconstraintsdefinedbyDefinition7,are introducedasinvariantswhichmustholdforeachunit.Theinvariantsarecheckedatcreation timeandaftertheunitmodifications.Theallowedmodificationprimitives,aredefinedas operationswhichcanbeacceptedbytheunits.Thesemanticsoftheseprimitiveoperationsis specifiedinRMondelwithintheBehaviorclauseoftheUNITtype.

typeUNIT=OBJECTwith UnitName :string; Import :set[UsedUnit]; Export :set[NamedObject]; Types :set[TypeDef]; Body :var[statement]; Invariant {theconstraints(1)to(6)ofDefinition7above,arespecifiedhereasinvariantsthatmust holdafteraunitmodifications} Operation DelImp(Unit); {dropaunitfromtheimportlist} AddExp(NamedObj); {addthe“NamedObj”objecttotheexportinterface} *Typeupdate:fortypemodificationsseeFigure4. AddStat(statement); {addastatementtotheunitbody} Behavior {wespecifyherethesemantics,intermsof RMondelstatements,oftheaboveoperations} EndtypeUnit

Figure6.ThetypeUNITspecification.

25 4. Conclusions

Wehavestudieddynamicmodificationswithinanobjectorientedlanguagethatis particularlysuitablefordistributedsystemsmodelingandspecification.Dynamictype modificationsisaninterestingandchallengingresearchproblem.Objectorientedsystemsin conjunctionwithreflection,allowustoapproachthisproblemthatconventionalsystemshave notbeenabletoaddress.Wehavepresentedagenericmodelwithtwolevelsofspecification modification.Thismodelallowsfortheevolutionoflargespecificationsatboththetypeand themodulelevels.WehaveshownhowsuchamodelissupportedbytheRMondelreflective language.Wehavegainedmoreflexibilityforthemodificationoflargespecificationsby consideringthatbothtypes(classes)andunits(modules)areobjects,andbydefiningthe modificationoperationsatametalevel.Inordertomaintaintheconsistencyofaspecification afteritsmodification,wehaveintroducedasetofconstraintsatbothlevels.Theallowed modificationsproposedinourapproacharerestrictedtothosewhichextendagiven specification.However,performinganykindofmodificationsremainadifficultproblem.Itis interestingtonotethatasetofmodificationsmaybeconsistentwhenperformedtogether, whereaseachsingleupdaterealizedindependentlymayyieldaninconsistentspecification. Thereforetheuseofthetransactionmechanismisveryimportant.

MondelhasbeenimplementedonaSunworkstation,andusedforwritingand simulatingthespecificationsoftheOSIdirectorysystem,andthepersonalcommunication services.AprototypeoftheRMondelinterpreterisimplementedinMondel.Ourapproach givesaninterestingframeworkbasedonaformalapproach,forthedevelopmentof correspondingCASEtools,especiallyforspecificationsprototypingandmaintenance.Our futureresearchfocusesonhowandunderwhichconditionsthemodificationstoagiven specificationmaybeperformeduponanimplementationwithinthesametransaction.The modificationmustbedoneinawaytopreservetheconformancerelationbetweenthe implementationanditsspecification.Wearealsoconsideringthedevelopmentofaversion controlmechanisminordertokeeptrackoftheevolutionhistoryofanevolvingspecification.

Acknowledgement ThisresearchwassupportedbyagrantfromtheCanadianInstituteforTelecommunications Research(CITR)undertheNCEprogramoftheGovernmentofCanada.Theauthors gratefullyacknowledgetheinsightfulcommentsofthereferee.

26 References

[Amer90] P.America,A Behavioral Approach to in object-oriented programming languages, PhilipsJournalofResearch,Vol.44,Nos.2/3,pp.365383,1990.

[Bane87] J.Banerjee,W.Kim,H.J.KimandH.F.Korth, Semantics and implementation of schema evolution in object oriented databases,inProceedings,ACMSIGMODInt.Conf.OnManagementofData,San Fransisco,CA,May1987,pp.311322.

[Barb91] M.Barbeau,Vérification de spécifications en langage de haut niveau par une approche basée sur les réseaux de Pétri,Ph.D.Thesis,UniversitédeMontréal,1991.

[Blac87] A.Black,N.Hutchinson,E.Jul,H.LeveyandL.Carter, Distribution and abstract types in Emerald,IEEETrans.onSoft.Eng.,VolSE13,no.1,1987,pp.6576.

[Blum87] E.K.Blum,H.EhrigandF.ParisiPresicce, Algebraic specification of modules and their basic interconnections,JournalofComputingandSystemSciences,V.34,pp.293339,1987.

[Boch89] G.v.Bochmann,Inheritance for objects with concurrency,Publicationdepartementale#687, DepartementIRO,UniversitédeMontréal,Septembre89.

[Boch90] G.v.Bochmann,M.Barbeau,M.Erradi,L.Lecomte,P.MondainMonvalandN.Williams, Mondel: An Object-Oriented Specification Language,Publicationdepartementale#748,DepartementIRO, UniversitédeMontréal,November90.,

[Boch91] G.v.Bochmann,L.LecomteandP.MondainMonval, Formal Description of Network Management Issues,Proc.Int.Symp.onIntegratedNetworkManagement(IFIP),Arlington,US,April1991, NorthHollandPubl.,pp.7794.

[Boch92] G.v.Bochmann,S.PoirierandP.MondainMonval, Object-oriented design for distributed systems and OSI standards,tobepublishedinProc.ofIFIPInt.Conf.onUpperLayerProtocols,Architectures andApplications,Vancouver,May1992.

[Brin86] E.BrinksmaandG.Scollo, Lotos specifications, their implementations and their tests, ProtocolSpecification,TestingandVerificationVI(IFIPWorkshop,Montreal,1986),NorthHollandPubl.,pp. 349360.

[Brin89] E.Brinksma,Specification Modules in LOTOS,FORTE'89,pp.137156.

[Coin87] P.Cointe, are first class: The ObjVLisp Model,OOPSLA'87,ACMSigplan Notices22,12,pp.156167.

[Delc91] C.DelcourtandR.Zicari,The design of an integrity consistency checker (ICC) for an object oriented database system,ECOOP'91.

[Erra90] M.ErradiandG.v.Bochmann, RMondel: A Reflective Object-Oriented Specification Language,TheECOOP/OOPSLA'90FirstWorkshopon:ReflectionandMetalevelArchitecturesinObject OrientedProgramming,Ottawa1990.

[Erra92a] M.ErradiandG.v.Bochmann, Semantics and definition of RMondel : A Reflective Object- Oriented Language,Internalreport,departementIRO,UniversityofMontreal,1992.

[Erra92b] M.Erradi,G.v.BochmannandR.Dssouli, Semantics and implementation of type dynamic modifications,Publication#813,DepartmentIRO,UniversityofMontreal,March1992.

27 [Erra92c] M.Erradi,G.v.BochmannandI.Hamid, Dynamic Modifications of Object-Oriented Specifications,CompEurop'92,IEEEInt.Conf.onComputerSystemsandsoftwareEngineering,May1992.

[Erra92d] M.Erradi,G.v.BochmannandI.A.Hamid, Type Evolution in a Reflective Object-Oriented Language,submitted.

[Ferb89] J.Ferber,Computational Reflection in Class based Object Oriented Languages,Proceedings ofOOPSLA'89,October16,1989,pp.317326.

[Ichi90] H.Ichikawa,K.YamanakaandJ.Kato, Incremental Specification in LOTOS,PSTV'90.pp. 185200.

[Khen92] F.KhendekandG.v.Bochmann, Incremental Construction of LOTOS Specifications with Internal Structure,submittedforpublication.

[Maes87] P.Maes,Concepts and Experiments in computational reflection,OOPSLA'87,ACMSigplan Notices22,12,pp.147155.

[Meye88] B.Meyer,Object Oriented Software Construction,C.A.R.HoareSeriesEditor,PrenticeHall, 1988.

[Parn72] D.L.Parnas,A technique for software module specification,CACM,Vol.15,No.5,pp.330 336,1972.

[Penn87] D.J.PenneyandJ.Stein, Class Modification in the GemStone object-oriented DBMS, OOPSLA'87,pp.111117.

[Skar87] A.H.SkarraandS.B.Zdonik, Type evolution in an Object-Oriented Databases,Research directionsinobjectorientedprogramming,Eds.PeterWegnerandBruceShriver,MITpress,pp.393415,1987.

[Smit82] B.C.Smith, Reflection and Semantics in a Procedural ,Ph.D. Thesis,MIT,MIT/LCS/TR272,1982.

[Tich82] W.F.Tichy, A data model for programming support environments and its application,In AutomatedToolsforInformationSystemDesignanddevelopment,Eds.H.J.SchneiderandA.I.Wasserman, Amsterdam:NorthHolland,1982,pp.3148.

[Viss88] C.Vissers,G.ScolloandM.v.Sinderen, Architecture and Specification Style in Formal Descriptions of Distributed Systems,Proc.IFIPSymposiumonProt.Spec.,Verif.andTesting,AtlanticCity, 1988.

[Webe86] H.WeberandH.Ehrig, Specification of modular systems,IEEETrans.onSoft.Eng.V.SE 12,N.7,July1986,pp.784798.

[Will90] N.Williams, Un simulateur pour un langage de spécification orienté-objet,MScthesis, UniversitédeMontréal,1990.

[Work91] M.H.Ibrahim, ECOOP/OOPSLA' 90/91 Workshops on Reflection and Metalevel Architectures in Object-Oriented Programming,

[Zafi78] P.Zafiropulo,Protocol validation by duologue-matrix analysis,IEEETrans.onComm.Vol. COM26,No.8,1978,pp.11871194.

[Zhao86] J.R.ZhaoandG.v.Bochmann,Reduced reachability analysis of communication protocols: a new approach,Proc.IFIPWorkshoponProtocl.Spec.TestingandVerification,NorthHollandPubl.,1986, pp.234254.

28