Bug 238431 - Problems attaching sources to entries (jars) on the aspect path
Summary: Problems attaching sources to entries (jars) on the aspect path
Status: RESOLVED FIXED
Alias: None
Product: AJDT
Classification: Tools
Component: UI (show other bugs)
Version: DEVELOPMENT   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 1.5.3   Edit
Assignee: AJDT-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-06-25 12:16 EDT by Andrew Clement CLA
Modified: 2008-07-09 11:05 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Clement CLA 2008-06-25 12:16:51 EDT
Some users are reporting problems with source attachments to entries on the aspectpath.  We need to make sure source attachments are supported just as with the regular classpath.  

Once attached there may be limited debugging support if, for example, around() advice from aspects on that path are applied to a project because code inlining prevents the user from stepping into the advice in question, but it should work just fine for other kinds of advice or when inlining is turned off.
Comment 1 Andrew Clement CLA 2008-06-26 14:10:07 EDT
I'm investigating some scenarios here, I'm a little surprised quite how broken it seems to be:

In my setup the aspects involved in the weave are created in an AJDT project then packaged into a jar file, aspects.jar - the src remains in the Project/src folder.

I then create a second project and by placing the aspects.jar on the aspectpath, the aspects are woven into the code in this project.  The gutter navigation works fine :)

I have a method advised by before advice from the aspect.  I have set a breakpoint on the first line of code in the advised method, I know that if it pauses there and I click 'step into' - it should take me to the advice.


First problem:

I DebugAs>JavaApplication and hit the break point.
On StepInto I get taken to SimpleAspect.class (from aspects.jar)
I click 'Change Attached Source' and set it to Project/src (where the aspect was built) - although it is accepted, it doesn't work and I am left in the .class file.  The source aspect is in a .aj file - that may make a difference.

Second problem:

Before launching, I go into Project properties for my woven project, I go to Java Build Path (AJDT auto added the aspects.jar entry into here when it was placed on the aspectpath).  On the libraries tab I open aspects.jar and set the source attachment to Project/src.   On launching the app, I still can't step into the advice.

Third problem: 

I switched to having the aspect in a .java file - didn't make any difference, still won't recognize when I change attached source.
Comment 2 Andrew Clement CLA 2008-06-26 16:04:57 EDT
source attachments do get recognized if the compiled aspects are not packaged inside a jar file, but simply left in the output folder of the aspects project and that bin folder is placed on the aspectpath of the project in which they should apply.  Once attached the step-through functionality works as I would expect, but new breakpoints cannot be set in the source view for the compiled aspect (fourth problem)
Comment 3 Andrew Eisenberg CLA 2008-06-27 14:21:10 EDT
OK.  I am working on fixing this.  I haven't checked in the code yet (it is attached to fixing bug 237979).  When I check it in, problems 1 and 2 mentioned above should be resolved.

However, problem 3 doesn't work because when the file has a .java extension, breakpoints cannot be applied.  I think this is a parser problem (ie- the java parser is required to figure out where the breakpoint can be placed and the Java parser cannot parse a file with aspectj in it), so for now it will be a requirement to use the .aj extension if you want to apply breakpoints.

That being said, however, if I set a breakpoint outside of the advice, I can still step into the advice using the debugger.

I think Problem 4 is saying that breakpoints cannot be set in the .class file if the file contains aspect code.  This is the same parser issue as above.  The solution is to set a breakpoint in the .aj file, and this will be respected by the debugger when runnning code.

So, in summary the solution is:

1. always use .aj files
2. always set breakpoints in the .aj file (not the class file)
3. specify a source attachment in the java build path page of the project properties
4. wait for my patch to be committed before all this will work.
Comment 4 Andrew Eisenberg CLA 2008-06-27 14:36:32 EDT
This bug will be fixed when the patch for bug 237979 is committed.
Comment 5 Andrew Clement CLA 2008-06-27 17:27:02 EDT
> 3. specify a source attachment in the java build path page of the project
properties

Is that the only way I can attach source?  I won't be able to just attach it when I hit a .class file and the 'click to attach source' button appears?
Comment 6 Andrew Eisenberg CLA 2008-06-27 17:43:43 EDT
> Is that the only way I can attach source?  I won't be able to just attach it
> when I hit a .class file and the 'click to attach source' button appears?

You will be able to do it either way. 

Comment 7 Andrew Clement CLA 2008-07-09 11:05:36 EDT
available in latest dev build.