SlideShare una empresa de Scribd logo
1 de 48
Pointcuts and Analysis Oege de Moor, Oxford on behalf of the  abc  team: Pavel Avgustinov, Eric Bodden, Torbj ő rn Ekman,  Elnar Hajiyev, Laurie Hendren, Ond ř ej Lhot á k,  Oege de Moor, Neil Ongkingco, Damien Sereni,  Ganesh Sittampalam, Julian Tibble
Swing thread safety (Ramnivas Laddad) Once a component is visible only the event-dispatching thread  can safely access or modify  the state of the realized component. (but some methods are exempt)
Doing it by hand… interface  Runnable { void  run(); } asynchronous invocation: EventQueue.invokeLater(Runnable run) synchronous invocation: EventQueue.invokeAndWait(Runnable run)
With an aspect… void   around () :  routedMethods() &&  voidReturnValueCalls() &&  !uiSyncMethodCalls()  { Runnable worker =  new  Runnable() { public   void  run() { proceed (); }}; EventQueue.invokeLater(worker); } only once instead of scattered over Swing client program
Some of the pointcuts ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Nice example of aspects: ,[object Object],[object Object],[object Object]
QUIZ: pointcuts are intuitive? Given types with fully qualified names a.b.c.SomeType a.b.c.SomeType.ANestedType ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],(first prize: free copy of abc; second prize: free copy of ajc)
Rules for matching type patterns ,[object Object],[object Object],Adrian Colyer : Bug 141133.
This talk ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],POPL 2007 speculative
Semantics of static pointcuts Walker  et al. :  -  formalise shadow matching via explicit labels - operational semantics for explicit labels
From static pointcuts to label sets (0) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],aspect  A { pointcut  a ( int  n) :  call (* f*(..))  &&  args (n) &&  cflowbelow ( execution (* f3(..))); before ( int  n) : a(n) { System.out.println( thisJoinPoint  + ": n="+n); } }
From static pointcuts to label sets (1) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],aspect  A { pointcut  a ( int  n) :  label (L3,L5,L8,L9)  // call (* f*(..))   &&  args (n) &&  cflowbelow ( label (L4)  // execution (* f3(..)) ); before ( int  n) : a(n) { System.out.println( thisJoinPoint  + ": n="+n); } }
Pointcuts are queries (0) ,[object Object],[object Object],[object Object],[object Object],(Naïve) query for  pointcut “ call (* f*(..))”  : p( S )  Ã   9   M  :  method ,  N  :  string  . callShadow( S ,  M , _), methodDecl( M ,  N , _, _, _), regexpmatch(’f.*’,  N ).
Pointcuts are queries (1) ,[object Object],[object Object],[object Object],[object Object],(Naïve) query for  pointcut “ execution (* f3(..))”  : p( S )  Ã   9   M  :  method ,  N  :  string  . executionShadow( S ,  M ), methodDecl( M ,  N , _, _, _), regexpmatch(’f3’,  N ).
Overview of semantics ,[object Object],[object Object],[object Object],[object Object]
Query language: Datalog ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Powered by Tarski (1902-1983) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Datalog has two kinds of relations ,[object Object],[object Object]
Example rule hasSubtype*( T  :  type ,  T  :  type ) . hasSubtype*( T  :  type ,  S  :  type )  Ã 9   U  :  type  .  hasSubtype( T ,  U ), hasSubtype*( U ,  S ) . hasSubtype is primitive (= stored in database)
Mapping pointcuts to queries ,[object Object],[object Object],[object Object],[object Object]
Example: call  versus  execution class  A {  void  m() {} } class  B  extends  A {} class  C  extends  B {  void  m() {} } pointcut  c() :  call (* B.m(..)); pointcut  e() :  execution (* B.m(..)); (new A()).m(); (new B()).m(); (new C()).m(); QUIZ 2: Where does c() match? Where does e() match?
Query for  c() :  call (* B.m(..)) c( Context  :  type ,  Shadow  :  shadow )   9   M  :  method ,  Recv  :  type ,  N  :  method   . matchpat( Context ,  M ,  Recv ) , overrides( N ,  M ) , callShadow( Shadow ,  N ,  Recv )  . reflexive relation overrides(N,M)
Matching method patterns matchpat( Context  :  type ,  M  :  method ,  Recv  :  type )   T  :  type ,  MD  :  type  . simpleTypeLookup( Context ,  ‘B’  ,  T ), hasSubtype*( T ,  Recv ), methodDecl( M , ‘ m ’ , _,  MD , _), ( ( hasStrModifier( M ,  ‘static ’),  MD = T  ) ; (  not (hasStrModifier( M ,  ‘static’  )),  hasSubtype*( MD ,  T ) ) )  .
Query for  e() :  execution (* B.m(..)) e( Context   :  type ,  Shadow  :  shadow )      M  :  method ,  Recv  :  type ,  N  :  method  . matchpat( Context ,  M ,  Recv ), overrides( N ,  M ), hasChild( Recv ,  N ),  executionShadow( Shadow , N )  . difference with call
Semantics of static AspectJ pointcuts All static pointcuts covered Only 90 rewrite rules Concrete syntax implementation with Stratego
Flavour of rewrite rules (0) aj2dl (pc1 && pc2,  C ,  S )     aj2dl (pc1, C , S ),  aj2dl (pc2, C , S )  aj2dl (pc1 || pc2, C , S )    aj2dl (pc1, C , S )  ;  aj2dl (pc2, C , S ) aj2dl (not(pc), C , S )    not ( aj2dl (pc, C , S ))
Flavour of rewrite rules (1) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],this is as complex as it gets
Implementation AspectJ program relational database (M$ SQL Server) pointcuts Datalog  program Shadow Grab (modified abc) Strip from source Stratego rewrites Matched shadows Procedural SQL CodeQuest compiler primitives
It works! 2.81 43.50 14.93 32.25 101 jigsaw 2.84 26.58 9.94 19.89 51 reweave 4.94 12.15 7.73 5.05 21 jhotdraw 4.09 9.15 7.79 5.49 10 weka Ratio = (PI + AQ + AJC) / AJC Aggregate Query (AQ) Populate + index (PI) ajc ksloc project
Should all AspectJ users learn Datalog? NO But power users will learn it…
Conclusions of pointcut semantics ,[object Object],[object Object],[object Object]
Beyond AspectJ
No calls to UI methods from beans declare error  : call (* java.awt..*.*(..)) &&  within (Bean+) : “ do not call GUI methods from Bean” only catches direct calls
Catching all errors maycall+( M  :  method ,  N  :  method )  Ã maycall( M , N ) ; 9   K  :  method  . maycall( M , K ), maycall+( K , N ). declare warning   at   M  : 9   T  :  type  . bean( T ), methodDecl( M ,_,_, T ,_,_), 9   N  :  method  . maycall+( M , N ), guiMethod( N ): “ may be calling a GUI method from this method”
Other applications ,[object Object],[object Object],[object Object],BUT: we are limited by the joinpoint model of AspectJ
Everything is a joinpoint
The 11 joinpoint kinds of AspectJ ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Why are these the right choice?
Joinpoints = Jimple instructions int  foo(int x, int y) { if  (x<y)    return  (y-x); else   return  (x-y); } int  foo( int ,  int ) {   Example this; int x, y, $i0, $i1; this := @this:Example; x := @parameter0: int; y := @parameter1: int; if  x >= y  goto  label0; $i0 = y - x; return  $i0; label0: $i1 = x - y; return  $i1; } Java: Jimple: Jimple: a typed, 3-address, stack-less representation of bytecode
Advantages of Joinpoints = Jimple ,[object Object],[object Object],[object Object],[object Object]
Disadvantage of Jimple = Joinpoints complete loss of encapsulation AspectJ does not have encapsulation, but now the problem is even worse…
Aspect Interfaces ,[object Object],[object Object]
Open modules aspects aspects aspects aspects classes Open module: specifies what can be advised by which aspect
An example open module module  FigureModule { class  Point,Figure; advertise  : call(Figure Figure.translate(int,int)); expose to   MoveTrackAspect : call (* Point.translate(int,int)) &&  within (Figure); } classes that are affected only external calls are advised MoveTrackAspect may advise the specified joinpoints
Opening modules for debugging module  Debug { open  FigureModule; expose to  debug.* :  call (* *.*(..)); } another form of module inclusion  constrains  included module
Datalog for semantics-based control expose to  <aspect-query> : <event-query> Current abc: aspect-query =  classname pattern expression event-query =  pointcut Using datalog queries, can express: pureaspect(A)  =  A’s only side effect is writing to System.err then expose to  pureaspect(A) : call(* mysys..*(..))
Hiding non-AspectJ shadows (0) ,[object Object],[object Object],[object Object],[object Object],[object Object]
Hiding non-AspectJ joinpoints (1) module  AspectJVisibility { constrain  existingModule; expose (S)  aspectjShadows(S) ; } only expose AspectJ joinpoints from an existing module:
Discussion points ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

Más contenido relacionado

La actualidad más candente

Pj01 4-operators and control flow
Pj01 4-operators and control flowPj01 4-operators and control flow
Pj01 4-operators and control flowSasidharaRaoMarrapu
 
C Recursion, Pointers, Dynamic memory management
C Recursion, Pointers, Dynamic memory managementC Recursion, Pointers, Dynamic memory management
C Recursion, Pointers, Dynamic memory managementSreedhar Chowdam
 
C Programming Storage classes, Recursion
C Programming Storage classes, RecursionC Programming Storage classes, Recursion
C Programming Storage classes, RecursionSreedhar Chowdam
 
11. Java Objects and classes
11. Java  Objects and classes11. Java  Objects and classes
11. Java Objects and classesIntro C# Book
 
05. Java Loops Methods and Classes
05. Java Loops Methods and Classes05. Java Loops Methods and Classes
05. Java Loops Methods and ClassesIntro C# Book
 
Collection frame work
Collection  frame workCollection  frame work
Collection frame workRahul Kolluri
 
19. Data Structures and Algorithm Complexity
19. Data Structures and Algorithm Complexity19. Data Structures and Algorithm Complexity
19. Data Structures and Algorithm ComplexityIntro C# Book
 
C aptitude.2doc
C aptitude.2docC aptitude.2doc
C aptitude.2docSrikanth
 
Functional Programming You Already Know
Functional Programming You Already KnowFunctional Programming You Already Know
Functional Programming You Already KnowKevlin Henney
 
20.1 Java working with abstraction
20.1 Java working with abstraction20.1 Java working with abstraction
20.1 Java working with abstractionIntro C# Book
 
Programming For Problem Solving Lecture Notes
Programming For Problem Solving Lecture NotesProgramming For Problem Solving Lecture Notes
Programming For Problem Solving Lecture NotesSreedhar Chowdam
 

La actualidad más candente (20)

Pj01 4-operators and control flow
Pj01 4-operators and control flowPj01 4-operators and control flow
Pj01 4-operators and control flow
 
C Recursion, Pointers, Dynamic memory management
C Recursion, Pointers, Dynamic memory managementC Recursion, Pointers, Dynamic memory management
C Recursion, Pointers, Dynamic memory management
 
C Programming Storage classes, Recursion
C Programming Storage classes, RecursionC Programming Storage classes, Recursion
C Programming Storage classes, Recursion
 
11. Java Objects and classes
11. Java  Objects and classes11. Java  Objects and classes
11. Java Objects and classes
 
05. Java Loops Methods and Classes
05. Java Loops Methods and Classes05. Java Loops Methods and Classes
05. Java Loops Methods and Classes
 
Oop objects_classes
Oop objects_classesOop objects_classes
Oop objects_classes
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
07. Arrays
07. Arrays07. Arrays
07. Arrays
 
Collection frame work
Collection  frame workCollection  frame work
Collection frame work
 
Advanced JavaScript
Advanced JavaScript Advanced JavaScript
Advanced JavaScript
 
19. Data Structures and Algorithm Complexity
19. Data Structures and Algorithm Complexity19. Data Structures and Algorithm Complexity
19. Data Structures and Algorithm Complexity
 
Captitude 2doc-100627004318-phpapp01
Captitude 2doc-100627004318-phpapp01Captitude 2doc-100627004318-phpapp01
Captitude 2doc-100627004318-phpapp01
 
C aptitude.2doc
C aptitude.2docC aptitude.2doc
C aptitude.2doc
 
Functional Programming You Already Know
Functional Programming You Already KnowFunctional Programming You Already Know
Functional Programming You Already Know
 
09. Java Methods
09. Java Methods09. Java Methods
09. Java Methods
 
Unit 3
Unit 3 Unit 3
Unit 3
 
Chapter 4 - Classes in Java
Chapter 4 - Classes in JavaChapter 4 - Classes in Java
Chapter 4 - Classes in Java
 
20.1 Java working with abstraction
20.1 Java working with abstraction20.1 Java working with abstraction
20.1 Java working with abstraction
 
Programming For Problem Solving Lecture Notes
Programming For Problem Solving Lecture NotesProgramming For Problem Solving Lecture Notes
Programming For Problem Solving Lecture Notes
 
7
77
7
 

Destacado

Java : How to Program - 7e
Java : How to Program - 7eJava : How to Program - 7e
Java : How to Program - 7eCHIH-PEI WEN
 
Probability and Stochastic Processes - A Friendly Introduction for Electrical...
Probability and Stochastic Processes - A Friendly Introduction for Electrical...Probability and Stochastic Processes - A Friendly Introduction for Electrical...
Probability and Stochastic Processes - A Friendly Introduction for Electrical...CHIH-PEI WEN
 
Yes You Can Use Copyrighted Materials
Yes You Can Use Copyrighted MaterialsYes You Can Use Copyrighted Materials
Yes You Can Use Copyrighted MaterialsRenee Hobbs
 
The Future of Everything
The Future of EverythingThe Future of Everything
The Future of EverythingCharbel Zeaiter
 

Destacado (6)

Java : How to Program - 7e
Java : How to Program - 7eJava : How to Program - 7e
Java : How to Program - 7e
 
Probability and Stochastic Processes - A Friendly Introduction for Electrical...
Probability and Stochastic Processes - A Friendly Introduction for Electrical...Probability and Stochastic Processes - A Friendly Introduction for Electrical...
Probability and Stochastic Processes - A Friendly Introduction for Electrical...
 
Yes You Can Use Copyrighted Materials
Yes You Can Use Copyrighted MaterialsYes You Can Use Copyrighted Materials
Yes You Can Use Copyrighted Materials
 
Inaugural Addresses
Inaugural AddressesInaugural Addresses
Inaugural Addresses
 
SlideShare 101
SlideShare 101SlideShare 101
SlideShare 101
 
The Future of Everything
The Future of EverythingThe Future of Everything
The Future of Everything
 

Similar a Pointcuts and Analysis

Leveraging R in Big Data of Mobile Ads (R在行動廣告大數據的應用)
Leveraging R in Big Data of Mobile Ads (R在行動廣告大數據的應用)Leveraging R in Big Data of Mobile Ads (R在行動廣告大數據的應用)
Leveraging R in Big Data of Mobile Ads (R在行動廣告大數據的應用)Craig Chao
 
Best C++ Programming Homework Help
Best C++ Programming Homework HelpBest C++ Programming Homework Help
Best C++ Programming Homework HelpC++ Homework Help
 
R Programming: Learn To Manipulate Strings In R
R Programming: Learn To Manipulate Strings In RR Programming: Learn To Manipulate Strings In R
R Programming: Learn To Manipulate Strings In RRsquared Academy
 
Profiling and optimization
Profiling and optimizationProfiling and optimization
Profiling and optimizationg3_nittala
 
Scala as a Declarative Language
Scala as a Declarative LanguageScala as a Declarative Language
Scala as a Declarative Languagevsssuresh
 
Visualizing the Model Selection Process
Visualizing the Model Selection ProcessVisualizing the Model Selection Process
Visualizing the Model Selection ProcessBenjamin Bengfort
 
01 - DAA - PPT.pptx
01 - DAA - PPT.pptx01 - DAA - PPT.pptx
01 - DAA - PPT.pptxKokilaK25
 
Python High Level Functions_Ch 11.ppt
Python High Level Functions_Ch 11.pptPython High Level Functions_Ch 11.ppt
Python High Level Functions_Ch 11.pptAnishaJ7
 
Python 2.5 reference card (2009)
Python 2.5 reference card (2009)Python 2.5 reference card (2009)
Python 2.5 reference card (2009)gekiaruj
 
The Art of Java Type Patterns
The Art of Java Type PatternsThe Art of Java Type Patterns
The Art of Java Type PatternsSimon Ritter
 
Writing beautiful code with Java 8
Writing beautiful code with Java 8Writing beautiful code with Java 8
Writing beautiful code with Java 8Sergiu Mircea Indrie
 
The Effect of Hierarchical Memory on the Design of Parallel Algorithms and th...
The Effect of Hierarchical Memory on the Design of Parallel Algorithms and th...The Effect of Hierarchical Memory on the Design of Parallel Algorithms and th...
The Effect of Hierarchical Memory on the Design of Parallel Algorithms and th...David Walker
 
Java Keeps Throttling Up!
Java Keeps Throttling Up!Java Keeps Throttling Up!
Java Keeps Throttling Up!José Paumard
 
JCConf 2020 - New Java Features Released in 2020
JCConf 2020 - New Java Features Released in 2020JCConf 2020 - New Java Features Released in 2020
JCConf 2020 - New Java Features Released in 2020Joseph Kuo
 
Design Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on ExamplesDesign Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on ExamplesGanesh Samarthyam
 

Similar a Pointcuts and Analysis (20)

R Language Introduction
R Language IntroductionR Language Introduction
R Language Introduction
 
Leveraging R in Big Data of Mobile Ads (R在行動廣告大數據的應用)
Leveraging R in Big Data of Mobile Ads (R在行動廣告大數據的應用)Leveraging R in Big Data of Mobile Ads (R在行動廣告大數據的應用)
Leveraging R in Big Data of Mobile Ads (R在行動廣告大數據的應用)
 
Best C++ Programming Homework Help
Best C++ Programming Homework HelpBest C++ Programming Homework Help
Best C++ Programming Homework Help
 
New C# features
New C# featuresNew C# features
New C# features
 
R Programming: Learn To Manipulate Strings In R
R Programming: Learn To Manipulate Strings In RR Programming: Learn To Manipulate Strings In R
R Programming: Learn To Manipulate Strings In R
 
Profiling and optimization
Profiling and optimizationProfiling and optimization
Profiling and optimization
 
Scala as a Declarative Language
Scala as a Declarative LanguageScala as a Declarative Language
Scala as a Declarative Language
 
numdoc
numdocnumdoc
numdoc
 
Visualizing the Model Selection Process
Visualizing the Model Selection ProcessVisualizing the Model Selection Process
Visualizing the Model Selection Process
 
01 - DAA - PPT.pptx
01 - DAA - PPT.pptx01 - DAA - PPT.pptx
01 - DAA - PPT.pptx
 
Python High Level Functions_Ch 11.ppt
Python High Level Functions_Ch 11.pptPython High Level Functions_Ch 11.ppt
Python High Level Functions_Ch 11.ppt
 
Python 2.5 reference card (2009)
Python 2.5 reference card (2009)Python 2.5 reference card (2009)
Python 2.5 reference card (2009)
 
The Art of Java Type Patterns
The Art of Java Type PatternsThe Art of Java Type Patterns
The Art of Java Type Patterns
 
Writing beautiful code with Java 8
Writing beautiful code with Java 8Writing beautiful code with Java 8
Writing beautiful code with Java 8
 
06slide.ppt
06slide.ppt06slide.ppt
06slide.ppt
 
The Effect of Hierarchical Memory on the Design of Parallel Algorithms and th...
The Effect of Hierarchical Memory on the Design of Parallel Algorithms and th...The Effect of Hierarchical Memory on the Design of Parallel Algorithms and th...
The Effect of Hierarchical Memory on the Design of Parallel Algorithms and th...
 
Java Keeps Throttling Up!
Java Keeps Throttling Up!Java Keeps Throttling Up!
Java Keeps Throttling Up!
 
JCConf 2020 - New Java Features Released in 2020
JCConf 2020 - New Java Features Released in 2020JCConf 2020 - New Java Features Released in 2020
JCConf 2020 - New Java Features Released in 2020
 
Design Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on ExamplesDesign Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on Examples
 
Jeop game-final-review
Jeop game-final-reviewJeop game-final-review
Jeop game-final-review
 

Último

A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 

Último (20)

A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 

Pointcuts and Analysis

  • 1. Pointcuts and Analysis Oege de Moor, Oxford on behalf of the abc team: Pavel Avgustinov, Eric Bodden, Torbj ő rn Ekman, Elnar Hajiyev, Laurie Hendren, Ond ř ej Lhot á k, Oege de Moor, Neil Ongkingco, Damien Sereni, Ganesh Sittampalam, Julian Tibble
  • 2. Swing thread safety (Ramnivas Laddad) Once a component is visible only the event-dispatching thread can safely access or modify the state of the realized component. (but some methods are exempt)
  • 3. Doing it by hand… interface Runnable { void run(); } asynchronous invocation: EventQueue.invokeLater(Runnable run) synchronous invocation: EventQueue.invokeAndWait(Runnable run)
  • 4. With an aspect… void around () : routedMethods() && voidReturnValueCalls() && !uiSyncMethodCalls() { Runnable worker = new Runnable() { public void run() { proceed (); }}; EventQueue.invokeLater(worker); } only once instead of scattered over Swing client program
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10. Semantics of static pointcuts Walker et al. : - formalise shadow matching via explicit labels - operational semantics for explicit labels
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19. Example rule hasSubtype*( T : type , T : type ) . hasSubtype*( T : type , S : type ) Ã 9 U : type . hasSubtype( T , U ), hasSubtype*( U , S ) . hasSubtype is primitive (= stored in database)
  • 20.
  • 21. Example: call versus execution class A { void m() {} } class B extends A {} class C extends B { void m() {} } pointcut c() : call (* B.m(..)); pointcut e() : execution (* B.m(..)); (new A()).m(); (new B()).m(); (new C()).m(); QUIZ 2: Where does c() match? Where does e() match?
  • 22. Query for c() : call (* B.m(..)) c( Context : type , Shadow : shadow )  9 M : method , Recv : type , N : method . matchpat( Context , M , Recv ) , overrides( N , M ) , callShadow( Shadow , N , Recv ) . reflexive relation overrides(N,M)
  • 23. Matching method patterns matchpat( Context : type , M : method , Recv : type )   T : type , MD : type . simpleTypeLookup( Context , ‘B’ , T ), hasSubtype*( T , Recv ), methodDecl( M , ‘ m ’ , _, MD , _), ( ( hasStrModifier( M , ‘static ’), MD = T ) ; ( not (hasStrModifier( M , ‘static’ )), hasSubtype*( MD , T ) ) ) .
  • 24. Query for e() : execution (* B.m(..)) e( Context : type , Shadow : shadow )   M : method , Recv : type , N : method . matchpat( Context , M , Recv ), overrides( N , M ), hasChild( Recv , N ), executionShadow( Shadow , N ) . difference with call
  • 25. Semantics of static AspectJ pointcuts All static pointcuts covered Only 90 rewrite rules Concrete syntax implementation with Stratego
  • 26. Flavour of rewrite rules (0) aj2dl (pc1 && pc2, C , S )  aj2dl (pc1, C , S ), aj2dl (pc2, C , S ) aj2dl (pc1 || pc2, C , S )  aj2dl (pc1, C , S ) ; aj2dl (pc2, C , S ) aj2dl (not(pc), C , S )  not ( aj2dl (pc, C , S ))
  • 27.
  • 28. Implementation AspectJ program relational database (M$ SQL Server) pointcuts Datalog program Shadow Grab (modified abc) Strip from source Stratego rewrites Matched shadows Procedural SQL CodeQuest compiler primitives
  • 29. It works! 2.81 43.50 14.93 32.25 101 jigsaw 2.84 26.58 9.94 19.89 51 reweave 4.94 12.15 7.73 5.05 21 jhotdraw 4.09 9.15 7.79 5.49 10 weka Ratio = (PI + AQ + AJC) / AJC Aggregate Query (AQ) Populate + index (PI) ajc ksloc project
  • 30. Should all AspectJ users learn Datalog? NO But power users will learn it…
  • 31.
  • 33. No calls to UI methods from beans declare error : call (* java.awt..*.*(..)) && within (Bean+) : “ do not call GUI methods from Bean” only catches direct calls
  • 34. Catching all errors maycall+( M : method , N : method ) Ã maycall( M , N ) ; 9 K : method . maycall( M , K ), maycall+( K , N ). declare warning at M : 9 T : type . bean( T ), methodDecl( M ,_,_, T ,_,_), 9 N : method . maycall+( M , N ), guiMethod( N ): “ may be calling a GUI method from this method”
  • 35.
  • 36. Everything is a joinpoint
  • 37.
  • 38. Joinpoints = Jimple instructions int foo(int x, int y) { if (x<y) return (y-x); else return (x-y); } int foo( int , int ) { Example this; int x, y, $i0, $i1; this := @this:Example; x := @parameter0: int; y := @parameter1: int; if x >= y goto label0; $i0 = y - x; return $i0; label0: $i1 = x - y; return $i1; } Java: Jimple: Jimple: a typed, 3-address, stack-less representation of bytecode
  • 39.
  • 40. Disadvantage of Jimple = Joinpoints complete loss of encapsulation AspectJ does not have encapsulation, but now the problem is even worse…
  • 41.
  • 42. Open modules aspects aspects aspects aspects classes Open module: specifies what can be advised by which aspect
  • 43. An example open module module FigureModule { class Point,Figure; advertise : call(Figure Figure.translate(int,int)); expose to MoveTrackAspect : call (* Point.translate(int,int)) && within (Figure); } classes that are affected only external calls are advised MoveTrackAspect may advise the specified joinpoints
  • 44. Opening modules for debugging module Debug { open FigureModule; expose to debug.* : call (* *.*(..)); } another form of module inclusion constrains included module
  • 45. Datalog for semantics-based control expose to <aspect-query> : <event-query> Current abc: aspect-query = classname pattern expression event-query = pointcut Using datalog queries, can express: pureaspect(A) = A’s only side effect is writing to System.err then expose to pureaspect(A) : call(* mysys..*(..))
  • 46.
  • 47. Hiding non-AspectJ joinpoints (1) module AspectJVisibility { constrain existingModule; expose (S) aspectjShadows(S) ; } only expose AspectJ joinpoints from an existing module:
  • 48.