ebook img

AspectMaps: Extending Moose to visualize AOP software PDF

17 Pages·2013·0.72 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview AspectMaps: Extending Moose to visualize AOP software

ScienceofComputerProgramming79(2014)6–22 ContentslistsavailableatScienceDirect Science of Computer Programming journalhomepage:www.elsevier.com/locate/scico AspectMaps: Extending Moose to visualize AOP software JohanFabrya,∗,AndyKellensb,SimonDenierc,StéphaneDucassec aPLEIADLaboratory,ComputerScienceDepartment(DCC),UniversityofChile,Chile1 bSoftwareLanguagesLab,VrijeUniversiteitBrussel,Belgium2 cRMoDTeam,INRIALille-NordEurope,France3 a r t i c l e i n f o a b s t r a c t Articlehistory: When using aspect-oriented programming the application implicitly invokes the Received24January2011 functionality contained in the aspects. Consequently program comprehension of such Receivedinrevisedform13November a software is more intricate. To alleviate this difficulty we developed the AspectMaps 2011 visualization and tool. AspectMaps extends the Moose program comprehension and Accepted23February2012 reverseengineeringplatformwithsupportforaspects,andisimplementedusingfacilities Availableonline10March2012 providedbyMoose.InthispaperwepresenttheAspectMapstool,andshowhowitcan beused byperforminganexploration ofafairlylarge aspect-orientedapplication. We Keywords: thenshowhowweextendedtheFAMIXmeta-modelfamilythatunderpinsMoosetoalso Aspect-orientedprogramming Visualization providesupportforaspects.ThisextensioniscalledASPIX,andthankstothisenhancement Moose Moosecannowalsotreataspect-orientedsoftware.Finally,wereportonourexperiences usingsomeofthetoolsinMoose;Mondriantoimplementthevisualization,andGlamourto buildtheuserinterface.Wediscusshowwewereabletoimplementasizablevisualization toolusingthemandhowwewereabletodealwithsomeoftheirlimitations. Note:Thispaperusescolorsextensively.Pleaseuseacolorversiontobetterunderstandthe ideaspresentedhere. ©2012ElsevierB.V.Allrightsreserved. 1. Introduction Aspect-oriented programming [18] is a novel programming paradigm that aims at modularizing what are called crosscuttingconcerns.Duetothe‘‘tyrannyofthedominantdecomposition’’[27],particularconcerns,e.g.,logging,tracing, transaction management, and so on, cannot be captured in individual modules using classical software engineering techniques.Insteadtheirimplementationisscatteredthroughoutvariousmodules,hencecrosscuttingtheimplementation oftheentiresystem. Totacklethisproblem,aspect-orientationintroducestheconceptofanaspect:anovelkindofmodulethatcapturessuch crosscuttingconcerns.Keytothenotionofaspectsisthefactthattheyintroduceanimplicitinvocationmechanism.Rather thaninvokingthecrosscuttingbehaviorexplicitlyfromwithinthecodeofasystem,thisbasecodenolongercontainsthese calls.Toallowimplicitinvocation,conceptually,eachexecutionstepoftheapplicationisreifiedasajoinpoint,e.g.,amethod call,anassignment,... Anaspectthendefinesthebehaviortobeexecuted,anadvice,tooccuroncertainjoinpoints.These areidentifiedbydefiningapointcut:apredicateoverjoinpoints.Inotherwords,whileanadvice4implementstheactual ∗ Correspondingauthor. E-mailaddress:[email protected](J.Fabry). 1 http://pleiad.cl. 2 http://soft.vub.ac.be. 3 http://rmod.lille.inria.fr. 4 IntheAOSDliteraturetheterm‘advice’isusedinsteadof‘apieceofadvice’andthepluralof‘advice’remains‘advice’. 0167-6423/$–seefrontmatter©2012ElsevierB.V.Allrightsreserved. doi:10.1016/j.scico.2012.02.007 J.Fabryetal./ScienceofComputerProgramming79(2014)6–22 7 crosscuttingbehavior,pointcutsselectatwhichpointsintheexecutionofthesystemtheadviceshouldbeexecuted.Finally, thestaticlocationinthesourcecodethatgivesrisetoajoinpointatexecutiontimeiscalledajoinpointshadow.Insummary, thefollowingprocess(conceptually)takesplaceforeachexecutionstepofthesoftware.Whenanexpressioninthesource code,i.e.,ajoinpointshadow,isexecuted,itcausesajoinpointtobeemitted.Allpointcutsofthesystemareautomatically calledwiththisjoinpointasargument,andforthepointcutsthatreturntruetheadviceassociatedtothispointcutisrun. Althoughaspectsopenupnewpossibilitiesintermsofmodularizationofcrosscuttingconcerns,thepresenceofthis implicit invocation mechanism can make it more difficult for a developer to understand the behavior of the system. In literature, various problems have been documented that are caused by this implicit invocation mechanism. One such problem is the fragile pointcut problem [17,19]. Due to the limited expressiveness of pointcut languages, such pointcut expressionsareoftentightlycoupledtothestructureofthebasecode.Asaconsequence,seeminglysafechangestothis basecodecanhaveanunexpectedanderroneousimpactonthebehavioroftheaspectsthataredefinedinthesystem. Similarproblemscanoccurwhenmultipleaspectsinterveneatasinglejoinpoint.Asitisnotimmediatelyclearwhich aspectsinterveneatasinglepointintheexecution,andastheseaspectspotentiallyinteractwitheachother,thiscanlead toerraticbehavior[26]. To alleviate these problems and aid developers to understand such software we have proposed the AspectMaps visualization [14]. AspectMaps aims to ease code comprehension of software using aspects by offering a scalable visualizationofimplicitinvocation.TheAspectMapsvisualizationisalsoimplementedasatool,ontopoftheMoose[9] reverseengineeringplatform,leveragingthefacilitiesofferedbythisplatform. Thispaperbuildsuponourpreviouswork[14],andfeaturestwonovelcontributions:Ontheonehanditpresentsa detailed discussion of the AspectMaps visualization tool, showing how it can be used to explore aspect-oriented code of a fairly large application, yielding some interesting observations. On the other hand it provides a discussion of the implementationofthetool.InthispartwefirstintroduceourextensiontoMoosethatallowsittoalsooperateonaspect- orientedcode.ThisextensioniscalledASPIX;itaugmentstheFAMIX[28]meta-modelthatunderliestheMooseplatform suchthatitsinstancescanmodelaspect-orientedsoftware.Second,wediscussourexperiencesofusingthetoolsoffered byMooseforbuildingvisualizations:Mondrian[24],andfor(specifickindsof)userinterfaces:Glamour[5].Wereporthow wewereabletousethesetoolstobuildareasonablylargevisualizationtool,whileavoidingsomeoftheirdrawbacks.For anin-depthdiscussionregardingtheconceptsunderlyingourvisualization,theprosandconsofthevisualizationandan initialempiricalvalidationofourapproachwerefertheinterestedreaderto[14]. Theintendedaudienceofthispaperistwofold,echoingthetwomaincontributionsofthetool.Ontheonehandwehave thedevelopersofaspect-orientedsoftwarethatwanttouseAspectMapstogainabetterunderstandingofthesoftwareon whichtheyareworking.OntheotherhandwehavedevelopersusingMoosethatmaywanttobuildtheirownanalysistool foraspect-orientedsoftware,orthatmaygainfromourlessonslearnedbuildingalargeanalysistoolusingthefeaturesof Moose. Thispaperisstructuredasfollows:WestartwithgivinganintroductiontotheAspectMapsvisualization,andinSection3 we present the tool, followed by an example case study showing how it can be used. Section 4 introduces ASPIX, our extensiontotheFAMIXmeta-modelthatallowsMoosetobeusedtoanalyzeaspect-orientedsoftware.Thisisfollowed inSection5byareportofourexperiencesonusingMoosetobuildtheAspectMapstool.Section6givesanoverviewof relatedwork,andSection7discussesfutureworkandconcludes. 2. TheAspectMapsvisualization AspectMapsisavisualizationthatoffersusersadetailedoverviewofimplicitinvocation.Itvisualizeswhereaspectsare specifiedtoapplyinasystem,basedonvisualizingjoinpointshadows,andhowaspectspossiblyinteractateachjoinpoint shadow.Moreoverthisisperformedinascalableway,thankstoamultilevelselectivestructuralzoom.Notethatthispaper doesnotfocusonthevisualizationitself:adiscussionofthedesignrationaleofourvisualization,itsmeritsandlimitation, andasmalluserstudycanbefoundin[14].WethereforehereonlygiveasummaryoftheAspectMapsvisualization,adapted from[14],beforediscussingthetool. Forthesakeofthisdiscussion,wedefinethatanaspectappliesatacertainsourcecodeelement(apackage,class,or method)ifforatleastonepointcutthatisassociatedwithanadviceofthataspect,atleastoneofitsjoinpointshadows belongtothatelement. AspectMapssupportsthetraditionalpointcut–advicemodelofaspectsappliedtoobject-orientedclass-basedlanguages. Thejoinpointswevisualizearemethodcallsandmethodexecutions.Advicecanexecutebefore,aroundorafterajoin point,andwedistinguishbetweenafterreturningandafterexceptionthrowing.Aspectsmaycontainvariousadvice,and anexecutionordermaybespecifiedbetweenaspects.TheaboveeffectivelyallowsustovisualizeasubsetofAspectJ[18]and Javacode(whichisarguablythemostpopularaspectlanguagecombination).Inthiscaseweignoreinter-typedeclarations aswellasadvicethatappliestofields.TheAspectMapstoolishowevernotfundamentallyrestrictedtotheAspectJ/Java combinationandmoredetailonthisisgiveninSection4. The key feature of AspectMaps is having the ability to selectively zoom in on the source code at different levels of granularity.Zoominginfromacoarserleveltoamorefine-grainedlevelrevealsmoredetail.Thebehaviorisanalogous tostreetmapapplications,e.g.,GoogleMaps,hencethenameAspectMaps. 8 J.Fabryetal./ScienceofComputerProgramming79(2014)6–22 Fig.1.Compactvisualizationofpackages:coordinationandspacewar. SpaceObject Pilot Player Robot Display Fig.2.Extendedvisualizationofthespacewarpackage(annotatedwithselectedclassnames). To detail the AspectMaps visualization, the remainder of this section is structured following its different levels of granularity.Foreachlevelweshowhowitisvisualized,andillustratethetoolusinganumberofexamples.Specifically,for Sections2.1and2.2weuseSpacewar,anexampleprogramthatisprovidedwiththeAspectJDevelopmentToolkit(AJDT)[7] andisalsoincludedasexampleintheAspectMapstool.Spacewardefinesmultipleaspects.Forthisdiscussionwevisualize theCoordinationaspectingreenandtheEnsureShipIsAliveaspectinred.InSection2.3,weuseanadditionalartificially createdexample,asSpacewardoesnotsufficetoshowallthefeaturesofAspectMaps. AdditionalmaterialisavailableattheAspectMapswebsitehttp://pleiad.cl/aspectmapse.g.,featuringsomescreencasts ofthetoolinaction. 2.1. Packagelevel When opening the tool, AspectMaps provides an overview of all packages in the visualized system. Each package is representedbyacompactvisualizationthatshowsthenameofthepackageandtheaspectsthatapplytothispackage.The coloroftherectangleofeachpackagecorrespondstothecoloroftheaspectthatapplies,ifthataspectiscurrentlyenabled forvisualization.Inthecasethatmultipleaspectsapplytoasinglepackage,thisisindicatedbythecolorblack(whichnever canserveasthecolorofanaspect).ThispackagevisualizationisshowninFig.1.Thisfigureshowstwopackages,namely coordinationandspacewar.Asmultipleaspectsinterveneinthespacewarpackage,itisindicatedinblack.Packagecontents isnotshownatthismoment. AuserofAspectMapscanobtainanextendedvisualization,revealingthepackagecontents,byzoominginonaselected package(clickinginapackage).Fig.2showsthisextendedvisualizationappliedtothespacewarpackage.Insideofthe package,alldifferentclassesandaspectsbelongingtothatpackageareshown.Thissameextendedvisualizationisshownin apop-upwhentheuserofthetoolhoversthemousepointeroverapackagethatisrepresentedinthecompactvisualization. OurextendedpackagevisualizationisinspiredbytheworkofLanzaetal.onPolymetricViews[21].Wehaveextended thisworktoalsosupportthevisualizationofaspects.KeytoPolymetricViewsisthatthedimensionsoftheentitiesreflect particularpropertiesoftheseentities(e.g.,LOC,numberofmethods).Atthislevelofdetail,ourvisualizationshowsthe followinginformation: • Classes:rectangleswithblackborders.InheritancerelationsarevisualizedusingUMLnotation. • Aspects:rectangleswiththickcoloredborders.Thebordercoloristhecolorfortheaspect(neverblack). • Whereaspectsapply:classrectangleshavethecoloroftheaspectthatapplies,blackformultipleaspects. • Classandaspectmetrics:theuserselectswhichdimensionreflectswhichmetric,ornone.Forthefiguresinthissection weselectnometric,forclarityofthediscussion. SimilartotheoriginalPolymetricViewsvisualization,AspectMapsdoesnotdisplaythenamesoftheclasses,inorder topreventclutteringthevisualization.Thesenamesareinsteadrevealedattheclasslevel,whereclassesandaspectsshow theirextendedvisualization.Thisvisualizationisshownasapop-upwhenthemousehoversoveraclassoraspect,orwhen theuserperformsazoomoperationonaclassoraspectbyclickingonit. 2.2. Classlevel Classesarerepresentedinourvisualizationusingrectangles.Atthetopoftherectangle,andseparatedfromtherestofthe rectanglebymeansofahorizontalline,thenameoftheclassisshown.Belowthehorizontallinewerepresenttheinstance J.Fabryetal./ScienceofComputerProgramming79(2014)6–22 9 run keyPressed keyReleased Fig.3.TheDebugaspectandthePilothierarchy(annotatedwithselectedmethodnames). Method Name Before Execution Around Call Shadows Execution After Execution Fig.4.Templateforvisualizationofexecutionshadowpoints(left),andanexampledestroymethod(right).Fig.7showscallvisualization. variables(asdiamonds)andmethods(smallerrectangles)oftheclass.Theheightandwidthofmethodscanbedetermined byametric.Themethodsarecoloredbasedontheapplicableaspects,takingintoaccountthatmultipleaspectsintervening atasingleentityarecoloredblack.Bymeansofapop-upontheclassname,theusercangetadditionalinformationofthe class(itssuperclass,thenamesandtypesoftheinstancevariables). Aspectsarevisualizedinasimilarfashion,wherethenameoftheaspectisindicatedabovethehorizontalline.Belowthe linewecanfindtheadvice(shownasrectangles)andpointcuts(shownasovals).Thedimensionsoftheadvicecanalsobe customizedbyauser-selectedmetric.Pop-upsfortheaspectshowthesuperaspect;forpointcutstheyshowthenameofthe pointcut.Pop-upsforadviceshowtheirsignatureandlinenumberintheaspect,asanadvicesignaturedoesnotuniquely identifyanadvice. Fig.3showsourvisualizationzoomedinonalltheclassesinthehierarchyofPilot,andalsoshowstheDebugaspect.The visualizationshowsthattherearemultipleaspectsapplyingtomethodrundefinedontheclassGame.Furthermore,wesee thattheaspectEnsureShipIsAliveappliestomethodskeyPressedandkeyReleased. 2.3. Methodlevel ThemethodlevelisthefinestlevelofdetailofferedbyAspectMaps.Atthislevel,ourvisualizationshowshowaspects interveneattheshadowpointswithinthemethod.Notethatmultipleaspectscaninterveneatasinglejoinpoint,andthat advicecanbedeclaredtoexecutebefore,afteroraroundthejoinpoint.Tocorrectlyreflectthesemanticsofsuchajoinpoint model,ourvisualizationofshadowpointsmustrepresentthisinformationaccordingly. Fig.4(left)showsthevariousregionsofourvisualizationofmethods.Fromtoptobottom,ourvisualizationshowsthe nameofthemethodfollowedbyseparateboxescontainingbefore,afterandaroundadviceappliedtoexecutionshadow points.Adviceapplicabletocallshadowpointsisdisplayedwithinaseparatebox(alsoseeSection2.3.2).Ontherightofthe figure,ourvisualizationisillustratedonamethodnameddestroy.Wecanseethattheblueaspectappliesbeforeandafter theexecutionofthismethod. Bymeansofapop-uponthemethodname,usersofthetoolcanaccesstheparameterlistofthemethod. 2.3.1. Adviceexecution,Run-timetests,Ordering Foreachapplicableadvice,ourvisualizationdrawsasmallfigurerepresentingtheshadowpointinthecorresponding divisionofourmethod-levelvisualization.Thecolorofthisrectanglecorrespondstothecoloroftheaspect.Withinasingle 10 J.Fabryetal./ScienceofComputerProgramming79(2014)6–22 after throwing 4 after advice advice order of advice with execution runtime test Fig.5.Fourafterexecutionadviceofasetmethod. 2 before advice execution order 2 around due to advice precedence declarations 4 after advice Fig.6.Eightexecutionadviceforagetmethod,withtwoprecedencedeclarationsyieldingthreeorderingarrows. Method Name Shadow 1 Call Shadows Shadow 2 Shadow 3 Before Around After Fig.7.Templateforcallshadowpoints. divisionofourvisualization,theserectanglesarestackedvertically.Asanillustrationofthis,considerFig.5thatshowsthe afterexecutionadviceofanexamplesetmethod. AspectMapsmakesthedistinctionbetweenafterthrowingadvice(shownusingtriangles)andallotherkindsofadvice (representedbyrectangles),inordertoemphasizethespecialnatureofafterthrowingadvice:itexecuteswhenthemethod terminatesbythrowinganexception.Ifthereisarun-timetestinvolvedinevaluatingthepointcutforanadviceexecution (e.g.,anif-testoracontrol-flowpointcut)thefigurehasathickborderinacontrastingcolor(forexample,thegreenaspect inFig.5). Notethatitispossibleformultipleadviceofthesameaspecttoapplyatasingleshadowpoint.Thisisrepresentedin AspectMapsbyvisualizingafigureforeachapplicationoftheadvice.Theorderinwhichtheseadvicewillbeexecutedis indicatedbymeansofagrayarrow.Forexample,inFig.5theregularafteradviceoftheredaspectoccursbeforetheafter throwingadvice.Whenmultipleadviceofdifferentaspectsapply,theorderoftheirapplicationmaybespecifiedbythe programmer.Ifsuchanorderisspecified,AspectMapsindicatesthisorderbymeansofablackarrow.Anexampleofthis isshowninFig.6.Consideringtheafteradvice,thecyanandredcodeisrunbeforethepinkadvice.Thereisnoordering specifiedbetweenthegreenaspectandanyoftheotheraspects,norbetweenthecyanandredaspects,hencenoarrowsare drawn.Fig.5doesnotshowanyblackarrows,indicatingnoorderingisspecifiedbetweenthegreen,brownandredaspects andthereforenoclaimscanbemadeabouttheorderatwhichtheaspectswillbeexecutedatrun-time. 2.3.2. Callshadowpoints Thebodyofamethodmaycontainmultiplecallshadowpoints,sequentiallyorderedbythesourcecodeofthemethod. Wevisualizeadviceexecutioninthissameorder,aligningthemvertically.Thevisualizationofcallshadowpointsusesthe samevisualizationasexecutionshadowpoints.Ithoweverordersthebefore,aroundandafterdivisionshorizontallyinstead ofvertically.AtemplateofthisisshowninFig.7. J.Fabryetal./ScienceofComputerProgramming79(2014)6–22 11 Fig.8.AselectionofmethodsinSpacewarshowingcallshadowpoints,aswellasapop-upofoneadviceexecution(inthenewPlayermethod). Fig.9.TheAspectMapstoolshowingapartofSpacewar.Aboveisthevisualization,belowisprojectselection,visualizationofaspectselection,zoom shortcutbuttonsandmetricsselection.Nonvisiblemetricschoices:classwidthisAttributes,aspectheightisLOC(linesofcode). Anexampleofthevisualizationofcallshadows–appliedtoanumberofmethodsoftheSpacewarexample–canbe foundinFig.8.Thisfigurealsodemonstratesthepop-upinformationforeachadviceexecutionthatcontainsthesignature oftheadvice,thelinenumberoftheaspectinthesourcecodeandthesourcecodeoftheshadowpoint. 3. UsingAspectMaps TheAspectMapsvisualizationhasbeenimplementedinPharo,aversionofSmalltalk,usingMoose[9],aplatformfor softwareanalysisandreverseengineering.TheresultingtoolisalsocalledAspectMaps.Itisastandalonetoolthatinits currentincarnationcanvisualizeAspectJ/JavacodedevelopedwiththeEclipseAspectJDevelopmentToolkit[7]. WeintroducethetoolhereandhowitislinkedtoEclipsebeforedescribingasoftwareexplorationsessionusingthetool. TheimplementationoftheAspectMapstoolisdiscussedinSections4and5. 3.1. TheAspectMapstooluserinterface TheAspectMapstoolconsistsofasinglewindow,showninFig.9.ThetoppartofthewindowshowstheAspectMaps visualization,andthebottompanelcontainsmultiplecontrolsthatdeterminewhatisvisualizedandhow.Wepresentthese controlsnext,followedbyadescriptionofthecontextmenuofthevisualization. 12 J.Fabryetal./ScienceofComputerProgramming79(2014)6–22 Available projects. AspectMaps allows for multiple Java projects to be visualized. In the figure these are AMTest and Spacewar2.Selectingaprojectshowsthevisualizationinthetoppartofthewindow,andpopulatestheAspectsinProjectlist. Thehierarchyofpackagesinaprojectisalsoavailableasaflattenedlist,byclickingontheexpansiontriangleshownbefore theprojectname.InthefigurethisisshownforSpacewar2.Selectingapackagefromthislistrestrictsthevisualizationto onlyshowthispackage. AstheAspectMapstoolisnotintegratedinanexistingJava/AspectJdevelopmentenvironment,thecodethatisvisualized needstobeimportedintothetool,whichaddsittothelist.ImportingisrequiredbecauseAspectMapsdoesnotoperateon the original source code, but builds its internal model in order to visualize it. (This process is discussed in Sections 4.1 and4.2.)AprojectcanberemovedfromtheAspectMapstoolrepository,nolongermakingitavailableforvisualization, byclickingonthetrashicon.Clickingonthefoldericonlaunchesanimportwizardthatwilladdtheprojecttothemodel repository.Importingisatwo-stepprocess:firsttheaspectualinformationoftheprojectisobtainedbyaskingforan.xcr fileoftheproject.SecondtheOOstructureoftheprojectisretrieved,eitherbyindicatingthesourcecodedirectoryofthe projectorbyprovidinga.mseMooseexchangefilefortheproject.Howtogenerateboth.xcrand.msefileisdiscussedin Section3.2. Aspectsinproject. Twosettingsfortheaspectsintheprojectthatiscurrentlybeingtreatedarespecifiedhere.Firstly,each aspectnameisshowninthecolorthatrepresentsitinthevisualization.Acontextmenuontheentriesinthislistallows theircolortobechangedbyselectingitfromalistofcolors.Secondly,visualizationofjoinpointshadowsofeachaspect canbeturnedonoroff.Forexample,inFig.9,visualizationofDebugisturnedon,whileforCoordinatoritisoff.Thecontext menuontheentriesinthelistallowsthisvisualizationstatetobetoggled.Clickingthecheckiconturnsonvisualizationof allaspectsinthelist,exceptfortheselectedaspect,ifany.Clickingthecrossiconperformstheinverse. Structuralzoom. Thestructuralzoombuttonsperformsevendifferentzoomoperationsontheentitiesbeingvisualized.In ordertheseare: ByQuery: Givenaquery,whichmaycontainwildcards,zoomsinmaximallyonentitiesofwhichtheirnamesmatch. EnabledAsp: Zoomsinmaximallyonalljoinpointshadowsofaspectsthatareturnedonforvisualization. MultipleAsp: Zoomsinmaximallyonalljoinpointshadowswheremultipleaspectsthatareturnedonarepresent. MaxIn: Maximalzoomlevelonallentitiesinthevisualization,i.e.,allentitiesshowtheirextendedrepresentation. Classcontents: Levelshowingcontentsuptoclassesandaspects,allmethodsshowingtheircompactrepresentation. Pkgcontents: Zoomlevelwherethepackagesshowtheircontents,andlowerlevelsshowthecompactrepresentation. Maxout: Zoomlevelwhereallentitiesshowtheircompactrepresentation. Classes, Methods, Aspects, Advice. These four tabs allow for a specification of the dimensions of the rectangles that representtheseentities,whendrawninthecompactrepresentation.ThisistakenfromPolymetricViews[21],asdiscussed in Section 2.1. By default the value here is constant, yielding small squares for each entity. Selecting a metric for a dimension,e.g.,LOCfortheheightofclassesinFig.9,specifiesthatthesizeofthisdimensionisequaltothevalueofthis metricfortheentitythattherectanglerepresents.Furtherconsideringtheclassesintheexample,thewidthofclassesisset totheAttributesmetric,indicatingthenumberofattributes.Thetallclassrectangleshencearelargeclasses,andthewide classeshavealargenumberofinstancevariables.Notethatmetricsonlyapplyonthecompactrepresentation,asinthe expendedrepresentationthesizeofanentityrectanglemayneedtoexpandtoshowitscontents. Context menu of the visualization. The last control of the visualization is the context menu that is available on selected entitiesthatarebeingvisualized.Wehavethefollowingcontextmenuitems: Onpointcuts: Revealingalljoinpointshadowsofthispointcutbyzoominginonthemethodscontainingthem. Onadvices: Revealingalljoinpointshadowsofthepointcutofthisadvice. Onadviceexecution: Revealingtheaspectoftheadviceandrevealingalltheexecutionsofthisadvice. 3.2. GeneratingimportfilesforAspectMaps Assaidpreviously,tovisualizeaprojectitfirstneedstobeimportedintoAspectMaps.Thisimportprocesstakesonthe onehandtheOOstructureoftheapplication,i.e.,whatisdefinedbytheJavacode,andontheotherhandtheaspectual information,i.e.,whatisdefinedbytheAspectJcode.TheimportprocessitselfisdiscussedinmoredetailinSections4.1and 4.2,wedescribeherehowtoobtainthefilesrequiredtoperformanimport. ToimporttheOOstructureoftheprojecttheAspectMapstoolrequiresa.msefilethatcontainstherelevantdataofthe projectbeingimported.As.mseisthestandardfileformatforMoosedatainterchange,therearemultipletoolsavailable thatproducea.msefilefromaJavasourcedirectory.OneoptionistheinFamixtoolbyintooitus,5asecondpossibilityto 5 http://www.intooitus.com/products/infamix. J.Fabryetal./ScienceofComputerProgramming79(2014)6–22 13 Fig.10.Thecrosscutreportplugintoolbarbutton(theshamrock)openstheconfigurationdialog. generatesuchfilesistouseVerveineJ.6AspectMapshassupportforbothtools(limitedtoUNIX/MacOSX):itcanusethem togeneratethe.msefileontheflywhenimporting,thusstreamliningtheprocess. AnotabledrawbackofusingJavasourcecodetogeneratethe.mseisthatthecodebeingexaminedmustbecorrectand fullycomplianttotheJavastandard.ThisisrelevantastheAspectJcompiler,usedinEclipseAJDT,alsoaccepts.javafiles whereaspects,pointcutsandadvicearedefined.ThereforesomeprojectsthatcompilesuccessfullywiththeAJDTcannot beimportedintoAspectMaps.Tosolvethis,thedevelopermustensurethatallaspectualcodeisdefinedinAspectJ.ajfiles, notin.javafiles. TheaspectualinformationofaprojectisgeneratedbyanEclipseplug-inweimplemented.Theplugin,calledXCutreport, istriggeredbyasuccessfulAspectJcompilation.AfteranAspectJprojectiscompiled,itproducestherelevantaspectual information.Thepluginhasastraightforwardconfigurationdialogbox,showninFig.10.Outputcanbeturnedoff(the defaultstate,whicheffectivelydisablestheplugin),shownontheEclipseconsoleorwrittentoan.xcrfile(orbothofthe latter).The.xcrfileformatandtheXCutreportpluginarediscussedinmoredetailinSection4.2.1. 3.3. Examplecase:AJHotDraw ToshowhowtheAspectMapstoolcanbeusedtoexploreagivenapplication,wenowpresentastudyofAJHotdraw[8] usingAspectMaps.Wechosethisapplicationasitisawidelyknownexampleofanaspect-orientedapplication.AJHotdraw isafairlylargeapplication,consistingof374classesand31aspects,whichservestoillustratethescalabilityofourtool.A fullinvestigationoftheAJHotdrawcodeisoutsideofthescopeofthispaper.Werestrictourdiscussionheretoshowing howthetoolwasusedtoreachsomenotableconclusionsfromourexploration. • Afirstassessmentofthelocationofclassesandaspects,usingthePkgcontentsbuttonshowsthatalltheaspectsare withintheccconcernspackagehierarchy. • LookingatthenamesofaspectsintheAspectsinProjectlist,weseethatofthe31aspects,atleast15arededicatedto undooperations. • Selecting the ccconcerns.tools.undo package in the Available projects (restricting the visualization to only show that package)showsthatitcontainsfiveundoaspects.PerformingaMaxinzoomoperationrevealsthatnoneofthesecontain apointcutnoranadvice.(Sourcecodeinspectionrevealsthattheseaspectsonlyperforminter-typedeclarations,which arenotvisualizedinAspectMaps.) • Investigatingthecontentsoftheotherccconcernspackageinthesamewaywefindthattheother10undooperationsare locatedinthepackageccconcerns.commands.undo.ThesehaveanamethatendsinUndo,exceptforUndoRedoActivity. Alloftheformeronlyhaveonepointcut.Usingthecontextmenuitemthatrevealstheshadowsofthepointcutwelearn thateachoftheseaspectssolelyaffectstheexecutemethodofaclasswiththecorrespondingname,withouttheUndo suffix.AlloftheaffectedclassesaresubclassesofAbstractCommand.Thisisshownbytheinheritanceedgeforsubclasses inthesamepackage,andalsobytheclassnamepop-upforsubclassesinadifferentpackagethanAbstractCommand. • UsingtheNum ShadowsmetricweseethatoneofthetwomostimportantaspectsisCommandContracts.Enabling visualizationofthisaspectonlyusingthetoolbariconandperformingaEnabledAspzoom,showsthatitaffectsthe executemethodthatispresentinalmostallclassesoftheAbstractCommandhierarchy.Manualzoomingandexploration oftheclassesinthehierarchythatarenotaffectedrevealthatthesedonotcontainanexecutemethod.Accordingtothe samemetric,theotherimportantaspectisUndoableCommand.Investigatingthisaspectinananalogousfashion,we seeitonlyaffectstheAbstractCommandclassand6moreclasses,eachofwhichisasubclassofaSwingcomponent:4 menu-relatedclasses,andthebuttonandcombo-boxclasses. 6 http://www.moosetechnology.org/tools/verveinej. 14 J.Fabryetal./ScienceofComputerProgramming79(2014)6–22 InadditiontoastudyofAJHotdraw,AspectMapshasbeenusedtoexploreSpacewar[14].Wealsohaveperformedauser studythatrevealsthatonanexplorationofSpacewar,AspectMapsfaroutperformsthevisualizationofAJDT[14],which isarguablythemostcompetitivesoftwarevisualizationforaspect-orientedsoftware.Again,adiscussionoftheseresultsis outsideofthescopeofthispaper,asherewefocusonthetool,andwerefertothepublishedarticle[14]formoreinformation. 4. AddingaspectsupporttoMoose TheAspectMapstoolisbuiltontopofMoose[9],aplatformforsoftwareanalysisandreverseengineering.Mooseoffers variousfacilitiesforbuildingsoftwareengineeringtools,rangingfromimportingdata,source-codemodelingandquerying, tobuildingsoftwarevisualizations.Inthepast,Moosehasbeensuccessfullyleveragedforbuildingawidevarietyoftools, suchasTorch[29](atoolsupportingsource-codechangeintegration),SmallDude[4](aduplicationdetector),andeDSM[22] (atooltodetectcyclicdependencies).Withinthecontextofthiswork,weoptedtobaseourtoolonMooseforthefollowing reasons: • FAMIX. FAMIX [28] is a language-independent meta-model for class-based programming languages that underpins the Moose tool suite. Using this model allows AspectMaps to achieve a certain level of base and aspect language independence.AdownsideisthatFAMIXhoweverdoesnotprovideconceptsforrepresentingaspect-orientedconstructs. • Mondrian.Mondrian[24]isadomain-specificlanguageforscriptingvisualizationsthatispartoftheMoosetoolsuite. Itisparticularlywell-suitedforimplementingAspectMapsasitdoesnotonlyofferconstructsfordeclaringthedifferent nodesandedgesthatmakeupavisualization,butalsoprovidesameanstocreatehighly-interactivevisualizations. • Glamour.SimilartoMondrian,Glamour[5]isadomain-specificlanguageforscriptingbrowsers.Itprovidesaconvenient wayfordeclaringandcomposingtheuser-interfacecomponentsofAspectMaps. • Integrationwithothertools.ByimplementingAspectMapsontopoftheMooseplatform,wecanalsoleveragetheother toolsthatarepartoftheMooseplatform(tocalculatemetrics,...). Assaidabove,Moosedoesnotprovidesupportforanalyzingaspect-orientedsoftwareastheFAMIXmeta-modelfamily lackstherequiredconcepts.Toaddressthisshortcoming,weprovidedanextensiontoFAMIXthataddsthissupport,called ASPIX.ASPIX(ASPectsInfamiX)isagenericclass-basedobject-orientedmeta-modeltowhichtheessentialaspect-oriented conceptshavebeenadded.TheASPIXmodelisgenericsuchthatitcanbeusedbyalloftheMoosetools,i.e.,enablingMoose tobeusedtoanalyzeaspect-orientedsoftware.Moreover,basingAspectMapsonASPIXallowsourtooltobeusedforother combinationsofbaselanguagesandaspectlanguages.Thisaslongastheyfollowthe,arguablyprevailing,modelofaspects beingcomposedofpointcutandadvice. InthissectionweprovideadescriptionofASPIXanddetailhowmodelinstancescanbecreated,i.e.,howaspect-oriented codeisrepresentedinourMooseextensionandhowthiscodecanbeimportedforanalysis. 4.1. ASPIX:ASPectsInfamiX Toperformvisualization,AspectMapsdoesnotconsidertheactualsourcecodeoftheprogram,butinsteadusesitsown model,asdotheothertoolsofMoose.ThismodelisaninstanceoftheASPIXmeta-model,amemberoftheFAMIXmeta- modelfamily[9,12,28],whichwecreatedsuchthatMooseisabletoworkwithAOPcode.ASPIX(ASPectsInfamiX)consists ofagenericclass-basedobject-orientedmeta-modelenrichedwithinformationofaspects,pointcuts,advice,adviceordering andshadowpoints.AnalogouslytoFAMIX,theideaistohavelanguage-specificimportersthatgeneratemodelinstances. Thesecanobtaintherequiredinformationfromthesourcecode.AspectMapscurrentlyonlyhasoneimporterforabase andaspectlanguagecombination:JavaandAspectJ.InthissectionwefirstgiveanoverviewofFAMIX,beforewedetail ouraspect-orientedextensionASPIX.Thenextsectiondetailshowinstancesofthemodelarebuiltbasedonthedatamade availablebytheimporter. ThecoreofFAMIXisalanguageindependentmeta-modelthatdescribesthestaticstructureofobject-orientedsoftware systems.TheFAMIXcorecandescribethestructureofobject-orientedsystemsfromthenamespaceleveldowntovariable accesses and method invocations. Fig. 11 shows relevant parts of FAMIX core (in gray) that are directly involved in AspectMaps.Namespaceistheentitywiththehighestgranularity:itisusedtorepresentJavapackagesinthecaseofJava systems.Typeisthemeta-descriptionforentitiescontainingmethodsinFAMIX(asindicatedbyitsmethodsattribute)and ClassisaspecializationofType.BehaviouralEntityisagenericmeta-descriptionforbehaviors,suchasitsspecialization Method.ItcancontainoutgoingInvocations(forexample,methodcalls)whichthemselvesaredescribedbyInvocation. ASPIXextendstheFAMIXcorewithmeta-descriptionsspecifictothestructureofanaspect-orientedsystem.Fig.11 shows(inblack)themeta-descriptions,attributes,andinheritancerelationshipswhichconstituteASPIXasanextensionto FAMIX.Hence,AspectisaspecializationofTypeandcontainsnamedPointcutsandadvices.AnAdvicehasakind(before, after,oraround),aprecedenceOverrelationshiptoindicateprecedenceoftheadviceoverotheradvices,andarelationto itspointcut(whichcanbeanamedpointcutoftheaspectoritsownanonymouspointcut).Pointcutholdsabooleanflag indicatingwhetherevaluatingitrequiresaruntimetest.ItalsopointstojoinpointShadowscapturedbythispointcut.The meta-descriptionJoinPointShadowholdstheoppositerelationinitsmatchingPointcutsattribute.Inthecurrentversionof ASPIX,twokindsofjoinpointshadowsaredescribed:ExecutionJoinPointwhichlinkstoamethodandCallJoinPointwhich J.Fabryetal./ScienceofComputerProgramming79(2014)6–22 15 Pointcut Namespace Type body: String classes methods hasRuntimeTest: Boolean aspects joinpointShadows Class Aspect BehaviouralEntity namedPointcuts outgoingInvocations advices sourceRange: Interval ExecutionJoinPoint Method Advice kind: String method joinpointShadow JoinPointShadow pointcut baseLineNumber: Integer precedenceOver matchingPointcuts CallJoinPoint Invocation baseCallString: String joinpointShadow expression Fig.11.ClassdiagramoftheASPIXmeta-model,withrelevantpartsoftheFAMIXcoremeta-modelshowningray. linkstoanexpression(aninstanceofInvocation).NotethatbothMethodandInvocationareextendedbyASPIXtolinkback totheirrespectivejoinpointShadow,whileNamespaceprovidesalinktoitscontainedaspects. 4.2. ConstructinganASPIXmodel ASPIXmodelsforJavaandAspectJcodearecreatedusingatwo-stepprocessasoutlinedinSection3.2.FirsttheJavaand AspectJcodeareanalyzedandtherelevantdataisexportedtoanexchangeformat:an.msefileforJavaandan.xcrfilefor AspectJ.SecondtheASPIXmodeliscreatedbasedonjoiningtheinformationinthesetwofiles.Therationaleforthistwo- stepprocessusingexchangeformatsistwofold.Ontheonehandwemaintainaloosecouplingbetweenthedifferentparts oftheloadingoperation.Ontheotherhand,intheimplementationweareabletoreuseasmuchexistinginfrastructureas possible. Theformerisimportantasitallowsforlanguageindependenceoftheimportprocessbyusingstandardizedinterchange formats.ToallowMoosetoworkwithdifferentbaseandaspectlanguagecombinations,e.g.,toletAspectMapstovisualize these,itsimplysufficestobeabletoexportthiscodetoacombinationof.mseand.xcrfile. ToclarifythecreationofboththesefilesandhowthesearejoinedtoformanASPIXmodel,wenowdiscussbothsteps oftheprocessinmoredetail. 4.2.1. ExportingJavaandAspectJcodeto.mseand.xcrfiles WehavechosentousethestandardMoose.mseexchangeformat[20]toimportJavacodeintoMoose,yieldingFAMIX modelinstances.ThisasitallowsustoreuseexistingJavato.mseexporttools,aswellasthestandardMoosefileimport feature.AssaidinSection3.2,whenloadinginsoftwaretobevisualizedtheAspectMapstoolcanautomaticallygeneratea .msefileusingtheinFusiontoolandanalternativewaytogeneratethemistouseVerveineJ. To the best of our knowledge, there is however no tool that takes AspectJ code and provides structural information ofaspectsandjoinpointshadowinformation.Neitherareweawareofanystandardfileformatforthisinformation.We thereforebuiltourownexporttoolanddefinedastraightforwardfileformat.AsmentionedinSection3.2,thetoolwe builtisanEclipseplugin,calledXCutReport.Whenactive,itusesAJDT[7]toproducean.xcrfilewheneverAspectJcodeis compiled.XCutReporthooksintoAJDTtoreceiveanotificationwhenevercompilationendssuccessfully.Thisnotification includesacompletestructuralmodeloftheprogramthatwascompiled.Thepluginthentraversesthisstructuralmodel, writingtherelevantdatatothecorresponding.xcrfile. Thestructureofan.xcrfileisaself-describinglistoftuples,whereeachtupleistab-delimitedandseparatedfromthe nexttuplebyanewline.Tuplesaregroupedaccordingtothenatureoftheelementtheydescribeandgroupsareseparated byanemptyline.Thefirsttwolinesofatuplegroupdescribethegroupasfollows:atitlelinedescribesthenatureofthe groupandadescriptionlinestatesthestructureofthetuples,i.e.,thesemanticsofeachfield.Thisfileformatwaschosen becauseitisstraightforwardtoparsewhenimporting,andmoreoveritcanbeeasilyreadwhenopenedbyaspreadsheet application(byimportingastab-separatedtext). Forexample,inFig.12weshowpartofthetuplegroupofjoinpointshadowsoftheSpacewarexample(witheachtuple wrappedtofitthesizeofthepage).Theexampleshowsthatforjoinpointshadows,tuplescontainthenameofandline numberintheadvisedclass,thetypeofjoinpoint,thenameoftheaspectandlinenumberoftheadvice,aswellaswhether theshadowpointhasruntimetests.Forcalljoinpoints,thesignatureofthecallaswellasthesourcecodeincludingthecall (Callsourcecode)arealsoreported.

Description:
c RMoD Team, INRIA Lille - Nord Europe, France3 Article history: 1. Introduction. Aspect-oriented programming [18] is a novel programming limited to a weaver (e.g., for Netbeans [2], IntelliJ [3] and JBuilder [1]) and a view
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.