diff options
author | jhugunin <jhugunin> | 2003-04-22 21:58:02 +0000 |
---|---|---|
committer | jhugunin <jhugunin> | 2003-04-22 21:58:02 +0000 |
commit | 6c9118bfa40d75467085d23a3b0d103199e137b2 (patch) | |
tree | 1ed9f725110d254582163a1eddcc54b60fb40bdc /tests/bugs/StackError.java | |
parent | 0a8dbdeed13fe79ddfd7a291e2b45b50b9a90579 (diff) | |
download | aspectj-6c9118bfa40d75467085d23a3b0d103199e137b2.tar.gz aspectj-6c9118bfa40d75467085d23a3b0d103199e137b2.zip |
tests and fixes for
Bugzilla Bug 29665
Inconsistant stack height
Diffstat (limited to 'tests/bugs/StackError.java')
-rw-r--r-- | tests/bugs/StackError.java | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/bugs/StackError.java b/tests/bugs/StackError.java new file mode 100644 index 000000000..2b3a04a09 --- /dev/null +++ b/tests/bugs/StackError.java @@ -0,0 +1,46 @@ +import java.lang.reflect.Method; + +public class StackError { + public static void main(String args[]) { + new StackError().testEqualsNull(); + } + + void assertTrue(String msg, boolean b) {} + + public void testEqualsNull() { + StackError one = new StackError(); + StackError two = new StackError(); + assertTrue("equal", one.equals(two)); // does not work + //boolean yes = one.equals(two); // works + } + + public boolean equals(Object other) { + return true; + } +} + +aspect EqualsContract { + pointcut equalsCall(Object thisOne, Object otherOne): + target(Object+) && + + target(thisOne) && + call(public boolean equals(Object+)) && + args(otherOne) && + !within(EqualsContract); + + boolean around(Object thisOne, Object otherOne): + equalsCall(thisOne, otherOne) { + boolean result = proceed(thisOne, otherOne); + Class cls = thisOne.getClass(); + String name = cls.getName(); + boolean hasHashCode = false; + try { + Method m = cls.getDeclaredMethod("hashCode", null); + String lookFor = "public int " + name + ".hashCode()"; + hasHashCode = lookFor.equals(m.toString()); + } + catch (NoSuchMethodException nsme) { + } + return result; + } +} |