Bug 243356 - AJDT appears to ignore ASPECTPATH_ATTRIBUTE classpath attribute
Summary: AJDT appears to ignore ASPECTPATH_ATTRIBUTE classpath attribute
Status: RESOLVED FIXED
Alias: None
Product: AJDT
Classification: Tools
Component: Core (show other bugs)
Version: 1.6.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 1.6.0   Edit
Assignee: AJDT-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-08-06 14:24 EDT by Igor Fedorenko CLA
Modified: 2012-04-03 14:19 EDT (History)
2 users (show)

See Also:


Attachments
patch that checks inside a classpath container for classpath entries on the in/aspect path (11.35 KB, patch)
2008-08-07 14:10 EDT, Andrew Eisenberg CLA
andrew.eisenberg: iplog+
Details | Diff
sample plugin, includes sources (8.92 KB, application/x-java-archive)
2008-08-11 21:08 EDT, Igor Fedorenko CLA
no flags Details
workspace expected by the samply plugin (5.36 KB, application/x-zip-compressed)
2008-08-11 21:09 EDT, Igor Fedorenko CLA
no flags Details
patch to AspectJCorePreferences.java (3.42 KB, patch)
2008-08-12 12:48 EDT, Andrew Eisenberg CLA
andrew.eisenberg: iplog+
Details | Diff
New patch...this time with test case (16.50 KB, patch)
2008-08-12 13:19 EDT, Andrew Eisenberg CLA
andrew.eisenberg: iplog+
Details | Diff
Patch to add aspect/in path elements to the UI (47.61 KB, patch)
2008-08-20 22:39 EDT, Andrew Eisenberg CLA
andrew.eisenberg: iplog+
Details | Diff
Fixing compile error in last patch (9.34 KB, patch)
2008-08-21 11:44 EDT, Andrew Eisenberg CLA
andrew.eisenberg: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Igor Fedorenko CLA 2008-08-06 14:24:18 EDT
Using eclipse 3.4 and ajdt 1.6.0.200808060124, adding AspectJCorePreferences.ASPECTPATH_ATTRIBUTE attribute to entries of custom classpath container (m2e "maven dependencies" to be specific) does not seem to add the entries to project aspect path, according to AspectJ Build properties in UI at least. 

This works as expected in AJDT 1.5.2.200804241330, so it looks like a regression in 1.6.0.200808060124.
Comment 1 Andrew Eisenberg CLA 2008-08-06 23:13:56 EDT
How do you add the aspect path attribute to the container?  Are you doing this programmatically, through the UI, or by editing the .classpath file?
Comment 2 Igor Fedorenko CLA 2008-08-06 23:31:01 EDT
The attribute is added programmatically to the entries of Maven classpath container. Here is simplified code


<code>

Set<IClasspathEntry> entries = new Set ...;
ArrayList<IClasspathAttribute> attributes = new ArrayList
...
        attributes,add(AspectJCorePreferences.ASPECTPATH_ATTRIBUTE);
...
        entries.add(JavaCore.newLibraryEntry(entryPath, //
            srcPath, srcRoot, new IAccessRule[0], //
            attributes.toArray(new IClasspathAttribute[attributes.size()]), // 
            false /*not exported*/));
...
        IClasspathContainer container = new MavenClasspathContainer(path, entries);

        JavaCore.setClasspathContainer(container.getPath(), new IJavaProject[] {javaProject},
            new IClasspathContainer[] {container}, monitor);

</code>
Comment 3 Andrew Eisenberg CLA 2008-08-07 00:14:33 EDT
OK.

After this code is executed, does the attribute appear the .classpath file?
Comment 4 Igor Fedorenko CLA 2008-08-07 08:38:08 EDT
No, like for all classpath containers .classpath has a record for container itself but not container content (this is the point of classpath containers). As I mentioned in original report, this exact code works with AJDT 1.5.2 and used to work with earlier 1.6.0 builds, so I am 100% sure that the attribute is properly associated with classpath entries inside the container. 
Comment 5 Andrew Eisenberg CLA 2008-08-07 12:13:23 EDT
Getting closer...does this happen for all classpath entries in the container or just for project entries?

If the answer is yes, then I will have a patch for you by the end of the day.  If not, then I will have to dig a little more.

To get around this issue, you can also add the apsect path attribute directly to the MavenClasspathContainer.
Comment 6 Andrew Eisenberg CLA 2008-08-07 12:19:48 EDT
Let me be more clear on that last sentence:

In order for the Classpath Container to appear in the aspect path UI, it *must* contain the aspect path attribute (same for the in path attribute).  If the container contains the aspect/in path attribute then all classpath entries it contains will as well.

Having a classpath container where only some elements have the aspect/in path attribute is not something that we have tested for.
Comment 7 Igor Fedorenko CLA 2008-08-07 12:53:10 EDT
We set the attribute for some entries in the container. We do not set the attribute for the container itself. 

The problem occurs for library entries. 

We need support for project entries too. I have not explicitly tested project entries yet, but will do it as soon as library entries work again.
Comment 8 Andrew Eisenberg CLA 2008-08-07 14:10:07 EDT
Created attachment 109439 [details]
patch that checks inside a classpath container for classpath entries on the in/aspect path

This patch will add entries inside of a classpath container to the in/aspect path if the entry has the appropriate attribute.

Note that the classpath container itself will not appear in the UI as being on the aspect/in path.  To do this, the attribute must be added to the container itself (and hence labelling every contained entry as being on the aspect/in path).

Frankly, I'm surprised this worked in previous versions of AJDT because this is something that we have never tested for to my knowledge.

Andy, please commit this to both the AJDT 1.5 and AJDT 1.6 streams.

Igor, after it is commited please update to the latest dev version of 1.6 and see if this properly addresses your problem.
Comment 9 Andrew Clement CLA 2008-08-07 14:48:34 EDT
committed to AJDT1.6 - dont have a 1.5 around right now to put it in, will get to it...
Comment 10 Andrew Clement CLA 2008-08-07 15:27:29 EDT
fix in AJDT 1.5 now too
Comment 11 Andrew Eisenberg CLA 2008-08-11 13:41:22 EDT
Igor,

Is this patch working for you?  Let us know and we can close the bug.
Comment 12 Igor Fedorenko CLA 2008-08-11 14:54:51 EDT
Sorry, I was down with the flu last days, will try to validate the fix today.
Comment 13 Igor Fedorenko CLA 2008-08-11 21:08:42 EDT
Created attachment 109729 [details]
sample plugin, includes sources
Comment 14 Igor Fedorenko CLA 2008-08-11 21:09:27 EDT
Created attachment 109730 [details]
workspace expected by the samply plugin
Comment 15 Igor Fedorenko CLA 2008-08-11 22:39:06 EDT
Unfortunately, this still does not work with 1.6.0.200808071509. I've attached sample plugin (with sources) and workspace projects that demonstrate the problem. 

The only "interesting" class in the sample plugin is ajcontainer.actions.ConfigureContainerJob. The job can be invoked from UI (Sample Menu/Sample Action) and it has hardcoded referenced to the projects from the sample workspace. The job creates "Sample Container" on project named "b" and adds one project and one jar entry to the container. Both entries have AspectJCorePreferences.ASPECTPATH_ATTRIBUTE.

After importing the sample projects into a fresh workspace and invoking ConfigureContainerJob, I can see that new "Sample Container" is added to project "b", however aspect path of the project is empty. Expected result is to have two separate aspect path entries, one for the jar, another for the project.

Let me know if you need more details.

PS: I think I left some debug calls to AspectJCorePreferences.getResolvedProjectAspectPath in ConfigureContainerJob. Please disregard, m2e does not use nor need to use getResolvedProjectAspectPath.
Comment 16 Andrew Eisenberg CLA 2008-08-12 12:48:40 EDT
Created attachment 109799 [details]
patch to AspectJCorePreferences.java

Fixes the trouble with getting aspect paths out of containers.

Thanks for the test case, Igor.  This patch should fix your problem.

Andy, please commit to 1.5 and 16 stream.
Comment 17 Andrew Eisenberg CLA 2008-08-12 13:19:42 EDT
Created attachment 109806 [details]
New patch...this time with test case

I made a test case out of the plugin and workspace you sent me.  

This patch overrides the previous one.
Comment 18 Andrew Clement CLA 2008-08-12 17:32:26 EDT
Patch for core preferences source file wont apply, neither this recent version or the older one without the testcase in.  Given the trauma we are having with patches recently I wonder if we have a bug with creating patches against AspectJ projects.
Comment 19 Andrew Clement CLA 2008-08-12 17:35:25 EDT
altho... I just looked at merging it by hand and it seemed to contain some stuff I had already put in from a patch yesterday.  Did you definetly completely synchronize AspectJCorePreferences and have no incoming/clashing changes before creating the patch?
Comment 20 Andrew Clement CLA 2008-08-12 17:45:48 EDT
patch forced in - will be in next dev build of ajdt1.6
Comment 21 Andrew Clement CLA 2008-08-12 19:48:41 EDT
ok - so it does appear per the chat we had just now that the patch was created at the 1.5 level.  I guess I assumed that as the bug was raised against AJDT 1.6.0 that the patch would be primarily for that level but something worth backporting.  It also looks like the patch includes changes for another bug (autobuild bug) that weren't already backported - as that is still open.

But I've committed this into 1.5 now too.  will just need to remember that the autobuild patch will clash when trying to commit that into 1.5
Comment 22 Andrew Eisenberg CLA 2008-08-15 16:01:22 EDT
Igor,

Please let us know if this patch works for you.  We want to make sure this is fixed for the AJDT 1.6.0 release coming up shortly.

Hope you are over your flu.
Comment 23 Igor Fedorenko CLA 2008-08-16 01:56:42 EDT
I am sorry to say this, but I still cannot make AJDT work with entries from classpath containers. Fresh e34 "classic" with AJDT 1.6.0.200808151716. I ran the test steps I explained in the comment #15 and do not see neither jar nor project in Aspect Path UI.
Comment 24 Andrew Eisenberg CLA 2008-08-18 15:04:20 EDT
This is surprising behavior to me.  And it seems a little strange that previous versions of AJDT would put things in the aspect path UI that are not directly on the path.

The previous patches ensure that the entries with the appropriate classpath attribute are placed on the appropriate in/aspect path.  But, it does not put them in the UI.  So, the entries are on the path, but they don't appear in the UI (just as other entries in classpath containers do not appear in the UI).

I will look to see what previous versions of AJDT did and see if it makes sense to recreate this behavior.
Comment 25 Andrew Eisenberg CLA 2008-08-20 12:45:14 EDT
I tested this in AJDT 1.5.1 and early development versions of 1.5.3 (couldn't get easy access to a version of 1.5.2).  In both cases, looking at the Aspect path properties page gives an infinite loop and an out of memory error.

This confirmed my suspicion that if the behavior you have seen does work in earlier versions of AJDT, it was because of a fluke rather than because it was designed to behave that way.  

I did a major refactoring of how aspect and in paths are handled for 1.5.3.  In the past, the raw classpath and the resolved classpath were being mixed in incorrect ways.  Additionally, projects could not be placed on the aspect or in paths.  So, I do not want to regress to previous behavior.

If the above behavior had worked and it would have been possible to view aspect path path entries in containers, and the programmer removed the aspect path entry from the dialog, the resulting classpath/aspect path would have been inconsistent.  Not good.

Here is my solution.  When displaying aspect/in paths, the UI will also peek inside of containers and display any entries inside of them, but these entries will not be able to be removed (perhaps a warning dialog will appear telling the programmer which container contributed them).
Comment 26 Andrew Eisenberg CLA 2008-08-20 13:58:12 EDT
But this solution raises another question:

Should exported aspect/in path entries on projects in the classpath also be included in the UI and in the Project's aspect path?

eg-

Project A has Project B on its classpath.  Project B has Jar C on its aspect path and exports it.  Should Jar C be on Project A's aspect path?  (Note that Jar C is already on Project A's classpath.)

For now, I am going to say no.  I don't have any other reason other than it is difficult to implement and it seems like an obscure case, but I am willing to implement this if someone requests this functionality.
Comment 27 Andrew Eisenberg CLA 2008-08-20 22:39:45 EDT
Created attachment 110510 [details]
Patch to add aspect/in path elements to the UI

This patch adds aspect/in path elements from containers to the Aspect Build Path properties page.

Now, you will be able to see these elements in the UI.  You will not be able to remove them, but there is a child node attached to each element specifying which container provides that element.

Andy, please commit to the 1.6 stream and Igor please let me know if this works for you.


This should be the final patch.  Once Andy
Comment 28 Andrew Clement CLA 2008-08-21 01:22:54 EDT
I have committed the patch.  However it seems to have left me with errors (it applied fine).  My workspace no longer compiles with errors about isAspectPathAttribute() and isInPathAttribute() not being defined on AspectJCorePreferences. And they aren't from what i see in my workspace.  From a cursory glance through the patch they don't seem to be added by it.

It also seems to contain the beginnings of changes for the extraneous element map rebuilds when working with multiple projects - did you mean to include that?

Comment 29 Andrew Eisenberg CLA 2008-08-21 11:44:13 EDT
Created attachment 110581 [details]
Fixing compile error in last patch

For some reason, the two files of this patch weren't included in the last one.  If you submit this patch, the build should be fixed.
Comment 30 Andrew Clement CLA 2008-08-21 12:56:43 EDT
comment 29 patch in
Comment 31 Igor Fedorenko CLA 2008-08-22 00:10:16 EDT
I checked 1.6.0.200808211329 and although I did not have much time to play with it, ajdt appears to properly add to aspect path both library and project entries (whoohoo!). Thank you very much for your help and I think this bug can be closed now.

Comment 32 Andrew Eisenberg CLA 2008-08-22 11:45:28 EDT
Glad to hear it is working.  (Finally!)  Please come back here if you notice any more problems.
Comment 33 Igor Fedorenko CLA 2008-08-22 20:13:56 EDT
Quick question, when do you expect ajdt 1.5.x build that includes this feature?
Comment 34 Andrew Clement CLA 2008-08-22 22:52:03 EDT
If Andrew confirms which patch will work on 1.5 (does the most recent include everything required?) then i can put it straight in.
Comment 35 Andrew Eisenberg CLA 2008-08-23 00:08:27 EDT
There have been so many patches lately that I need to check what's already in 1.5.  Some of the functionality is there, but not all of it.
Comment 36 Andrew Eisenberg CLA 2008-08-27 11:53:14 EDT
The change is in the 1.5 stream now.  

Andy, please close this bug as fixed.
Comment 37 Andrew Clement CLA 2008-08-27 12:14:03 EDT
fixed in AJDT 1.5 and 1.6, wooo