4. public class AdminController {
public void handleCreateUser() {
if(getLoggedInUser() == null || !getLoggedInUser().isAdmin())
throw new AccessViolationException();
// rest of code
}
public void handleRemoveUser() {
if(getLoggedInUser() == null || !getLoggedInUser().isAdmin())
throw new AccessViolationException();
// rest of code
}
}
public class ProductController {
public void handleBuyProduct() {
if(getLoggedInUser() == null)
throw new AccessViolationException();
// rest of code
}
public void handleSellProduct() {
if(getLoggedInUser() == null)
throw new AccessViolationException();
// rest of code
}
} 4
12. Rewriting based advice weaving
approaches rewrite the code public void testProductBuy() {
at potentially advised join u = User.find(“joe”);
point shadows (JPS) to before_advice();
u.login(“pass”);
invoke the advice (guarded ...
by residual dynamic checks) if (some_guard())
some_other_before_advice();
Product.buy(u, 12);
}
}
12
13. Rewriting based advice weaving
approaches rewrite the code public void testProductBuy() {
at potentially advised join u = User.find(“joe”);
point shadows (JPS) to before_advice();
u.login(“pass”);
invoke the advice (guarded ...
by residual dynamic checks) if (some_guard())
some_other_before_advice();
Product.buy(u, 12);
}
}
13
14. Rewriting based advice weaving
approaches rewrite the code public void testProductBuy() {
at potentially advised join u = User.find(“joe”);
point shadows (JPS) to before_advice();
u.login(“pass”);
invoke the advice (guarded ...
by residual dynamic checks) if (some_guard())
some_other_before_advice();
Product.buy(u, 12);
}
}
14
16. When (and how) to weave?
interpreter
compile time load time JIT
eg. ajc
Rewrites the bytecode or source code of the application at compile time
+ no scanning and rewriting overhead at runtime
no “late weaving”
requires a global scan of the program ==>
not suited for incremental development
16
17. When (and how) to weave?
interpreter
compile time load time JIT
eg. ajc ltw
Rewrites the bytecode as part of class loading
+ allows “late weaving”
scanning and rewriting overhead at runtime ==>
leads to slower applications startup
not suited for incremental development
17
18. When (and how) to weave?
interpreter
compile time load time JIT
Rewriting based weaving can impact application startup.
18
19. When (and how) to weave?
interpreter
compile time load time JIT
Nonrewriting based weaving can lead to faster startup but at the
cost of reduced execution efficiency.
It has to do advice lookup and potential execution at each join point
(note: NOT join point shadow!)
19
20. When (and how) to weave?
interpreter
compile time load time JIT
VMs face a similar tradeoff between application startup and good
steady state performance which is why they use the interpreter/JIT
combination.
20
21. When (and how) to weave?
interpreter
compile time load time JIT
We believe that having a combination of interpreter based non
rewriting weaving and JIT based rewriting weaving might balance the
startup/steady state efficiency trade off for aspectoriented programs.
21
22. When (and how) to weave?
interpreter
compile time load time JIT
In this talk, we focus on the interpreter part of the equation and present
the design, implementation and evaluation of an interpreter based non
rewriting weaver.
22