Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2018-02-11 13:22:55 +0000
committerStephan Herrmann2018-02-11 20:24:17 +0000
commit0599087a119d2b2ed062d8c78b37990c4a27ef4d (patch)
tree52ec1c68eb60090e6472abae91c6b43a9a3d9c23
parent96006c13f10fb476ec38acafbdffb5789e41ca86 (diff)
downloadorg.eclipse.objectteams-0599087a119d2b2ed062d8c78b37990c4a27ef4d.tar.gz
org.eclipse.objectteams-0599087a119d2b2ed062d8c78b37990c4a27ef4d.tar.xz
org.eclipse.objectteams-0599087a119d2b2ed062d8c78b37990c4a27ef4d.zip
Bug 530914 - [otdre] Wrong kind of super-call in callOrig where super is
in fact not woven. - tests using weavable regions for comparison with original example - when OTDRE asks OT/Equinox don't search supers
-rw-r--r--plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/OTWeavingHook.java12
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/regression/ComplexStructures.java185
2 files changed, 191 insertions, 6 deletions
diff --git a/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/OTWeavingHook.java b/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/OTWeavingHook.java
index 9e7dd44fa..229f271a7 100644
--- a/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/OTWeavingHook.java
+++ b/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/OTWeavingHook.java
@@ -356,7 +356,7 @@ public class OTWeavingHook implements WeavingHook, WovenClassListener {
return WeavingReason.Base; // we may be first, go ahead and trigger the trip wire
}
}
- if (isAdaptedBaseClass(aspectBindings, className, bytes, bundleWiring.getClassLoader()))
+ if (isAdaptedBaseClass(aspectBindings, className, bytes != null, bytes, bundleWiring.getClassLoader()))
return WeavingReason.Base;
}
@@ -378,8 +378,10 @@ public class OTWeavingHook implements WeavingHook, WovenClassListener {
return false;
}
- /** check need for weaving by finding an aspect binding affecting this exact base class or one of its supers. */
- boolean isAdaptedBaseClass(List<AspectBinding> aspectBindings, String className, byte[] bytes, ClassLoader resourceLoader) {
+ /** check need for weaving by finding an aspect binding affecting this exact base class or one of its supers.
+ * @param searchSupers controls whether super classes should be considered, too.
+ */
+ boolean isAdaptedBaseClass(List<AspectBinding> aspectBindings, String className, boolean searchSupers, byte[] bytes, ClassLoader resourceLoader) {
if (skipBaseClassCheck) return true; // have aspect bindings, flag requests to transform *all* classes in this base bundle
if ("java.lang.Object".equals(className))
@@ -405,11 +407,11 @@ public class OTWeavingHook implements WeavingHook, WovenClassListener {
return false;
}
}
- if (classInfo != null && !classInfo.isInterface()) {
+ if (searchSupers && classInfo != null && !classInfo.isInterface()) {
// TODO(performance): check common prefix to recognize when crossing the plugin-boundary?
String superClassName = classInfo.getSuperClassName();
if (superClassName != null)
- return isAdaptedBaseClass(aspectBindings, superClassName, null, resourceLoader);
+ return isAdaptedBaseClass(aspectBindings, superClassName, searchSupers, null, resourceLoader);
}
return false;
} finally {
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/regression/ComplexStructures.java b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/regression/ComplexStructures.java
index 57b27539b..358b1608d 100644
--- a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/regression/ComplexStructures.java
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/regression/ComplexStructures.java
@@ -80,7 +80,7 @@ public class ComplexStructures extends AbstractOTJLDTest {
"I am a basic graph ...");
}
- public void testMultiLevelSuper() {
+ public void testMultiLevelSuper1() {
runConformTest(
new String[] {
"t/M.java",
@@ -155,4 +155,187 @@ public class ComplexStructures extends AbstractOTJLDTest {
},
"Role\nBase0.m()");
}
+
+ public void testMultiLevelSuper2() {
+ myWriteFiles(new String[] {"weavable.txt", "weavable.\nt\n"});
+ runConformTest(
+ new String[] {
+ "t/M.java",
+ "package t;\n" +
+ "import weavable.*;\n" +
+ "public class M {\n" +
+ " public static void main(String... args) {\n" +
+ " new Team1().activate();\n" +
+ " new Base4().m(5);\n" +
+ " new Base4().m(0);\n" +
+ " }\n" +
+ "}\n",
+ "unweavable/Base0.java",
+ "package unweavable;\n" +
+ "public class Base0 {\n" +
+ " public void m(int i) {\n" +
+ " System.out.println(\"Base0.m()\");\n" +
+ " }\n" +
+ "}\n",
+ "weavable/Base1.java",
+ "package weavable;\n" +
+ "public class Base1 extends unweavable.Base0 {\n" +
+ " public void m(int i) {\n" +
+ " if (i != 1)\n" +
+ " super.m(i);\n" +
+ " }\n" +
+ "}\n",
+ "unweavable/Base2.java",
+ "package unweavable;\n" +
+ "public class Base2 extends weavable.Base1 {\n" +
+ " public void m(int i) {\n" +
+ " if (i != 2)\n" +
+ " super.m(i);\n" +
+ " }\n" +
+ "}\n",
+ "weavable/Base3.java",
+ "package weavable;\n" +
+ "public class Base3 extends unweavable.Base2 {\n" +
+ " public void m(int i) {\n" +
+ " if (i != 3)\n" +
+ " super.m(i);\n" +
+ " }\n" +
+ "}\n",
+ "weavable/Base4.java",
+ "package weavable;\n" +
+ "public class Base4 extends Base3 {\n" +
+ " public void m(int i) {\n" +
+ " if (i != 4)\n" +
+ " super.m(i);\n" +
+ " }\n" +
+ "}\n",
+ "t/Team0.java",
+ "package t;\n" +
+ "import base weavable.Base1;\n" +
+ "import base weavable.Base3;\n" +
+ "public team class Team0 {\n" +
+ " protected class R0 playedBy Base1 {\n" +
+ " }\n" +
+ " protected class R1 extends R0 playedBy Base3 { }\n" +
+ "}\n",
+ "t/Team1.java",
+ "package t;\n" +
+ "import base weavable.Base4;\n" +
+ "public team class Team1 extends Team0 {\n" +
+ " protected class R2 extends R1 playedBy Base4 {\n" +
+ " void q(int i) <- replace void m(int i) base when (i == 5);\n" +
+ " callin void q(int i) {\n" +
+ " System.out.println(\"Role\");\n" +
+ " }\n" +
+ " }\n" +
+ "}\n",
+ },
+ "Role\nBase0.m()",
+ null,
+ false,
+ new String[] { "-Dot.weavable="+this.outputTestDirectory+"/weavable.txt" });
+ }
+
+ public void testMultiLevelSuper3() {
+ myWriteFiles(new String[] {"weavable.txt", "weavable.\nt\n"});
+ runConformTest(
+ new String[] {
+ "t/M.java",
+ "package t;\n" +
+ "import weavable.*;\n" +
+ "public class M {\n" +
+ " public static void main(String... args) {\n" +
+ " new Team1().activate();\n" +
+ " new Base6().m(5);\n" +
+ " new Base6().m(0);\n" +
+ " }\n" +
+ "}\n",
+ "unweavable/Base0.java",
+ "package unweavable;\n" +
+ "public class Base0 {\n" +
+ " public void m(int i) {\n" +
+ " System.out.println(\"Base0.m()\");\n" +
+ " }\n" +
+ "}\n",
+ "weavable/Base1.java",
+ "package weavable;\n" +
+ "public class Base1 extends unweavable.Base0 {\n" +
+ " @Override\n" +
+ " public void m(int i) {\n" +
+ " if (i != 1)\n" +
+ " super.m(i);\n" +
+ " }\n" +
+ "}\n",
+ "weavable/Base2.java",
+ "package weavable;\n" +
+ "public class Base2 extends Base1 {\n" +
+ " @Override\n" +
+ " public void m(int i) {\n" +
+ " if (i != 2)\n" +
+ " super.m(i);\n" +
+ " }\n" +
+ "}\n",
+ "unweavable/Base3.java",
+ "package unweavable;\n" +
+ "public class Base3 extends weavable.Base2 {\n" +
+ " @Override\n" +
+ " public void m(int i) {\n" +
+ " if (i != 3)\n" +
+ " super.m(i);\n" +
+ " }\n" +
+ "}\n",
+ "unweavable/Base4.java",
+ "package unweavable;\n" +
+ "public class Base4 extends Base3 {\n" +
+ " @Override\n" +
+ " public void m(int i) {\n" +
+ " if (i != 4)\n" +
+ " super.m(i);\n" +
+ " }\n" +
+ "}\n",
+ "weavable/Base5.java",
+ "package weavable;\n" +
+ "public class Base5 extends unweavable.Base4 {\n" +
+ " @Override\n" +
+ " public void m(int i) {\n" +
+ " if (i != 5)\n" +
+ " super.m(i);\n" +
+ " }\n" +
+ "}\n",
+ "weavable/Base6.java",
+ "package weavable;\n" +
+ "public class Base6 extends Base5 {\n" +
+ " @Override\n" +
+ " public void m(int i) {\n" +
+ " if (i != 6)\n" +
+ " super.m(i);\n" +
+ " }\n" +
+ "}\n",
+ "t/Team0.java",
+ "package t;\n" +
+ "import base weavable.Base1;\n" +
+ "import base weavable.Base5;\n" +
+ "public team class Team0 {\n" +
+ " protected class R0 playedBy Base1 {\n" +
+ " }\n" +
+ " protected class R1 extends R0 playedBy Base5 { }\n" +
+ "}\n",
+ "t/Team1.java",
+ "package t;\n" +
+ "import base weavable.Base6;\n" +
+ "public team class Team1 extends Team0 {\n" +
+ " protected class R2 extends R1 playedBy Base6 {\n" +
+ " void q(int i) <- replace void m(int i) base when (i == 5);\n" +
+ " callin void q(int i) {\n" +
+ " System.out.println(\"Role\");\n" +
+ " }\n" +
+ " }\n" +
+ "}\n",
+ },
+ "Role\nBase0.m()",
+ null,
+ false,
+ new String[] { "-Dot.weavable="+this.outputTestDirectory+"/weavable.txt" });
+ }
+
}

Back to the top