Bug 547840 - loader re-entrance conflicts with adding otre imports
diff --git a/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/AspectBinding.java b/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/AspectBinding.java
index 6e7b0af..ccf3830 100644
--- a/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/AspectBinding.java
+++ b/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/AspectBinding.java
@@ -1,7 +1,7 @@
 /**********************************************************************
  * This file is part of "Object Teams Development Tooling"-Software
  * 
- * Copyright 2009, 2015 Germany and Technical University Berlin, Germany and others.
+ * Copyright 2009, 2019 Germany and Technical University Berlin, Germany and others.
  * 
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
@@ -263,7 +263,6 @@
 		String bundleName;
 		/** Team classes indexed by base classes that should trigger activating the team. */
 		final HashMap<String, Set<TeamBinding>> teamsPerBase = new HashMap<>();
-		boolean otreAdded;		
 
 		public BaseBundle(String bundleName) {
 			this.bundleName = bundleName;
diff --git a/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/BaseBundleLoadTrigger.java b/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/BaseBundleLoadTrigger.java
index 9a1c224..8f3bac2 100644
--- a/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/BaseBundleLoadTrigger.java
+++ b/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/BaseBundleLoadTrigger.java
@@ -1,7 +1,7 @@
 /**********************************************************************
  * This file is part of "Object Teams Development Tooling"-Software
  * 
- * Copyright 2013, 2015 GK Software AG
+ * Copyright 2013, 2019 GK Software AG
  *  
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
@@ -45,7 +45,6 @@
 
 	private String baseBundleName;	
 	@Nullable private BaseBundle baseBundle; // null when representing an aspectBundle with SELF-adapting teams
-	private boolean otreAdded = false;
 	private List<AspectBinding> aspectBindings = new ArrayList<>();
 
 	public BaseBundleLoadTrigger(String bundleSymbolicName, @Nullable BaseBundle baseBundle, AspectBindingRegistry aspectBindingRegistry, 
@@ -85,11 +84,7 @@
 		// (1) OTRE import added once per base bundle:
 		WeavingScheme weavingScheme = getWeavingScheme();
 		synchronized(this) {
-			final BaseBundle baseBundle2 = baseBundle;
-			if (!otreAdded) {
-				otreAdded = true;
-				addOTREImport(baseBundle2, baseBundleName, baseClass, weavingScheme == WeavingScheme.OTDRE);
-			}
+			addOTREImport(baseBundleName, baseClass, weavingScheme == WeavingScheme.OTDRE);
 		}
 		
 		// for each team in each aspect binding:
@@ -151,13 +146,8 @@
 		}
 	}
 
-	static void addOTREImport(@Nullable BaseBundle baseBundle, String baseBundleName, WovenClass baseClass, boolean useDynamicWeaver) 
+	static void addOTREImport(String baseBundleName, WovenClass baseClass, boolean useDynamicWeaver) 
 	{
-		if (baseBundle != null) {
-			if (baseBundle.otreAdded)
-				return;
-			baseBundle.otreAdded = true;
-		}
 		log(IStatus.INFO, "Adding OTRE import to "+baseBundleName);
 		List<String> imports = baseClass.getDynamicImports();
 		imports.add("org.objectteams");
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 9440f93..91303ab 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
@@ -1,7 +1,7 @@
 /**********************************************************************
  * This file is part of "Object Teams Development Tooling"-Software
  * 
- * Copyright 2013, 2018 GK Software SE
+ * Copyright 2013, 2019 GK Software SE
  *  
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
@@ -278,8 +278,7 @@
 						log(IStatus.WARNING, "Not performing thread weaving for "+className+" (weaving scheme not yet knonw)");
 						return;
 					}
-					BaseBundle baseBundle = this.aspectBindingRegistry.getBaseBundle(bundleName);
-					BaseBundleLoadTrigger.addOTREImport(baseBundle, bundleName, wovenClass, DEFAULT_WEAVING_SCHEME == WeavingScheme.OTDRE);
+					BaseBundleLoadTrigger.addOTREImport(bundleName, wovenClass, DEFAULT_WEAVING_SCHEME == WeavingScheme.OTDRE);
 				} 
 
 				long time = 0;
diff --git a/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/otequinox/TransformerPlugin.java b/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/otequinox/TransformerPlugin.java
index e926da2..ce9b133 100644
--- a/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/otequinox/TransformerPlugin.java
+++ b/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/otequinox/TransformerPlugin.java
@@ -32,7 +32,6 @@
 import org.eclipse.equinox.log.ExtendedLogService;
 import org.eclipse.equinox.log.LogFilter;
 import org.eclipse.equinox.log.Logger;
-import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.objectteams.internal.osgi.weaving.AspectBinding;