Bug 406518 - migrate OT/Equinox to the standard OSGi WeavingHook
- debug output for errors in org.eclipse.objectteams.otdt.test.builder
diff --git a/plugins/org.eclipse.objectteams.runtime/src/org/eclipse/objectteams/otre/ObjectTeamsTransformation.java b/plugins/org.eclipse.objectteams.runtime/src/org/eclipse/objectteams/otre/ObjectTeamsTransformation.java
index daaa278..67e19ce 100644
--- a/plugins/org.eclipse.objectteams.runtime/src/org/eclipse/objectteams/otre/ObjectTeamsTransformation.java
+++ b/plugins/org.eclipse.objectteams.runtime/src/org/eclipse/objectteams/otre/ObjectTeamsTransformation.java
@@ -558,12 +558,28 @@
 								  		 String class_name,
 								  		 ConstantPoolGen cpg)
     {
+    	checkReadClassAttributes(ce, cg, class_name, cpg, false);
+    }
+    public void checkReadClassAttributes(ClassEnhancer ce,
+	         ClassGen cg,
+	  		 String class_name,
+	  		 ConstantPoolGen cpg,
+	  		 boolean isScanOnly)
+    {
+
     	AttributeReadingGuard guard = AttributeReadingGuard.getInstanceForLoader(this.loader);
     	boolean addTeamInitializations = false;
     	List<String> classesToLoad;
     	synchronized (guard) {
-    		if (!guard.iAmTheFirst(class_name))
-    			return;
+    		if (!guard.iAmTheFirst(class_name)) {
+    			if (isScanOnly) {
+    				System.err.println("I'm not the first "+this);
+    				System.err.println(" guard ="+guard);
+    				System.err.println(" loader="+this.loader);
+    				System.err.println(" class ="+class_name);
+    			}
+				return;
+			}
 			if (AttributeReadingGuard.isFirstLoadedClass())
 				addTeamInitializations = true;
 			// scan for attributes here, because this transformer is applied first:
diff --git a/plugins/org.eclipse.objectteams.runtime/src/org/eclipse/objectteams/otre/jplis/ObjectTeamsTransformer.java b/plugins/org.eclipse.objectteams.runtime/src/org/eclipse/objectteams/otre/jplis/ObjectTeamsTransformer.java
index 275d68d..0f0e3f6 100644
--- a/plugins/org.eclipse.objectteams.runtime/src/org/eclipse/objectteams/otre/jplis/ObjectTeamsTransformer.java
+++ b/plugins/org.eclipse.objectteams.runtime/src/org/eclipse/objectteams/otre/jplis/ObjectTeamsTransformer.java
@@ -245,7 +245,7 @@
 		DietClassLoaderRepository prevRepository = RepositoryAccess.setClassLoader(loader);
 		try {
 			setFirstTransformation(new ObjectTeamsTransformation(loader) {});
-			firstTransformation.checkReadClassAttributes(jpe, cg, cg.getClassName(), cg.getConstantPool());
+			firstTransformation.checkReadClassAttributes(jpe, cg, cg.getClassName(), cg.getConstantPool(), true);
 		} finally {
 			RepositoryAccess.resetRepository(prevRepository);
 		}
diff --git a/plugins/org.eclipse.objectteams.runtime/src/org/eclipse/objectteams/otre/util/AttributeReadingGuard.java b/plugins/org.eclipse.objectteams.runtime/src/org/eclipse/objectteams/otre/util/AttributeReadingGuard.java
index 52a449c..cbda8f2 100644
--- a/plugins/org.eclipse.objectteams.runtime/src/org/eclipse/objectteams/otre/util/AttributeReadingGuard.java
+++ b/plugins/org.eclipse.objectteams.runtime/src/org/eclipse/objectteams/otre/util/AttributeReadingGuard.java
@@ -49,6 +49,15 @@
     	this.servedClasses.add(className);    
     }
     
+    @Override
+    public String toString() {
+    	StringBuilder buf = new StringBuilder("AttributeReadingGuard with served classes:");
+    	for (String clazz : servedClasses) {
+			buf.append("\n\t"+clazz);
+		}
+    	return buf.toString();
+    }
+    
     /**
      * @return whether this class is the first being loaded => possibly the main class.
      */