Summary: | pointcut call(MethodPattern) matches non-visible methods in parent class | ||
---|---|---|---|
Product: | [Tools] AspectJ | Reporter: | David Grainger <dgrainge> |
Component: | Compiler | Assignee: | Adrian Colyer <adrian.colyer> |
Status: | RESOLVED FIXED | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | ||
Version: | 1.2 | ||
Target Milestone: | 1.5.0 M4 | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Whiteboard: |
Description
David Grainger
2004-07-30 10:36:22 EDT
marked as target 1.2.1 Case(1) - we all agree its right :) === Case(2) is 'working as designed'. According to the new eclipse AspectJ book: For the call() pcd: "If a declared type pattern is specified, then the pointcut will only match calls made to methods that are declared in a type matched by the pattern, *or one of its super-types.*" So here we are talking about where things are *declared*, not whether the subclass is calling the superclass. Your subclass logic calls B().m() and although the m() in the subclass runs, it is declared in the superclass (the full signature for the declaration in the superclass matches your pointcut). === Case (3) is similar to case (2) but we are still thinking about it. It may be working as designed but it is unhelpful. Although you aren't overriding m() in the subclass, from the JVM spec (8.4.2): "The signature of a method consists of the name of the method and the number and types of formal parameters." It doesn't include the visibility modifier. So, if we ignore the visibility modifier then this is the same as case (2). Our AspectJ language guru, Erik Hilsdale is off back packing this week thinking through the semantic issues... more to follow ... we should take note of visibility in ResolvedMemberImpl.getJoinPointSignatures Fixed!! Given the program below, the "should match" warning does match, and the "should not match" warning does not. class A { private void foo() {} } class B extends A { protected void foo() {} } class C extends B {} class D extends C { public void foo() {} } aspect X { void bar() { D d = new D(); d.foo(); } declare warning : call(* B.foo()) : "should match"; declare warning : call(* A.foo()) : "should not match"; } Will be available in next published build on AspectJ download page. |