[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-users] Changes in introduction for aspectj compiler 1.1
|
I was playing around with porting over our current project witch uses
1.0.6 to the new compiler and looking into the little differences that
would need to be addressed. I came across a obscure difference between
the two concerning introduction. I thought it would be of help to pass
it along. Here is the example.
interface Identifiable {
void setId(Id id);
Id getId();
}
aspect IdentifiableAspect {
private Id Identifiable.id = null;
public Id Identifiable.getId() {
return this.id;
}
public void Identifiable.setId(Id id) {
this.id = id;
}
public int Identifiable.hashCode() {
return (this.getId() == null)
? super.hashCode()
: this.getId().hashCode();
}
}
The method of interest is the introduction of hashCode. Proir to the new
compiler this worked fine. Now it throws a NullPointer exception in the
compiler w/o a good error message. However, if you change the
functionallity to the following:
int around(Identifiable i): target(i)
&& call(public int hashCode())
{
return (i.getId() == null)
? proceed(i)
: i.getId().hashCode();
}
It accomplishes the same goal. I believe this has to do with the new
compiler bytecode weaving as opposed to the source code weaving done
with the prior version. Hope that can save someone some trouble.
- wd