Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] compilation error with generics (possible bug?)

Hi!

The following code seems correct to me:

[code]
public interface Identifiable<T> {
  T getId();

  void setId(T t);
}

public interface LongIdentifiable extends Identifiable<Long> {
}

public class Bean implements LongIdentifiable {

  public Long getId() {
    return null;
  }

  public void setId(Long t) {
  }

}
[/code]

at least it compiles oke with Eclipse 3.1.1.

Going back to AspectJ and AJDT adding the following aspect:

[code]
public aspect IdentifiableAspect {
    declare parents: Bean implements LongIdentifiable;

    private Long LongIdentifiable.m_id;

    public Long LongIdentifiable.getId() {
        return m_id;
    }

    public void LongIdentifiable.setId(Long id) {
        m_id= id;
    }
}
[/code]

results in 3 compilation errors:

Severity	Description	Resource	In Folder	Location	Creation Time	Id
2 can't override java.lang.Long org.noco.generics.LongIdentifiable.getId() with java.lang.Object org.noco.generics.Bean.getId() return types don't match IdentifiableAspect.aj aj5_examples/src/main/org/noco/generics line 8 November 14, 2005 3:01:43 PM 27085

Severity	Description	Resource	In Folder	Location	Creation Time	Id
2 The return type is incompatible with org.noco.generics.Identifiable<java.lang.Long>.getId() Bean.java aj5_examples/src/main/org/noco/generics line 1 November 14, 2005 3:01:43 PM 27094

Severity	Description	Resource	In Folder	Location	Creation Time	Id
2 can't override java.lang.Long org.noco.generics.LongIdentifiable.getId() with java.lang.Object org.noco.generics.Bean.getId() return types don't match Bean.java aj5_examples/src/main/org/noco/generics line 1 November 14, 2005 3:01:43 PM 27095


Env:

Eclipse 3.1.1
AJDT: ajdt_1.3.0.20051108143751_archive.zip

Am I doing something wrong? Is this a known bug?

thanks in avdance,

./alex
--
.w( the_mindstorm )p.



Back to the top