Bug 333723 - AspectJ crashing, when weaving IDT into another project in Eclipse
Summary: AspectJ crashing, when weaving IDT into another project in Eclipse
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: IDE (show other bugs)
Version: 1.6.10   Edit
Hardware: PC Windows XP
: P3 critical (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-07 02:32 EST by Martin Benedict CLA
Modified: 2013-06-24 11:05 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 Martin Benedict CLA 2011-01-07 02:32:35 EST
Hello,

currently im working with aspectj in an eclipse-environment. I also want to use Maven for my projects. Now I've got a problem with weaving.

I have one project (let's call it AdressBook), which contains classes for an adress book. For this project dependency-management is enabled. Let's say, we have a class Person in this package. This class defines methods for set and get Name and other person-details.

I have a second project (let's call it Aut) which provides classes for autorisation and authentication. In these project there are some Interfaces like RoleAuthorization. These interfaces getting through Intertype Declaration a default implementation. For example a method grantAccess(Role role).

public void RoleAuthorizationBase.grantAccess(Role role) {
        authorizedObject.grantAccess(role); 
    }

Now I want to define a bridge between these two projects in a new project (let's call it Bridge). I've defined some aspects that should connect the two referer explained projects.

I've defined the following:

declare parents: contacts.* implements RoleAuthorization;

With this, all classes of my AdressBook-project should realize the interface RoleAuthorization. The default-implementations from Aut-Project should be weaved into the classes, which realizes the interface. But this isn't done. I've tried to add the Projects Aut and AdressBook to the InPath of the Bridge-project, but then the AspectJ-compiler crashes with the following

java.lang.NullPointerException
at org.aspectj.ajdt.internal.compiler.lookup.AjLookupEnvironment.doDeclareAnnotations(AjLookupEnvironment.java:1031)
at org.aspectj.ajdt.internal.compiler.lookup.AjLookupEnvironment.weaveInterTypeDeclarations(AjLookupEnvironment.java:745)
at org.aspectj.ajdt.internal.compiler.lookup.AjLookupEnvironment.weaveInterTypeDeclarations(AjLookupEnvironment.java:652)
at org.aspectj.ajdt.internal.compiler.lookup.AjLo ... on$1.run(GlobalBuildAction.java:179)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

Compile error: NullPointerException thrown: null

I've also tried to configure the maven-aspectj-plugin, but that also wasn't successful. I've added the following to my POM of the Bridge:

<aspectLibraries>
    <aspectLibrary>
        <groupId>Aut</groupId>
        <artifactId>Aut</artifactId>
    </aspectLibrary>
<weaveDependencies>
    <weaveDependency>
        <groupId>Aut</groupId>
            <artifactId>Aut</artifactId>
    </weaveDependency>
    <weaveDependency>
        <groupId>AddressBook</groupId>
        <artifactId>AddressBook</artifactId>
    </weaveDependency>
</weaveDependencies>

f.E. Person should get the grantAccessMethod

   Person person = new Person ("foo","bar");
   person.setName("baz"); //This is a method of the class person
   person.grantAccess(adminRole); // This is injected by Intertype Declaration

I think I should mention, that a build on console with maven2 sucessfully works, but in eclipse the compile crashed with the previous mentioned Exception. I think the Problem would also happen, if no maven2 is used. Currently i do my builds on console with maven, but its not a very lucky way, because I couldn't use eclipses source-error-labeling and code completion. This makes my work very ineffective. 

I think the crash is a bug in AspectJ.

My Eclipse-Version is Helios Service Release 1, Build id: 20100917-0705

greetings, Martin
Comment 1 Andrew Clement CLA 2011-01-07 17:58:50 EST
The exception indicates you also have a declare annotation in the mix somewhere.  Can you tell me what that looks like?  is it in the bridge project or the Aut project?

What you are trying to do is the valid way to do it, using inpath.  Possibly your bridge project just needs the AddressBook project on the inpath whilst the Aut project only has to be on the aspectpath - but it depends what you want in the output folder of Bridge.  if you want everything (all the AddressBook and Aut classes) then you need to put them both on the inpath.  With just AddressBook on the inpath, the output folder for the bridge project will contain woven AddressBook classes and you'll need the Aut project on the classpath to run your code.
Comment 2 Martin Benedict CLA 2011-01-08 09:31:35 EST
If you mean the @DeclareAnnontation-Annotation, I didn't use it in my Projects. Currently I didn't use any AspectJ-Annotation. All my declares, pointcuts and advices are defined in .aj-Files. So I'm wondering about this.
I use Annotations for Hibernate, but I don't think, that they conflict with AspectJ-Annotations.

I have set the two Projects in the inpath, because they are two specific domains and the bridge connects them to an application. I've also tried to set the Aut-Project to the aspect-path, but the same problem occurs.

Hope this additional Informations help. If you wish, i could send you a copy of my three projects. They are for university, so i think they are note classified.
Comment 3 Andrew Clement CLA 2011-01-27 16:29:12 EST
If you could send me the failing projects, that would really help!  Use my gmail address, andrew.clement
Comment 4 Andrew Clement CLA 2013-06-24 11:05:05 EDT
unsetting the target field which is currently set for something already released