Project: AspectJ
Bug 39993 ajc stack trace on declaring hashcode() method in aspect
Reported: 2003-07-13 15:02:03 | Status: resolved fixed

From an email sent to the user's list 6/26/2003: ------------------------------------------ ajc 1.1 NPE when an aspect declares hashcode() as follows: 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(); } } A workaround for callers the compiler controls is to replace the declaration with around advice: int around(Identifiable i): target(i) && call(public int hashCode()) { return (i.getId() == null) ? proceed(i) : i.getId().hashCode(); }

Files changed in fix:
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterSuperFixerVisitor.java org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterSuperReference.java org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeDeclaration.java tests/bugs/MultipleSuperCf.java tests/bugs/OverridingInterfaceObjectMethod.java weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java