Fix in otdre: must not try to weave into abstract methods
diff --git a/plugins/org.eclipse.objectteams.otre/.classpath b/plugins/org.eclipse.objectteams.otre/.classpath
index 3ed5c66..9fbd4bd 100644
--- a/plugins/org.eclipse.objectteams.otre/.classpath
+++ b/plugins/org.eclipse.objectteams.otre/.classpath
@@ -3,6 +3,6 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="bcelpatchsrc"/>
+ <classpathentry kind="src" output="bcelpatchbin" path="bcelpatchsrc"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AbstractTransformableClassNode.java b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AbstractTransformableClassNode.java
index 13d52bb..3bd0b12 100644
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AbstractTransformableClassNode.java
+++ b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AbstractTransformableClassNode.java
@@ -1,7 +1,7 @@
/**********************************************************************
* This file is part of "Object Teams Dynamic Runtime Environment"
*
- * Copyright 2009, 2012 Oliver Frank and others.
+ * Copyright 2009, 2014 Oliver Frank and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -273,6 +273,7 @@
/**
* In this method, concrete Implementations of this class
* can manipulate the bytecode
+ * @return whether transformation actually happened
*/
- protected abstract void transform();
+ protected abstract boolean transform();
}
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AsmWritableBoundClass.java b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AsmWritableBoundClass.java
index 510f4dc..a943878 100644
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AsmWritableBoundClass.java
+++ b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/AsmWritableBoundClass.java
@@ -140,10 +140,11 @@
for (AbstractTransformableClassNode node : nodes) {
reader = new ClassReader(allocateAndGetBytecode());
reader.accept(node, ClassReader.SKIP_FRAMES);
- node.transform();
- writer = new ClassWriter(reader, ClassWriter.COMPUTE_FRAMES);
- node.accept(writer);
- setBytecode(writer.toByteArray());
+ if (node.transform()) {
+ writer = new ClassWriter(reader, ClassWriter.COMPUTE_FRAMES);
+ node.accept(writer);
+ setBytecode(writer.toByteArray());
+ }
}
dump();
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateAddRemoveRoleMethod.java b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateAddRemoveRoleMethod.java
index d0c3758..92461ac 100644
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateAddRemoveRoleMethod.java
+++ b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateAddRemoveRoleMethod.java
@@ -1,7 +1,7 @@
/**********************************************************************
* This file is part of "Object Teams Dynamic Runtime Environment"
*
- * Copyright 2009, 2012 Stephan Herrmann.
+ * Copyright 2009, 2014 Stephan Herrmann.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -38,7 +38,7 @@
@Override
- protected void transform() {
+ protected boolean transform() {
// void _OT$addRemoveRole(Object role, boolean isAdding) {
MethodNode method = getMethod(ConstantMembers.addOrRemoveRole);
method.instructions.clear();
@@ -75,6 +75,7 @@
method.maxStack = 3;
method.maxLocals = 4; // this + 2 args + 1 local ("set")
+ return true;
}
void genGetInitializedRoleSet(InsnList instructions, int targetLocal) {
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateCallAllBindingsCallInOrgMethod.java b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateCallAllBindingsCallInOrgMethod.java
index d3ca8d9..b66df32 100644
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateCallAllBindingsCallInOrgMethod.java
+++ b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateCallAllBindingsCallInOrgMethod.java
@@ -1,7 +1,7 @@
/**********************************************************************
* This file is part of "Object Teams Dynamic Runtime Environment"
*
- * Copyright 2009, 2012 Oliver Frank and others.
+ * Copyright 2009, 2014 Oliver Frank and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -53,8 +53,9 @@
}
@Override
- public void transform() {
+ public boolean transform() {
MethodNode method = getMethod(orgMethod);
+ if ((method.access & Opcodes.ACC_ABSTRACT) != 0) return false;
// if (method.name.equals("<init>")) {
// int size = method.instructions.size();
@@ -142,6 +143,8 @@
}
method.maxStack = args.length > 0 ? 5+maxArgSize : 3;
method.maxLocals = localSlots+1;
+
+ return true;
}
void addCatchSneakyException(MethodNode method, LabelNode start) {
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateDispatchCodeInCallAllBindingsAdapter.java b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateDispatchCodeInCallAllBindingsAdapter.java
index 9b49160..045faa5 100644
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateDispatchCodeInCallAllBindingsAdapter.java
+++ b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateDispatchCodeInCallAllBindingsAdapter.java
@@ -1,7 +1,7 @@
/**********************************************************************
* This file is part of "Object Teams Dynamic Runtime Environment"
*
- * Copyright 2009, 2012 Oliver Frank and others.
+ * Copyright 2009, 2014 Oliver Frank and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -58,12 +58,13 @@
}
@Override
- public void transform() {
+ public boolean transform() {
MethodNode callAllBindings = getMethod(ConstantMembers.callAllBindingsClient);
InsnList instructions = getDispatchCode(callAllBindings, joinpointId, boundMethodId);
addNewLabelToSwitch(callAllBindings.instructions, instructions, boundMethodId);
callAllBindings.maxStack = getMaxStack();
callAllBindings.maxLocals = getMaxLocals();
+ return true;
}
@Override
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateDispatchCodeInOrgMethodAdapter.java b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateDispatchCodeInOrgMethodAdapter.java
index 27e8cbe..fe33617 100644
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateDispatchCodeInOrgMethodAdapter.java
+++ b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateDispatchCodeInOrgMethodAdapter.java
@@ -1,7 +1,7 @@
/**********************************************************************
* This file is part of "Object Teams Dynamic Runtime Environment"
*
- * Copyright 2009, 2012 Oliver Frank and others.
+ * Copyright 2009, 2014 Oliver Frank and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -60,13 +60,15 @@
}
@Override
- public void transform() {
+ public boolean transform() {
MethodNode orgMethod = getMethod(method);
+ if ((orgMethod.access & Opcodes.ACC_ABSTRACT) != 0) return false;
orgMethod.instructions.clear();
orgMethod.instructions.add(getDispatchCode(orgMethod, joinPointId, boundMethodId));
orgMethod.maxStack = getMaxStack();
orgMethod.maxLocals = getMaxLocals();
+ return true;
}
@Override
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateFieldAccessAdapter.java b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateFieldAccessAdapter.java
index 2b240e3..40af15c 100644
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateFieldAccessAdapter.java
+++ b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateFieldAccessAdapter.java
@@ -1,7 +1,7 @@
/**********************************************************************
* This file is part of "Object Teams Dynamic Runtime Environment"
*
- * Copyright 2009, 2012 Oliver Frank and others.
+ * Copyright 2009, 2014 Oliver Frank and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -65,7 +65,7 @@
}
@Override
- public void transform() {
+ public boolean transform() {
InsnList instructions = new InsnList();
// put accessId on the stack
@@ -125,6 +125,8 @@
//add the instructions to a new label in the existing switch
MethodNode method = getMethod(access);
addNewLabelToSwitch(method.instructions, instructions, accessId);
+
+ return true;
}
}
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateMethodAccessAdapter.java b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateMethodAccessAdapter.java
index af24ec8..6cc903d 100644
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateMethodAccessAdapter.java
+++ b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateMethodAccessAdapter.java
@@ -58,7 +58,7 @@
}
@Override
- public void transform() {
+ public boolean transform() {
MethodNode methodNode = getMethod(method);
InsnList instructions = new InsnList();
@@ -121,6 +121,8 @@
//add the instructions to a new label in the existing switch
MethodNode access = getMethod(this.access);
addNewLabelToSwitch(access.instructions, instructions, accessId);
+
+ return true;
}
}
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateSuperCallInCallOrigAdapter.java b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateSuperCallInCallOrigAdapter.java
index e81bf82..664c677 100644
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateSuperCallInCallOrigAdapter.java
+++ b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateSuperCallInCallOrigAdapter.java
@@ -1,7 +1,7 @@
/**********************************************************************
* This file is part of "Object Teams Dynamic Runtime Environment"
*
- * Copyright 2009, 2012 Oliver Frank and others.
+ * Copyright 2009, 2014 Oliver Frank and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -41,7 +41,7 @@
}
@Override
- public void transform() {
+ public boolean transform() {
MethodNode callOrig = getMethod(ConstantMembers.callOrig);
InsnList instructions = new InsnList();
@@ -54,5 +54,6 @@
instructions.add(new InsnNode(Opcodes.ARETURN));
addNewLabelToSwitch(callOrig.instructions, instructions, joinpointId);
callOrig.maxStack = Math.max(callOrig.maxStack, args.length + 1);
+ return true;
}
}
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateSwitchAdapter.java b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateSwitchAdapter.java
index dbbabcf..47a8466 100644
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateSwitchAdapter.java
+++ b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/CreateSwitchAdapter.java
@@ -1,7 +1,7 @@
/**********************************************************************
* This file is part of "Object Teams Dynamic Runtime Environment"
*
- * Copyright 2009, 2012 Oliver Frank and others.
+ * Copyright 2009, 2014 Oliver Frank and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -55,9 +55,9 @@
}
@Override
- public void transform() {
+ public boolean transform() {
MethodNode methodNode = getMethod(method);
- if (methodNode == null) return; // doesn't exist, don't transform
+ if (methodNode == null) return false; // doesn't exist, don't transform
methodNode.instructions.clear();
addPreSwitchInstructions(methodNode);
@@ -71,6 +71,7 @@
addPostSwitchInstructions(methodNode);
methodNode.maxStack = getMaxStack();
+ return true;
}
/**
diff --git a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/MoveCodeToCallOrigAdapter.java b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/MoveCodeToCallOrigAdapter.java
index 8438da8..47e1b3f 100644
--- a/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/MoveCodeToCallOrigAdapter.java
+++ b/plugins/org.eclipse.objectteams.otredyn/src/org/eclipse/objectteams/otredyn/bytecode/asm/MoveCodeToCallOrigAdapter.java
@@ -1,7 +1,7 @@
/**********************************************************************
* This file is part of "Object Teams Dynamic Runtime Environment"
*
- * Copyright 2009, 2012 Oliver Frank and others.
+ * Copyright 2009, 2014 Oliver Frank and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -52,8 +52,10 @@
}
}
- public void transform() {
+ public boolean transform() {
MethodNode orgMethod = getMethod(method);
+ if ((orgMethod.access & Opcodes.ACC_ABSTRACT) != 0) return false;
+
MethodNode callOrig = getMethod(this.callOrig);
Type returnType = Type.getReturnType(orgMethod.desc);
@@ -105,5 +107,6 @@
callOrig.maxStack += 1;
}
callOrig.maxLocals = Math.max(callOrig.maxLocals, orgMethod.maxLocals);
+ return true;
}
}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/regression/ReportedBugs.java b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/regression/ReportedBugs.java
index a6438a0..218f2ca 100644
--- a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/regression/ReportedBugs.java
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/regression/ReportedBugs.java
@@ -1,13 +1,12 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
*
- * Copyright 2005-2010 Berlin Institute of Technology, Germany.
+ * Copyright 2005, 2014 Berlin Institute of Technology, Germany.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- * $Id$
*
* Please visit http://www.eclipse.org/objectteams for updates and contact.
*
@@ -2271,6 +2270,34 @@
"----------\n");
}
+ // tiny exercise towards sh51: OTDRE could not weave into abstract base method.
+ public void testB11_sh51_0() {
+ runConformTest(
+ new String[] {
+ "TeamB11sh51_0.java",
+ "public team class TeamB11sh51_0 {\n" +
+ " protected class R playedBy TB11sh51_0_1 {\n" +
+ " void print() { System.out.print('p'); }\n" +
+ " print <- after test;\n" +
+ " }\n" +
+ " public static void main(String... args) {\n" +
+ " within (new TeamB11sh51_0()) {\n" +
+ " new TB11sh51_0_2().test();\n" +
+ " }\n" +
+ " }\n" +
+ "}\n",
+ "TB11sh51_0_1.java",
+ "public abstract class TB11sh51_0_1 {\n" +
+ " abstract void test();\n" +
+ "}\n",
+ "TB11sh51_0_2.java",
+ "public class TB11sh51_0_2 extends TB11sh51_0_1 {\n" +
+ " void test() { System.out.print('t'); }\n" +
+ "}\n",
+ },
+ "tp");
+ }
+
// curiosities if bound base method is covariantly redefined, reported by hsudof, base version: OK
// B.1.1-otjld-sh-51
public void testB11_sh51() {