1 / 23

StrongRelaxAJ : integrating adaptability of RelaxAJ and expressiveness of StrongAspectJ

Early stage work. StrongRelaxAJ : integrating adaptability of RelaxAJ and expressiveness of StrongAspectJ. Tomoyuki Aotani Manabu Touyama and Hidehiko Masuhara University of Tokyo, Japan. Background: improving typ e-safety and expressiveness of around advice. AspectJ [Kiczales’01].

luann
Download Presentation

StrongRelaxAJ : integrating adaptability of RelaxAJ and expressiveness of StrongAspectJ

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Early stage work StrongRelaxAJ: integrating adaptability of RelaxAJ and expressiveness of StrongAspectJ TomoyukiAotani Manabu Touyama and Hidehiko Masuhara University of Tokyo, Japan

  2. Background: improving type-safety and expressiveness of around advice AspectJ [Kiczales’01] RelaxAJ [Masuhara’10] Safe & flexible Safe & generic generic StrongAspectJ [De Frain’08] StrongRelaxAJ flexible

  3. Background – AspectJ is less flexible:changing a JDialog to a JWindow Replace with JWindow: void showPreview(Frame mainWin){ JDialog popup= new JDialog(mainWin); JButton close=new JButton("close"); popup.getContentPane().add(close); popup.setVisible(true); } JWindow popup= new JWindow(mainWin); Wrong Component JWindow around(Frame f): call(JDialog.new(Frame))&&args(f){ new JWindow(f); } RPC Window JDialog JWindow

  4. Background – AspectJ is less flexible: JDialog cannot be replaced due to types • forall Rs. Ra <= Rs must be hold • Rs: return type of a join point shadow • Ra: return type of around advice Not satisfied! Must be a subtypeof JDialog in AspectJ Component JWindow around(Frame f): call(JDialog.new(Frame))&&args(f){ new JWindow(f); } RPC Window apply JDialog JWindow new JDialog(mainWin);

  5. Background – RelaxAJ[Masuhara’10]:accepting any type if safely used • forall Rs. Ra <= Rs is NOT required • Rs: return type of a join point shadow • Ra: return type of around advice • Instead, Ra must be a subtype of all the usage types of the returned value • receiver’s type of a method call • field’s type of a field set

  6. Background – RelaxAJ[Masuhara’10]:accepting any type if safely used Component RPC Window JWindow around(Frame f): call(JDialog.new(Frame))&&args(f){ return new JWindow(mainWin); } collect usage types of returned value JDialog JWindow RelaxAJcompiler OK! void showPreview(Frame mainWin){ JDialog popup= new JDialog(mainWin); JButton close=new JButton("close"); popup.getContentPane() .add(close); popup.setVisible(true); } check relation used as RPC used as Component

  7. Problems of RelaxAJ • Lack of expressiveness:return type of around advice must be a single class • Strange typing:signature of proceed is the same to the one of around advice • Same to AspectJ

  8. Problems of RelaxAJ • Lack of expressiveness:return type of around advice must be a single class • Strange typing:signature of proceed is the same to the one of around advice • Same to AspectJ

  9. Extended example: replacing a JDialog with a JWindow conditionally Replace with JWindow: void showPreview(Frame mainWin){ JDialog popup= new JDialog(mainWin); JButton close=new JButton("close"); popup.getContentPane().add(close); popup.setVisible(true); } JWindow popup= new JWindow(mainWin); if DECORATEis false Wrong JWindow around(Frame f): call(JDialog.new(Frame))&&args(f){ if(DECORATE) return proceed(f); else return new JWindow(f); }

  10. Extended example: replacing a JDialog with a JWindow conditionally Component Replace with JWindow: void showPreview(Frame mainWin){ JDialog popup= new JDialog(mainWin); JButton close=new JButton("close"); popup.getContentPane().add(close); popup.setVisible(true); } RPC Window JWindow popup= new JWindow(mainWin); if DECORATEis false JDialog JWindow returns JDialog not JWindow Wrong JWindow around(Frame f): call(JDialog.new(Frame))&&args(f){ if(DECORATE) return proceed(f); else return new JWindow(f); } not subtype What can be the return type?

  11. Problem 1: no suitable return typefor the advice void showPreview(Frame mainWin){ JDialog popup= new JDialog(mainWin); JButton close=new JButton("close"); popup.getContentPane().add(close); popup.setVisible(true); } • Return type T should be: • T <: RPC • T <: Window • JWindow <: T • JDialog <: T Component T around(Frame f): call(JDialog.new(Frame))&&args(f){ if(DECORATE) return proceed(f); else return new JWindow(f); } RPC Window No such type! JDialog JWindow

  12. Problems of RelaxAJ • Lack of expressiveness:return type of around advice must be a single class • Strange typing:signature of proceed is the same to the one of around advice • Same to AspectJ

  13. Extended example:making a JDialog modal Make the JDialog modaland use JWindowas a popup void showPreview(Frame mainWin){ JDialog popup= new JDialog(mainWin); JButton close=new JButton("close"); popup.getContentPane().add(clase); popup.setVisible(true); } JDialog d= new JDialog(mainWin);d.setModal(true); JWindow popup= new JWindow(mainWin); Wrong Component JWindow around(Frame f): call(JDialog.new(Frame))&&args(f){ proceed(f).setModal(true); return new JWindow(f);} RPC Window JDialog JWindow

  14. Problem 2: return types of around advice and its proceed are the same Make the JDialog modaland use JWindowas a popup void showPreview(Frame mainWin){ JDialog popup= new JDialog(mainWin); JButton close=new JButton("close"); popup.getContentPane().add(clase); popup.setVisible(true); } JDialog d= new JDialog(mainWin);d.setModal(true); JWindow popup= new JWindow(mainWin); Wrong Component JWindow around(Frame f): call(JDialog.new(Frame))&&args(f){ proceed(f).setModal(true); return new JWindow(f);} Sig. of proceed:Frame -> JWindow RPC Window But it never returns JWindow! JDialog JWindow

  15. Our solution: StrongRelaxAJ Advice in StrongRelaxAJ: • Extending RelaxAJ with • Bounded type variables:representing “some type thatcan be used as type A and B” • Explicit signature of proceed:specifying the return type ofproceed • These features are found in StrongAspectJ • StrongRelaxAJ may= StrongAspectJ + RelaxAJ <T extends A&B> Ra around() : pointcut(): Rp proceed() { ....}

  16. Type variables: representing “some type that can be used as type A and B” Replace with JWindow: void showPreview(Frame mainWin){ JDialog popup= new JDialog(mainWin); JButton close=new JButton("close"); popup.getContentPane().add(close); popup.setVisible(true); } JWindow popup= new JWindow(mainWin); if DECORATEis false Some type that be used asComponentand RPC Component <T extends Component & RPC>Taround(Frame f): call(JWindow.new(Frame))&&args(f){ if(!DECORATE) return proceed(f); else return new JWindow(f); } JDialog as T RPC Window JWindow as T JDialog JWindow

  17. Explicit signature of proceed:specifying the return type of proceed Make the JDialog modaland use JWindowas a popup void showPreview(Frame mainWin){ JDialog popup= new JDialog(mainWin); JButton close=new JButton("close"); popup.getContentPane().add(clase); popup.setVisible(true); } JDialog d= new JDialog(mainWin);d.setModal(true); JWindow popup= new JWindow(mainWin); OK! Component JWindow around(Frame f): call(JDialog.new(Frame))&&args(f) : JDialog proceed(Frame){ proceed(f).setModal(true); return new JWindow(f);} RPC Window Sig. of proceed:Frame -> JDialog JDialog JWindow

  18. Relationship between the return types of advice and proceed o=(Rs)e; ((U1)o).m1(); ((U2)o).m2(); Ra around(): match(Rs e) : Rp proceed(){ …} • Rs: ret. type of shadow • Ra: ret. type of advice • Ui: usage type of advice return

  19. Countedthe number of variables that is used as more than 2 types in Shimple (SSA) by using Soot[Vallée-Rai’99] Experiments: # of application chances in applications A few, but not none!

  20. Conclusions and future work • StrongRelaxAJ:an extension to RelaxAJ with • Bounded type variables • Explicit signature of proceed • A few chances to apply StrongRelaxAJ aspects according to the result of preliminaly experiments • Future work includes • Completing type-checking rule • Discussing type-safety formally • Mining useful examples from real applications

  21. Type-checking the return types of proceed and advice o=(Rs)e; ((U1)o).m1(); ((U2)o).m2(); Ra1 around(): match(Rs e) : Rp1 proceed(){ …} Ra2 around(): match(Rs e) : Rp2 proceed(){ …} • Ra2 <= Rp1 • Rs <= Rp1 • Ra1 <= U1 • Ra1 <= U2 Independent of order(precedence) • Ra1 <= Rp2 • Rs <= Rp2 • Ra2 <= U1 • Ra2 <= U2

  22. Background: around advice is usefulchanging Window to JWindow Replace with JWindow: void showPreview(Frame mainWin){ Window popup= new Window(mainWin); ...} JWindow popup= new JWindow(mainWin); JWindow around(Frame f): call(Window.new(Frame))&&args(f){ new JWindow(mainWin); } Component RPC Window JWindow

More Related