Bug 41952 - XLint warning for call PCD's using subtype of defining type
Summary: XLint warning for call PCD's using subtype of defining type
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.1.0   Edit
Hardware: PC Windows NT
: P3 enhancement (vote)
Target Milestone: 1.2   Edit
Assignee: Jim Hugunin CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 49371 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-08-26 05:38 EDT by Wes Isberg CLA
Modified: 2012-04-03 16:18 EDT (History)
2 users (show)

See Also:


Attachments
adds requested XLint warning (8.09 KB, patch)
2003-08-26 05:45 EDT, Wes Isberg CLA
aclement: iplog+
Details | Diff
minimal test case for the patch, to install in tests/bugs (1.83 KB, text/plain)
2003-08-26 05:46 EDT, Wes Isberg CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Wes Isberg CLA 2003-08-26 05:38:20 EDT
Some would like an XLint compiler warning when the user in a call PCD specifies
a declaring type that is not the defining type, because that constrains the join
points to those whose bytecode signature contain the specified type as the
declaring type.  e.g., 

----
class A { void run() {} }
class B extends A {}
aspect C {
    before() : call(void B.run()) { } // warn here
}
public class Main {
    public static void main(String[] args) {
        // ok with -1.4; otherwise, becomes A.run in bytecode
        new B().run();        
        // never works - compile-time type of reference is A, not B
        ((A) new B()).run();
}
----
This warning is useful for two reasons.  First, the user probably intended that
any call to an instance of that object be picked out (regardless of the
compile-time type of the reference used to make the call), and thus should use

   target(B) && call(void run())

(This suggestion could be in the XLint message.)

Second, older compilers (i.e., compilers not using -1.4) would incorrectly
specify the declaring type of the method call as the first type in the hierarchy
which defined the method, so even if the user meant to constrain the join point
by the compile-time reference type, the bytecode signature could be incorrect
and the pointcut fail to pick out the join point.

One problem with this XLint warning is that is also picks out valid declare
warning/error statements enforcing requirements at compile-time about the type
of the reference used to invoke a method (e.g., when using a static reference of
the wrong type).  So perhaps the default level should be ignore.

See also bug 41888.
Comment 1 Wes Isberg CLA 2003-08-26 05:45:12 EDT
Created attachment 5851 [details]
adds requested XLint warning

This works but seem expensive and like there are probably utilities elsewhere
to do this kind of matching (the signature matches are not quite right).
Comment 2 Wes Isberg CLA 2003-08-26 05:46:39 EDT
Created attachment 5852 [details]
minimal test case for the patch, to install in tests/bugs
Comment 3 Jim Hugunin CLA 2004-01-07 04:32:38 EST
*** Bug 49371 has been marked as a duplicate of this bug. ***
Comment 4 Matthew Webster CLA 2004-01-07 12:05:41 EST
fixed in tree based on patch from George Harley and Matthew Webster
Comment 5 Jim Hugunin CLA 2004-01-07 12:07:28 EST
see previous comment