[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Issue with generics

I repeated your steps and got no errors. My setup is as follows:

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

Yes, this is what I said in the first e-mail. I am not sure if you want something else? It should be relatively straight forward:

1. Get Eclipse Galileo.
2. Install aspectj support using the following update site: http://download.eclipse.org/tools/ajdt/35/update.
3. Create an AspectJ project with this one file in it (MyAspect.aj) and run it as an AspectJ project.

I am now thinking though that since this problem seems to be manifesting in Eclipse's support for AspectJ and not in the standalone downloadable of AspectJ that perhaps I should take up this matter with the ajdt-dev mailing list instead.

-Michel


Andy Clement wrote:
I just compiled your new program (with the empty interface that I
mentioned) fine on AspectJ 1.6.7.  I also tried it with 1.6.6 and it
worked there too.

  
ajc -1.5 MyAspect.java -showWeaveInfo
    

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

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

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

Your message:  "The method instanceOf(Class<Object>) from the type
MyObject refers to the missing type Object" sounds rather unusual.
Perhaps if you tell me precisely how you compile it, that will help?

Andy


2009/12/30 Michel Parisien <codingkriggs@xxxxxxxxx>:
  
Thank you Andy,

However, this does not work on my end. Let me paste the entirety of what I
have in my 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, at the same place, a new 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>, and that's from where the error emerges in this case. Also
notice I made a slight modification to the main, by passing instanceOf the
value MyObject.class. I did this to show that simply changing the method
argument's type from Class<? extends Object> to Class<Object> would not be
sufficient to handle something other than Object.class.

-Michel


Andy Clement wrote:

As a simple workaround until it is fixed, you can remove the
declaration from the interface and just let the ITD do its work.



public aspect MyAspect
{
  public interface MyInterface {}

  declare parents: MyObject implements MyInterface;

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


Andy

2009/12/30 Michel Parisien <codingkriggs@xxxxxxxxx>:


I have to say, this was not the response I was hoping for. :) But thanks.

The bug has been filed here:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=298665

-Michel


Andrew Eisenberg wrote:

This does appear to be a bug with generics.  I am able to get your
program to compile by removing the type parameters on your method
declarations:

public aspect MyAspect
{
  public interface MyInterface
  {
      public boolean instanceOf(Class c);
  }

  declare parents: MyObject implements MyInterface;

  public boolean MyInterface.instanceOf(Class c)
  {
      return c.isInstance(this);
  }
}

class MyObject
{
}

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

I'd suggest that you raise a bug for this in bugzilla.

On Tue, Dec 29, 2009 at 11:40 PM, Michel Parisien
<codingkriggs@xxxxxxxxx> wrote:


Hello,

I have a problem that I tried boiling down to as small a code sample as
possible. The following gives me the error "The method instanceOf(Class<?
extends Object>) is ambiguous for the type MyObject" on the "instanceOf"
method call in the main method:

public aspect MyAspect
{
  public interface MyInterface
  {
      public boolean instanceOf(Class<? extends Object> c);
  }

  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(Object.class);
  }
}

First, I wonder if this fails to compile for everyone or if it is just me.
Second, since I suspect I may have a compatibility issue, here are my specs:

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

If the problem is with the code, I'd like to know the "better" way to
accomplish the above.

I would appreciate any help you could give,

-Michel

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users



_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users



_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users




_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users



_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users


    
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users