Bug 298692 - [handle] Spurious error in editor using generics
Summary: [handle] Spurious error in editor using generics
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.6.6   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 1.6.10   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 298683
Blocks:
  Show dependency tree
 
Reported: 2009-12-31 16:33 EST by Andrew Eisenberg CLA
Modified: 2010-07-23 18:58 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-12-31 16:33:41 EST
This bug is the aspectj side of Bug 298683.  The problem is with handle identifiers from AJC.  The '+' for pointcuts overloads the '+' for type parameter upper bounds.  '+' should be changed to something like ':'.  This change also needs to be reflected in AJDT.

+++ This bug was initially created as a clone of Bug #298683 +++

From the mailing list:

==============
Essentially I tried creating an Eclipse AspectJ project with just one MyAspect.aj file (in the default namespace) with the following contents (toy example):

public aspect MyAspect
{
    public interface MyInterface
    {
    }

    declare parents: MyObject implements MyInterface;

    public boolean MyInterface.instanceOf(Class<? extends Object> c)
    {
        return c.isInstance(this);
    }
}

class MyObject
{
}

class Main
{
    public static void main(String[] args)
    {
        new MyObject().instanceOf(MyObject.class);
    }
}

I get, over "instanceOf" in the main method, the following error: "The method instanceOf(Class<Object>) from the type MyObject refers to the missing type Object". Notice that it is declared as Class<? extends Object> but during weaving becomes Class<Object>.

Here is my setup:

* Mac OS X 10.4 Tiger
* Eclipse Galileo
* Mac OS X JavaVM 1.5.0 (J2SE-1.5)
* AspectJ 1.6.6
* AJDT 2.0.1

I downloaded the standalone aspectj-1.6.6.jar at http://www.eclipse.org/aspectj/, installed it correctly, and ran the command "ajc -1.5 MyAspect.aj -showWeaveInfo" and it didn't give me that error (or any other error). What it did give me was the following:

Type 'MyAspect$MyInterface' (MyAspect.aj) has intertyped method from 'MyAspect' (MyAspect.aj:'boolean MyAspect$MyInterface.instanceOf(java.lang.Class<? extends java.lang.Object>)')

Extending interface set for type 'MyObject' (MyAspect.aj) to include 'MyAspect$MyInterface' (MyAspect.aj)

Type 'MyObject' (MyAspect.aj) has intertyped method from 'MyAspect' (MyAspect.aj:'boolean MyAspect$MyInterface.instanceOf(java.lang.Class<? extends java.lang.Object>)')

So I think there is a disconnect between how ajc behaves on the command line and how ajdt behaves in Eclipse. I'd be particularly curious to know if there are any setups possible that would get Eclipse to weave this properly. Right now I am removing a ton of generics from my project, but you can obviously understand that I would prefer to keep them around if at all possible. :)
========================

The problem is that AJDT does not use ajc to analyze the code when within the AJ Editor.  There is probably some problem with the type augmentation when generics are being used in this situation.  I will have a look at this.
Comment 1 Andrew Clement CLA 2010-04-05 18:34:44 EDT
I am about to change the + to : for the pointcut delimiter.  If you are using HandleProviderDelimiter.POINTCUT to access the delimiter, you will automatically pickup the change.  If you are keeping your own copy of the delimiters, I guess you may need to make some changes?
Comment 2 Andrew Eisenberg CLA 2010-07-20 22:56:31 EDT
Please make one more change.

Can you make HandleProviderDelimiter.ASPECT_TYPE become '-'?

The current handle identifier character for AspectTypes override the character for Annotations.  I think '-' is a good candidate for AspectTypes.  Although it is used in rare situations inside of type signatures (which may appear as parameter inside of a method or ITD), it will not conflict with declarations of Aspects.
Comment 3 Andrew Clement CLA 2010-07-23 18:58:38 EDT
changes all made as per request in that other bug (320425)