Bug 263310 - [handles] Initializer handle counts are not properly computed
Summary: [handles] Initializer handle counts are not properly computed
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Build (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-02 17:34 EST by Andrew Eisenberg CLA
Modified: 2013-06-24 11:01 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Eisenberg CLA 2009-02-02 17:34:38 EST
The handles for initializers should contain a count that is computed based on the type it is declared in, not the compilation unit.

Eg- The initializer of InnerInterAspect should be:

pacakge p;
public aspect HandleTestingAspect {
	static class InnerClass {
		{  }
		static aspect InnerInnerAspect {
			static { }
		}
	}
}

=Handle Testing/src<p{HandleTestingAspect.aj}HandleTestingAspect[InnerClass}InnerInnerAspect|1
but Aspectj has it as

=Handle Testing/src<p{HandleTestingAspect.aj}HandleTestingAspect[InnerClass}InnerInnerAspect|4

(I don't know why the count is 4.  Maybe it is including some default initializers as well).
Comment 1 Andrew Clement CLA 2009-02-04 16:32:12 EST
i cant recreate this, it is coming out as |1 for me for the code on this line:

package p;
public aspect HandleTestingAspect {
        static class InnerClass {
                {  }
                static aspect InnerInnerAspect {
                        static { } // <<<<<<<<<<<<<<<<<
                }
        }
}

Dont believe I fixed it with what I just changed...
Comment 2 Andrew Eisenberg CLA 2009-02-04 17:00:12 EST
(In reply to comment #1)
> 
> Dont believe I fixed it with what I just changed...
> 
I'll wait for the next drop of AspectJ into AJDT and see if it is now working.
Comment 3 Andrew Clement CLA 2009-02-06 11:33:25 EST
with a new aj in, is this failing for you?
Comment 4 Andrew Eisenberg CLA 2009-02-06 11:49:05 EST
This is working 85% right now.  I think the remaining part may be an AJDT problem.

The handles are getting created properly.  Gutter markers and navigation are working properly.

The only thing not working is that the xref view seems not to refresh properly all the time.  When moving cursor up and down sometimes the wrong around advice is being created.

I will open an AJDT bug for that.  You can close this bug.  Thanks.
Comment 5 Andrew Eisenberg CLA 2009-02-06 11:55:50 EST
(In reply to comment #4)
Oops...meant to put this comment on bug 263668.

I am still seeing initializers with the wrong count on it.
Comment 6 Andrew Eisenberg CLA 2009-02-06 11:59:52 EST
Here is the full code of the case I am using. Maybe the problem has something to do with the full code.

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

package p;

import java.util.ArrayList;

public aspect HandleTestingAspect {
	
	static class InnerClass {
		int x;
		{  }
		
		static aspect InnerInnerAspect {
			int x;
			static { }
		}
		
		public void doNothing() {}
	}
	
	before() : call(* *.doNothing()) {
		
	}
	
	before(int x, long y) : execution(* *.foo(int,long)) && args(x,y) {
		InnerClass u = new InnerClass() {
			public void doNothing() { 
				doNothing();
			}
		};
		u.doNothing();
	}
	
	interface X { }
	
	
	public void doNothing() {}
	
	// testing ITDs
	int X.X = 6;
    int X.itd() { }
    X.new() { }
    int X.itd(int x) { }
    X.new(int x) { }
	
	
	declare parents : HandleTestingClass extends InnerClass;
	declare parents : HandleTestingClass implements X;
	declare soft : Exception : execution(void HandleTestingClass.foo1(int,long));
	declare error : call(void HandleTestingClass.foo1(int,long)) : "";
	declare warning : call(void HandleTestingClass.foo2(int,long)) : "";
	
	pointcut ypc(int y) : call(* *.yCall(int)) && args(y);
	pointcut zpc(int z) : call(* *.zCall(int)) && args(z);
	
	// should not have a count
	before(int y) : ypc(y) { }
	after(int y) : ypc(y) { }
	after(int y) throwing(Exception e) : ypc(y) { }
	after(int y) returning(int z) : ypc(y) { }
    int around(int y) : ypc(y) { return 1; }
	
	// should have a count
	before(int y) : zpc(y) { }
	after(int y) : zpc(y) { }
	after(int y) throwing(Exception e) : zpc(y) { }
	after(int y) returning(int z) : zpc(y) { }
    int around(int y) : ypc(y) { return 1; }

    // should have a count of 3
    Object around(int y) : ypc(y) { return null; }

    
    after() returning(java.util.List z) : call(* *.zCall(int)) { }
}
Comment 7 Andrew Clement CLA 2009-02-06 18:00:09 EST
hmm, might be nice to have a code sample that compiled......

I added the missing HandleTestingClass, I removed the ITDs that dont work (lines 39-42), I then compiled and asked for the handle for line 13:

<p{HandleTestingAspect.java}HandleTestingAspect[InnerClass}InnerInnerAspect|1

still seems fine to me.

Were you getting wrong handles when the code is invalid? ie. with those ITDs in?

Which testcase in AJDT can I run to investigate/see the failure?
Comment 8 Andrew Eisenberg CLA 2009-02-06 19:42:41 EST
Run the AJModelTest4 test.  The test case purposely has some broken code in the sample project, but the class I sent you should compile properly.
Comment 9 Andrew Clement CLA 2009-02-06 20:33:20 EST
In the code attached in comment 6:

    int X.itd() { }
    X.new() { }
    int X.itd(int x) { }
    X.new(int x) { }

you can't itd ctors onto an interface.  two of them don't return the value they are defined to.

But I'll try running the test program you suggest.
Comment 10 Andrew Clement CLA 2010-04-05 18:53:35 EDT
I finally got round to running the AJModelTest4.  It passes - and I can't see anything to uncomment that might get it to fail in such a way as there is something to debug with respect to handle counters.  If this is still a problem, can you give me some code that compiles cleanly and yet shows the problem?
Comment 11 Andrew Clement CLA 2013-06-24 11:01:45 EDT
unsetting the target field which is currently set for something already released