Bug 468217: [otdre] stack overflow at callin-bound base method involving
super calls
- trigger wicket-super-call replacement on one more path
- detect wicket-super-call differing only in signatures
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/AbstractBoundClass.java b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/AbstractBoundClass.java
index ea7c707..541e953 100644
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/AbstractBoundClass.java
+++ b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/AbstractBoundClass.java
@@ -686,11 +686,19 @@
 							if (method.isImplemented()) {
 								// So redefine the method
 								weaveBindingInImplementedMethod(task);
+								if (!method.isStatic() && weavingContext.isWeavable(getSuperClassName())) {
+									AbstractBoundClass superclass = getSuperclass();
+									Method superMethod = superclass.getMethod(method.getName(), method.getSignature(), true, false);
+									if (superMethod.isImplemented()) {
+										// binding affects also the super implementation, need to handle wicked super calls:
+										replaceWickedSuperCalls(getSuperclass(), method);
+									}
+								}
 							} else {
 								//No, so weave this class and delegate to the super class
 								weaveBindingInNotImplementedMethod(task);
-								AbstractBoundClass superclass = getSuperclass();
 								if (weavingContext.isWeavable(getSuperClassName())) {
+									AbstractBoundClass superclass = getSuperclass();
 									Method superMethod = superclass.getMethod(method, task);
 									if (superMethod != null) {
 										WeavingTask newTask = new WeavingTask(WeavingTaskType.WEAVE_BINDING_OF_SUBCLASS, superMethod, task);
@@ -724,10 +732,12 @@
 					case WEAVE_INHERITED_BINDING:
 						if (method.isImplemented()) {
 							weaveBindingInImplementedMethod(task);
+							if (!method.isStatic()) {
+								replaceWickedSuperCalls(getSuperclass(), method);
+							}
 						} else {
 							weaveBindingInNotImplementedMethod(task);
 						}
-						replaceWickedSuperCalls(getSuperclass(), method);
 		
 						// Delegate the WeavingTask to the subclasses
 						for (AbstractBoundClass subclass : getSubclasses()) {
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/ReplaceWickedSuperCallsAdapter.java b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/ReplaceWickedSuperCallsAdapter.java
index d1500c7..eaaaaf9 100644
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/ReplaceWickedSuperCallsAdapter.java
+++ b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/ReplaceWickedSuperCallsAdapter.java
@@ -91,7 +91,9 @@
 			@Override
 			public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
 				super.visitMethodInsn(opcode, owner, name, desc, itf);
-				if (opcode == Opcodes.INVOKESPECIAL && !enclosingMethodName.equals(name) && owner.equals(superclass.getInternalName())) {
+				if (opcode == Opcodes.INVOKESPECIAL
+						&& !(enclosingMethodName.equals(name) && enclosingMethodDesc.contentEquals(desc))
+						&& owner.equals(superclass.getInternalName())) {
 					// we have a wicked super call ...
 					for (Method tgt: targetMethods) {
 						if (tgt.getName().equals(name) && tgt.getSignature().equals(desc)) {