Bug 514325: regression in test
InheritanceHierarchyOfTeams.test127_nonTeamSuperclass1a
diff --git a/plugins/org.eclipse.objectteams.runtime/src/org/eclipse/objectteams/otredyn/runtime/TeamManager.java b/plugins/org.eclipse.objectteams.runtime/src/org/eclipse/objectteams/otredyn/runtime/TeamManager.java
index 708837e..1001a20 100644
--- a/plugins/org.eclipse.objectteams.runtime/src/org/eclipse/objectteams/otredyn/runtime/TeamManager.java
+++ b/plugins/org.eclipse.objectteams.runtime/src/org/eclipse/objectteams/otredyn/runtime/TeamManager.java
@@ -194,11 +194,18 @@
 
 	private void stateChangeForJoinpoint(ITeam t, ITeamManager.TeamStateChange stateChange, IBinding binding,
 			IBoundClass boundClass, IMethod method, int joinpointId) {
-		changeTeamsForJoinpoint(t, binding.getPerTeamId(), joinpointId, stateChange);
+		Set<Integer> joinpointIds = new HashSet<Integer>();
+		collectSubJoinpoints(joinpointId, joinpointIds);
+		for (Integer id : joinpointIds) {
+			changeTeamsForJoinpoint(t, binding.getPerTeamId(), id, stateChange);
+		}
+	}
+	private void collectSubJoinpoints(int joinpointId, Set<Integer> joinpointIds) {
+		joinpointIds.add(joinpointId);
 		List<Integer> subJoinpoints = joinpointToSubJoinpoints.get(joinpointId);
 		if (subJoinpoints != null)
 			for (Integer subJoinpoint : subJoinpoints)
-				stateChangeForJoinpoint(t, stateChange, binding, boundClass, method, subJoinpoint);
+				collectSubJoinpoints(subJoinpoint, joinpointIds);
 	}
 	
 	/**
@@ -379,8 +386,15 @@
 		List<Integer> srcCallins = _callinIds.get(srcJoinpointId);
 		for (int s=0; s<srcTeams.size(); s++) {
 			int d = 0; // FIXME(SH): find insertion index based on activation priority!!
-			teams.add(d, srcTeams.get(s));
-			callinIds.add(0, srcCallins.get(s));
+			ITeam srcTeam = srcTeams.get(s);
+			Integer srcCallin = srcCallins.get(s);
+			int idx = teams.indexOf(srcTeam);
+			if (idx != -1 && idx < callinIds.size()) {
+				if (callinIds.get(idx) == srcCallin)
+					continue;
+			}
+			teams.add(d, srcTeam);
+			callinIds.add(0, srcCallin);
 		}
 		// transitively pass the new information down the tree of subJoinpoints:
 		List<Integer> destDests = joinpointToSubJoinpoints.get(destJoinpointId);
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/rolesandteams/InheritanceHierarchyOfTeams.java b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/rolesandteams/InheritanceHierarchyOfTeams.java
index 6c44b85..18c5c58 100644
--- a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/rolesandteams/InheritanceHierarchyOfTeams.java
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/rolesandteams/InheritanceHierarchyOfTeams.java
@@ -362,7 +362,12 @@
 			    "        t.activate();\n" +
 			    "        t.hello();\n" +
 			    "        t.world();\n" +
-			    "        System.out.print(t.getAllRoles().length);\n" +
+			    "        System.out.println(t.getAllRoles().length);\n" +
+			    "		 t.deactivate();\n" +
+			    "		 t.hello();\n" +
+			    "        t.activate();\n" +
+			    "        t.hello();\n" +
+			    "        t.world();\n" +
 			    "    }\n" +
 			    "}\n" +
 			    "    \n",
@@ -386,7 +391,8 @@
 			    "}\n" +
 			    "    \n"
             },
-            "hello world1");
+            "hello world1\n" +
+            "hellohello world");
     }
 
     // replace callin: