Bug 98290 - no "matches declare" entry in structure model for single declare warning statement
Summary: no "matches declare" entry in structure model for single declare warning stat...
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: DEVELOPMENT   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 1.5.0 M4   Edit
Assignee: Andrew Clement CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-03 10:57 EDT by Helen Beeken CLA
Modified: 2005-09-01 15:48 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Helen Beeken CLA 2005-06-03 10:57:01 EDT
A project containing one class and one aspect:

-----------------------------------------------------

package pack;

public class C {

	public static void main(String[] args) {
		new C().sayHello();
	}
	
	public void sayHello() {
		System.out.println("HELLO");
	}
}

----------------------------------------------------

package pack;

public aspect A {
		
	declare warning : 
		execution(* C.sayHello(..)) :
			"blah blah";	
		
}

-----------------------------------------------------

has the "matched by" entry for A.aj, but doesn't have the "matches declare"
entry for C.java.

This means that in AJDT, C.sayHello isn't added to our map and consequently we
don't get any relationships showing in the Cross Reference view for A.aj.
Comment 1 Andrew Clement CLA 2005-06-03 12:56:12 EDT
Do you get them for other declares? Since I know we have done some work in AJ to
support them - maybe the AJDE is out of date that is in AJDT, hmmm.
Comment 2 Andrew Clement CLA 2005-06-03 13:44:06 EDT
The related bug was bug 91090 - but that was only to do with the
staticinitialization PCD.  Worth seeing if this problem occurs if the declare
warning is all on one line rather than split across multiple lines.
Comment 3 Helen Beeken CLA 2005-06-06 05:21:48 EDT
Yes, this problem still happens when the declare statement is on one line. It
also happens with declare error.
Comment 4 Andrew Clement CLA 2005-06-06 09:12:39 EDT
Dumping out the structure model contents using the usual API call gives us this
helpful output:

=== MODEL STATUS REPORT ========= After a batch build
A.generated.lst  [build configuration file]
  pack  [package]
    A.java  [java source file]
K:\eclipse31m7\eclipse\runtime-workspace\A\A.java:1::0
      import declarations  [import reference]
      A  [aspect] K:\eclipse31m7\eclipse\runtime-workspace\A\A.java:3::31
        declare warning: "blah blah"  [declare warning]
K:\eclipse31m7\eclipse\runtime-workspace\A\A.java:5::42
    C.java  [java source file]
K:\eclipse31m7\eclipse\runtime-workspace\A\C.java:1::0
      import declarations  [import reference]
      C  [class] K:\eclipse31m7\eclipse\runtime-workspace\A\C.java:3::31
        main(String[])  [method]
K:\eclipse31m7\eclipse\runtime-workspace\A\C.java:5::58
        sayHello()  [method]
K:\eclipse31m7\eclipse\runtime-workspace\A\C.java:9::124
=== END OF MODEL REPORT =========
=== RELATIONSHIPS REPORT ========= After a batch build
Hid:1:(targets=1) K:\eclipse31m7\eclipse\runtime-workspace\A\A.java|5|0|42 (matc
hed by) K:\eclipse31m7\eclipse\runtime-workspace\A\C.java|9|0|0
Hid:2:(targets=1) K:\eclipse31m7\eclipse\runtime-workspace\A\C.java|9|0|0 (match
es declare) K:\eclipse31m7\eclipse\runtime-workspace\A\A.java|5|0|42
=== END OF RELATIONSHIPS REPORT ==
=== Properties of the model and relationships map =====
method=2
import reference=2
aspect=1
declare warning=1
class=1
RelationshipMapSize=2
build configuration file=1
FileMapSize=2
package=1
java source file=2

which says that the relationships do exist in both directions.  The problem is
with one of the endpoints.

The problem is the ASM records line 9 like this:
sayHello()  [method] K:\eclipse31m7\eclipse\runtime-workspace\A\C.java:9::124

whilst the relationship map records it with handle:

K:\eclipse31m7\eclipse\runtime-workspace\A\C.java|9|0|0

since the offsets don't match (one is 0, one is 124) then they aren't considered
equivalent.  The fix is to make sure the offset isn't lost.b
Comment 5 Adrian Colyer CLA 2005-09-01 15:48:06 EDT
offset is now correctly preserved and "matches declare" relationship created in the case that the source is 
compiled by ajc (needs our MethodDeclarationLineNumber attribute). This is of course the case for AJDT 
which is the primary client of this feature.