[jboss-cvs] JBossAS SVN: r71185 - projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sun Mar 23 23:46:45 EDT 2008


Author: flavia.rainone at jboss.com
Date: 2008-03-23 23:46:45 -0400 (Sun, 23 Mar 2008)
New Revision: 71185

Removed:
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/GeneratedAdvised.java
Modified:
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/Advisor.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/AdvisorFactory.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/AspectAnnotationLoader.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/AspectManager.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/AspectXmlLoader.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/CallerConstructorInfo.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/CallerMethodInfo.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/ClassAdvisor.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/ClassContainer.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/ClassInstanceAdvisor.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/ConByConInfo.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/ConByMethodInfo.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/ConstructionInfo.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/ConstructorInfo.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/Deployment.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/Domain.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/DynamicAOPStrategy.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/FieldInfo.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/GeneratedAdvisorDomain.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/GeneratedClassAdvisor.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/GeneratedInstanceAdvisorMixin.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/HotSwapStrategy.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/InstanceAdvisorDelegate.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/InterceptionMarkers.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/InterceptorChainObserver.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/Introduction.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/JoinPointInfo.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/LoadInterceptedClassesStrategy.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/MethodByConInfo.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/MethodByMethodInfo.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/MethodInfo.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/MethodInterceptors.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/MethodMatchInfo.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/Mixin.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/ReflectiveAspectBinder.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/SecurityActions.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/WeavingStrategySupport.java
Log:
Merging with trunk.

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/Advisor.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/Advisor.java	2008-03-24 03:41:24 UTC (rev 71184)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/Advisor.java	2008-03-24 03:46:45 UTC (rev 71185)
@@ -35,13 +35,11 @@
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.CopyOnWriteArraySet;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
 
 import javassist.CtClass;
 import javassist.CtConstructor;
@@ -107,6 +105,7 @@
          hash = 29 * hash + (joinpoint != null ? joinpoint.hashCode() : 0);
       }
 
+      @Override
       public boolean equals(Object o)
       {
          if (this == o) return true;
@@ -120,6 +119,7 @@
          return true;
       }
 
+      @Override
       public int hashCode()
       {
          return hash;
@@ -127,7 +127,7 @@
    }
 
    /** Read/Write lock to be used when lazy creating the collections */
-   protected ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
+   protected Object lazyCollectionLock = new Object();
 
    protected Set<AdviceBinding> adviceBindings = new HashSet<AdviceBinding>();
    protected volatile ArrayList<InterfaceIntroduction> interfaceIntroductions = UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
@@ -143,22 +143,24 @@
    protected boolean doesHaveAspects = false;
 
    protected String name;
-   protected ConcurrentHashMap aspects = new ConcurrentHashMap();
-   protected HashMap adviceInterceptors = new HashMap();
-   protected volatile CopyOnWriteArraySet perInstanceAspectDefinitions = UnmodifiableEmptyCollections.EMPTY_COPYONWRITE_ARRAYSET;
-   protected volatile ConcurrentHashMap perInstanceJoinpointAspectDefinitions = UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP;
+   protected ConcurrentHashMap<String, Object> aspects = new ConcurrentHashMap<String, Object>();
+   protected HashMap<AspectDefinition, Map<String, Interceptor>> adviceInterceptors = new HashMap<AspectDefinition, Map<String, Interceptor>>();
+   protected volatile CopyOnWriteArraySet<AspectDefinition> perInstanceAspectDefinitions = UnmodifiableEmptyCollections.EMPTY_COPYONWRITE_ARRAYSET;
+   protected volatile ConcurrentHashMap<AspectDefinition, Set<Joinpoint>> perInstanceJoinpointAspectDefinitions = UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP;
 
-   static Class cl = java.lang.String.class;
+   static Class<?> cl = java.lang.String.class;
    protected volatile TLongObjectHashMap advisedMethods = UnmodifiableEmptyCollections.EMPTY_TLONG_OBJECT_HASHMAP;
    // The method signatures are sorted at transformation and load time to
    // make sure the tables line up.
    //Common sense suggests that this should be lazily initialised for generated advisors, profiling shows that is a major performance hit...
-   /** @deprecated use methodInfos instead */
+   /** @deprecated use methodInfos instead. These remain here for compatibility with EJB 3 in JBoss 4.x. See JBAOP-517
+    * @see AspectManager#maintainAdvisorMethodInterceptors
+    */
    protected TLongObjectHashMap methodInterceptors = new TLongObjectHashMap();
    protected MethodInterceptors methodInfos = new MethodInterceptors(this);;
    protected AspectManager manager;
-   protected Class clazz = null;
-   protected Constructor[] constructors;
+   protected Class<?> clazz = null;
+   protected Constructor<?>[] constructors;
 
    /** @deprecated Use constructorInfos instead */
    protected Interceptor[][] constructorInterceptors;
@@ -178,7 +180,7 @@
       this.manager = manager;
    }
 
-   public Constructor[] getConstructors()
+   public Constructor<?>[] getConstructors()
    {
       return constructors;
    }
@@ -230,7 +232,7 @@
    }
 
 
-   public List getClassMetadataBindings()
+   public List<ClassMetaDataBinding> getClassMetadataBindings()
    {
       return classMetaDataBindings;
    }
@@ -265,12 +267,12 @@
     */
    public void deployAnnotationOverrides()
    {
-      List annotationOverrides = getManager().getAnnotationOverrides();
+      List<AnnotationIntroduction> annotationOverrides = getManager().getAnnotationOverrides();
       if (annotationOverrides != null)
       {
          for (int i = 0; i < annotationOverrides.size(); ++i)
          {
-            AnnotationIntroduction introduction = (AnnotationIntroduction) annotationOverrides.get(i);
+            AnnotationIntroduction introduction = annotationOverrides.get(i);
             deployAnnotationOverride(introduction);
          }
       }
@@ -295,7 +297,7 @@
          annotations.addClassAnnotation(introduction.getAnnotation().getIdentifier(), introduction.getOriginalAnnotationExpr());
       }
 
-      Class theClass = clazz;
+      Class<?> theClass = clazz;
 
       deployMethodAnnotationOverrides(theClass, introduction);
       Field[] fields = theClass.getDeclaredFields();
@@ -306,7 +308,7 @@
             annotations.addAnnotation(fields[i], introduction.getAnnotation().getIdentifier(), introduction.getOriginalAnnotationExpr());
          }
       }
-      Constructor[] cons = theClass.getDeclaredConstructors();
+      Constructor<?>[] cons = theClass.getDeclaredConstructors();
       for (int i = 0; i < cons.length; i++)
       {
          if (introduction.matches(this, cons[i]))
@@ -316,12 +318,12 @@
       }
    }
 
-   protected void initializeInterfaceIntroductions(Class theClass)
+   protected void initializeInterfaceIntroductions(Class<?> theClass)
    {
       manager.applyInterfaceIntroductions(this, theClass);
    }
 
-   protected void deployMethodAnnotationOverrides(Class theClass, AnnotationIntroduction introduction)
+   protected void deployMethodAnnotationOverrides(Class<?> theClass, AnnotationIntroduction introduction)
    {
       if (theClass.getSuperclass() != null)
       {
@@ -343,20 +345,26 @@
       return annotations;
    }
 
-   public Object resolveAnnotation(Class annotation)
+   public Object resolveAnnotation(Class<? extends Annotation> annotation)
    {
+      return resolveTypedAnnotation(annotation);
+   }
+   
+   public <T extends Annotation> T resolveTypedAnnotation(Class<T> annotation)
+   {
       if (metadata != null)
       {
-         Object value = metadata.getAnnotation(annotation);
+         T value = metadata.getAnnotation(annotation);
          if (value != null) return value;
       }
 
+      //Need to use the untyped version since that is used by EJB3
       if (annotations.isDisabled(annotation))
          return null;
 
-      Object value = annotations.resolveClassAnnotation(annotation);
-      if (clazz == null) return null;
-      if (value == null && metadata == null)
+      //MUST call this instead of AR.resolveTypedClassAnnotation since EJB3 overrides AR.resolveClassAnnotation
+      T value = (T)annotations.resolveClassAnnotation(annotation);
+      if (value == null && clazz != null && metadata == null)
       {
          value = AnnotationElement.getVisibleAnnotation(clazz, annotation);
       }
@@ -368,12 +376,12 @@
       return hasAnnotation(clazz, annotation);
    }
 
-   public boolean hasAnnotation(Class tgt, String annotation)
+   public boolean hasAnnotation(Class<?> tgt, String annotation)
    {
       return hasAnnotation(tgt, annotation, null);
    }
 
-   public boolean hasAnnotation(Class tgt, Class annotation)
+   public boolean hasAnnotation(Class<?> tgt, Class<? extends Annotation> annotation)
    {
       return hasAnnotation(tgt, null, annotation);
    }
@@ -531,37 +539,21 @@
       return annotationNames;
    }
    
-   private boolean hasAnnotation(Class tgt, String annotation, Class annotationClass)
+   private boolean hasAnnotation(Class<?> tgt, String annotation, Class<? extends Annotation> annotationClass)
    {
       if (annotation == null && annotationClass == null)
       {
          throw new RuntimeException("annotation or annotationClass must be passed in");
       }
 
-      try
+      if (annotation == null)
       {
-         if (metadata != null)
-         {
-            if (annotationClass == null)
-            {
-               ClassLoader cl = SecurityActions.getClassLoader(tgt);
-               if (cl == null)
-               {
-                  cl = SecurityActions.getContextClassLoader();
-               }
-               annotationClass = cl.loadClass(annotation);
-            }
-            if (annotationClass != null && metadata.isAnnotationPresent(annotationClass)) return true;
-         }
+         annotation = annotationClass.getName();
       }
-      catch (ClassNotFoundException e)
-      {
-         //The "annotation" is probably aop metadata for which there will be no corresponding class
-      }
 
-      if (annotation == null)
+      if (metadata != null)
       {
-         annotation = annotationClass.getName();
+         if (metadata.isMetaDataPresent(annotation)) return true;
       }
 
       if (annotations.hasClassAnnotation(annotation)) return true;
@@ -580,20 +572,30 @@
       return false;
    }
 
-   public Object resolveAnnotation(Method m, Class annotation)
+   public Object resolveAnnotation(Method m, Class<? extends Annotation> annotation)
    {
-      return resolveAnnotation(0, m, annotation);
+      return resolveTypedAnnotation(0, m, annotation);
    }
+   
+   public <T extends Annotation> T resolveTypedAnnotation(Method m, Class<T> annotation)
+   {
+      return resolveTypedAnnotation(0, m, annotation);
+   }
 
-   public Object resolveAnnotation(long hash, Method m, Class annotation)
+   public Object resolveAnnotation(long hash, Method m, Class<? extends Annotation> annotation)
    {
+      return resolveTypedAnnotation(hash, m, annotation);
+   }
+   
+   public <T extends Annotation> T resolveTypedAnnotation(long hash, Method m, Class<T> annotation)
+   {
       if (metadata != null)
       {
          MethodSignature signature = new MethodSignature(m.getName(), m.getParameterTypes());
          MetaData methodMD = metadata.getComponentMetaData(signature);
          if (methodMD != null)
          {
-            Object val = methodMD.getAnnotation(annotation);
+            T val = methodMD.getAnnotation(annotation);
             if (val != null) return val;
          }
       }
@@ -601,7 +603,8 @@
       if (annotations.isDisabled(m,annotation))
          return null;
 
-      Object value = annotations.resolveAnnotation(m, annotation);
+      //MUST call this instead of AR.resolveTypedClassAnnotation since EJB3 overrides AR.resolveClassAnnotation
+      T value = (T)annotations.resolveAnnotation(m, annotation);
       if (value == null && metadata == null) 
       {
          value = AnnotationElement.getVisibleAnnotation(m, annotation);
@@ -609,19 +612,35 @@
       return value;
    }
 
-   public Object resolveAnnotation(Method m, Class[] annotationChoices)
+   public Object resolveAnnotation(Method m, Class<?>[] annotationChoices)
    {
-      for (Class ann : annotationChoices)
+      for (Class<?> ann : annotationChoices)
       {
-         Object val = resolveAnnotation(m, annotationChoices);
+         Object val = resolveTypedAnnotation(m, (Class<? extends Annotation>)ann);
          if (val != null) return val;
       }
       return null;
    }
 
-   public Object resolveAnnotation(Field f, Class annotation)
+   public <T extends Annotation> T resolveTypedAnnotation(Method m, Class<T>[] annotationChoices)
    {
-      Object value = null;
+      for (Class<T> ann : annotationChoices)
+      {
+         T val = resolveTypedAnnotation(m, ann);
+         if (val != null) return val;
+      }
+      return null;
+   }
+
+
+   public Object resolveAnnotation(Field f, Class<? extends Annotation> annotation)
+   {
+      return resolveTypedAnnotation(f, annotation);
+   }
+   
+   public <T extends Annotation> T resolveTypedAnnotation(Field f, Class<T> annotation)
+   {
+      T value = null;
       if (metadata != null)
       {
          FieldSignature signature = new FieldSignature(f);
@@ -633,7 +652,8 @@
          }
       }
       
-      value = annotations.resolveAnnotation(f, annotation);
+      //MUST call this instead of AR.resolveTypedClassAnnotation since EJB3 overrides AR.resolveClassAnnotation
+      value = (T)annotations.resolveAnnotation(f, annotation);
       if (value == null && metadata == null)
       {
          value = AnnotationElement.getVisibleAnnotation(f, annotation);
@@ -641,9 +661,14 @@
       return value;
    }
 
-   public Object resolveAnnotation(Constructor c, Class annotation)
+   public Object resolveAnnotation(Constructor<?> c, Class<? extends Annotation> annotation)
    {
-      Object value = null;
+      return resolveTypedAnnotation(c, annotation);
+   }
+   
+   public <T extends Annotation> T resolveTypedAnnotation(Constructor<?> c, Class<T> annotation)
+   {
+      T value = null;
       if (metadata != null)
       {
          ConstructorSignature signature = new ConstructorSignature(c);
@@ -655,7 +680,8 @@
          }
       }
       
-      value = annotations.resolveAnnotation(c, annotation);
+      //MUST call this instead of AR.resolveTypedClassAnnotation since EJB3 overrides AR.resolveClassAnnotation
+      value = (T)annotations.resolveAnnotation(c, annotation);
       if (value == null && metadata == null)
       {
          value = AnnotationElement.getVisibleAnnotation(c, annotation);
@@ -668,12 +694,12 @@
       return hasAnnotation(0, m, annotation, null);
    }
 
-   public boolean hasAnnotation(Method m, Class annotation)
+   public boolean hasAnnotation(Method m, Class<? extends Annotation> annotation)
    {
       return hasAnnotation(0, m, null, annotation);
    }
 
-   private boolean hasAnnotation(long hash, Method m, String annotation, Class annotationClass)
+   private boolean hasAnnotation(long hash, Method m, String annotation, Class<? extends Annotation> annotationClass)
    {
       if (annotation == null && annotationClass == null)
       {
@@ -686,7 +712,7 @@
       }
       if (metadata != null)
       {
-         if (hasJoinPointAnnotation(m.getDeclaringClass(), new MethodSignature(m), annotationClass))
+         if (hasJoinPointAnnotation(m.getDeclaringClass(), new MethodSignature(m), annotation))
          {
             return true;
          }
@@ -711,7 +737,7 @@
    {
       if (metadata != null)
       {
-         if (hasJoinPointAnnotationFromStringName(m.getDeclaringClass(), new FieldSignature(m), annotation))
+         if (hasJoinPointAnnotation(m.getDeclaringClass(), new FieldSignature(m), annotation))
          {
             return true;
          }
@@ -735,7 +761,7 @@
    {
       if (metadata != null)
       {
-         if (hasJoinPointAnnotationFromStringName(m.getDeclaringClass(), new ConstructorSignature(m), annotation))
+         if (hasJoinPointAnnotation(m.getDeclaringClass(), new ConstructorSignature(m), annotation))
          {
             return true;
          }
@@ -750,53 +776,21 @@
       }
       catch (Exception e)
       {
-         throw new RuntimeException(e);  //To change body of catch statement use Options | File Templates.
+         throw new RuntimeException(e);
       }
       return false;
    }
 
-   private boolean hasJoinPointAnnotationFromStringName(Class declaringClass, org.jboss.metadata.spi.signature.Signature sig, String annotationName)
+   private boolean hasJoinPointAnnotation(Class<?> declaringClass, org.jboss.metadata.spi.signature.Signature sig, String annotation)
    {
-      try
-      {
-         if (metadata != null)
-         {
-            ClassLoader cl = SecurityActions.getClassLoader(declaringClass);
-            if (cl == null)
-            {
-               cl = SecurityActions.getContextClassLoader();
-            }
-            if (cl != null)
-            {
-               Class annotationClass = cl.loadClass(annotationName);
-               if (annotationClass != null)
-               {
-                  return this.hasJoinPointAnnotation(declaringClass, sig, annotationClass);
-               }
-            }
-         }
-      }
-      catch (ClassNotFoundException e)
-      {
-         //The "annotation" is probably aop metadata for which there will be no corresponding class
-      }
-      catch(Exception e)
-      {
-         throw new RuntimeException(e);
-      }
-      return false;
-   }
-   
-   private boolean hasJoinPointAnnotation(Class declaringClass, org.jboss.metadata.spi.signature.Signature sig, Class annotationClass)
-   {
       if (metadata != null)
       {
-         if (annotationClass != null)
+         if (annotation != null)
          {
             MetaData md = metadata.getComponentMetaData(sig);
             if (md != null)
             {
-               if (md.isAnnotationPresent(annotationClass))
+               if (md.isMetaDataPresent(annotation))
                   return true;
             }
          }
@@ -876,7 +870,7 @@
       doesHaveAspects = adviceBindings.size() > 0;
    }
 
-   public synchronized void removeAdviceBindings(ArrayList bindings)
+   public synchronized void removeAdviceBindings(ArrayList<AdviceBinding> bindings)
    {
       adviceBindings.removeAll(bindings);
       rebuildInterceptors();
@@ -937,7 +931,7 @@
       perInstanceAspectDefinitions.remove(def);
    }
 
-   public Set getPerInstanceAspectDefinitions()
+   public Set<AspectDefinition> getPerInstanceAspectDefinitions()
    {
       return perInstanceAspectDefinitions;
    }
@@ -946,10 +940,10 @@
 
    public void addPerInstanceJoinpointAspect(Joinpoint joinpoint, AspectDefinition def)
    {
-      Set joinpoints = (Set) perInstanceJoinpointAspectDefinitions.get(def);
+      Set<Joinpoint> joinpoints = perInstanceJoinpointAspectDefinitions.get(def);
       if (joinpoints == null)
       {
-         joinpoints = new CopyOnWriteArraySet();
+         joinpoints = new CopyOnWriteArraySet<Joinpoint>();
          initPerInstanceJoinpointAspectDefinitionsMap();
          perInstanceJoinpointAspectDefinitions.put(def, joinpoints);
          def.registerAdvisor(this);
@@ -957,13 +951,13 @@
       joinpoints.add(joinpoint);
    }
 
-   void addPerInstanceJoinpointAspect(Set joinpoints, AspectDefinition def)
+   void addPerInstanceJoinpointAspect(Set<Joinpoint> joinpoints, AspectDefinition def)
    {
       initPerInstanceJoinpointAspectDefinitionsMap();
-      Set setJoinpoints = (Set) perInstanceJoinpointAspectDefinitions.get(def);
+      Set<Joinpoint> setJoinpoints = perInstanceJoinpointAspectDefinitions.get(def);
       if (setJoinpoints == null)
       {
-         setJoinpoints = new CopyOnWriteArraySet();
+         setJoinpoints = new CopyOnWriteArraySet<Joinpoint>();
          perInstanceJoinpointAspectDefinitions.put(def, setJoinpoints);
          def.registerAdvisor(this);
       }
@@ -975,7 +969,7 @@
       perInstanceJoinpointAspectDefinitions.remove(def);
    }
 
-   public Map getPerInstanceJoinpointAspectDefinitions()
+   public Map<AspectDefinition, Set<Joinpoint>> getPerInstanceJoinpointAspectDefinitions()
    {
       return perInstanceJoinpointAspectDefinitions;
    }
@@ -1009,11 +1003,10 @@
       AdviceInterceptorKey key = new AdviceInterceptorKey(adviceName, joinpoint);
       synchronized (adviceInterceptors)
       {
-         Map map = null;
-         map = (Map) adviceInterceptors.get(def);
+         Map<String, Interceptor> map = adviceInterceptors.get(def);
          if (map != null)
          {
-            return (Interceptor) map.get(key);
+            return map.get(key);
          }
       }
       return null;
@@ -1023,10 +1016,10 @@
    {
       synchronized (adviceInterceptors)
       {
-         Map map = (Map) adviceInterceptors.get(def);
+         Map<String, Interceptor> map = adviceInterceptors.get(def);
          if (map == null)
          {
-            map = new HashMap();
+            map = new HashMap<String, Interceptor>();
             adviceInterceptors.put(def, map);
          }
          map.put(adviceName, interceptor);
@@ -1119,6 +1112,9 @@
    
    protected void finalizeMethodChain()
    {
+      boolean maintain = AspectManager.maintainAdvisorMethodInterceptors;
+      TLongObjectHashMap newMethodInfos = (maintain) ? new TLongObjectHashMap() : null;
+      
       long[] keys = methodInfos.keys();
       for (int i = 0; i < keys.length; i++)
       {
@@ -1132,7 +1128,13 @@
             interceptors = applyPrecedence(list.toArray(new Interceptor[list.size()]));
          }
          info.setInterceptors(interceptors);
+         
+         if (maintain)
+         {
+            newMethodInfos.put(keys[i], info);
+         }
       }
+      methodInterceptors = newMethodInfos;
    }
 
    public InvocationResponse dynamicInvoke(Object target, Invocation invocation)
@@ -1144,7 +1146,7 @@
          Interceptor[] aspects = null;
          MethodInvocation methodInvocation = (MethodInvocation) invocation;
          long hash = methodInvocation.getMethodHash();
-         MethodInfo info = (MethodInfo) methodInfos.getMethodInfo(hash);
+         MethodInfo info = methodInfos.getMethodInfo(hash);
          aspects = info.getInterceptors();
          if (aspects == null) aspects = new Interceptor[0];
          if (target != null && target instanceof Advised)
@@ -1164,17 +1166,24 @@
       throw new RuntimeException("dynamic field invocations not supported yet!");
    }
 
+   /**
+    * EJB3 counts on this being unchecked
+    */
+   @SuppressWarnings("unchecked")
    public Class getClazz()
    {
       return clazz;
    }
 
-   void setClazz(Class clazz)
+   void setClazz(Class<?> clazz)
    {
       this.clazz = clazz;
    }
 
-   public static String getSimpleName(Class clazz)
+   /**
+    * @deprecated Use Class.getSimpleName() instead
+    */
+   public static String getSimpleName(Class<?> clazz)
    {
       String name = clazz.getName();
       int lastIndex = name.lastIndexOf('.');
@@ -1201,8 +1210,8 @@
          info.setIndex(i);
          try
          {
-            final String name = ConstructorExecutionTransformer.constructorFactory(getSimpleName(clazz));
-            final Class[] types = constructors[i].getParameterTypes();
+            final String name = ConstructorExecutionTransformer.constructorFactory(clazz.getSimpleName());
+            final Class<?>[] types = constructors[i].getParameterTypes();
             Method method = AccessController.doPrivileged(new PrivilegedExceptionAction<Method>()
             {
                public Method run() throws Exception
@@ -1258,7 +1267,7 @@
 
          try
          {
-            Field infoField = clazz.getDeclaredField(ConstructionTransformer.getConstructionInfoFieldName(getSimpleName(clazz), i));
+            Field infoField = clazz.getDeclaredField(ConstructionTransformer.getConstructionInfoFieldName(clazz.getSimpleName(), i));
             infoField.setAccessible(true);
             infoField.set(null, new WeakReference<ConstructionInfo>(info));
          }
@@ -1333,7 +1342,7 @@
    {
       for (int i = 0; i < constructors.length; i++)
       {
-         Constructor constructor = constructors[i];
+         Constructor<?> constructor = constructors[i];
          if (binding.getPointcut().matchesExecution(this, constructor))
          {
             if (AspectManager.verbose) System.err.println("[debug] constructor matched binding: " + constructor);
@@ -1351,7 +1360,7 @@
          for (int i = 0; i < constructionInfos.length ;i++)
          {
             ConstructionInfo info = constructionInfos[i];
-            Constructor constructor = info.getConstructor();
+            Constructor<?> constructor = info.getConstructor();
             if (binding.getPointcut().matchesConstruction(this, constructor))
             {
                if (AspectManager.verbose) System.err.println("[debug] construction matched binding: " + constructor);
@@ -1384,7 +1393,7 @@
       {
          ArrayList<Interceptor> cflowChain = new ArrayList<Interceptor>();
          createInterceptorChain(binding.getInterceptorFactories(), cflowChain, joinpoint);
-         Interceptor[] cflowInterceptors = (Interceptor[]) cflowChain.toArray(new Interceptor[cflowChain.size()]);
+         Interceptor[] cflowInterceptors = cflowChain.toArray(new Interceptor[cflowChain.size()]);
          curr.add(new CFlowInterceptor(binding.getCFlowString(), binding.getCFlow(), cflowInterceptors));
       }
       else
@@ -1448,7 +1457,7 @@
          {
             try
             {
-               AccessController.doPrivileged(new PrivilegedExceptionAction()
+               AccessController.doPrivileged(new PrivilegedExceptionAction<Object>()
                {
                   public Object run()
                   {
@@ -1481,21 +1490,19 @@
    public void cleanup()
    {
       //AspectDefinitions have strong links back to us
-      for(Iterator it = perInstanceAspectDefinitions.iterator() ; it.hasNext() ; )
+      for(AspectDefinition def : perInstanceAspectDefinitions)
       {
-         AspectDefinition def = (AspectDefinition)it.next();
          removePerInstanceAspect(def);
          def.unregisterAdvisor(this);
       }
       
-      for(Iterator it = perInstanceJoinpointAspectDefinitions.keySet().iterator() ; it.hasNext() ; )
+      for(AspectDefinition def : perInstanceJoinpointAspectDefinitions.keySet())
       {
-         AspectDefinition def = (AspectDefinition)it.next();
          removePerInstanceJoinpointAspect(def);
          def.unregisterAdvisor(this);
       }
 
-      AspectDefinition[] defs = (AspectDefinition[])adviceInterceptors.keySet().toArray(new AspectDefinition[adviceInterceptors.size()]);
+      AspectDefinition[] defs = adviceInterceptors.keySet().toArray(new AspectDefinition[adviceInterceptors.size()]);
       for(int i = 0 ; i < defs.length ; i++)
       {
          if (defs[i].getScope() == Scope.PER_CLASS)
@@ -1511,38 +1518,17 @@
       }
    }
    
-   /**
-    * Lock for write
-    */
-   protected void lockWrite()
-   {
-      lock.writeLock().lock();
-   }
-
-   /**
-    * Unlock for write
-    */
-   protected void unlockWrite()
-   {
-      lock.writeLock().unlock();
-   }
-
    protected void initInterfaceIntroductionsList()
    {
       if (interfaceIntroductions == UnmodifiableEmptyCollections.EMPTY_ARRAYLIST)
       {
-         lockWrite();
-         try
+         synchronized(lazyCollectionLock)
          {
             if (interfaceIntroductions == UnmodifiableEmptyCollections.EMPTY_ARRAYLIST)
             {
                interfaceIntroductions = new ArrayList<InterfaceIntroduction>();
             }
          }
-         finally
-         {
-            unlockWrite();
-         }
       }
    }
    
@@ -1550,18 +1536,13 @@
    {
       if (classMetaDataBindings == UnmodifiableEmptyCollections.EMPTY_ARRAYLIST)
       {
-         lockWrite();
-         try
+         synchronized(lazyCollectionLock)
          {
             if (classMetaDataBindings == UnmodifiableEmptyCollections.EMPTY_ARRAYLIST)
             {
-               classMetaDataBindings = new ArrayList();
+               classMetaDataBindings = new ArrayList<ClassMetaDataBinding>();
             }
          }
-         finally
-         {
-            unlockWrite();
-         }
       }
    }
    
@@ -1569,18 +1550,13 @@
    {
       if (perInstanceAspectDefinitions == UnmodifiableEmptyCollections.EMPTY_COPYONWRITE_ARRAYSET)
       {
-         lockWrite();
-         try
+         synchronized(lazyCollectionLock)
          {
             if (perInstanceAspectDefinitions == UnmodifiableEmptyCollections.EMPTY_COPYONWRITE_ARRAYSET)
             {
-               perInstanceAspectDefinitions = new CopyOnWriteArraySet();
+               perInstanceAspectDefinitions = new CopyOnWriteArraySet<AspectDefinition>();
             }
          }
-         finally
-         {
-            unlockWrite();
-         }
       }
    }
    
@@ -1588,18 +1564,13 @@
    {
       if (perInstanceJoinpointAspectDefinitions == UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP)
       {
-         lockWrite();
-         try
+         synchronized(lazyCollectionLock)
          {
             if (perInstanceJoinpointAspectDefinitions == UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP)
             {
-               perInstanceJoinpointAspectDefinitions = new ConcurrentHashMap();
+               perInstanceJoinpointAspectDefinitions = new ConcurrentHashMap<AspectDefinition, Set<Joinpoint>>();
             }
          }
-         finally
-         {
-            unlockWrite();
-         }
       }
    }
 
@@ -1607,18 +1578,13 @@
    {
       if (advisedMethods == UnmodifiableEmptyCollections.EMPTY_TLONG_OBJECT_HASHMAP)
       {
-         lockWrite();
-         try
+         synchronized(lazyCollectionLock)
          {
             if (advisedMethods == UnmodifiableEmptyCollections.EMPTY_TLONG_OBJECT_HASHMAP)
             {
                advisedMethods = new TLongObjectHashMap();
             }
          }
-         finally
-         {
-            unlockWrite();
-         }
       }
    }
 }
\ No newline at end of file

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/AdvisorFactory.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/AdvisorFactory.java	2008-03-24 03:41:24 UTC (rev 71184)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/AdvisorFactory.java	2008-03-24 03:46:45 UTC (rev 71185)
@@ -48,10 +48,10 @@
    protected static final int OTHER_ADVISOR = 1000; //The jrockit aop advisor is in another jar which we should not depend on
    protected static int advisor = 0;
    
-   protected static Constructor otherAdvisorConstructor;
+   protected static Constructor<?> otherAdvisorConstructor;
    
-   private static final Class[] NO_ARGS = new Class[0];
-   private static final Class[] CONSTRUCTOR_SIG = new Class[] {String.class, AspectManager.class};
+   private static final Class<?>[] NO_ARGS = new Class<?>[0];
+   private static final Class<?>[] CONSTRUCTOR_SIG = new Class<?>[] {String.class, AspectManager.class};
    
    
    public static void initialise(String property)
@@ -72,7 +72,7 @@
             try
             {
                // FIXME ClassLoader - why should this class be visible from the context classloader?
-               Class otherAdvisorClass = SecurityActions.getContextClassLoader().loadClass(property);
+               Class<?> otherAdvisorClass = SecurityActions.getContextClassLoader().loadClass(property);
                otherAdvisorConstructor = otherAdvisorClass.getConstructor(CONSTRUCTOR_SIG);
             }
             catch (ClassNotFoundException e)
@@ -95,7 +95,7 @@
       }
    }
 
-   public static ClassAdvisor getClassAdvisor(Class clazz, AspectManager am)
+   public static ClassAdvisor getClassAdvisor(Class<?> clazz, AspectManager am)
    {
       return getClassAdvisor(clazz.getName(), am, clazz);
    }
@@ -105,7 +105,7 @@
       return getClassAdvisor(clazz.getName(), am, null);
    }
    
-   private static ClassAdvisor getClassAdvisor(String className, AspectManager am, Class loadedClass)
+   private static ClassAdvisor getClassAdvisor(String className, AspectManager am, Class<?> loadedClass)
    {
       if(advisor == CLASS)
       {

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/AspectAnnotationLoader.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/AspectAnnotationLoader.java	2008-03-24 03:41:24 UTC (rev 71184)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/AspectAnnotationLoader.java	2008-03-24 03:46:45 UTC (rev 71185)
@@ -99,11 +99,11 @@
       this.cl = cl;
    }
    
-   public void deployInputStreamIterator(Iterator it) throws Exception
+   public void deployInputStreamIterator(Iterator<InputStream> it) throws Exception
    {
       while (it.hasNext())
       {
-         InputStream stream = (InputStream) it.next();
+         InputStream stream = it.next();
          DataInputStream dstream = new DataInputStream(stream);
          ClassFile cf = null;
          try
@@ -158,11 +158,11 @@
       }
    }
    
-   public void undeployInputStreamIterator(Iterator it) throws Exception
+   public void undeployInputStreamIterator(Iterator<InputStream> it) throws Exception
    {
       while (it.hasNext())
       {
-         InputStream stream = (InputStream) it.next();
+         InputStream stream = it.next();
          DataInputStream dstream = new DataInputStream(stream);
          ClassFile cf = null;
          try
@@ -396,11 +396,11 @@
       {
          if (AspectManager.verbose && logger.isDebugEnabled()) logger.debug("Found top-level @Precedence in: " + cf.getName());
          
-         ArrayList entries = new ArrayList();
-         Iterator fields = cf.getFields().iterator();
+         ArrayList<PrecedenceDefEntry> entries = new ArrayList<PrecedenceDefEntry>();
+         Iterator<FieldInfo> fields = cf.getFields().iterator();
          while (fields.hasNext())
          {
-            FieldInfo finfo = (javassist.bytecode.FieldInfo) fields.next();
+            FieldInfo finfo = fields.next();
             AnnotationsAttribute mgroup = (AnnotationsAttribute) finfo.getAttribute(AnnotationsAttribute.visibleTag);
             if (mgroup == null) continue;
             javassist.bytecode.annotation.Annotation binfo = mgroup.getAnnotation(PrecedenceInterceptor.class.getName());
@@ -420,7 +420,7 @@
                }
             }
          }
-         PrecedenceDefEntry[] pentries = (PrecedenceDefEntry[])entries.toArray(new PrecedenceDefEntry[entries.size()]); 
+         PrecedenceDefEntry[] pentries = entries.toArray(new PrecedenceDefEntry[entries.size()]); 
          PrecedenceDef precedenceDef = new PrecedenceDef(cf.getName(), pentries);
          manager.addPrecedence(precedenceDef);
       }
@@ -438,10 +438,10 @@
    private void deployAspectMethodBindings(ClassFile cf, AspectDefinition def)
    throws Exception
    {
-      Iterator methods = cf.getMethods().iterator();
+      Iterator<MethodInfo> methods = cf.getMethods().iterator();
       while (methods.hasNext())
       {
-         javassist.bytecode.MethodInfo minfo = (javassist.bytecode.MethodInfo) methods.next();
+         MethodInfo minfo = methods.next();
          AnnotationsAttribute mgroup = (AnnotationsAttribute) minfo.getAttribute(AnnotationsAttribute.visibleTag);
          if (mgroup == null) continue;
          javassist.bytecode.annotation.Annotation binfo = mgroup.getAnnotation(Bind.class.getName());
@@ -506,10 +506,10 @@
    private void undeployAspectMethodBindings(ClassFile cf)
    throws Exception
    {
-      Iterator methods = cf.getMethods().iterator();
+      Iterator<MethodInfo> methods = cf.getMethods().iterator();
       while (methods.hasNext())
       {
-         javassist.bytecode.MethodInfo minfo = (javassist.bytecode.MethodInfo) methods.next();
+         MethodInfo minfo = methods.next();
          AnnotationsAttribute mgroup = (AnnotationsAttribute) minfo.getAttribute(AnnotationsAttribute.visibleTag);
          if (mgroup == null) continue;
          javassist.bytecode.annotation.Annotation binfo = mgroup.getAnnotation(Bind.class.getName());
@@ -569,10 +569,10 @@
    private void deployPointcuts(ClassFile cf)
    throws Exception
    {
-      Iterator fields = cf.getFields().iterator();
+      Iterator<FieldInfo> fields = cf.getFields().iterator();
       while (fields.hasNext())
       {
-         javassist.bytecode.FieldInfo finfo = (javassist.bytecode.FieldInfo) fields.next();
+         FieldInfo finfo = fields.next();
          AnnotationsAttribute mgroup = (AnnotationsAttribute) finfo.getAttribute(AnnotationsAttribute.visibleTag);
          if (mgroup == null) continue;
          javassist.bytecode.annotation.Annotation binfo = mgroup.getAnnotation(PointcutDef.class.getName());
@@ -588,10 +588,10 @@
    private void undeployPointcuts(ClassFile cf)
    throws Exception
    {
-      Iterator fields = cf.getFields().iterator();
+      Iterator<FieldInfo> fields = cf.getFields().iterator();
       while (fields.hasNext())
       {
-         javassist.bytecode.FieldInfo finfo = (javassist.bytecode.FieldInfo) fields.next();
+         FieldInfo finfo = fields.next();
          AnnotationsAttribute mgroup = (AnnotationsAttribute) finfo.getAttribute(AnnotationsAttribute.visibleTag);
          if (mgroup == null) continue;
          javassist.bytecode.annotation.Annotation binfo = mgroup.getAnnotation(PointcutDef.class.getName());
@@ -608,10 +608,10 @@
    private void deployMixins(ClassFile cf)
    throws Exception
    {
-      Iterator methods = cf.getMethods().iterator();
+      Iterator<MethodInfo> methods = cf.getMethods().iterator();
       while (methods.hasNext())
       {
-         javassist.bytecode.MethodInfo minfo = (javassist.bytecode.MethodInfo) methods.next();
+         MethodInfo minfo = methods.next();
          AnnotationsAttribute mgroup = (AnnotationsAttribute) minfo.getAttribute(AnnotationsAttribute.visibleTag);
          if (mgroup == null) continue;
          javassist.bytecode.annotation.Annotation binfo = mgroup.getAnnotation(Mixin.class.getName());
@@ -727,10 +727,10 @@
    private void undeployMixins(ClassFile cf)
    throws Exception
    {
-      Iterator methods = cf.getMethods().iterator();
+      Iterator<MethodInfo> methods = cf.getMethods().iterator();
       while (methods.hasNext())
       {
-         javassist.bytecode.MethodInfo minfo = (javassist.bytecode.MethodInfo) methods.next();
+         MethodInfo minfo = methods.next();
          AnnotationsAttribute mgroup = (AnnotationsAttribute) minfo.getAttribute(AnnotationsAttribute.visibleTag);
          if (mgroup == null) continue;
          javassist.bytecode.annotation.Annotation binfo = mgroup.getAnnotation(Mixin.class.getName());
@@ -744,10 +744,10 @@
    private void deployIntroductions(ClassFile cf)
    throws Exception
    {
-      Iterator fields = cf.getFields().iterator();
+      Iterator<FieldInfo> fields = cf.getFields().iterator();
       while (fields.hasNext())
       {
-         FieldInfo finfo = (javassist.bytecode.FieldInfo) fields.next();
+         FieldInfo finfo = fields.next();
          AnnotationsAttribute mgroup = (AnnotationsAttribute) finfo.getAttribute(AnnotationsAttribute.visibleTag);
          if (mgroup == null) continue;
          javassist.bytecode.annotation.Annotation binfo = mgroup.getAnnotation(Introduction.class.getName());
@@ -784,10 +784,10 @@
    private void undeployIntroductions(ClassFile cf)
    throws Exception
    {
-      Iterator fields = cf.getFields().iterator();
+      Iterator<FieldInfo> fields = cf.getFields().iterator();
       while (fields.hasNext())
       {
-         FieldInfo finfo = (javassist.bytecode.FieldInfo) fields.next();
+         FieldInfo finfo = fields.next();
          AnnotationsAttribute mgroup = (AnnotationsAttribute) finfo.getAttribute(AnnotationsAttribute.visibleTag);
          if (mgroup == null) continue;
          javassist.bytecode.annotation.Annotation binfo = mgroup.getAnnotation(Introduction.class.getName());
@@ -801,10 +801,10 @@
 
    private void deployTypedefs(ClassFile cf) throws Exception
    {
-      Iterator fields = cf.getFields().iterator();
+      Iterator<FieldInfo> fields = cf.getFields().iterator();
       while (fields.hasNext())
       {
-         FieldInfo finfo = (javassist.bytecode.FieldInfo) fields.next();
+         FieldInfo finfo = fields.next();
          AnnotationsAttribute mgroup = (AnnotationsAttribute) finfo.getAttribute(AnnotationsAttribute.visibleTag);
          if (mgroup == null) continue;
          javassist.bytecode.annotation.Annotation binfo = mgroup.getAnnotation(TypeDef.class.getName());
@@ -821,10 +821,10 @@
 
    private void undeployTypedefs(ClassFile cf) throws Exception
    {
-      Iterator fields = cf.getFields().iterator();
+      Iterator<FieldInfo> fields = cf.getFields().iterator();
       while (fields.hasNext())
       {
-         FieldInfo finfo = (javassist.bytecode.FieldInfo) fields.next();
+         FieldInfo finfo = fields.next();
          AnnotationsAttribute mgroup = (AnnotationsAttribute) finfo.getAttribute(AnnotationsAttribute.visibleTag);
          if (mgroup == null) continue;
          javassist.bytecode.annotation.Annotation binfo = mgroup.getAnnotation(TypeDef.class.getName());
@@ -844,10 +844,10 @@
 
    private void deployCFlowStackDefs(ClassFile cf) throws Exception
    {
-      Iterator fields = cf.getFields().iterator();
+      Iterator<FieldInfo> fields = cf.getFields().iterator();
       while (fields.hasNext())
       {
-         FieldInfo finfo = (javassist.bytecode.FieldInfo) fields.next();
+         FieldInfo finfo = fields.next();
          AnnotationsAttribute mgroup = (AnnotationsAttribute) finfo.getAttribute(AnnotationsAttribute.visibleTag);
          if (mgroup == null) continue;
          javassist.bytecode.annotation.Annotation binfo = mgroup.getAnnotation(CFlowStackDef.class.getName());
@@ -871,10 +871,10 @@
 
    private void undeployCFlowStackDefs(ClassFile cf) throws Exception
    {
-      Iterator fields = cf.getFields().iterator();
+      Iterator<FieldInfo> fields = cf.getFields().iterator();
       while (fields.hasNext())
       {
-         FieldInfo finfo = (javassist.bytecode.FieldInfo) fields.next();
+         FieldInfo finfo = fields.next();
          AnnotationsAttribute mgroup = (AnnotationsAttribute) finfo.getAttribute(AnnotationsAttribute.visibleTag);
          if (mgroup == null) continue;
          javassist.bytecode.annotation.Annotation binfo = mgroup.getAnnotation(CFlowStackDef.class.getName());
@@ -892,10 +892,10 @@
 
    private void deployPrepares(ClassFile cf) throws Exception
    {
-      Iterator fields = cf.getFields().iterator();
+      Iterator<FieldInfo> fields = cf.getFields().iterator();
       while (fields.hasNext())
       {
-         FieldInfo finfo = (javassist.bytecode.FieldInfo) fields.next();
+         FieldInfo finfo = fields.next();
          AnnotationsAttribute mgroup = (AnnotationsAttribute) finfo.getAttribute(AnnotationsAttribute.visibleTag);
          if (mgroup == null) continue;
          javassist.bytecode.annotation.Annotation binfo = mgroup.getAnnotation(Prepare.class.getName());
@@ -911,10 +911,10 @@
 
    private void undeployPrepares(ClassFile cf) throws Exception
    {
-      Iterator fields = cf.getFields().iterator();
+      Iterator<FieldInfo> fields = cf.getFields().iterator();
       while (fields.hasNext())
       {
-         FieldInfo finfo = (javassist.bytecode.FieldInfo) fields.next();
+         FieldInfo finfo = fields.next();
          AnnotationsAttribute mgroup = (AnnotationsAttribute) finfo.getAttribute(AnnotationsAttribute.visibleTag);
          if (mgroup == null) continue;
          javassist.bytecode.annotation.Annotation binfo = mgroup.getAnnotation(Prepare.class.getName());
@@ -932,10 +932,10 @@
    
    private void deployAnnotationIntroductions(ClassFile cf) throws Exception
    {
-      Iterator fields = cf.getFields().iterator();
+      Iterator<FieldInfo> fields = cf.getFields().iterator();
       while (fields.hasNext())
       {
-         FieldInfo finfo = (javassist.bytecode.FieldInfo) fields.next();
+         FieldInfo finfo = fields.next();
          AnnotationsAttribute mgroup = (AnnotationsAttribute) finfo.getAttribute(AnnotationsAttribute.visibleTag);
          if (mgroup == null) continue;
          javassist.bytecode.annotation.Annotation binfo = mgroup.getAnnotation(AnnotationIntroductionDef.class.getName());
@@ -955,10 +955,10 @@
 
    private void undeployAnnotationIntroductions(ClassFile cf) throws Exception
    {
-      Iterator fields = cf.getFields().iterator();
+      Iterator<FieldInfo> fields = cf.getFields().iterator();
       while (fields.hasNext())
       {
-         FieldInfo finfo = (javassist.bytecode.FieldInfo) fields.next();
+         FieldInfo finfo = fields.next();
          AnnotationsAttribute mgroup = (AnnotationsAttribute) finfo.getAttribute(AnnotationsAttribute.visibleTag);
          if (mgroup == null) continue;
          javassist.bytecode.annotation.Annotation binfo = mgroup.getAnnotation(AnnotationIntroductionDef.class.getName());
@@ -978,10 +978,10 @@
 
    private void deployDeclares(ClassFile cf) throws Exception
    {
-      Iterator fields = cf.getFields().iterator();
+      Iterator<FieldInfo> fields = cf.getFields().iterator();
       while (fields.hasNext())
       {
-         FieldInfo finfo = (javassist.bytecode.FieldInfo) fields.next();
+         FieldInfo finfo = fields.next();
          AnnotationsAttribute mgroup = (AnnotationsAttribute) finfo.getAttribute(AnnotationsAttribute.visibleTag);
          if (mgroup == null) continue;
          javassist.bytecode.annotation.Annotation dwinfo = mgroup.getAnnotation(DeclareWarning.class.getName());

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/AspectManager.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/AspectManager.java	2008-03-24 03:41:24 UTC (rev 71184)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/AspectManager.java	2008-03-24 03:46:45 UTC (rev 71185)
@@ -28,6 +28,7 @@
 import java.security.ProtectionDomain;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -35,10 +36,8 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.StringTokenizer;
 import java.util.WeakHashMap;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
 
 import javassist.ClassPool;
 import javassist.CtClass;
@@ -106,57 +105,61 @@
         implements Translator
 {
    private static final Logger logger = AOPLogger.getLogger(AspectManager.class);
-   
-   /** Read/Write lock to be used when lazy creating the collections */
-   ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
 
+   /** Lock to be used when lazy creating the collections */
+   Object lazyCollectionLock = new Object();
+
    /** Advisors registered with this manager/domain */
-   protected final WeakHashMap advisors = new WeakHashMap();
-   
+   protected final WeakHashMap<Class<?>, WeakReference<Advisor>> advisors = new WeakHashMap<Class<?>, WeakReference<Advisor>>();
+
    /** A map of domains by class, maintaned by the top level AspectManager */
-   protected volatile WeakHashMap subDomainsPerClass = UnmodifiableEmptyCollections.EMPTY_WEAK_HASHMAP;
-   
+   protected volatile WeakHashMap<Class<?>, WeakReference<Domain>> subDomainsPerClass = UnmodifiableEmptyCollections.EMPTY_WEAK_HASHMAP;
+
    /** A map of domains by name */
-   protected volatile WeakValueHashMap subDomainsByName = UnmodifiableEmptyCollections.EMPTY_WEAK_VALUE_HASHMAP;
+   protected volatile WeakValueHashMap<String, Domain> subDomainsByName = UnmodifiableEmptyCollections.EMPTY_WEAK_VALUE_HASHMAP;
 
    /** Each domain may have sub domains interested in changes happening in this manager/domain */
-   protected volatile WeakHashMap subscribedSubDomains = UnmodifiableEmptyCollections.EMPTY_WEAK_HASHMAP;
+   protected volatile WeakHashMap<Domain, Object> subscribedSubDomains = UnmodifiableEmptyCollections.EMPTY_WEAK_HASHMAP;
 
    /** A queue for adding new subscribed subdomains to */
-   protected volatile WeakHashMap subscribedSubDomainsQueue = UnmodifiableEmptyCollections.EMPTY_WEAK_HASHMAP;
+   protected volatile WeakHashMap<Domain, Object> subscribedSubDomainsQueue = UnmodifiableEmptyCollections.EMPTY_WEAK_HASHMAP;
    protected int subscribedDomainQueueRef;
 
-   protected volatile LinkedHashMap interfaceIntroductions = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
-   protected volatile LinkedHashMap arrayReplacements = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
-   protected volatile LinkedHashMap arrayBindings = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
-   protected volatile LinkedHashMap annotationIntroductions =UnmodifiableEmptyCollections. EMPTY_LINKED_HASHMAP;
-   protected volatile LinkedHashMap annotationOverrides = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
-   protected volatile LinkedHashMap bindings = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
-   protected volatile LinkedHashMap typedefs = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
-   protected volatile HashMap interceptorFactories = UnmodifiableEmptyCollections.EMPTY_HASHMAP;
-   protected volatile HashMap classMetaDataLoaders = UnmodifiableEmptyCollections.EMPTY_HASHMAP;
-   protected volatile HashMap interceptorStacks = UnmodifiableEmptyCollections.EMPTY_HASHMAP;
-   protected volatile HashMap declares = UnmodifiableEmptyCollections.EMPTY_HASHMAP;
-   protected volatile ConcurrentHashMap cflowStacks = UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP;
-   protected volatile ConcurrentHashMap dynamicCFlows = UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP;
-   protected volatile ConcurrentHashMap aspectDefinitions = UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP;
-   protected volatile ConcurrentHashMap perVMAspects = UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP;
+   protected volatile LinkedHashMap<String, InterfaceIntroduction> interfaceIntroductions = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
+   protected volatile LinkedHashMap<String, ArrayReplacement> arrayReplacements = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
+   protected volatile LinkedHashMap<String, ArrayBinding> arrayBindings = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
+   protected volatile LinkedHashMap<String, AnnotationIntroduction> annotationIntroductions =UnmodifiableEmptyCollections. EMPTY_LINKED_HASHMAP;
+   protected volatile LinkedHashMap<String, AnnotationIntroduction> annotationOverrides = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
+   protected volatile LinkedHashMap<String, AdviceBinding> bindings = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
+   protected volatile LinkedHashMap<String, Typedef> typedefs = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
+   protected volatile HashMap<String, InterceptorFactory> interceptorFactories = UnmodifiableEmptyCollections.EMPTY_HASHMAP;
+   protected volatile HashMap<String,ClassMetaDataLoader> classMetaDataLoaders = UnmodifiableEmptyCollections.EMPTY_HASHMAP;
+   protected volatile HashMap<String, AdviceStack> interceptorStacks = UnmodifiableEmptyCollections.EMPTY_HASHMAP;
+   protected volatile HashMap<String, DeclareDef> declares = UnmodifiableEmptyCollections.EMPTY_HASHMAP;
+   protected volatile ConcurrentHashMap<String, CFlowStack> cflowStacks = UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP;
+   protected volatile ConcurrentHashMap<String, DynamicCFlowDefinition> dynamicCFlows = UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP;
+   protected volatile ConcurrentHashMap<String, AspectDefinition> aspectDefinitions = UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP;
+   protected volatile ConcurrentHashMap<String, Object> perVMAspects = UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP;
 
    /** class name prefixes to explicitly exclude unless contained in include. Maintained by top-level AspectManager */
-   protected volatile ArrayList exclude = UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
+   protected volatile ArrayList<String> exclude = UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
 
    /** class name prefixes to explicitly include, this overrides whatever was set in exclude. Maintained by top-level AspectManager */
-   protected volatile ArrayList include = UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
+   protected volatile ArrayList<String> include = UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
 
    /** A set of wildcard enabled classnames that will be ignored no matter if they have been included. Maintained by top-level AspectManager */
-   protected volatile ArrayList ignore = UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
+   protected volatile ArrayList<String> ignore = UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
 
+   /** A set of annotation names that will be included even though they are invisible. */
+   protected List<String> includeInvisibleAnnotations = Collections .emptyList();
+
    /** ClassExpressions built from ignore. Maintained by top-level AspectManager */
    protected ClassExpression[] ignoreExpressions = new ClassExpression[0];
 
-   protected volatile LinkedHashMap pointcuts = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
+
+   protected volatile LinkedHashMap<String, Pointcut> pointcuts = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
    // contains pointcuts-binding association info
-   protected volatile LinkedHashMap pointcutInfos = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
+   protected volatile LinkedHashMap<String, PointcutInfo> pointcutInfos = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
    // these fields represent whether there are certain pointcut types.
    // for performance reasons the transformers and binders can make a lot of us of this.
    protected boolean execution = false;
@@ -168,9 +171,9 @@
    protected boolean withincode = false;
    public static boolean classicOrder = false;
 
-   protected volatile LinkedHashMap classMetaData = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
-   protected volatile HashMap containers = UnmodifiableEmptyCollections.EMPTY_HASHMAP;
-   protected volatile LinkedHashMap precedenceDefs = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
+   protected volatile LinkedHashMap<String, ClassMetaDataBinding> classMetaData = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
+   protected volatile HashMap<String, DomainDefinition> containers = UnmodifiableEmptyCollections.EMPTY_HASHMAP;
+   protected volatile LinkedHashMap<String, PrecedenceDef> precedenceDefs = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
    protected PrecedenceDefEntry[] sortedPrecedenceDefEntries;
    protected WeavingStrategy weavingStrategy;
    
@@ -181,11 +184,11 @@
    
    // indicates that the transformation process has begun
    protected boolean transformationStarted = false;
-   
+
    /** The classloader scoping policy */
    // This shouldn't really be static (artifact of singleton and self-bootstrap design)
    private static AOPClassLoaderScopingPolicy classLoaderScopingPolicy;
-   
+
    //Keeps track of if we need to convert references etc for a given class. Domains for scoped classloaders will have their own version of this
    protected static InterceptionMarkers interceptionMarkers = new InterceptionMarkers();
    
@@ -205,8 +208,15 @@
    public static boolean verbose = false;
 
    /**
+    * Whether or not we should maintain the deprecated Advisor.methodInterceptors field
+    * This is required in jboss 4.x for backwards compatibility with EJB 3
+    * See JBAOP-517
+    */
+   public static boolean maintainAdvisorMethodInterceptors;
+
+   /**
     * Get the top level aspect manager
-    * 
+    *
     * @return the top level aspect manager
     */
    public static synchronized AspectManager getTopLevelAspectManager()
@@ -228,10 +238,10 @@
    {
       return instance(SecurityActions.getContextClassLoader());
    }
-   
+
    /**
     * Get the aspect manager for a classloader
-    * 
+    *
     * @param loadingClassLoader the classloader
     * @return the aspect manager
     */
@@ -249,9 +259,9 @@
 
    /**
     * Initialise the manager if not already dones so<p>
-    * 
+    *
     * This method should be invoked in a synchronized block
-    * 
+    *
     * @return the manager
     */
    private static AspectManager initManager()
@@ -274,10 +284,12 @@
                }
                manager = new AspectManager();
                //Initialise frequently used fields needed by the top-level manager
-               manager.subDomainsPerClass = new WeakHashMap();
-               manager.exclude = new ArrayList();
-               manager.include = new ArrayList();
-               manager.ignore = new ArrayList();
+               manager.subDomainsPerClass = new WeakHashMap<Class<?>, WeakReference<Domain>>();
+               manager.exclude = new ArrayList<String>();
+               manager.include = new ArrayList<String>();
+               manager.ignore = new ArrayList<String>();
+               manager.includeInvisibleAnnotations = new ArrayList<String>();
+               
 
                AOPClassPoolRepository.getInstance().setAspectManager(manager);
 
@@ -288,36 +300,27 @@
                String exclude = System.getProperty("jboss.aop.exclude", null);
                if (exclude != null)
                {
-                  ArrayList list = new ArrayList();
-                  StringTokenizer tokenizer = new StringTokenizer(exclude, ",");
-                  while (tokenizer.hasMoreTokens())
-                  {
-                     list.add(tokenizer.nextToken().trim());
-                  }
+                  ArrayList<String> list = splitString(exclude, ",");
                   manager.setExclude(list);
                }
                String include = System.getProperty("jboss.aop.include", null);
                if (include != null)
                {
-                  ArrayList list = new ArrayList();
-                  StringTokenizer tokenizer = new StringTokenizer(include, ",");
-                  while (tokenizer.hasMoreTokens())
-                  {
-                     list.add(tokenizer.nextToken().trim());
-                  }
+                  ArrayList<String> list = splitString(include, ",");
                   manager.setInclude(list);
                }
                String ignore = System.getProperty("jboss.aop.ignore", null);
                if (ignore != null)
                {
-                  ArrayList list = new ArrayList();
-                  StringTokenizer tokenizer = new StringTokenizer(ignore, ",");
-                  while (tokenizer.hasMoreTokens())
-                  {
-                     list.add(tokenizer.nextToken().trim());
-                  }
+                  ArrayList<String> list = splitString(ignore, ",");
                   manager.setIgnore(list);
                }
+               String invisibleAnnotations = System.getProperty("jboss.aop.invisible.annotations", null);
+               if(invisibleAnnotations != null)
+               {
+                  ArrayList<String> list = splitString(invisibleAnnotations, ",");
+                  manager.setIncludedInvisibleAnnotations(list);
+               }
 
                String instrument = System.getProperty("jboss.aop.instrumentor", null);
                InstrumentorFactory.initialise(instrument);
@@ -337,7 +340,13 @@
                   classicOrder = (new Boolean(classic)).booleanValue();
                }
 
+               String methodInterceptors = System.getProperty("jboss.aop.advisor.methodInterceptors", null);
+               if (methodInterceptors != null)
+               {
+                  maintainAdvisorMethodInterceptors = (new Boolean(methodInterceptors)).booleanValue();
+               }
 
+
                Deployment.deploy();
                return null;
             }
@@ -346,9 +355,23 @@
       return manager;
    }
 
+   private static ArrayList<String> splitString(String string, String delim)
+   {
+      if (string != null)
+      {
+         ArrayList<String> list = new ArrayList<String>();
+         for(String token : string.split(delim))
+         {
+            list.add(token.trim());
+         }
+         return list;
+      }
+      return null;
+   }
+   
    /**
     * Get the classLoaderScopingPolicy.
-    * 
+    *
     * @return the classLoaderScopingPolicy.
     */
    public static AOPClassLoaderScopingPolicy getClassLoaderScopingPolicy()
@@ -358,7 +381,7 @@
 
    /**
     * Set the classLoaderScopingPolicy.
-    * 
+    *
     * TODO does it make sense for this to be modified once it has been set?
     * @param classLoaderScopingPolicy the classLoaderScopingPolicy.
     */
@@ -372,19 +395,19 @@
       return interceptionMarkers;
    }
 
-   public LinkedHashMap getPointcuts()
+   public LinkedHashMap<String, Pointcut> getPointcuts()
    {
       return pointcuts;
    }
 
-   public LinkedHashMap getPointcutInfos()
+   public LinkedHashMap<String, PointcutInfo> getPointcutInfos()
    {
       return pointcutInfos;
    }
 
    public CFlowStack getCFlowStack(String name)
    {
-      return (CFlowStack) cflowStacks.get(name);
+      return cflowStacks.get(name);
    }
 
    public void addCFlowStack(CFlowStack stack)
@@ -400,7 +423,7 @@
 
    public DynamicCFlow getDynamicCFlow(String name)
    {
-      DynamicCFlowDefinition def = (DynamicCFlowDefinition) dynamicCFlows.get(name);
+      DynamicCFlowDefinition def = dynamicCFlows.get(name);
 
       if (def != null)
       {
@@ -459,7 +482,7 @@
     */
    public ClassMetaDataLoader findClassMetaDataLoader(String group)
    {
-      ClassMetaDataLoader loader = (ClassMetaDataLoader) classMetaDataLoaders.get(group);
+      ClassMetaDataLoader loader = classMetaDataLoaders.get(group);
       if (loader == null) loader = SimpleClassMetaDataLoader.singleton;
       return loader;
    }
@@ -485,7 +508,7 @@
       classMetaDataLoaders.remove(group);
    }
 
-   public Map getAdvisors()
+   public Map<Class<?>, WeakReference<Advisor>> getAdvisors()
    {
       return advisors;
    }
@@ -501,17 +524,17 @@
       throw new RuntimeException("OPERATION NOT SUPPORTED ANYMORE");
    }
 
-   public LinkedHashMap getBindings()
+   public LinkedHashMap<String, AdviceBinding> getBindings()
    {
       return bindings;
    }
 
-   protected Map getSubDomainsPerClass()
+   protected Map<Class<?>, WeakReference<Domain>> getSubDomainsPerClass()
    {
       return subDomainsPerClass;
    }
 
-   public Advisor findAdvisor(Class clazz)
+   public Advisor findAdvisor(Class<?> clazz)
    {
       if (getSubDomainsPerClass().size() > 0)
       {
@@ -520,10 +543,10 @@
          Domain subDomain = null;
          synchronized (getSubDomainsPerClass())
          {
-            WeakReference ref = (WeakReference)getSubDomainsPerClass().get(clazz);
+            WeakReference<Domain> ref = getSubDomainsPerClass().get(clazz);
             if (ref != null)
             {
-               subDomain = (Domain)ref.get();
+               subDomain = ref.get();
             }
          }
 
@@ -539,16 +562,16 @@
 
       synchronized (advisors)
       {
-         WeakReference ref = (WeakReference) advisors.get(clazz);
+         WeakReference<Advisor> ref = advisors.get(clazz);
          if (ref == null) return null;
-         return (Advisor) ref.get();
+         return ref.get();
       }
    }
-   
+
    /**
     * Takes a string of the form /sub1/sub2/sub3 of subdomains by name, where the leading "/" is the main AspectManager.
     * The main user of the naming of domains is (un)serialization of advisors/containers
-    * 
+    *
     * @param The FQN of the domain
     * @return the domain referenced by the FQN or null if it does not exist
     */
@@ -557,7 +580,7 @@
       String[] nameparts = fqn.split("/");
       return findManagerByName(nameparts);
    }
-   
+
    private AspectManager findManagerByName(String[] nameparts)
    {
       AspectManager found = this;
@@ -575,24 +598,24 @@
       }
       return found;
    }
-   
+
    private AspectManager findManagerByNameInternal(String name)
    {
-      return (Domain)subDomainsByName.get(name);
+      return subDomainsByName.get(name);
    }
-   
+
    protected void addSubDomainByName(Domain domain)
    {
       initSubDomainsByNameMap();
       subDomainsByName.put(domain.getDomainName(), domain);
    }
-   
+
    public String getManagerFQN()
    {
       return "/";
    }
 
-   public ClassAdvisor getAdvisorIfAdvised(Class clazz)
+   public ClassAdvisor getAdvisorIfAdvised(Class<?> clazz)
    {
       return (ClassAdvisor)getAnyAdvisorIfAdvised(clazz);
    }
@@ -600,7 +623,7 @@
    /**
     * Take into account that an advisor may be a container
     */
-   public Advisor getAnyAdvisorIfAdvised(Class clazz)
+   public Advisor getAnyAdvisorIfAdvised(Class<?> clazz)
    {
       try
       {
@@ -634,7 +657,7 @@
     * @param clazz
     * @return
     */
-   public synchronized ClassAdvisor getAdvisor(Class clazz)
+   public synchronized ClassAdvisor getAdvisor(Class<?> clazz)
    {
       ClassAdvisor advisor = null;
       // See if one already exists
@@ -648,11 +671,11 @@
       return advisor;
    }
 
-   public synchronized void initialiseClassAdvisor(Class clazz, ClassAdvisor advisor)
+   public synchronized void initialiseClassAdvisor(Class<?> clazz, ClassAdvisor advisor)
    {
       synchronized (advisors)
       {
-         advisors.put(clazz, new WeakReference(advisor));
+         advisors.put(clazz, new WeakReference<Advisor>(advisor));
       }
 
       registerClass(clazz);
@@ -667,7 +690,7 @@
 
    // Public -------------------------------------------------------
 
-   public static Map getRegisteredCLs()
+   public static Map<ClassLoader, ClassPool> getRegisteredCLs()
    {
       return AOPClassPoolRepository.getInstance().getRegisteredCLs();
    }
@@ -717,7 +740,7 @@
 
    protected ClassPool getRegisteredClassPool(ClassLoader cl)
    {
-      return (ClassPool)getRegisteredCLs().get(cl);
+      return getRegisteredCLs().get(cl);
    }
 
    public ClassPool registerClassLoader(ClassLoader ucl)
@@ -725,7 +748,7 @@
       return AOPClassPoolRepository.getInstance().registerClassLoader(ucl);
    }
 
-   protected void registerClass(Class clazz)
+   protected void registerClass(Class<?> clazz)
    {
       AOPClassPoolRepository.getInstance().registerClass(clazz);
    }
@@ -735,53 +758,65 @@
       AOPClassPoolRepository.getInstance().unregisterClassLoader(cl);
    }
 
-   public ArrayList getExclude()
+   public ArrayList<String> getExclude()
    {
       return exclude;
    }
 
-   public void setExclude(ArrayList exclude)
+   public void setExclude(ArrayList<String> exclude)
    {
       this.exclude.clear();
       this.exclude.addAll(exclude);
    }
 
-   public ArrayList getInclude()
+   public ArrayList<String> getInclude()
    {
       return include;
    }
 
-   public void setInclude(ArrayList include)
+   public void setInclude(ArrayList<String> include)
    {
       this.include.clear();
       this.include.addAll(include);
    }
 
-   public ArrayList getIgnore()
+   public ArrayList<String> getIgnore()
    {
       return ignore;
    }
+   
+   
+   public List<String> getIncludedInvisibleAnnotations()
+   {
+      return includeInvisibleAnnotations;
+   }
+   
+   public void setIncludedInvisibleAnnotations(List<String> ia)
+   {
+      includeInvisibleAnnotations.clear();
+      includeInvisibleAnnotations.addAll(ia);
+   }
 
    public ClassExpression[] getIgnoreExpressions()
    {
       return ignoreExpressions;
    }
 
-   public void setIgnore(ArrayList ignore)
+   public void setIgnore(ArrayList<String> ignore)
    {
       this.ignore.clear();
       this.ignore.addAll(ignore);
       ignoreExpressions = new ClassExpression[ignore.size()];
       for (int i = 0 ; i < ignore.size() ; i++)
       {
-        String ex = (String)ignore.get(i);
+        String ex = ignore.get(i);
         ignoreExpressions[i] = new ClassExpression(ex);
       }
    }
 
    public boolean ignoreClass(String classname)
    {
-      ArrayList ignore = getIgnore();
+      ArrayList<String> ignore = getIgnore();
       if (ignore == null) return false;
       ClassExpression[] ignoreExprs = getIgnoreExpressions();
       for (int i = 0; i < ignoreExprs.length; i++)
@@ -793,11 +828,11 @@
 
    public boolean includeClass(String classname)
    {
-      ArrayList include = getInclude();
+      ArrayList<String> include = getInclude();
       if (include == null) return false;
       for (int i = 0; i < include.size(); i++)
       {
-         String str = (String) include.get(i);
+         String str = include.get(i);
          if (classname.startsWith(str)) return true;
       }
       return false;
@@ -805,11 +840,12 @@
 
    public boolean excludeClass(String classname)
    {
-      ArrayList exclude = getExclude();
+      ArrayList<String> exclude = getExclude();
       if (exclude == null) return false;
       for (int i = 0; i < exclude.size(); i++)
       {
-         String str = (String) exclude.get(i);
+         String str = exclude.get(i);
+         if (str.equals("*")) return true;
          if (classname.startsWith(str)) return true;
       }
       return false;
@@ -840,7 +876,7 @@
       if (ignoreClass(classname)) return true;
       if (includeClass(classname)) return false;
       if (excludeClass(classname)) return true;
-      return (classname.startsWith("org.jboss.aop") ||
+      return (classname.startsWith("org.jboss.aop.") ||
               classname.endsWith("$aop") ||
               classname.startsWith("javassist") ||
               classname.startsWith("org.jboss.util.") ||
@@ -876,7 +912,7 @@
     */
    public byte[] transform(ClassLoader loader,
                            String className,
-                           Class classBeingRedefined,
+                           @SuppressWarnings(value= {"all"}) Class classBeingRedefined,
                            ProtectionDomain protectionDomain,
                            byte[] classfileBuffer)
            throws Exception
@@ -902,9 +938,9 @@
    /**
     * This is to be backward compatible with JBoss 3.2.3 Translator interface
     * TODO: stalep, added a synchronized block for the entire method to prevent
-    *  a deadlock. its not optimal and should be further reviewed. 
+    *  a deadlock. its not optimal and should be further reviewed.
     *  (commented out sync block inside the method)
-    * 
+    *
     * @param className
     * @param loader
     * @return
@@ -955,7 +991,7 @@
          interceptorFactories.put(name, factory);
       }
    }
-   
+
    /**
     * Remove an interceptor factory that can be referenced by name.
     */
@@ -967,7 +1003,7 @@
       }
    }
 
-   public Map getInterceptorFactories()
+   public Map<String, InterceptorFactory> getInterceptorFactories()
    {
       return interceptorFactories;
    }
@@ -979,7 +1015,7 @@
    {
       synchronized (interceptorFactories)
       {
-         return (InterceptorFactory) interceptorFactories.get(name);
+         return interceptorFactories.get(name);
       }
    }
 
@@ -1016,9 +1052,8 @@
          boolean newSubscribers = true;
          while (newSubscribers)
          {
-            for (Iterator it = subscribedSubDomains.keySet().iterator() ; it.hasNext() ; )
+            for (Domain domain : subscribedSubDomains.keySet())
             {
-               Domain domain = (Domain)it.next();
                domain.forceResortPrecedenceDefs();
             }
             newSubscribers = copySubDomainsFromQueue(false);
@@ -1026,7 +1061,7 @@
       }
    }
 
-   public LinkedHashMap getPrecedenceDefs()
+   public LinkedHashMap<String, PrecedenceDef> getPrecedenceDefs()
    {
       return precedenceDefs;
    }
@@ -1076,7 +1111,7 @@
    {
       synchronized (interceptorStacks)
       {
-         return (AdviceStack) interceptorStacks.get(name);
+         return interceptorStacks.get(name);
       }
    }
 
@@ -1086,10 +1121,8 @@
       boolean attached = false;
       synchronized (classMetaData)
       {
-         Iterator it = classMetaData.values().iterator();
-         while (it.hasNext())
+         for (ClassMetaDataBinding data : classMetaData.values())
          {
-            ClassMetaDataBinding data = (ClassMetaDataBinding) it.next();
             if (data.matches(advisor, clazz))
             {
                attached = true;
@@ -1102,14 +1135,12 @@
       return attached;
    }
 
-   protected void attachMetaData(Advisor advisor, Class clazz)
+   protected void attachMetaData(Advisor advisor, Class<?> clazz)
    {
       synchronized (classMetaData)
       {
-         Iterator it = classMetaData.values().iterator();
-         while (it.hasNext())
+         for (ClassMetaDataBinding data : classMetaData.values())
          {
-            ClassMetaDataBinding data = (ClassMetaDataBinding) it.next();
             addAdvisorToClassMetaDataBinding(data, clazz, advisor, clazz);
          }
       }
@@ -1117,21 +1148,20 @@
 
    public ClassAdvisor getTempClassAdvisor(CtClass clazz) throws Exception
    {
-      String classname = clazz.getName();
       ClassAdvisor advisor = AdvisorFactory.getClassAdvisor(clazz, this);
       attachMetaData(advisor, clazz, false);
       applyInterfaceIntroductions(advisor, clazz);
       return advisor;
    }
 
-   public Advisor getTempClassAdvisorIfNotExist(Class clazz)
+   public Advisor getTempClassAdvisorIfNotExist(Class<?> clazz)
    {
       Advisor advisor = findAdvisor(clazz);
       if (advisor != null) return advisor;
       if (Advised.class.isAssignableFrom(clazz))
       {
 
-         Class superClass = clazz;
+         Class<?> superClass = clazz;
          try
          {
             while (superClass != null)
@@ -1170,7 +1200,7 @@
 
    public DomainDefinition getContainer(String name)
    {
-      return (DomainDefinition) containers.get(name);
+      return containers.get(name);
    }
 
    public void addContainer(DomainDefinition def)
@@ -1191,7 +1221,7 @@
    {
       synchronized (pointcuts)
       {
-         return (Pointcut) pointcuts.get(name);
+         return pointcuts.get(name);
       }
    }
 
@@ -1315,7 +1345,7 @@
    /**
     * Remove an interceptor pointcut with a given name
     */
-   public synchronized void removeBinding(String name)
+   public void removeBinding(String name)
    {
       AdviceBinding binding = internalRemoveBinding(name);
       if (binding != null)
@@ -1324,11 +1354,11 @@
       }
    }
 
-   public synchronized void removeBindings(ArrayList binds)
+   public synchronized void removeBindings(ArrayList<String> binds)
    {
       clearUnregisteredClassLoaders();
 
-      ArrayList removedBindings = new ArrayList();
+      ArrayList<AdviceBinding> removedBindings = new ArrayList<AdviceBinding>();
       synchronized (bindings)
       {
          int bindSize = binds.size();
@@ -1336,13 +1366,13 @@
          for (int i = 0; i < bindSize; i++)
          {
 
-            AdviceBinding binding = (AdviceBinding) bindings.get(binds.get(i));
+            AdviceBinding binding = bindings.get(binds.get(i));
             if (binding == null)
             {
                logger.debug("AspectManager.removeBindings() no binding found with name " + binds.get(i));
                continue;
             }
-            ArrayList ads = binding.getAdvisors();
+            ArrayList<Advisor> ads = binding.getAdvisors();
             bindings.remove(binding.getName());
             Pointcut pointcut = binding.getPointcut();
             this.removePointcut(pointcut.getName());
@@ -1355,33 +1385,41 @@
    /**
     * Add an interceptor pointcut with a given name
     */
-   public synchronized void addBinding(AdviceBinding binding)
+   public void addBinding(AdviceBinding binding)
    {
-      AdviceBinding removedBinding = internalRemoveBinding(binding.getName());
-      initBindingsMap();
-      synchronized (bindings)
+      Set<Advisor> affectedAdvisors = null;
+      AdviceBinding removedBinding = null;
+      synchronized(this)
       {
-         bindings.put(binding.getName(), binding);
+         removedBinding = internalRemoveBinding(binding.getName());
+         affectedAdvisors = removedBinding == null ? null : new HashSet<Advisor>(removedBinding.getAdvisors());
+         initBindingsMap();
+         synchronized (bindings)
+         {
+            bindings.put(binding.getName(), binding);
+         }
+
+         initPointcutsMap();
+         initPointcutInfosMap();
+         synchronized (pointcuts)
+         {
+            Pointcut pointcut = binding.getPointcut();
+            pointcuts.put(pointcut.getName(), pointcut);
+            pointcutInfos.put(pointcut.getName(), new PointcutInfo(pointcut, binding, this.transformationStarted));
+            updatePointcutStats(pointcut);
+         }
       }
-      
-      initPointcutsMap();
-      initPointcutInfosMap();
-      synchronized (pointcuts)
+      synchronized (advisors)
       {
-         Pointcut pointcut = binding.getPointcut();
-         pointcuts.put(pointcut.getName(), pointcut);
-         pointcutInfos.put(pointcut.getName(), new PointcutInfo(pointcut, binding, this.transformationStarted));
-         updatePointcutStats(pointcut);
-      }
-      
-      if (removedBinding == null)
-      {
+         if (removedBinding == null)
+         {
          this.joinPointManager.bindingAdded(binding);
+         }
+         else
+         {
+            this.joinPointManager.bindingUpdated(binding, removedBinding);
+         }  
       }
-      else
-      {
-         this.joinPointManager.bindingUpdated(binding, removedBinding);
-      }
    }
 
 
@@ -1389,10 +1427,10 @@
    {
       synchronized (advisors)
       {
-         Collection keys = advisors.keySet();
+         Collection<Class<?>> keys = advisors.keySet();
          if (keys.size() > 0)
          {
-            Iterator it = keys.iterator();
+            Iterator<Class<?>> it = keys.iterator();
             while (it.hasNext())
             {
                Advisor advisor = getAdvisorFromAdvisorsKeySetIterator(it);
@@ -1419,13 +1457,12 @@
          boolean newSubscribers = true;
          while (newSubscribers)
          {
-            Collection keys =  subscribedSubDomains.keySet();
-            if (keys.size() > 0)
+            Collection<Domain> domains =  subscribedSubDomains.keySet();
+            if (domains.size() > 0)
             {
                //When interceptors are installed as beans in the microcontainer, creating the interceptor instances
-               for (Iterator it = keys.iterator() ; it.hasNext() ; )
+               for (Domain domain : domains)
                {
-                  Domain domain = (Domain)it.next();
                   domain.updateAdvisorsForAddedBinding(binding);
                }
             }
@@ -1443,7 +1480,7 @@
    {
       synchronized (classMetaData)
       {
-         ClassMetaDataBinding meta = (ClassMetaDataBinding) classMetaData.remove(name);
+         ClassMetaDataBinding meta = classMetaData.remove(name);
          if (meta == null) return;
          meta.clearAdvisors();
       }
@@ -1453,7 +1490,7 @@
    {
       internalRemoveClassMetaData(meta.getName());
 
-      //Add the metadata before we update the advisors. Important for the generated instance advisors 
+      //Add the metadata before we update the advisors. Important for the generated instance advisors
       initClassMetaDataMap();
       synchronized (classMetaData)
       {
@@ -1467,14 +1504,14 @@
    {
       synchronized (advisors)
       {
-         Iterator it = advisors.keySet().iterator();
+         Iterator<Class<?>> it = advisors.keySet().iterator();
 
          while (it.hasNext())
          {
             Advisor advisor = getAdvisorFromAdvisorsKeySetIterator(it);
             if (advisor == null) continue;
 
-            Class clazz = advisor.getClazz();
+            Class<?> clazz = advisor.getClazz();
             addAdvisorToClassMetaDataBinding(meta, clazz, advisor, clazz);
          }
       }
@@ -1487,9 +1524,8 @@
          {
             if (subscribedSubDomains.size() > 0)
             {
-               for (Iterator it = subscribedSubDomains.keySet().iterator() ; it.hasNext() ; )
+               for (Domain domain : subscribedSubDomains.keySet())
                {
-                  Domain domain = (Domain)it.next();
                   domain.updateAdvisorsForAddedClassMetaData(meta);
                }
             }
@@ -1498,7 +1534,7 @@
       }
    }
 
-   protected void addAdvisorToClassMetaDataBinding(ClassMetaDataBinding meta, Class clazz, Advisor advisor, Class advisedClass)
+   protected void addAdvisorToClassMetaDataBinding(ClassMetaDataBinding meta, Class<?> clazz, Advisor advisor, Class<?> advisedClass)
    {
       if (meta.matches(advisor, clazz))
       {
@@ -1508,7 +1544,7 @@
       {
          //If advisor class does not match class metadata directly, try the superclasses so that methods can inherit
          //old skool weaving doesn't support metadata overriding for inherited methods, so only do this extra work for generated advisors
-         Class superClass = clazz.getSuperclass();
+         Class<?> superClass = clazz.getSuperclass();
          if (superClass != null && superClass != Object.class)
          {
             addAdvisorToClassMetaDataBinding(meta, superClass, advisor, advisedClass);
@@ -1525,7 +1561,7 @@
    {
       synchronized (interfaceIntroductions)
       {
-         return (InterfaceIntroduction) interfaceIntroductions.get(name);
+         return interfaceIntroductions.get(name);
       }
    }
 
@@ -1549,20 +1585,20 @@
    {
       synchronized (interfaceIntroductions)
       {
-         InterfaceIntroduction pointcut = (InterfaceIntroduction) interfaceIntroductions.remove(name);
+         InterfaceIntroduction pointcut = interfaceIntroductions.remove(name);
          if (pointcut == null) return;
          pointcut.clearAdvisors();
       }
    }
-   
+
    /**
     * Retrieve an introduction pointcut of a certain name
     */
-   public InterfaceIntroduction getArrayReplacement(String name)
+   public ArrayReplacement getArrayReplacement(String name)
    {
       synchronized (arrayReplacements)
       {
-         return (InterfaceIntroduction) arrayReplacements.get(name);
+         return arrayReplacements.get(name);
       }
    }
 
@@ -1586,8 +1622,7 @@
    {
       synchronized (arrayReplacements)
       {
-         ArrayReplacement pointcut = (ArrayReplacement) arrayReplacements.remove(name);
-         if (pointcut == null) return;
+         arrayReplacements.remove(name);
       }
    }
 
@@ -1598,7 +1633,7 @@
    {
       synchronized (arrayBindings)
       {
-         return (ArrayBinding) arrayBindings.get(name);
+         return arrayBindings.get(name);
       }
    }
 
@@ -1623,7 +1658,7 @@
    {
       synchronized (arrayBindings)
       {
-         ArrayBinding pointcut = (ArrayBinding) arrayBindings.remove(name);
+         ArrayBinding pointcut = arrayBindings.remove(name);
          if (pointcut == null) return;
          ArrayAdvisor.removeBinding(pointcut);
       }
@@ -1656,11 +1691,11 @@
       }
    }
 
-   public List getAnnotationIntroductions()
+   public List<AnnotationIntroduction> getAnnotationIntroductions()
    {
       synchronized (annotationIntroductions)
       {
-         return new ArrayList(annotationIntroductions.values());
+         return new ArrayList<AnnotationIntroduction>(annotationIntroductions.values());
       }
    }
 
@@ -1689,20 +1724,18 @@
       }
    }
 
-   public Iterator getDeclares()
+   public Iterator<DeclareDef> getDeclares()
    {
       return declares.values().iterator();
    }
 
-   protected void applyInterfaceIntroductions(Advisor advisor, Class clazz)
+   protected void applyInterfaceIntroductions(Advisor advisor, Class<?> clazz)
    {
-      Map interfaceIntroductions = getInterfaceIntroductions();
+      Map<String, InterfaceIntroduction> interfaceIntroductions = getInterfaceIntroductions();
       if (interfaceIntroductions != null && interfaceIntroductions.size() > 0)
       {
-         Iterator it = interfaceIntroductions.values().iterator();
-         while (it.hasNext())
+         for (InterfaceIntroduction pointcut : interfaceIntroductions.values())
          {
-            InterfaceIntroduction pointcut = (InterfaceIntroduction) it.next();
             if (pointcut.matches(advisor, clazz))
             {
                pointcut.addAdvisor(advisor);
@@ -1713,13 +1746,11 @@
 
    protected void applyInterfaceIntroductions(ClassAdvisor advisor, CtClass clazz) throws Exception
    {
-      Map interfaceIntroductions = getInterfaceIntroductions();
+      Map<String, InterfaceIntroduction> interfaceIntroductions = getInterfaceIntroductions();
       if (interfaceIntroductions != null && interfaceIntroductions.size() > 0)
       {
-         Iterator it = interfaceIntroductions.values().iterator();
-         while (it.hasNext())
+         for (InterfaceIntroduction pointcut : interfaceIntroductions.values())
          {
-            InterfaceIntroduction pointcut = (InterfaceIntroduction) it.next();
             if (pointcut.matches(advisor, clazz))
             {
                pointcut.addAdvisor(advisor);
@@ -1747,7 +1778,7 @@
    {
       synchronized (advisors)
       {
-         Iterator it = advisors.keySet().iterator();
+         Iterator<Class<?>> it = advisors.keySet().iterator();
          while (it.hasNext())
          {
             Advisor advisor = getAdvisorFromAdvisorsKeySetIterator(it);
@@ -1762,9 +1793,8 @@
          boolean newSubscribers = true;
          while (newSubscribers)
          {
-            for (Iterator it = subscribedSubDomains.keySet().iterator() ; it.hasNext() ; )
+            for (Domain domain : subscribedSubDomains.keySet())
             {
-               Domain domain = (Domain)it.next();
                domain.updateAdvisorsForAddedAnnotationOverride(introduction);
             }
             newSubscribers = copySubDomainsFromQueue(false);
@@ -1785,11 +1815,11 @@
       }
    }
 
-   public List getAnnotationOverrides()
+   public List<AnnotationIntroduction> getAnnotationOverrides()
    {
       synchronized (annotationOverrides)
       {
-         return new ArrayList(annotationOverrides.values());
+         return new ArrayList<AnnotationIntroduction>(annotationOverrides.values());
       }
    }
 
@@ -1803,7 +1833,7 @@
       Object aspect = perVMAspects.get(def);
       if (aspect == null)
       {
-         AspectDefinition adef = (AspectDefinition)aspectDefinitions.get(def);
+         AspectDefinition adef = aspectDefinitions.get(def);
          if (adef != null && adef.getScope() == Scope.PER_VM)
          {
             synchronized (adef)
@@ -1814,7 +1844,7 @@
       }
       return aspect;
    }
-   
+
    protected Object createPerVmAspect(String def, AspectDefinition adef, ClassLoader scopedClassLoader)
    {
       Object instance = null;
@@ -1853,10 +1883,10 @@
    {
       internalRemoveAspectDefintion(name);
    }
-   
+
    protected AspectDefinition internalRemoveAspectDefintion(String name)
    {
-      AspectDefinition def = (AspectDefinition) aspectDefinitions.remove(name);
+      AspectDefinition def = aspectDefinitions.remove(name);
       if (def != null)
       {
          def.undeploy();
@@ -1865,14 +1895,14 @@
       return def;
    }
 
-   public Map getAspectDefinitions()
+   public Map<String, AspectDefinition> getAspectDefinitions()
    {
       return aspectDefinitions;
    }
 
    public AspectDefinition getAspectDefinition(String name)
    {
-      return (AspectDefinition) aspectDefinitions.get(name);
+      return aspectDefinitions.get(name);
    }
 
    public synchronized void addTypedef(Typedef def) throws Exception
@@ -1897,51 +1927,51 @@
    {
       synchronized (typedefs)
       {
-         return (Typedef) typedefs.get(name);
+         return typedefs.get(name);
       }
    }
 
-   public Map getInterfaceIntroductions()
+   public Map<String, InterfaceIntroduction> getInterfaceIntroductions()
    {
       return interfaceIntroductions;
    }
-   
-   public Map getArrayReplacements()
+
+   public Map<String, ArrayReplacement> getArrayReplacements()
    {
       return arrayReplacements;
    }
 
-   public Map getTypedefs()
+   public Map<String, Typedef> getTypedefs()
    {
       return typedefs;
    }
 
-   public Map getInterceptorStacks()
+   public Map<String, AdviceStack> getInterceptorStacks()
    {
       return interceptorStacks;
    }
 
-   public Map getClassMetaDataLoaders()
+   public Map<String, ClassMetaDataLoader> getClassMetaDataLoaders()
    {
       return classMetaDataLoaders;
    }
 
-   public Map getCflowStacks()
+   public Map<String, CFlowStack> getCflowStacks()
    {
       return cflowStacks;
    }
 
-   public Map getDynamicCFlows()
+   public Map<String, DynamicCFlowDefinition> getDynamicCFlows()
    {
       return dynamicCFlows;
    }
 
-   public Map getPerVMAspects()
+   public Map<String, Object> getPerVMAspects()
    {
       return perVMAspects;
    }
 
-   public Map getClassMetaData()
+   public Map<String, ClassMetaDataBinding> getClassMetaData()
    {
       return classMetaData;
    }
@@ -1973,11 +2003,11 @@
     * Removes an AdviceBinding without notifying dynamic aop strategy.
     * @param name the binding to be removed.
     */
-   private AdviceBinding internalRemoveBinding(String name)
+   private synchronized AdviceBinding internalRemoveBinding(String name)
    {
       synchronized (bindings)
       {
-         AdviceBinding binding = (AdviceBinding) bindings.remove(name);
+         AdviceBinding binding = bindings.remove(name);
          if (binding == null)
          {
             return null;
@@ -1995,11 +2025,11 @@
 //      this.bindings.putAll(bindings);
 //   }
 
-   public void addSubDomainPerClass(Class clazz, Domain domain)
+   public void addSubDomainPerClass(Class<?> clazz, Domain domain)
    {
       synchronized (getSubDomainsPerClass())
       {
-         getSubDomainsPerClass().put(clazz, new WeakReference(domain));
+         getSubDomainsPerClass().put(clazz, new WeakReference<Domain>(domain));
       }
    }
 
@@ -2024,23 +2054,23 @@
          subscribedSubDomains.remove(domain);
       }
    }
-      
-   public Map getSubscribedSubDomains()
+
+   public Map<Domain, Object> getSubscribedSubDomains()
    {
       return subscribedSubDomains;
    }
 
-   private Advisor getAdvisorFromAdvisorsKeySetIterator(Iterator it)
+   private Advisor getAdvisorFromAdvisorsKeySetIterator(Iterator<Class<?>> it)
    {
-      Class clazz = (Class) it.next();
+      Class<?> clazz = it.next();
       if (classLoaderValidator != null && !classLoaderValidator.isValidClassLoader(clazz.getClassLoader()))
       {
          it.remove();
          return null;
       }
-      WeakReference ref = (WeakReference) advisors.get(clazz);
+      WeakReference<Advisor> ref = advisors.get(clazz);
       if (ref == null) return null;
-      Advisor advisor = (Advisor) ref.get();
+      Advisor advisor = ref.get();
       if (advisor == null)
       {
          it.remove();
@@ -2077,12 +2107,12 @@
    {
       lifecycleManager.addLifecycleDefinition(def);
    }
-   
+
    public void removeLifecycleDefinition(String name)
    {
       lifecycleManager.removeLifecycleDefinition(name);
    }
-   
+
    public void addLifecycleBinding(LifecycleCallbackBinding lifecycleBinding)
    {
       lifecycleManager.addLifecycleBinding(lifecycleBinding);
@@ -2097,218 +2127,162 @@
    {
       lifecycleManager.removeLifecycleBinding(name);
    }
-   
-   
-/*
-   public void dumpSubDomainsAndAdvisors(int indent)
-   {
-      indent(indent);
-      System.out.println("Manager: " + this);
-      indent++;
-      indent(indent);
-      System.out.println("<Advisors>");
-      //indent(indent);
 
-      for (Iterator it = advisors.keySet().iterator() ; it.hasNext() ; )
-      {
-         Class clazz = (Class) it.next();
-         Advisor advisor = null;
-         WeakReference ref = (WeakReference) advisors.get(clazz);
-         if (ref != null) advisor = (Advisor) ref.get();
-         indent(indent);
-         System.out.println(System.identityHashCode(advisor) + " " + advisor);
-         indent(indent);
-      }
-      indent--;
-      indent(indent);
-      System.out.println("</Advisors>");
 
-      indent(indent);
-      System.out.println("<Sub domains>");
-      indent++;
-      for (Iterator it = subscribedSubDomains.keySet().iterator(); it.hasNext() ; )
-      {
-         AspectManager manager = (AspectManager)it.next();
-         manager.dumpSubDomainsAndAdvisors(indent);
-      }
-      indent--;
-      indent(indent);
-      System.out.println("</Sub domains>");
-      indent--;
 
-   }
+//   public void dumpSubDomainsAndAdvisors(int indent)
+//   {
+//      indent(indent);
+//      System.out.println("Manager: " + this);
+//      indent++;
+//      indent(indent);
+//      System.out.println("<Advisors>");
+//      //indent(indent);
+//
+//      for (Iterator it = advisors.keySet().iterator() ; it.hasNext() ; )
+//      {
+//         Class clazz = (Class) it.next();
+//         Advisor advisor = null;
+//         WeakReference ref = (WeakReference) advisors.get(clazz);
+//         if (ref != null) advisor = (Advisor) ref.get();
+//         indent(indent);
+//         System.out.println(System.identityHashCode(advisor) + " " + advisor);
+//         indent(indent);
+//      }
+//      indent--;
+//      indent(indent);
+//      System.out.println("</Advisors>");
+//
+//      indent(indent);
+//      System.out.println("<Sub domains>");
+//      indent++;
+//      for (Iterator it = subscribedSubDomains.keySet().iterator(); it.hasNext() ; )
+//      {
+//         AspectManager manager = (AspectManager)it.next();
+//         manager.dumpSubDomainsAndAdvisors(indent);
+//      }
+//      indent--;
+//      indent(indent);
+//      System.out.println("</Sub domains>");
+//      indent--;
+//
+//   }
+//
+//   private void indent(int indent)
+//   {
+//      for (int i = 0 ; i < indent ; i++) System.out.print(" ");
+//   }
 
-   private void indent(int indent)
-   {
-      for (int i = 0 ; i < indent ; i++) System.out.print(" ");
-   }
-*/
-   /**
-    * Lock for write
-    */
-   protected void lockWrite()
-   {
-      lock.writeLock().lock();
-   }
-
-   /**
-    * Unlock for write
-    */
-   protected void unlockWrite()
-   {
-      lock.writeLock().unlock();
-   }
-
    protected void initSubDomainsByNameMap()
    {
       if (subDomainsByName == UnmodifiableEmptyCollections.EMPTY_WEAK_VALUE_HASHMAP)
       {
-         lockWrite();
-         try
+         synchronized(lazyCollectionLock)
          {
             if (subDomainsByName == UnmodifiableEmptyCollections.EMPTY_WEAK_VALUE_HASHMAP)
             {
-               subDomainsByName = new WeakValueHashMap();
+               subDomainsByName = new WeakValueHashMap<String, Domain>();
             }
          }
-         finally
-         {
-            unlockWrite();
-         }
       }
    }
-   
+
    protected void initSubscribedSubDomainsMap()
    {
       if (subscribedSubDomains == UnmodifiableEmptyCollections.EMPTY_WEAK_HASHMAP)
       {
-         lockWrite();
-         try
+         synchronized(lazyCollectionLock)
          {
             if (subscribedSubDomains == UnmodifiableEmptyCollections.EMPTY_WEAK_HASHMAP)
             {
-               subscribedSubDomains = new WeakHashMap();
+               subscribedSubDomains = new WeakHashMap<Domain, Object>();
             }
          }
-         finally
-         {
-            unlockWrite();
-         }
-      }      
+      }
    }
-   
+
    protected void initSubscribedSubDomainsQueueMap()
    {
       if (subscribedSubDomainsQueue == UnmodifiableEmptyCollections.EMPTY_WEAK_HASHMAP)
       {
-         lockWrite();
-         try
+         synchronized(lazyCollectionLock)
          {
             if (subscribedSubDomainsQueue == UnmodifiableEmptyCollections.EMPTY_WEAK_HASHMAP)
             {
-               subscribedSubDomainsQueue = new WeakHashMap();
+               subscribedSubDomainsQueue = new WeakHashMap<Domain, Object>();
             }
          }
-         finally
-         {
-            unlockWrite();
-         }
       }
    }
-   
+
    protected void initInterfaceIntroductionsMap()
    {
       if (interfaceIntroductions == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
       {
-         lockWrite();
-         try
+         synchronized(lazyCollectionLock)
          {
             if (interfaceIntroductions == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
             {
-               interfaceIntroductions = new LinkedHashMap();
+               interfaceIntroductions = new LinkedHashMap<String, InterfaceIntroduction>();
             }
          }
-         finally
-         {
-            unlockWrite();
-         }
       }
    }
-   
+
    protected void initArrayReplacementMap()
    {
       if (arrayReplacements == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
       {
-         lockWrite();
-         try
+         synchronized(lazyCollectionLock)
          {
             if (arrayReplacements == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
             {
-               arrayReplacements = new LinkedHashMap();
+               arrayReplacements = new LinkedHashMap<String, ArrayReplacement>();
             }
          }
-         finally
-         {
-            unlockWrite();
-         }
       }
    }
-   
+
    protected void initArrayBindingMap()
    {
       if (arrayBindings == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
       {
-         lockWrite();
-         try
+         synchronized(lazyCollectionLock)
          {
             if (arrayBindings == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
             {
-               arrayBindings = new LinkedHashMap();
+               arrayBindings = new LinkedHashMap<String, ArrayBinding>();
             }
          }
-         finally
-         {
-            unlockWrite();
-         }
       }
    }
-   
-   
+
+
    protected void initAnnotationIntroductionsMap()
    {
       if (annotationIntroductions == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
       {
-         lockWrite();
-         try
+         synchronized(lazyCollectionLock)
          {
             if (annotationIntroductions == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
             {
-               annotationIntroductions = new LinkedHashMap();
+               annotationIntroductions = new LinkedHashMap<String, AnnotationIntroduction>();
             }
          }
-         finally
-         {
-            unlockWrite();
-         }
       }
    }
-   
+
    protected void initAnnotationOverridesMap()
    {
       if (annotationOverrides == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
       {
-         lockWrite();
-         try
+         synchronized(lazyCollectionLock)
          {
             if (annotationOverrides == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
             {
-               annotationOverrides = new LinkedHashMap();
+               annotationOverrides = new LinkedHashMap<String, AnnotationIntroduction>();
             }
          }
-         finally
-         {
-            unlockWrite();
-         }
       }
    }
 
@@ -2316,18 +2290,13 @@
    {
       if (bindings == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
       {
-         lockWrite();
-         try
+         synchronized(lazyCollectionLock)
          {
             if (bindings == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
             {
-               bindings = new LinkedHashMap();
+               bindings = new LinkedHashMap<String, AdviceBinding>();
             }
          }
-         finally
-         {
-            unlockWrite();
-         }
       }
    }
 
@@ -2335,18 +2304,13 @@
    {
       if (typedefs == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
       {
-         lockWrite();
-         try
+         synchronized(lazyCollectionLock)
          {
             if (typedefs == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
             {
-               typedefs = new LinkedHashMap();
+               typedefs = new LinkedHashMap<String, Typedef>();
             }
          }
-         finally
-         {
-            unlockWrite();
-         }
       }
    }
 
@@ -2354,247 +2318,182 @@
    {
       if (interceptorFactories == UnmodifiableEmptyCollections.EMPTY_HASHMAP)
       {
-         lockWrite();
-         try
+         synchronized(lazyCollectionLock)
          {
             if (interceptorFactories == UnmodifiableEmptyCollections.EMPTY_HASHMAP)
             {
-               interceptorFactories = new HashMap();
+               interceptorFactories = new HashMap<String, InterceptorFactory>();
             }
          }
-         finally
-         {
-            unlockWrite();
-         }
       }
    }
-   
+
    protected void initClassMetaDataLoadersMap()
    {
       if (classMetaDataLoaders == UnmodifiableEmptyCollections.EMPTY_HASHMAP)
       {
-         lockWrite();
-         try
+         synchronized(lazyCollectionLock)
          {
             if (classMetaDataLoaders == UnmodifiableEmptyCollections.EMPTY_HASHMAP)
             {
-               classMetaDataLoaders = new HashMap();
+               classMetaDataLoaders = new HashMap<String, ClassMetaDataLoader>();
             }
          }
-         finally
-         {
-            unlockWrite();
-         }
       }
    }
-   
+
    protected void initInerceptorStacksMap()
    {
       if (interceptorStacks == UnmodifiableEmptyCollections.EMPTY_HASHMAP)
       {
-         lockWrite();
-         try
+         synchronized(lazyCollectionLock)
          {
             if (interceptorStacks == UnmodifiableEmptyCollections.EMPTY_HASHMAP)
             {
-               interceptorStacks = new HashMap();
+               interceptorStacks = new HashMap<String, AdviceStack>();
             }
          }
-         finally
-         {
-            unlockWrite();
-         }
       }
    }
-   
-   
+
+
    protected void initDeclaresMap()
    {
       if (declares == UnmodifiableEmptyCollections.EMPTY_HASHMAP)
       {
-         lockWrite();
-         try
+         synchronized(lazyCollectionLock)
          {
             if (declares == UnmodifiableEmptyCollections.EMPTY_HASHMAP)
             {
-               declares = new HashMap();
+               declares = new HashMap<String, DeclareDef>();
             }
          }
-         finally
-         {
-            unlockWrite();
-         }
       }
    }
-   
+
    protected void initCflowStacksMap()
    {
       if (cflowStacks == UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP)
       {
-         lockWrite();
-         try
+         synchronized(lazyCollectionLock)
          {
             if (cflowStacks == UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP)
             {
-               cflowStacks = new ConcurrentHashMap();
+               cflowStacks = new ConcurrentHashMap<String, CFlowStack>();
             }
          }
-         finally
-         {
-            unlockWrite();
-         }
       }
    }
-   
+
    protected void initDynamicCflowsMap()
    {
       if (dynamicCFlows == UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP)
       {
-         lockWrite();
-         try
+         synchronized(lazyCollectionLock)
          {
             if (dynamicCFlows == UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP)
             {
-               dynamicCFlows = new ConcurrentHashMap();
+               dynamicCFlows = new ConcurrentHashMap<String, DynamicCFlowDefinition>();
             }
          }
-         finally
-         {
-            unlockWrite();
-         }
       }
    }
-   
+
    protected void initAspectDefintitionsMap()
    {
       if (aspectDefinitions == UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP)
       {
-         lockWrite();
-         try
+         synchronized(lazyCollectionLock)
          {
             if (aspectDefinitions == UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP)
             {
-               aspectDefinitions = new ConcurrentHashMap();
+               aspectDefinitions = new ConcurrentHashMap<String, AspectDefinition>();
             }
          }
-         finally
-         {
-            unlockWrite();
-         }
       }
    }
-   
+
    protected void initPerVMAspectsMap()
    {
       if (perVMAspects == UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP)
       {
-         lockWrite();
-         try
+         synchronized(lazyCollectionLock)
          {
             if (perVMAspects == UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP)
             {
-               perVMAspects = new ConcurrentHashMap();
+               perVMAspects = new ConcurrentHashMap<String, Object>();
             }
          }
-         finally
-         {
-            unlockWrite();
-         }
       }
    }
-   
+
    protected void initPointcutsMap()
    {
       if (pointcuts == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
       {
-         lockWrite();
-         try
+         synchronized(lazyCollectionLock)
          {
             if (pointcuts == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
             {
-               pointcuts = new LinkedHashMap();
+               pointcuts = new LinkedHashMap<String, Pointcut>();
             }
          }
-         finally
-         {
-            unlockWrite();
-         }
       }
    }
-   
+
    protected void initPointcutInfosMap()
    {
       if (pointcutInfos == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
       {
-         lockWrite();
-         try
+         synchronized(lazyCollectionLock)
          {
             if (pointcutInfos == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
             {
-               pointcutInfos = new LinkedHashMap();
+               pointcutInfos = new LinkedHashMap<String, PointcutInfo>();
             }
          }
-         finally
-         {
-            unlockWrite();
-         }
       }
    }
-   
-   
+
+
    protected void initClassMetaDataMap()
    {
       if (classMetaData == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
       {
-         lockWrite();
-         try
+         synchronized(lazyCollectionLock)
          {
             if (classMetaData == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
             {
-               classMetaData = new LinkedHashMap();
+               classMetaData = new LinkedHashMap<String, ClassMetaDataBinding>();
             }
          }
-         finally
-         {
-            unlockWrite();
-         }
       }
    }
    protected void initContainersMap()
    {
       if (containers == UnmodifiableEmptyCollections.EMPTY_HASHMAP)
       {
-         lockWrite();
-         try
+         synchronized(lazyCollectionLock)
          {
             if (containers == UnmodifiableEmptyCollections.EMPTY_HASHMAP)
             {
-               containers = new HashMap();
+               containers = new HashMap<String, DomainDefinition>();
             }
          }
-         finally
-         {
-            unlockWrite();
-         }
       }
    }
-   
+
    protected void initPrecedenceDefsMap()
    {
       if (precedenceDefs == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
       {
-         lockWrite();
-         try
+         synchronized(lazyCollectionLock)
          {
             if (precedenceDefs == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
             {
-               precedenceDefs = new LinkedHashMap();
+               precedenceDefs = new LinkedHashMap<String, PrecedenceDef>();
             }
          }
-         finally
-         {
-            unlockWrite();
-         }
       }
    }
 

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/AspectXmlLoader.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/AspectXmlLoader.java	2008-03-24 03:41:24 UTC (rev 71184)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/AspectXmlLoader.java	2008-03-24 03:46:45 UTC (rev 71185)
@@ -311,8 +311,8 @@
       
       Type theType = Type.valueOf(type);
       
-      ArrayList interceptors = loadInterceptors(element);
-      InterceptorFactory[] inters = (InterceptorFactory[]) interceptors.toArray(new InterceptorFactory[interceptors.size()]);
+      ArrayList<InterceptorFactory> interceptors = loadInterceptors(element);
+      InterceptorFactory[] inters = interceptors.toArray(new InterceptorFactory[interceptors.size()]);
       for (int i = 0 ; i < inters.length ; i++)
       {
          if (!inters[i].getAspect().getScope().equals(Scope.PER_VM))
@@ -588,7 +588,7 @@
    {
       String tag = element.getAttribute("tag");
       String classname = element.getAttribute("class");
-      Class clazz = getClassLoader().loadClass(classname);
+      Class<?> clazz = getClassLoader().loadClass(classname);
       ClassMetaDataLoader loader = (ClassMetaDataLoader) clazz.newInstance();
       if (loader instanceof XmlLoadable)
       {
@@ -638,7 +638,7 @@
 
       Pointcut p = null;
 
-      Class pClass = null;
+      Class<?> pClass = null;
       try
       {
          pClass = getClassLoader().loadClass(clazz);
@@ -870,10 +870,10 @@
          ASTStart start = new TypeExpressionParser(new StringReader(ast)).Start();
          pcut = new InterfaceIntroduction(name, start, ifaces);
       }
-      Iterator it = XmlHelper.getChildrenByTagName(pointcut, "mixin");
+      Iterator<Element> it = XmlHelper.getChildrenByTagName(pointcut, "mixin");
       while (it.hasNext())
       {
-         Element mixin = (Element) it.next();
+         Element mixin = it.next();
          if (mixin != null)
          {
             String construction = XmlHelper.getOptionalChildContent(mixin, "construction");
@@ -1068,7 +1068,11 @@
       }
 
       DomainDefinition def = manager.getContainer(name);
-      if (def == null) throw new RuntimeException("Unable to undeploy container: " + name);
+      if (def == null)
+      {
+         logger.warn("No domain found with name: " + name);
+         return;
+      }
       AspectManager push = manager;
       ArrayList<String> oldFactories = factories;
       ArrayList<String> oldAspects = aspects;
@@ -1212,12 +1216,12 @@
       manager.removeBindings(bindings);
       for (int i = 0; i < factories.size(); i++)
       {
-         String factory = (String) factories.get(i);
+         String factory = factories.get(i);
          manager.removeInterceptorFactory(factory);
       }
       for (int i = 0; i < aspects.size(); i++)
       {
-         String aspect = (String) aspects.get(i);
+         String aspect = aspects.get(i);
          manager.removeAspectDefinition(aspect);
       }
    }

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/CallerConstructorInfo.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/CallerConstructorInfo.java	2008-03-24 03:41:24 UTC (rev 71184)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/CallerConstructorInfo.java	2008-03-24 03:46:45 UTC (rev 71185)
@@ -36,13 +36,13 @@
  **/
 public abstract class CallerConstructorInfo extends JoinPointInfo implements ConstructorCall
 {
-   private final Constructor constructor;
-   private final Class callingClass;
+   private final Constructor<?> constructor;
+   private final Class<?> callingClass;
    private final Method wrappingMethod;
    private final long calledConHash;
-   private final Class calledClass;
+   private final Class<?> calledClass;
    
-   public CallerConstructorInfo(Advisor advisor, Class calledClass, Constructor called, long calledConHash, Method wrappingMethod, Interceptor[] in, Class clazz)
+   public CallerConstructorInfo(Advisor advisor, Class<?> calledClass, Constructor<?> called, long calledConHash, Method wrappingMethod, Interceptor[] in, Class<?> clazz)
    {
       super(advisor, clazz);
       this.calledClass = calledClass;
@@ -66,12 +66,12 @@
       this.calledClass = other.calledClass;
    }
 
-   public Constructor getConstructor()
+   public Constructor<?> getConstructor()
    {
       return constructor;
    }
 
-   public Class getCallingClass()
+   public Class<?> getCallingClass()
    {
       return callingClass;
    }
@@ -86,7 +86,7 @@
       return calledConHash;
    }
 
-   public Class getCalledClass()
+   public Class<?> getCalledClass()
    {
       return calledClass;
    }

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/CallerMethodInfo.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/CallerMethodInfo.java	2008-03-24 03:41:24 UTC (rev 71184)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/CallerMethodInfo.java	2008-03-24 03:46:45 UTC (rev 71185)
@@ -35,12 +35,12 @@
  **/
 public abstract class CallerMethodInfo extends JoinPointInfo implements MethodCall
 {
-   private final Class callingClass;
-   private final Class calledClass;
+   private final Class<?> callingClass;
+   private final Class<?> calledClass;
    private final Method method;
    private final long calledMethodHash;
 
-   public CallerMethodInfo(Advisor advisor, Class calledClass, Method m, long calledMethodHash, Interceptor[] in, Class clazz)
+   public CallerMethodInfo(Advisor advisor, Class<?> calledClass, Method m, long calledMethodHash, Interceptor[] in, Class<?> clazz)
    {
       super(advisor, clazz);
       this.calledClass = calledClass;
@@ -62,12 +62,12 @@
       this.calledMethodHash = other.calledMethodHash;
    }
 
-   public Class getCallingClass()
+   public Class<?> getCallingClass()
    {
       return callingClass;
    }
 
-   public Class getCalledClass()
+   public Class<?> getCalledClass()
    {
       return calledClass;
    }

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/ClassAdvisor.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/ClassAdvisor.java	2008-03-24 03:41:24 UTC (rev 71184)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/ClassAdvisor.java	2008-03-24 03:46:45 UTC (rev 71185)
@@ -36,7 +36,6 @@
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
 
 import org.jboss.aop.advice.AdviceBinding;
@@ -86,7 +85,7 @@
 public class ClassAdvisor extends Advisor
 {
    private static final Logger logger = AOPLogger.getLogger(ClassAdvisor.class);
-   
+
    /**
     * Suffix added to unadvised methods.
     */
@@ -102,14 +101,14 @@
    private volatile ConByMethodData conByMethodData;
 
    // caller pointcut support for constructors calling methods
-   protected HashMap[] methodCalledByConBindings;
-   protected HashMap[] methodCalledByConInterceptors;
-   protected HashMap backrefMethodCalledByConstructorBindings = new HashMap();
+   protected HashMap<String, TLongObjectHashMap>[] methodCalledByConBindings; // TLongObjectHashMap contains Objects of type ArrayList<AdviceBinding>
+   protected HashMap<String, TLongObjectHashMap>[] methodCalledByConInterceptors; //TLongObjectHashMap contains Objects of type MethodByConInfo
+   protected HashMap<String, ArrayList<ArrayList<AdviceBinding>>> backrefMethodCalledByConstructorBindings = new HashMap<String, ArrayList<ArrayList<AdviceBinding>>>();
 
    // caller pointcut support for constructors calling methods
-   protected HashMap[] conCalledByConBindings;
-   protected HashMap[] conCalledByConInterceptors;
-   protected HashMap backrefConCalledByConstructorBindings = new HashMap();
+   protected HashMap<String, TLongObjectHashMap>[] conCalledByConBindings; // TLongObjectHashMap contains Objects of type ArrayList<AdviceBinding>
+   protected HashMap<String, TLongObjectHashMap>[] conCalledByConInterceptors; //TLongObjectHashMap contains Objects of type ConByConInfo
+   protected HashMap<String, ArrayList<ArrayList<AdviceBinding>>> backrefConCalledByConstructorBindings = new HashMap<String, ArrayList<ArrayList<AdviceBinding>>>();
 
    // Used by instrumentor to access separate interceptor chains for read and write access
    /** @deprecated Use fieldReadInfos instead*/
@@ -124,7 +123,7 @@
    //PER_JOINPOINT aspects for static fields or PER_CLASS_JOINPOINT aspects
    //all apply to fields, and we need this since the same aspect should be used for
    //read and write
-   private HashMap fieldAspectsWithNoInstance = new HashMap();
+   private volatile HashMap<AspectDefinition, HashMap<FieldJoinpoint, Object>> fieldAspectsWithNoInstance = new HashMap<AspectDefinition, HashMap<FieldJoinpoint, Object>>();
 
    protected boolean initialized = false;
 
@@ -133,7 +132,7 @@
       super(classname, manager);
    }
 
-   public ClassAdvisor(Class clazz, AspectManager manager)
+   public ClassAdvisor(Class<?> clazz, AspectManager manager)
    {
       this(clazz.getName(), manager);
       this.clazz = clazz;
@@ -152,15 +151,15 @@
     */
    public Object getFieldAspect(FieldJoinpoint joinpoint, AspectDefinition def)
    {
-      HashMap map = (HashMap)fieldAspectsWithNoInstance.get(def);
+      HashMap<FieldJoinpoint, Object> map = fieldAspectsWithNoInstance.get(def);
       if (map == null)
       {
          synchronized (fieldAspectsWithNoInstance)
          {
-            map = (HashMap)fieldAspectsWithNoInstance.get(def);
+            map = fieldAspectsWithNoInstance.get(def);
             if (map == null)
             {
-               map = new HashMap();
+               map = new HashMap<FieldJoinpoint, Object>();
                fieldAspectsWithNoInstance.put(def, map);
             }
          }
@@ -198,7 +197,8 @@
       return unadvisedMethods;
    }
 
-   public Constructor[] getConstructors()
+   @Override
+   public Constructor<?>[] getConstructors()
    {
       return constructors;
    }
@@ -208,12 +208,12 @@
       return getMethodByMethodData().getMethodCalledByMethodInterceptors();
    }
 
-   public HashMap[] getMethodCalledByConInterceptors()
+   public HashMap<String, TLongObjectHashMap>[] getMethodCalledByConInterceptors()
    {
       return methodCalledByConInterceptors;
    }
 
-   public HashMap[] getConCalledByConInterceptors()
+   public HashMap<String, TLongObjectHashMap>[] getConCalledByConInterceptors()
    {
       return conCalledByConInterceptors;
    }
@@ -259,7 +259,7 @@
    /**
     * Constructs a new helper.
     */
-   public synchronized void attachClass(final Class clazz)
+   public synchronized void attachClass(final Class<?> clazz)
    {
       if (initialized) return;
       try
@@ -306,9 +306,9 @@
             }
          });
          /*
-         System.out.println("******************");
-         System.out.println("attachClass: " + clazz.getName() + " took " + (System.currentTimeMillis() - start));
-         System.out.println("******************");
+//         System.out.println("******************");
+//         System.out.println("attachClass: " + clazz.getName() + " took " + (System.currentTimeMillis() - start));
+//         System.out.println("******************");
          */
       }
       catch (PrivilegedActionException e)
@@ -321,7 +321,7 @@
     * Get method from clazz .If method not found,get the method
     * from the clazz's parent.
     */
-   static private Method getMethod(Class clazz, Method method) throws NoSuchMethodException
+   static private Method getMethod(Class<?> clazz, Method method) throws NoSuchMethodException
    {
 
       if ((clazz == null) || (clazz.equals(Object.class))) throw new NoSuchMethodException(method.getName());
@@ -339,7 +339,7 @@
    /**
     * Get a constructor's index in the class. Returns -1 if not there
     */
-   public int getConstructorIndex(Constructor constructor)
+   public int getConstructorIndex(Constructor<?> constructor)
    {
       for (int i = 0; i < constructors.length; i++)
       {
@@ -375,22 +375,20 @@
     */
    protected void populateMixinMethods() throws Exception
    {
-      ArrayList pointcuts = getInterfaceIntroductions();
-      Iterator it = pointcuts.iterator();
-      while (it.hasNext())
+      ArrayList<InterfaceIntroduction> introductions = getInterfaceIntroductions();
+      for (InterfaceIntroduction introduction : introductions)
       {
-         InterfaceIntroduction pointcut = (InterfaceIntroduction) it.next();
-         ArrayList mixins = pointcut.getMixins();
+         ArrayList<InterfaceIntroduction.Mixin> mixins = introduction.getMixins();
          for (int i = 0; i < mixins.size(); i++)
          {
-            InterfaceIntroduction.Mixin mixin = (InterfaceIntroduction.Mixin) mixins.get(i);
+            InterfaceIntroduction.Mixin mixin = mixins.get(i);
             // FIXME ClassLoader - how do we know the class is visible from the context classloader?
             ClassLoader cl = SecurityActions.getContextClassLoader();
             cl.loadClass(mixin.getClassName());
             String[] interfaces = mixin.getInterfaces();
             for (int j = 0; j < interfaces.length; j++)
             {
-               Class intf = cl.loadClass(interfaces[j]);
+               Class<?> intf = cl.loadClass(interfaces[j]);
                if (intf.isAssignableFrom(clazz))//This is a fix for JBAOP-365. Class may have been woven, with the extra mixin information only available at init time
                {
                   Method[] methods = intf.getMethods();
@@ -409,18 +407,19 @@
       }
    }
 
-
+   @Override
    public synchronized void removeAdviceBinding(AdviceBinding binding)
    {
       removeCallerPointcut(binding); // if binding is a caller remove references to it
       super.removeAdviceBinding(binding);
    }
 
-   public synchronized void removeAdviceBindings(ArrayList bindings)
+   @Override
+   public synchronized void removeAdviceBindings(ArrayList<AdviceBinding> bindings)
    {
       for (int i = 0; i < bindings.size(); i++)
       {
-         AdviceBinding binding = (AdviceBinding) bindings.get(i);
+         AdviceBinding binding = bindings.get(i);
          removeCallerPointcut(binding);
       }
       adviceBindings.removeAll(bindings);
@@ -444,7 +443,7 @@
          }
       }
    }
-   
+
    protected void initializeMethodChain()
    {
       long[] keys = advisedMethods.keys();
@@ -572,7 +571,7 @@
 //         info.setInterceptors(interceptors);
 //      }
 //   }
-   
+
    protected void createInterceptorChains() throws Exception
    {
       if (AspectManager.verbose && logger.isDebugEnabled()) logger.debug("Creating chains for " + clazz + " " + ((clazz != null) ? clazz.getClassLoader() : null ));
@@ -586,16 +585,14 @@
          initializeFieldWriteChain();
          initializeMethodChain();
       }
-      
+
       initializeConstructorChain();
       initializeConstructionChain();
 
       synchronized (manager.getBindings())
       {
-         Iterator it = manager.getBindings().values().iterator();
-         while (it.hasNext())
+         for (AdviceBinding binding : manager.getBindings().values())
          {
-            AdviceBinding binding = (AdviceBinding) it.next();
             if (AspectManager.verbose && logger.isDebugEnabled()) logger.debug("iterate binding " + binding.getName() + " " + binding.getPointcut().getExpr());
             resolveMethodPointcut(binding);
             resolveFieldPointcut(fieldReadInfos, binding, false);
@@ -613,17 +610,17 @@
       if (this.interceptorChainObserver != null)
       {
          this.interceptorChainObserver.interceptorChainsUpdated(fieldReadInterceptors, fieldWriteInterceptors,
-               constructorInterceptors, methodInterceptors);
+               constructorInterceptors, methodInfos);
       }
    }
-   
+
    protected void updateInterceptorChains() throws Exception
    {
       if (AspectManager.verbose && logger.isDebugEnabled())
       {
-         logger.debug("Updating chains for " + clazz + " " + ((clazz != null) ? clazz.getClassLoader() : null ));  
+         logger.debug("Updating chains for " + clazz + " " + ((clazz != null) ? clazz.getClassLoader() : null ));
       }
-      
+
       lockWriteChain(methodInfos);
       lockWriteChain(fieldReadInfos);
       lockWriteChain(fieldWriteInfos);
@@ -636,13 +633,11 @@
          resetChain(fieldWriteInfos);
          resetChain(constructorInfos);
          resetChain(constructionInfos);
-   
+
          synchronized (manager.getBindings())
          {
-            Iterator it = manager.getBindings().values().iterator();
-            while (it.hasNext())
+            for (AdviceBinding binding : manager.getBindings().values())
             {
-               AdviceBinding binding = (AdviceBinding) it.next();
                if (AspectManager.verbose && logger.isDebugEnabled()) logger.debug("iterate binding " + binding.getName() + " " + binding.getPointcut().getExpr());
                resolveMethodPointcut(binding);
                resolveFieldPointcut(fieldReadInfos, binding, false);
@@ -651,7 +646,7 @@
                resolveConstructionPointcut(binding);
             }
          }
-   
+
          finalizeChains();
          populateInterceptorsFromInfos();
       }
@@ -663,13 +658,13 @@
          unlockWriteChain(constructorInfos);
          unlockWriteChain(constructionInfos);
       }
-      
+
       doesHaveAspects = adviceBindings.size() > 0;
       // Notify observer about this change
       if (this.interceptorChainObserver != null)
       {
          this.interceptorChainObserver.interceptorChainsUpdated(fieldReadInterceptors, fieldWriteInterceptors,
-               constructorInterceptors, methodInterceptors);
+               constructorInterceptors, methodInfos);
       }
    }
 
@@ -681,16 +676,16 @@
       finalizeChain(constructorInfos);
       finalizeChain(constructionInfos);
    }
-   
-   private MethodByConInfo initializeConstructorCallerInterceptorsMap(Class callingClass, int callingIndex, String calledClass, long calledMethodHash, Method calledMethod) throws Exception
+
+   private MethodByConInfo initializeConstructorCallerInterceptorsMap(Class<?> callingClass, int callingIndex, String calledClass, long calledMethodHash, Method calledMethod) throws Exception
    {
-      HashMap calledClassesMap = methodCalledByConInterceptors[callingIndex];
+      HashMap<String, TLongObjectHashMap> calledClassesMap = methodCalledByConInterceptors[callingIndex];
       if (calledClassesMap == null)
       {
-         calledClassesMap = new HashMap();
+         calledClassesMap = new HashMap<String, TLongObjectHashMap>();
          methodCalledByConInterceptors[callingIndex] = calledClassesMap;
       }
-      TLongObjectHashMap calledMethodsMap = (TLongObjectHashMap) calledClassesMap.get(calledClass);
+      TLongObjectHashMap calledMethodsMap = calledClassesMap.get(calledClass);
       if (calledMethodsMap == null)
       {
          calledMethodsMap = new TLongObjectHashMap();
@@ -698,23 +693,24 @@
       }
 
       //The standard MethodCalledByXXXXInvocation class calls by reflection and needs access
-      calledMethod.setAccessible(true);
+      SecurityActions.setAccessible(calledMethod);
+
       // FIXME ClassLoader - how do we know the class is visible from the context classloader?
-      Class calledClazz = SecurityActions.getContextClassLoader().loadClass(calledClass);
+      Class<?> calledClazz = SecurityActions.getContextClassLoader().loadClass(calledClass);
       MethodByConInfo info = new MethodByConInfo(this, calledClazz, callingClass, callingIndex, calledMethod, calledMethodHash, null);
       calledMethodsMap.put(calledMethodHash, info);
       return info;
    }
 
-   private ConByConInfo initializeConCalledByConInterceptorsMap(Class callingClass, int callingIndex, String calledClass, long calledConHash, Constructor calledCon) throws Exception
+   private ConByConInfo initializeConCalledByConInterceptorsMap(Class<?> callingClass, int callingIndex, String calledClass, long calledConHash, Constructor<?> calledCon) throws Exception
    {
-      HashMap calledClassesMap = conCalledByConInterceptors[callingIndex];
+      HashMap<String, TLongObjectHashMap> calledClassesMap = conCalledByConInterceptors[callingIndex];
       if (calledClassesMap == null)
       {
-         calledClassesMap = new HashMap();
+         calledClassesMap = new HashMap<String, TLongObjectHashMap>();
          conCalledByConInterceptors[callingIndex] = calledClassesMap;
       }
-      TLongObjectHashMap calledMethodsMap = (TLongObjectHashMap) calledClassesMap.get(calledClass);
+      TLongObjectHashMap calledMethodsMap = calledClassesMap.get(calledClass);
       if (calledMethodsMap == null)
       {
          calledMethodsMap = new TLongObjectHashMap();
@@ -726,12 +722,12 @@
    }
 
 
-   private ConByConInfo createConByConInfo(Class callingClass, int callingIndex, String calledClass, Constructor calledCon, long calledConHash) throws Exception
+   private ConByConInfo createConByConInfo(Class<?> callingClass, int callingIndex, String calledClass, Constructor<?> calledCon, long calledConHash) throws Exception
    {
       //The standard ConstructorCalledByXXXXInvocation class calls by reflection and needs access
       calledCon.setAccessible(true);
       // FIXME ClassLoader - how do we know the class is visible from the context classloader?
-      Class calledClazz = SecurityActions.getContextClassLoader().loadClass(calledClass);
+      Class<?> calledClazz = SecurityActions.getContextClassLoader().loadClass(calledClass);
 
       try
       {
@@ -754,19 +750,17 @@
       }
       for (int i = 0; i < methodCalledByConInterceptors.length; i++)
       {
-         HashMap calledClasses = methodCalledByConInterceptors[i];
+         HashMap<String, TLongObjectHashMap> calledClasses = methodCalledByConInterceptors[i];
          if (calledClasses == null) continue;
-         Iterator classesIterator = calledClasses.entrySet().iterator();
-         while (classesIterator.hasNext())
+         for (Map.Entry<String, TLongObjectHashMap> entry : calledClasses.entrySet())
          {
-            Map.Entry entry = (Map.Entry) classesIterator.next();
-            String cname = (String) entry.getKey();
-            TLongObjectHashMap calledMethods = (TLongObjectHashMap) entry.getValue();
+            String cname = entry.getKey();
+            TLongObjectHashMap calledMethods = entry.getValue();
             long[] calledKeys = calledMethods.keys();
             for (int j = 0; j < calledKeys.length; j++)
             {
                long calledHash = calledKeys[j];
-               ArrayList bindings = getConstructorCallerBindings(i, cname, calledHash);
+               ArrayList<AdviceBinding> bindings = getConstructorCallerBindings(i, cname, calledHash);
                bindConstructorCallerInterceptorChain(bindings, i, cname, calledHash);
             }
          }
@@ -777,69 +771,65 @@
       }
       for (int i = 0; i < conCalledByConInterceptors.length; i++)
       {
-         HashMap calledClasses = conCalledByConInterceptors[i];
+         HashMap<String, TLongObjectHashMap> calledClasses = conCalledByConInterceptors[i];
          if (calledClasses == null) continue;
-         Iterator classesIterator = calledClasses.entrySet().iterator();
-         while (classesIterator.hasNext())
+         for (Map.Entry<String, TLongObjectHashMap> entry : calledClasses.entrySet())
          {
-            Map.Entry entry = (Map.Entry) classesIterator.next();
-            String cname = (String) entry.getKey();
-            TLongObjectHashMap calledMethods = (TLongObjectHashMap) entry.getValue();
+            String cname = entry.getKey();
+            TLongObjectHashMap calledMethods = entry.getValue();
             long[] calledKeys = calledMethods.keys();
             for (int j = 0; j < calledKeys.length; j++)
             {
                long calledHash = calledKeys[j];
-               ArrayList bindings = getConCalledByConBindings(i, cname, calledHash);
+               ArrayList<AdviceBinding> bindings = getConCalledByConBindings(i, cname, calledHash);
                bindConCalledByConInterceptorChain(bindings, i, cname, calledHash);
             }
          }
       }
    }
 
-   private ArrayList getConstructorCallerBindings(int callingIndex, String cname, long calledHash)
+   private ArrayList<AdviceBinding> getConstructorCallerBindings(int callingIndex, String cname, long calledHash)
    {
-      HashMap calledClasses = methodCalledByConBindings[callingIndex];
-      TLongObjectHashMap calledMethods = (TLongObjectHashMap) calledClasses.get(cname);
-      return (ArrayList) calledMethods.get(calledHash);
+      HashMap<String, TLongObjectHashMap> calledClasses = methodCalledByConBindings[callingIndex];
+      TLongObjectHashMap calledMethods = calledClasses.get(cname);
+      return (ArrayList<AdviceBinding>) calledMethods.get(calledHash);
    }
 
-   private ArrayList getConCalledByConBindings(int callingIndex, String cname, long calledHash)
+   private ArrayList<AdviceBinding> getConCalledByConBindings(int callingIndex, String cname, long calledHash)
    {
-      HashMap calledClasses = conCalledByConBindings[callingIndex];
-      TLongObjectHashMap calledMethods = (TLongObjectHashMap) calledClasses.get(cname);
-      return (ArrayList) calledMethods.get(calledHash);
+      HashMap<String, TLongObjectHashMap> calledClasses = conCalledByConBindings[callingIndex];
+      TLongObjectHashMap calledMethods = calledClasses.get(cname);
+      return (ArrayList<AdviceBinding>) calledMethods.get(calledHash);
    }
 
    protected void finalizeMethodCalledByMethodInterceptorChain(MethodByMethodInfo info)
    {
-      ArrayList list = info.getInterceptorChain();
+      ArrayList<Interceptor> list = info.getInterceptorChain();
       Interceptor[] interceptors = null;
       if (list.size() > 0)
       {
-         interceptors = (Interceptor[]) list.toArray(new Interceptor[list.size()]);
+         interceptors = list.toArray(new Interceptor[list.size()]);
       }
       info.setInterceptors(interceptors);
    }
 
    protected void finalizeConCalledByMethodInterceptorChain(ConByMethodInfo info)
    {
-      ArrayList list = info.getInterceptorChain();
+      ArrayList<Interceptor> list = info.getInterceptorChain();
       Interceptor[] interceptors = null;
       if (list.size() > 0)
       {
-         interceptors = (Interceptor[]) list.toArray(new Interceptor[list.size()]);
+         interceptors = list.toArray(new Interceptor[list.size()]);
       }
       info.setInterceptors(interceptors);
    }
 
-   private void bindConCalledByConInterceptorChain(ArrayList bindings, int callingIndex, String cname, long calledHash)
+   private void bindConCalledByConInterceptorChain(ArrayList<AdviceBinding> bindings, int callingIndex, String cname, long calledHash)
    {
       ConByConInfo info = getConCalledByCon(callingIndex, cname, calledHash);
       info.clear();
-      Iterator it = bindings.iterator();
-      while (it.hasNext())
+      for (AdviceBinding binding : bindings)
       {
-         AdviceBinding binding = (AdviceBinding) it.next();
          pointcutResolved(info, binding, new ConstructorCalledByConstructorJoinpoint(info.getCallingConstructor(), info.getConstructor()));
       }
       finalizeConCalledByConInterceptorChain(info);
@@ -847,23 +837,21 @@
 
    protected void finalizeConCalledByConInterceptorChain(ConByConInfo info)
    {
-      ArrayList list = info.getInterceptorChain();
+      ArrayList<Interceptor> list = info.getInterceptorChain();
       Interceptor[] interceptors = null;
       if (list.size() > 0)
       {
-         interceptors = (Interceptor[]) list.toArray(new Interceptor[list.size()]);
+         interceptors = list.toArray(new Interceptor[list.size()]);
       }
       info.setInterceptors(interceptors);
    }
 
-   private void bindConstructorCallerInterceptorChain(ArrayList bindings, int callingIndex, String cname, long calledHash)
+   private void bindConstructorCallerInterceptorChain(ArrayList<AdviceBinding> bindings, int callingIndex, String cname, long calledHash)
    {
       MethodByConInfo info = getConstructorCallerMethodInfo(callingIndex, cname, calledHash);
       info.clear();
-      Iterator it = bindings.iterator();
-      while (it.hasNext())
+      for (AdviceBinding binding : bindings)
       {
-         AdviceBinding binding = (AdviceBinding) it.next();
          pointcutResolved(info, binding, new MethodCalledByConstructorJoinpoint(info.getCallingConstructor(), info.getMethod()));
       }
       finalizeMethodCalledByConInterceptorChain(info);
@@ -871,11 +859,11 @@
 
    protected void finalizeMethodCalledByConInterceptorChain(MethodByConInfo info)
    {
-      ArrayList list = info.getInterceptorChain();
+      ArrayList<Interceptor> list = info.getInterceptorChain();
       Interceptor[] interceptors = null;
       if (list.size() > 0)
       {
-         interceptors = (Interceptor[]) list.toArray(new Interceptor[list.size()]);
+         interceptors = list.toArray(new Interceptor[list.size()]);
       }
       info.setInterceptors(interceptors);
    }
@@ -929,7 +917,7 @@
          Field[] fields = advisedFields;
          // set to empty array because advisedFields may not have been initialized yet
          if (fields == null) fields = new Field[0];
-         Constructor[] cons = constructors;
+         Constructor<?>[] cons = constructors;
          // set to empty array because constructors may not have been initialized yet
          if (cons == null) cons = new Constructor[0];
          for (int i = 0; i < objs.length; i++) methods[i] = (Method) objs[i];
@@ -952,7 +940,7 @@
 
       for (int i = 0; i < classMetaDataBindings.size(); i++)
       {
-         ClassMetaDataBinding data = (ClassMetaDataBinding) classMetaDataBindings.get(i);
+         ClassMetaDataBinding data = classMetaDataBindings.get(i);
          bindClassMetaData(data);
       }
 
@@ -990,44 +978,44 @@
 
    private void initializeEmptyConstructorCallerChain(int callingIndex, String calledClass, long calledMethodHash) throws Exception
    {
-      HashMap callingCon = methodCalledByConBindings[callingIndex];
+      HashMap<String, TLongObjectHashMap>  callingCon = methodCalledByConBindings[callingIndex];
       if (callingCon == null)
       {
-         callingCon = new HashMap();
+         callingCon = new HashMap<String, TLongObjectHashMap>();
          methodCalledByConBindings[callingIndex] = callingCon;
       }
-      TLongObjectHashMap classMap = (TLongObjectHashMap) callingCon.get(calledClass);
+      TLongObjectHashMap classMap = callingCon.get(calledClass);
       if (classMap == null)
       {
          classMap = new TLongObjectHashMap();
          callingCon.put(calledClass, classMap);
       }
-      ArrayList bindings = (ArrayList) classMap.get(calledMethodHash);
+      ArrayList<AdviceBinding> bindings = (ArrayList<AdviceBinding>) classMap.get(calledMethodHash);
       if (bindings == null)
       {
-         bindings = new ArrayList();
+         bindings = new ArrayList<AdviceBinding>();
          classMap.put(calledMethodHash, bindings);
       }
    }
 
    private void initializeConCalledByConEmptyChain(int callingIndex, String calledClass, long calledConHash) throws Exception
    {
-      HashMap callingCon = conCalledByConBindings[callingIndex];
+      HashMap<String, TLongObjectHashMap> callingCon = conCalledByConBindings[callingIndex];
       if (callingCon == null)
       {
-         callingCon = new HashMap();
+         callingCon = new HashMap<String, TLongObjectHashMap>();
          conCalledByConBindings[callingIndex] = callingCon;
       }
-      TLongObjectHashMap classMap = (TLongObjectHashMap) callingCon.get(calledClass);
+      TLongObjectHashMap classMap = callingCon.get(calledClass);
       if (classMap == null)
       {
          classMap = new TLongObjectHashMap();
          callingCon.put(calledClass, classMap);
       }
-      ArrayList bindings = (ArrayList) classMap.get(calledConHash);
+      ArrayList<AdviceBinding> bindings = (ArrayList<AdviceBinding>) classMap.get(calledConHash);
       if (bindings == null)
       {
-         bindings = new ArrayList();
+         bindings = new ArrayList<AdviceBinding>();
          classMap.put(calledConHash, bindings);
       }
    }
@@ -1037,33 +1025,33 @@
       if (AspectManager.verbose) System.err.println("constructor call matched binding " + binding.getPointcut().getExpr());
       adviceBindings.add(binding);
       binding.addAdvisor(this);
-      HashMap callingCon = methodCalledByConBindings[callingIndex];
+      HashMap<String, TLongObjectHashMap> callingCon = methodCalledByConBindings[callingIndex];
       if (callingCon == null)
       {
-         callingCon = new HashMap();
+         callingCon = new HashMap<String, TLongObjectHashMap>();
          methodCalledByConBindings[callingIndex] = callingCon;
       }
-      TLongObjectHashMap classMap = (TLongObjectHashMap) callingCon.get(calledClass);
+      TLongObjectHashMap classMap = callingCon.get(calledClass);
       if (classMap == null)
       {
          classMap = new TLongObjectHashMap();
          callingCon.put(calledClass, classMap);
       }
-      ArrayList bindings = (ArrayList) classMap.get(calledMethodHash);
+      ArrayList<AdviceBinding> bindings = (ArrayList<AdviceBinding>) classMap.get(calledMethodHash);
       boolean createdBindings = false;
       if (bindings == null)
       {
-         bindings = new ArrayList();
+         bindings = new ArrayList<AdviceBinding>();
          classMap.put(calledMethodHash, bindings);
          createdBindings = true;
       }
       if (!bindings.contains(binding)) bindings.add(binding);
 
       // this is so that we can undeploy a caller
-      ArrayList backrefs = (ArrayList) backrefMethodCalledByConstructorBindings.get(binding.getName());
+      ArrayList<ArrayList<AdviceBinding>> backrefs = backrefMethodCalledByConstructorBindings.get(binding.getName());
       if (backrefs == null)
       {
-         backrefs = new ArrayList();
+         backrefs = new ArrayList<ArrayList<AdviceBinding>>();
          backrefMethodCalledByConstructorBindings.put(binding.getName(), backrefs);
          backrefs.add(bindings);
       }
@@ -1075,33 +1063,33 @@
       if (AspectManager.verbose) System.err.println("constructor call matched binding " + binding.getPointcut().getExpr());
       adviceBindings.add(binding);
       binding.addAdvisor(this);
-      HashMap callingCon = conCalledByConBindings[callingIndex];
+      HashMap<String, TLongObjectHashMap> callingCon = conCalledByConBindings[callingIndex];
       if (callingCon == null)
       {
-         callingCon = new HashMap();
+         callingCon = new HashMap<String, TLongObjectHashMap>();
          conCalledByConBindings[callingIndex] = callingCon;
       }
-      TLongObjectHashMap classMap = (TLongObjectHashMap) callingCon.get(calledClass);
+      TLongObjectHashMap classMap = callingCon.get(calledClass);
       if (classMap == null)
       {
          classMap = new TLongObjectHashMap();
          callingCon.put(calledClass, classMap);
       }
-      ArrayList bindings = (ArrayList) classMap.get(calledConHash);
+      ArrayList<AdviceBinding> bindings = (ArrayList<AdviceBinding>) classMap.get(calledConHash);
       boolean createdBindings = false;
       if (bindings == null)
       {
-         bindings = new ArrayList();
+         bindings = new ArrayList<AdviceBinding>();
          classMap.put(calledConHash, bindings);
          createdBindings = true;
       }
       if (!bindings.contains(binding)) bindings.add(binding);
 
       // this is so that we can undeploy a caller
-      ArrayList backrefs = (ArrayList) backrefConCalledByConstructorBindings.get(binding.getName());
+      ArrayList<ArrayList<AdviceBinding>> backrefs = backrefConCalledByConstructorBindings.get(binding.getName());
       if (backrefs == null)
       {
-         backrefs = new ArrayList();
+         backrefs = new ArrayList<ArrayList<AdviceBinding>>();
          backrefConCalledByConstructorBindings.put(binding.getName(), backrefs);
          backrefs.add(bindings);
       }
@@ -1156,7 +1144,7 @@
             method.getParameterTypes()[0].equals(InstanceAdvisor.class)));
    }
 
-   private void populateFieldTable(ArrayList fields, Class superclass)
+   private void populateFieldTable(ArrayList<Field> fields, Class<?> superclass)
    throws Exception
    {
       if (superclass == null) return;
@@ -1166,7 +1154,7 @@
 
       // if (!isAdvised(superclass)) return;
 
-      ArrayList temp = new ArrayList();
+      ArrayList<Field> temp = new ArrayList<Field>();
       Field[] declaredFields = superclass.getDeclaredFields();
       for (int i = 0; i < declaredFields.length; i++)
       {
@@ -1186,15 +1174,15 @@
     */
    protected void createFieldTable() throws Exception
    {
-      ArrayList fields = new ArrayList();
+      ArrayList<Field> fields = new ArrayList<Field>();
 
       populateFieldTable(fields, clazz);
 
-      advisedFields = (Field[]) fields.toArray(new Field[fields.size()]);
+      advisedFields = fields.toArray(new Field[fields.size()]);
 
    }
 
-   protected void addDeclaredMethods(Class superclass) throws Exception
+   protected void addDeclaredMethods(Class<?> superclass) throws Exception
    {
       Method[] declaredMethods = superclass.getDeclaredMethods();
       for (int i = 0; i < declaredMethods.length; i++)
@@ -1224,7 +1212,7 @@
     * Superclasses get added first so subclasses will override with
     * correct overriden method
     */
-   private void populateMethodTables(Class superclass)
+   private void populateMethodTables(Class<?> superclass)
    throws Exception
    {
       if (superclass == null) return;
@@ -1274,10 +1262,10 @@
       return getMethodByMethodData().resolveCallerMethodInfo(callingMethodHash, calledClass, calledMethodHash);
    }
 
-   public WeakReference resolveCallerMethodInfoAsWeakReference(long callingMethodHash, String calledClass, long calledMethodHash)
+   public WeakReference<MethodByMethodInfo> resolveCallerMethodInfoAsWeakReference(long callingMethodHash, String calledClass, long calledMethodHash)
    {
       //Javassist doesn't like this in a field initialiser hence this method
-      return new WeakReference(resolveCallerMethodInfo(callingMethodHash, calledClass, calledMethodHash));
+      return new WeakReference<MethodByMethodInfo>(resolveCallerMethodInfo(callingMethodHash, calledClass, calledMethodHash));
    }
 
    public ConByMethodInfo resolveCallerConstructorInfo(long callingMethodHash, String calledClass, long calledConHash)
@@ -1285,10 +1273,10 @@
       return getConByMethodData().resolveCallerConstructorInfo(callingMethodHash, calledClass, calledConHash);
    }
 
-   public WeakReference resolveCallerConstructorInfoAsWeakReference(long callingMethodHash, String calledClass, long calledConHash)
+   public WeakReference<ConByMethodInfo> resolveCallerConstructorInfoAsWeakReference(long callingMethodHash, String calledClass, long calledConHash)
    {
       //Javassist doesn't like this in a field initialiser hence this method
-      return new WeakReference(resolveCallerConstructorInfo(callingMethodHash, calledClass, calledConHash));
+      return new WeakReference<ConByMethodInfo>(resolveCallerConstructorInfo(callingMethodHash, calledClass, calledConHash));
    }
 
    @Deprecated
@@ -1296,8 +1284,8 @@
    {
       return resolveConstructorCallerMethodInfo(this.getClazz(), callingIndex, calledClass, calledMethodHash);
    }
-   
-   public MethodByConInfo resolveConstructorCallerMethodInfo(Class callingClass, int callingIndex, String calledClass, long calledMethodHash)
+
+   public MethodByConInfo resolveConstructorCallerMethodInfo(Class<?> callingClass, int callingIndex, String calledClass, long calledMethodHash)
    {
       if (System.getSecurityManager() == null)
       {
@@ -1309,14 +1297,14 @@
       }
    }
 
-   private MethodByConInfo doResolveConstructorCallerMethodInfo(Class callingClass, int callingIndex, String calledClass, long calledMethodHash)
+   private MethodByConInfo doResolveConstructorCallerMethodInfo(Class<?> callingClass, int callingIndex, String calledClass, long calledMethodHash)
    {
       try
       {
-         Constructor callingConstructor = constructors[callingIndex];
+         Constructor<?> callingConstructor = constructors[callingIndex];
          if (callingConstructor == null) throw new RuntimeException("Unable to figure out calling method of a caller pointcut");
          // FIXME ClassLoader - how do we know the class is visible from the context classloader?
-         Class called = SecurityActions.getContextClassLoader().loadClass(calledClass);
+         Class<?> called = SecurityActions.getContextClassLoader().loadClass(calledClass);
          Method calledMethod = MethodHashing.findMethodByHash(called, calledMethodHash);
          if (calledMethod == null) throw new RuntimeException("Unable to figure out calledmethod of a caller pointcut");
 
@@ -1324,10 +1312,8 @@
 
          synchronized (manager.getBindings())
          {
-            Iterator it = manager.getBindings().values().iterator();
-            while (it.hasNext())
+            for (AdviceBinding binding : manager.getBindings().values())
             {
-               AdviceBinding binding = (AdviceBinding) it.next();
                if (binding.getPointcut().matchesCall(this, callingConstructor, called, calledMethod))
                {
                   addConstructorCallerPointcut(callingIndex, calledClass, calledMethodHash, binding);
@@ -1337,7 +1323,7 @@
          }
          if (!matched) initializeEmptyConstructorCallerChain(callingIndex, calledClass, calledMethodHash);
          MethodByConInfo info = initializeConstructorCallerInterceptorsMap(callingClass, callingIndex, calledClass, calledMethodHash, calledMethod);
-         ArrayList bindings = getConstructorCallerBindings(callingIndex, calledClass, calledMethodHash);
+         ArrayList<AdviceBinding> bindings = getConstructorCallerBindings(callingIndex, calledClass, calledMethodHash);
          bindConstructorCallerInterceptorChain(bindings, callingIndex, calledClass, calledMethodHash);
          return info;
       }
@@ -1348,24 +1334,24 @@
    }
 
    @Deprecated
-   public WeakReference resolveConstructorCallerMethodInfoAsWeakReference(int callingIndex, String calledClass, long calledMethodHash)
+   public WeakReference<MethodByConInfo> resolveConstructorCallerMethodInfoAsWeakReference(int callingIndex, String calledClass, long calledMethodHash)
    {
       //Javassist doesn't like this in a field initialiser hence this method
-      return new WeakReference(resolveConstructorCallerMethodInfo(callingIndex, calledClass, calledMethodHash));
+      return new WeakReference<MethodByConInfo>(resolveConstructorCallerMethodInfo(callingIndex, calledClass, calledMethodHash));
    }
 
-   public WeakReference resolveConstructorCallerMethodInfoAsWeakReference(Class callingClass, int callingIndex, String calledClass, long calledMethodHash)
+   public WeakReference<MethodByConInfo> resolveConstructorCallerMethodInfoAsWeakReference(Class<?> callingClass, int callingIndex, String calledClass, long calledMethodHash)
    {
       //Javassist doesn't like this in a field initialiser hence this method
-      return new WeakReference(resolveConstructorCallerMethodInfo(callingClass, callingIndex, calledClass, calledMethodHash));
+      return new WeakReference<MethodByConInfo>(resolveConstructorCallerMethodInfo(callingClass, callingIndex, calledClass, calledMethodHash));
    }
 
    public ConByConInfo resolveConstructorCallerConstructorInfo(int callingIndex, String calledClass, long calledConHash)
    {
       return resolveConstructorCallerConstructorInfo(this.getClazz(), callingIndex, calledClass, calledConHash);
    }
-   
-   public ConByConInfo resolveConstructorCallerConstructorInfo(Class callingClass, int callingIndex, String calledClass, long calledConHash)
+
+   public ConByConInfo resolveConstructorCallerConstructorInfo(Class<?> callingClass, int callingIndex, String calledClass, long calledConHash)
    {
       if (System.getSecurityManager() == null)
       {
@@ -1377,24 +1363,22 @@
       }
    }
 
-   private ConByConInfo doResolveConstructorCallerConstructorInfo(Class callingClass, int callingIndex, String calledClass, long calledConHash)
+   private ConByConInfo doResolveConstructorCallerConstructorInfo(Class<?> callingClass, int callingIndex, String calledClass, long calledConHash)
    {
       try
       {
-         Constructor callingConstructor = constructors[callingIndex];
+         Constructor<?> callingConstructor = constructors[callingIndex];
          if (callingConstructor == null) throw new RuntimeException("Unable to figure out calling method of a caller pointcut");
          // FIXME ClassLoader - how do we know the class is visible from the context classloader?
-         Class called = SecurityActions.getContextClassLoader().loadClass(calledClass);
-         Constructor calledCon = MethodHashing.findConstructorByHash(called, calledConHash);
+         Class<?> called = SecurityActions.getContextClassLoader().loadClass(calledClass);
+         Constructor<?> calledCon = MethodHashing.findConstructorByHash(called, calledConHash);
          if (calledCon == null) throw new RuntimeException("Unable to figure out calledcon of a caller pointcut");
 
          boolean matched = false;
          synchronized (manager.getBindings())
          {
-            Iterator it = manager.getBindings().values().iterator();
-            while (it.hasNext())
+            for (AdviceBinding binding : manager.getBindings().values())
             {
-               AdviceBinding binding = (AdviceBinding) it.next();
                if (binding.getPointcut().matchesCall(this, callingConstructor, called, calledCon))
                {
                   addConstructorCalledByConPointcut(callingIndex, calledClass, calledConHash, binding);
@@ -1404,7 +1388,7 @@
          }
          if (!matched) initializeConCalledByConEmptyChain(callingIndex, calledClass, calledConHash);
          ConByConInfo info = initializeConCalledByConInterceptorsMap(callingClass, callingIndex, calledClass, calledConHash, calledCon);
-         ArrayList bindings = getConCalledByConBindings(callingIndex, calledClass, calledConHash);
+         ArrayList<AdviceBinding> bindings = getConCalledByConBindings(callingIndex, calledClass, calledConHash);
          bindConCalledByConInterceptorChain(bindings, callingIndex, calledClass, calledConHash);
          return info;
       }
@@ -1415,18 +1399,18 @@
    }
 
    @Deprecated
-   public WeakReference resolveConstructorCallerConstructorInfoAsWeakReference(int callingIndex, String calledClass, long calledConHash)
+   public WeakReference<ConByConInfo> resolveConstructorCallerConstructorInfoAsWeakReference(int callingIndex, String calledClass, long calledConHash)
    {
       //Javassist doesn't like this in a field initialiser hence this method
-      return new WeakReference(resolveConstructorCallerConstructorInfo(callingIndex, calledClass, calledConHash));
+      return new WeakReference<ConByConInfo>(resolveConstructorCallerConstructorInfo(callingIndex, calledClass, calledConHash));
    }
-   
-   public WeakReference resolveConstructorCallerConstructorInfoAsWeakReference(Class callingClass, int callingIndex, String calledClass, long calledConHash)
+
+   public WeakReference<ConByConInfo> resolveConstructorCallerConstructorInfoAsWeakReference(Class<?> callingClass, int callingIndex, String calledClass, long calledConHash)
    {
       //Javassist doesn't like this in a field initialiser hence this method
-      return new WeakReference(resolveConstructorCallerConstructorInfo(callingClass, callingIndex, calledClass, calledConHash));
+      return new WeakReference<ConByConInfo>(resolveConstructorCallerConstructorInfo(callingClass, callingIndex, calledClass, calledConHash));
    }
-   
+
    /////////////////////////
    // Invoking
 
@@ -1447,7 +1431,7 @@
       }
    }
 
-   public Object invokeNewWithoutAdvisement(Object[] arguments, Constructor constructor) throws Throwable
+   public Object invokeNewWithoutAdvisement(Object[] arguments, Constructor<?> constructor) throws Throwable
    {
       try
       {
@@ -1489,7 +1473,7 @@
    public Object invokeMethod(InstanceAdvisor instanceAdvisor, Object target, long methodHash, Object[] arguments)
    throws Throwable
    {
-      MethodInfo info = (MethodInfo) methodInfos.getMethodInfo(methodHash);
+      MethodInfo info = methodInfos.getMethodInfo(methodHash);
       if (info == null && logger.isDebugEnabled())
       {
          logger.debug("info is null for hash: " + methodHash + " of " + clazz.getName());
@@ -1625,16 +1609,16 @@
 
    private MethodByConInfo getConstructorCallerMethodInfo(int callingIndex, String calledClass, long calledMethodHash)
    {
-      HashMap calledClasses = methodCalledByConInterceptors[callingIndex];
-      TLongObjectHashMap calledMethods = (TLongObjectHashMap) calledClasses.get(calledClass);
+      HashMap<String, TLongObjectHashMap> calledClasses = methodCalledByConInterceptors[callingIndex];
+      TLongObjectHashMap calledMethods = calledClasses.get(calledClass);
       MethodByConInfo info = (MethodByConInfo) calledMethods.get(calledMethodHash);
       return info;
    }
 
    private ConByConInfo getConCalledByCon(int callingIndex, String calledClass, long calledConHash)
    {
-      HashMap calledClasses = conCalledByConInterceptors[callingIndex];
-      TLongObjectHashMap calledMethods = (TLongObjectHashMap) calledClasses.get(calledClass);
+      HashMap<String, TLongObjectHashMap> calledClasses = conCalledByConInterceptors[callingIndex];
+      TLongObjectHashMap calledMethods = calledClasses.get(calledClass);
       ConByConInfo info = (ConByConInfo) calledMethods.get(calledConHash);
       return info;
    }
@@ -1735,12 +1719,12 @@
       {
          ConstructorInvocation cInvocation = (ConstructorInvocation) invocation;
          Object[] arguments = cInvocation.getArguments();
-         Constructor constructor = cInvocation.getConstructor();
+         Constructor<?> constructor = cInvocation.getConstructor();
          return invokeNewWithoutAdvisement(arguments, constructor);
       }
       throw new IllegalStateException("Unknown Invocation type: " + invocation.getClass().getName());
    }
-   
+
    @Override
    public void cleanup()
    {
@@ -1756,7 +1740,7 @@
          conByMethodData = null;
       }
    }
-   
+
    // interceptor chain observer
    private InterceptorChainObserver interceptorChainObserver;
 
@@ -1777,12 +1761,13 @@
       if (observer != null && this.initialized)
       {
          observer.initialInterceptorChains(this.clazz, fieldReadInterceptors, fieldWriteInterceptors,
-               constructorInterceptors, methodInterceptors);
+               constructorInterceptors, methodInfos);
       }
       this.interceptorChainObserver = observer;
    }
 
    /** @deprecated We should just be using xxxxInfos */
+   @Override
    protected void populateInterceptorsFromInfos()
    {
       super.populateInterceptorsFromInfos();
@@ -1801,25 +1786,20 @@
       {
          constructionInterceptors[i] = constructionInfos[i].getInterceptors();
       }
-   
+
    }
 
    protected MethodByMethodData getMethodByMethodData()
    {
       if (methodByMethodData == null)
       {
-         lockWrite();
-         try
+         synchronized(lazyCollectionLock)
          {
             if (methodByMethodData == null)
             {
                methodByMethodData = new MethodByMethodData();
             }
          }
-         finally
-         {
-            unlockWrite();
-         }
       }
       return methodByMethodData;
    }
@@ -1828,18 +1808,13 @@
    {
       if (conByMethodData == null)
       {
-         lockWrite();
-         try
+         synchronized(lazyCollectionLock)
          {
             if (conByMethodData == null)
             {
                conByMethodData = new ConByMethodData();
             }
          }
-         finally
-         {
-            unlockWrite();
-         }
       }
       return conByMethodData;
    }
@@ -1854,9 +1829,9 @@
          {
             try
             {
-               return (ConByMethodInfo)AccessController.doPrivileged(new PrivilegedExceptionAction()
+               return AccessController.doPrivileged(new PrivilegedExceptionAction<ConByMethodInfo>()
                {
-                  public Object run() throws Exception
+                  public ConByMethodInfo run() throws Exception
                   {
                      return data.doResolveCallerConstructorInfo(callingMethodHash, calledClass, calledConHash);
                   }
@@ -1893,9 +1868,9 @@
          {
             try
             {
-               return (MethodByMethodInfo)AccessController.doPrivileged(new PrivilegedExceptionAction()
+               return AccessController.doPrivileged(new PrivilegedExceptionAction<MethodByMethodInfo>()
                {
-                  public Object run() throws Exception
+                  public MethodByMethodInfo run() throws Exception
                   {
                      return data.doResolveCallerMethodInfo(callingMethodHash, calledClass, calledMethodHash);
                   }
@@ -1924,17 +1899,17 @@
 
    interface ResolveConstructorCallerMethodInfoAction
    {
-      MethodByConInfo resolveInfo(ClassAdvisor advisor, Class callingClass, int callingIndex, String calledClass, long calledMethodHash);
+      MethodByConInfo resolveInfo(ClassAdvisor advisor, Class<?> callingClass, int callingIndex, String calledClass, long calledMethodHash);
 
       ResolveConstructorCallerMethodInfoAction PRIVILEGED = new ResolveConstructorCallerMethodInfoAction()
       {
-         public MethodByConInfo resolveInfo(final ClassAdvisor advisor, final Class callingClass, final int callingIndex, final String calledClass, final long calledMethodHash)
+         public MethodByConInfo resolveInfo(final ClassAdvisor advisor, final Class<?> callingClass, final int callingIndex, final String calledClass, final long calledMethodHash)
          {
             try
             {
-               return (MethodByConInfo)AccessController.doPrivileged(new PrivilegedExceptionAction()
+               return AccessController.doPrivileged(new PrivilegedExceptionAction<MethodByConInfo>()
                {
-                  public Object run() throws Exception
+                  public MethodByConInfo run() throws Exception
                   {
                      return advisor.doResolveConstructorCallerMethodInfo(callingClass, callingIndex, calledClass, calledMethodHash);
                   }
@@ -1954,7 +1929,7 @@
 
       ResolveConstructorCallerMethodInfoAction NON_PRIVILEGED = new ResolveConstructorCallerMethodInfoAction()
       {
-         public MethodByConInfo resolveInfo(ClassAdvisor advisor, Class callingClass, int callingIndex, String calledClass, long calledMethodHash)
+         public MethodByConInfo resolveInfo(ClassAdvisor advisor, Class<?> callingClass, int callingIndex, String calledClass, long calledMethodHash)
          {
             return advisor.doResolveConstructorCallerMethodInfo(callingClass, callingIndex, calledClass, calledMethodHash);
          }
@@ -1963,17 +1938,17 @@
 
    interface ResolveConstructorCallerConstructorInfoAction
    {
-      ConByConInfo resolveInfo(ClassAdvisor advisor, Class callingClass, int callingIndex, String calledClass, long calledConHash);
+      ConByConInfo resolveInfo(ClassAdvisor advisor, Class<?> callingClass, int callingIndex, String calledClass, long calledConHash);
 
       ResolveConstructorCallerConstructorInfoAction PRIVILEGED = new ResolveConstructorCallerConstructorInfoAction()
       {
-         public ConByConInfo resolveInfo(final ClassAdvisor advisor, final Class callingClass, final int callingIndex, final String calledClass, final long calledConHash)
+         public ConByConInfo resolveInfo(final ClassAdvisor advisor, final Class<?> callingClass, final int callingIndex, final String calledClass, final long calledConHash)
          {
             try
             {
-               return (ConByConInfo)AccessController.doPrivileged(new PrivilegedExceptionAction()
+               return AccessController.doPrivileged(new PrivilegedExceptionAction<ConByConInfo>()
                {
-                  public Object run() throws Exception
+                  public ConByConInfo run() throws Exception
                   {
                      return advisor.doResolveConstructorCallerConstructorInfo(callingClass, callingIndex, calledClass, calledConHash);
                   }
@@ -1993,7 +1968,7 @@
 
       ResolveConstructorCallerConstructorInfoAction NON_PRIVILEGED = new ResolveConstructorCallerConstructorInfoAction()
       {
-         public ConByConInfo resolveInfo(ClassAdvisor advisor, Class callingClass, int callingIndex, String calledClass, long calledConHash)
+         public ConByConInfo resolveInfo(ClassAdvisor advisor, Class<?> callingClass, int callingIndex, String calledClass, long calledConHash)
          {
             return advisor.doResolveConstructorCallerConstructorInfo(callingClass, callingIndex, calledClass, calledConHash);
          }
@@ -2038,11 +2013,11 @@
          }
       };
    }
-   
+
    private class MethodByMethodData
    {
       private volatile TLongObjectHashMap methodCalledByMethodBindings = UnmodifiableEmptyCollections.EMPTY_TLONG_OBJECT_HASHMAP;
-      private volatile HashMap backrefMethodCalledByMethodBindings = UnmodifiableEmptyCollections.EMPTY_HASHMAP;
+      private volatile HashMap<String, ArrayList<ArrayList<AdviceBinding>>> backrefMethodCalledByMethodBindings = UnmodifiableEmptyCollections.EMPTY_HASHMAP;
       private volatile TLongObjectHashMap methodCalledByMethodInterceptors = UnmodifiableEmptyCollections.EMPTY_TLONG_OBJECT_HASHMAP;
 
       public TLongObjectHashMap getMethodCalledByMethodInterceptors()
@@ -2064,18 +2039,16 @@
          for (int i = 0; i < callingKeys.length; i++)
          {
             long callingHash = callingKeys[i];
-            HashMap calledClasses = (HashMap) methodCalledByMethodInterceptors.get(callingHash);
-            Iterator classesIterator = calledClasses.entrySet().iterator();
-            while (classesIterator.hasNext())
+            HashMap<String, TLongObjectHashMap> calledClasses = (HashMap<String, TLongObjectHashMap>) methodCalledByMethodInterceptors.get(callingHash);
+            for (Map.Entry<String, TLongObjectHashMap> entry : calledClasses.entrySet())
             {
-               Map.Entry entry = (Map.Entry) classesIterator.next();
-               String cname = (String) entry.getKey();
-               TLongObjectHashMap calledMethods = (TLongObjectHashMap) entry.getValue();
+               String cname = entry.getKey();
+               TLongObjectHashMap calledMethods = entry.getValue();
                long[] calledKeys = calledMethods.keys();
                for (int j = 0; j < calledKeys.length; j++)
                {
                   long calledHash = calledKeys[j];
-                  ArrayList bindings = getCallerBindings(callingHash, cname, calledHash);
+                  ArrayList<AdviceBinding> bindings = getCallerBindings(callingHash, cname, calledHash);
                   Method calling = MethodHashing.findMethodByHash(clazz, callingHash);
                   bindCallerInterceptorChain(bindings, callingHash, cname, calledHash, calling);
                }
@@ -2086,11 +2059,11 @@
       public void removeCallerPointcut(AdviceBinding binding)
       {
          //No need to initialise map here if it is empty
-         ArrayList backrefs = (ArrayList) backrefMethodCalledByMethodBindings.get(binding.getName());
+         ArrayList<ArrayList<AdviceBinding>> backrefs = backrefMethodCalledByMethodBindings.get(binding.getName());
          if (backrefs == null) return;
          for (int i = 0; i < backrefs.size(); i++)
          {
-            ArrayList ref = (ArrayList) backrefs.get(i);
+            ArrayList<AdviceBinding> ref = backrefs.get(i);
             ref.remove(binding);
          }
       }
@@ -2098,12 +2071,11 @@
       public MethodByMethodInfo resolveCallerMethodInfo(long callingMethodHash, String calledClass, long calledMethodHash)
       {
          //The main entry point for adding data to the maps, let us initialise them here.
-         if (methodCalledByMethodBindings == UnmodifiableEmptyCollections.EMPTY_TLONG_OBJECT_HASHMAP || 
-               backrefMethodCalledByMethodBindings == UnmodifiableEmptyCollections.EMPTY_HASHMAP || 
+         if (methodCalledByMethodBindings == UnmodifiableEmptyCollections.EMPTY_TLONG_OBJECT_HASHMAP ||
+               backrefMethodCalledByMethodBindings == UnmodifiableEmptyCollections.EMPTY_HASHMAP ||
                methodCalledByMethodInterceptors == UnmodifiableEmptyCollections.EMPTY_TLONG_OBJECT_HASHMAP)
          {
-            lockWrite();
-            try
+            synchronized(lazyCollectionLock)
             {
                if (methodCalledByMethodBindings == UnmodifiableEmptyCollections.EMPTY_TLONG_OBJECT_HASHMAP)
                {
@@ -2111,19 +2083,15 @@
                }
                if (backrefMethodCalledByMethodBindings == UnmodifiableEmptyCollections.EMPTY_HASHMAP)
                {
-                  backrefMethodCalledByMethodBindings = new HashMap();
+                  backrefMethodCalledByMethodBindings = new HashMap<String, ArrayList<ArrayList<AdviceBinding>>>();
                }
                if (methodCalledByMethodInterceptors == UnmodifiableEmptyCollections.EMPTY_TLONG_OBJECT_HASHMAP)
                {
                   methodCalledByMethodInterceptors = new TLongObjectHashMap();
                }
             }
-            finally
-            {
-               unlockWrite();
-            }
          }
-         
+
          if (System.getSecurityManager() == null)
          {
             return ResolveCallerMethodInfoAction.NON_PRIVILEGED.resolveInfo(this, callingMethodHash, calledClass, calledMethodHash);
@@ -2142,15 +2110,13 @@
             Method callingMethod = MethodHashing.findMethodByHash(clazz, callingMethodHash);
             if (callingMethod == null) throw new RuntimeException("Unable to figure out calling method of a caller pointcut");
             // FIXME ClassLoader - how do we know the class is visible from the context classloader?
-            Class called = SecurityActions.getContextClassLoader().loadClass(calledClass);
+            Class<?> called = SecurityActions.getContextClassLoader().loadClass(calledClass);
             Method calledMethod = MethodHashing.findMethodByHash(called, calledMethodHash);
             if (calledMethod == null) throw new RuntimeException("Unable to figure out calledmethod of a caller pointcut");
 
-            Iterator it = manager.getBindings().values().iterator();
             boolean matched = false;
-            while (it.hasNext())
+            for (AdviceBinding binding : manager.getBindings().values())
             {
-               AdviceBinding binding = (AdviceBinding) it.next();
                if (binding.getPointcut().matchesCall(ClassAdvisor.this, callingMethod, called, calledMethod))
                {
                   addMethodCalledByMethodPointcut(callingMethodHash, calledClass, calledMethodHash, binding);
@@ -2159,7 +2125,7 @@
             }
             if (!matched) initializeEmptyCallerChain(callingMethodHash, calledClass, calledMethodHash);
             MethodByMethodInfo info = initializeCallerInterceptorsMap(callingMethodHash, calledClass, calledMethodHash, callingMethod, calledMethod);
-            ArrayList bindings = getCallerBindings(callingMethodHash, calledClass, calledMethodHash);
+            ArrayList<AdviceBinding> bindings = getCallerBindings(callingMethodHash, calledClass, calledMethodHash);
             bindCallerInterceptorChain(bindings, callingMethodHash, calledClass, calledMethodHash, callingMethod);
             return info;
          }
@@ -2175,33 +2141,33 @@
          if (AspectManager.verbose) System.err.println("method call matched binding " + binding.getPointcut().getExpr());
          adviceBindings.add(binding);
          binding.addAdvisor(ClassAdvisor.this);
-         HashMap callingMethod = (HashMap) methodCalledByMethodBindings.get(callingMethodHash);
+         HashMap<String, TLongObjectHashMap> callingMethod = (HashMap<String, TLongObjectHashMap>)methodCalledByMethodBindings.get(callingMethodHash);
          if (callingMethod == null)
          {
-            callingMethod = new HashMap();
+            callingMethod = new HashMap<String, TLongObjectHashMap>();
             methodCalledByMethodBindings.put(callingMethodHash, callingMethod);
          }
-         TLongObjectHashMap classMap = (TLongObjectHashMap) callingMethod.get(calledClass);
+         TLongObjectHashMap classMap = callingMethod.get(calledClass);
          if (classMap == null)
          {
             classMap = new TLongObjectHashMap();
             callingMethod.put(calledClass, classMap);
          }
-         ArrayList bindings = (ArrayList) classMap.get(calledMethodHash);
+         ArrayList<AdviceBinding> bindings = (ArrayList<AdviceBinding>) classMap.get(calledMethodHash);
          boolean createdBindings = false;
          if (bindings == null)
          {
-            bindings = new ArrayList();
+            bindings = new ArrayList<AdviceBinding>();
             classMap.put(calledMethodHash, bindings);
             createdBindings = true;
          }
          if (!bindings.contains(binding)) bindings.add(binding);
-      
+
          // this is so that we can undeploy a caller
-         ArrayList backrefs = (ArrayList) backrefMethodCalledByMethodBindings.get(binding.getName());
+         ArrayList<ArrayList<AdviceBinding>> backrefs = backrefMethodCalledByMethodBindings.get(binding.getName());
          if (backrefs == null)
          {
-            backrefs = new ArrayList();
+            backrefs = new ArrayList<ArrayList<AdviceBinding>>();
             backrefMethodCalledByMethodBindings.put(binding.getName(), backrefs);
             backrefs.add(bindings);
          }
@@ -2211,22 +2177,22 @@
       private void initializeEmptyCallerChain(long callingMethodHash, String calledClass, long calledMethodHash) throws Exception
       {
          //Called via resolveCallerMethodInfo, maps are initialised
-         HashMap callingMethod = (HashMap) methodCalledByMethodBindings.get(callingMethodHash);
+         HashMap<String, TLongObjectHashMap> callingMethod = (HashMap<String, TLongObjectHashMap>) methodCalledByMethodBindings.get(callingMethodHash);
          if (callingMethod == null)
          {
-            callingMethod = new HashMap();
+            callingMethod = new HashMap<String, TLongObjectHashMap>();
             methodCalledByMethodBindings.put(callingMethodHash, callingMethod);
          }
-         TLongObjectHashMap classMap = (TLongObjectHashMap) callingMethod.get(calledClass);
+         TLongObjectHashMap classMap = callingMethod.get(calledClass);
          if (classMap == null)
          {
             classMap = new TLongObjectHashMap();
             callingMethod.put(calledClass, classMap);
          }
-         ArrayList bindings = (ArrayList) classMap.get(calledMethodHash);
+         ArrayList<AdviceBinding> bindings = (ArrayList<AdviceBinding>) classMap.get(calledMethodHash);
          if (bindings == null)
          {
-            bindings = new ArrayList();
+            bindings = new ArrayList<AdviceBinding>();
             classMap.put(calledMethodHash, bindings);
          }
       }
@@ -2234,13 +2200,13 @@
       private MethodByMethodInfo initializeCallerInterceptorsMap(long callingMethodHash, String calledClass, long calledMethodHash, Method callingMethod, Method calledMethod) throws Exception
       {
          //Called via resolveCallerMethodInfo, maps are initialised
-         HashMap calledClassesMap = (HashMap) methodCalledByMethodInterceptors.get(callingMethodHash);
+         HashMap<String, TLongObjectHashMap> calledClassesMap = (HashMap<String, TLongObjectHashMap>) methodCalledByMethodInterceptors.get(callingMethodHash);
          if (calledClassesMap == null)
          {
-            calledClassesMap = new HashMap();
+            calledClassesMap = new HashMap<String, TLongObjectHashMap>();
             methodCalledByMethodInterceptors.put(callingMethodHash, calledClassesMap);
          }
-         TLongObjectHashMap calledMethodsMap = (TLongObjectHashMap) calledClassesMap.get(calledClass);
+         TLongObjectHashMap calledMethodsMap = calledClassesMap.get(calledClass);
          if (calledMethodsMap == null)
          {
             calledMethodsMap = new TLongObjectHashMap();
@@ -2250,29 +2216,27 @@
          calledMethod.setAccessible(true);
 
          // FIXME ClassLoader - how do we know the class is visible from the context classloader?
-         Class calledClazz = SecurityActions.getContextClassLoader().loadClass(calledClass);
+         Class<?> calledClazz = SecurityActions.getContextClassLoader().loadClass(calledClass);
          MethodByMethodInfo info = new MethodByMethodInfo(ClassAdvisor.this, calledClazz, calledMethod, callingMethod, callingMethodHash, calledMethodHash, null);
          calledMethodsMap.put(calledMethodHash, info);
          return info;
       }
 
-      private ArrayList getCallerBindings(long callingHash, String cname, long calledHash)
+      private ArrayList<AdviceBinding> getCallerBindings(long callingHash, String cname, long calledHash)
       {
          //Called via resolveCallerMethodInfo, maps are initialised
-         HashMap calledClasses = (HashMap) methodCalledByMethodBindings.get(callingHash);
-         TLongObjectHashMap calledMethods = (TLongObjectHashMap) calledClasses.get(cname);
-         return (ArrayList) calledMethods.get(calledHash);
+         HashMap<String, TLongObjectHashMap> calledClasses = (HashMap<String, TLongObjectHashMap>) methodCalledByMethodBindings.get(callingHash);
+         TLongObjectHashMap calledMethods = calledClasses.get(cname);
+         return (ArrayList<AdviceBinding>) calledMethods.get(calledHash);
       }
 
-      private void bindCallerInterceptorChain(ArrayList bindings, long callingHash, String cname, long calledHash, Method calling)
+      private void bindCallerInterceptorChain(ArrayList<AdviceBinding> bindings, long callingHash, String cname, long calledHash, Method calling)
       {
          //Called via resolveCallerMethodInfo, maps are initialised
          MethodByMethodInfo info = getCallerMethodInfo(callingHash, cname, calledHash);
          info.clear();
-         Iterator it = bindings.iterator();
-         while (it.hasNext())
+         for (AdviceBinding binding : bindings)
          {
-            AdviceBinding binding = (AdviceBinding) it.next();
             pointcutResolved(info, binding, new MethodCalledByMethodJoinpoint(info.getCallingMethod(), info.getMethod()));
          }
          finalizeMethodCalledByMethodInterceptorChain(info);
@@ -2281,8 +2245,8 @@
       private MethodByMethodInfo getCallerMethodInfo(long callingMethodHash, String calledClass, long calledMethodHash)
       {
          //Called via resolveCallerMethodInfo, maps are initialised
-         HashMap calledClasses = (HashMap) methodCalledByMethodInterceptors.get(callingMethodHash);
-         TLongObjectHashMap calledMethods = (TLongObjectHashMap) calledClasses.get(calledClass);
+         HashMap<String, TLongObjectHashMap> calledClasses = (HashMap<String, TLongObjectHashMap>) methodCalledByMethodInterceptors.get(callingMethodHash);
+         TLongObjectHashMap calledMethods = calledClasses.get(calledClass);
          MethodByMethodInfo info = (MethodByMethodInfo) calledMethods.get(calledMethodHash);
          return info;
       }
@@ -2294,24 +2258,24 @@
          methodCalledByMethodInterceptors.clear();
       }
    }
-   
+
    private class ConByMethodData
    {
       // constructor caller pointcut support for methods calling constructors only
       private volatile TLongObjectHashMap conCalledByMethodBindings = UnmodifiableEmptyCollections.EMPTY_TLONG_OBJECT_HASHMAP;
-      private volatile HashMap backrefConCalledByMethodBindings = UnmodifiableEmptyCollections.EMPTY_HASHMAP;
+      private volatile HashMap<String, ArrayList<ArrayList<AdviceBinding>>> backrefConCalledByMethodBindings = UnmodifiableEmptyCollections.EMPTY_HASHMAP;
       private volatile TLongObjectHashMap conCalledByMethodInterceptors = UnmodifiableEmptyCollections.EMPTY_TLONG_OBJECT_HASHMAP;
-      
+
       public TLongObjectHashMap getConCalledByMethodInterceptors()
       {
          return conCalledByMethodInterceptors;
       }
 
-      public ArrayList getConCalledByMethodBindings(long callingHash, String cname, long calledHash)
+      public ArrayList<AdviceBinding> getConCalledByMethodBindings(long callingHash, String cname, long calledHash)
       {
-         HashMap calledClasses = (HashMap) conCalledByMethodBindings.get(callingHash);
-         TLongObjectHashMap calledCons = (TLongObjectHashMap) calledClasses.get(cname);
-         return (ArrayList) calledCons.get(calledHash);
+         HashMap<String, TLongObjectHashMap> calledClasses = (HashMap<String, TLongObjectHashMap>) conCalledByMethodBindings.get(callingHash);
+         TLongObjectHashMap calledCons = calledClasses.get(cname);
+         return (ArrayList<AdviceBinding>) calledCons.get(calledHash);
       }
 
       public void rebuildCallerInterceptors() throws Exception
@@ -2320,33 +2284,30 @@
          for (int i = 0; i < callingKeys.length; i++)
          {
             long callingHash = callingKeys[i];
-            HashMap calledClasses = (HashMap) conCalledByMethodInterceptors.get(callingHash);
-            Iterator classesIterator = calledClasses.entrySet().iterator();
-            while (classesIterator.hasNext())
+            HashMap<String, TLongObjectHashMap> calledClasses = (HashMap<String, TLongObjectHashMap>) conCalledByMethodInterceptors.get(callingHash);
+            for (Map.Entry<String, TLongObjectHashMap> entry : calledClasses.entrySet())
             {
-               Map.Entry entry = (Map.Entry) classesIterator.next();
-               String cname = (String) entry.getKey();
-               TLongObjectHashMap calledMethods = (TLongObjectHashMap) entry.getValue();
+               String cname = entry.getKey();
+               TLongObjectHashMap calledMethods = entry.getValue();
                long[] calledKeys = calledMethods.keys();
                for (int j = 0; j < calledKeys.length; j++)
                {
                   long calledHash = calledKeys[j];
-                  ArrayList bindings = getConCalledByMethodBindings(callingHash, cname, calledHash);
+                  ArrayList<AdviceBinding> bindings = getConCalledByMethodBindings(callingHash, cname, calledHash);
                   bindConCalledByMethodInterceptorChain(bindings, callingHash, cname, calledHash);
                }
             }
          }
       }
-      
+
       public ConByMethodInfo resolveCallerConstructorInfo(long callingMethodHash, String calledClass, long calledConHash)
       {
          //The main entry point for adding data to the maps, let us initialise them here.
-         if (conCalledByMethodBindings == UnmodifiableEmptyCollections.EMPTY_TLONG_OBJECT_HASHMAP || 
-               backrefConCalledByMethodBindings == UnmodifiableEmptyCollections.EMPTY_HASHMAP || 
+         if (conCalledByMethodBindings == UnmodifiableEmptyCollections.EMPTY_TLONG_OBJECT_HASHMAP ||
+               backrefConCalledByMethodBindings == UnmodifiableEmptyCollections.EMPTY_HASHMAP ||
                conCalledByMethodInterceptors == UnmodifiableEmptyCollections.EMPTY_TLONG_OBJECT_HASHMAP)
          {
-            lockWrite();
-            try
+            synchronized(lazyCollectionLock)
             {
                if (conCalledByMethodBindings == UnmodifiableEmptyCollections.EMPTY_TLONG_OBJECT_HASHMAP)
                {
@@ -2354,19 +2315,15 @@
                }
                if (backrefConCalledByMethodBindings == UnmodifiableEmptyCollections.EMPTY_HASHMAP)
                {
-                  backrefConCalledByMethodBindings = new HashMap();
+                  backrefConCalledByMethodBindings = new HashMap<String, ArrayList<ArrayList<AdviceBinding>>>();
                }
                if (conCalledByMethodInterceptors == UnmodifiableEmptyCollections.EMPTY_TLONG_OBJECT_HASHMAP)
                {
                   conCalledByMethodInterceptors = new TLongObjectHashMap();
                }
             }
-            finally
-            {
-               unlockWrite();
-            }
          }
-         
+
          if (System.getSecurityManager() == null)
          {
             return ResolveCallerConstuctorInfoAction.NON_PRIVILEGED.resolveInfo(this, callingMethodHash, calledClass, calledConHash);
@@ -2384,17 +2341,15 @@
             Method callingMethod = MethodHashing.findMethodByHash(clazz, callingMethodHash);
             if (callingMethod == null) throw new RuntimeException("Unable to figure out calling method of a constructor caller pointcut");
             // FIXME ClassLoader - how do we know the class is visible from the context classloader?
-            Class called = SecurityActions.getContextClassLoader().loadClass(calledClass);
-            Constructor calledCon = MethodHashing.findConstructorByHash(called, calledConHash);
+            Class<?> called = SecurityActions.getContextClassLoader().loadClass(calledClass);
+            Constructor<?> calledCon = MethodHashing.findConstructorByHash(called, calledConHash);
             if (calledCon == null) throw new RuntimeException("Unable to figure out calledcon of a constructor caller pointcut");
 
             boolean matched = false;
             synchronized (manager.getBindings())
             {
-               Iterator it = manager.getBindings().values().iterator();
-               while (it.hasNext())
+               for (AdviceBinding binding : manager.getBindings().values())
                {
-                  AdviceBinding binding = (AdviceBinding) it.next();
                   if (binding.getPointcut().matchesCall(ClassAdvisor.this, callingMethod, called, calledCon))
                   {
                      addConstructorCalledByMethodPointcut(callingMethodHash, calledClass, calledConHash, binding);
@@ -2404,7 +2359,7 @@
             }
             if (!matched) initializeConCalledByMethodEmptyChain(callingMethodHash, calledClass, calledConHash);
             ConByMethodInfo info = initializeConCalledByMethodInterceptorsMap(callingMethod, callingMethodHash, calledClass, calledConHash, calledCon);
-            ArrayList bindings = getConCalledByMethodBindings(callingMethodHash, calledClass, calledConHash);
+            ArrayList<AdviceBinding> bindings = getConCalledByMethodBindings(callingMethodHash, calledClass, calledConHash);
             bindConCalledByMethodInterceptorChain(bindings, callingMethodHash, calledClass, calledConHash);
             return info;
          }
@@ -2419,48 +2374,48 @@
          if (AspectManager.verbose) System.err.println("method call matched binding " + binding.getPointcut().getExpr());
          adviceBindings.add(binding);
          binding.addAdvisor(ClassAdvisor.this);
-         HashMap callingMethod = (HashMap) conCalledByMethodBindings.get(callingMethodHash);
+         HashMap<String, TLongObjectHashMap> callingMethod = (HashMap<String, TLongObjectHashMap>) conCalledByMethodBindings.get(callingMethodHash);
          if (callingMethod == null)
          {
-            callingMethod = new HashMap();
+            callingMethod = new HashMap<String, TLongObjectHashMap>();
             conCalledByMethodBindings.put(callingMethodHash, callingMethod);
          }
-         TLongObjectHashMap classMap = (TLongObjectHashMap) callingMethod.get(calledClass);
+         TLongObjectHashMap classMap = callingMethod.get(calledClass);
          if (classMap == null)
          {
             classMap = new TLongObjectHashMap();
             callingMethod.put(calledClass, classMap);
          }
-         ArrayList bindings = (ArrayList) classMap.get(calledMethodHash);
+         ArrayList<AdviceBinding> bindings = (ArrayList<AdviceBinding>) classMap.get(calledMethodHash);
          boolean createdBindings = false;
          if (bindings == null)
          {
-            bindings = new ArrayList();
+            bindings = new ArrayList<AdviceBinding>();
             classMap.put(calledMethodHash, bindings);
             createdBindings = true;
          }
          if (!bindings.contains(binding)) bindings.add(binding);
-      
+
          // this is so that we can undeploy a caller
-         ArrayList backrefs = (ArrayList) backrefConCalledByMethodBindings.get(binding.getName());
+         ArrayList<ArrayList<AdviceBinding>> backrefs = backrefConCalledByMethodBindings.get(binding.getName());
          if (backrefs == null)
          {
-            backrefs = new ArrayList();
+            backrefs = new ArrayList<ArrayList<AdviceBinding>>();
             backrefConCalledByMethodBindings.put(binding.getName(), backrefs);
             backrefs.add(bindings);
          }
          else if (createdBindings) backrefs.add(bindings);
       }
 
-      private ConByMethodInfo initializeConCalledByMethodInterceptorsMap(Method callingMethod, long callingMethodHash, String calledClass, long calledConHash, Constructor calledCon) throws Exception
+      private ConByMethodInfo initializeConCalledByMethodInterceptorsMap(Method callingMethod, long callingMethodHash, String calledClass, long calledConHash, Constructor<?> calledCon) throws Exception
       {
-         HashMap calledClassesMap = (HashMap) conCalledByMethodInterceptors.get(callingMethodHash);
+         HashMap<String, TLongObjectHashMap> calledClassesMap = (HashMap<String, TLongObjectHashMap>) conCalledByMethodInterceptors.get(callingMethodHash);
          if (calledClassesMap == null)
          {
-            calledClassesMap = new HashMap();
+            calledClassesMap = new HashMap<String, TLongObjectHashMap>();
             conCalledByMethodInterceptors.put(callingMethodHash, calledClassesMap);
          }
-         TLongObjectHashMap calledMethodsMap = (TLongObjectHashMap) calledClassesMap.get(calledClass);
+         TLongObjectHashMap calledMethodsMap = calledClassesMap.get(calledClass);
          if (calledMethodsMap == null)
          {
             calledMethodsMap = new TLongObjectHashMap();
@@ -2474,41 +2429,41 @@
 
       private void initializeConCalledByMethodEmptyChain(long callingMethodHash, String calledClass, long calledConHash) throws Exception
       {
-         HashMap callingMethod = (HashMap) conCalledByMethodBindings.get(callingMethodHash);
+         HashMap<String, TLongObjectHashMap> callingMethod = (HashMap<String, TLongObjectHashMap>) conCalledByMethodBindings.get(callingMethodHash);
          if (callingMethod == null)
          {
-            callingMethod = new HashMap();
+            callingMethod = new HashMap<String, TLongObjectHashMap>();
             conCalledByMethodBindings.put(callingMethodHash, callingMethod);
          }
-         TLongObjectHashMap classMap = (TLongObjectHashMap) callingMethod.get(calledClass);
+         TLongObjectHashMap classMap = callingMethod.get(calledClass);
          if (classMap == null)
          {
             classMap = new TLongObjectHashMap();
             callingMethod.put(calledClass, classMap);
          }
-         ArrayList bindings = (ArrayList) classMap.get(calledConHash);
+         ArrayList<AdviceBinding> bindings = (ArrayList<AdviceBinding>) classMap.get(calledConHash);
          if (bindings == null)
          {
-            bindings = new ArrayList();
+            bindings = new ArrayList<AdviceBinding>();
             classMap.put(calledConHash, bindings);
          }
       }
 
       private ConByMethodInfo getConCalledByMethod(long callingMethodHash, String calledClass, long calledConHash)
       {
-         HashMap calledClasses = (HashMap) conCalledByMethodInterceptors.get(callingMethodHash);
-         TLongObjectHashMap calledMethods = (TLongObjectHashMap) calledClasses.get(calledClass);
+         HashMap<String, TLongObjectHashMap> calledClasses = (HashMap<String, TLongObjectHashMap>) conCalledByMethodInterceptors.get(callingMethodHash);
+         TLongObjectHashMap calledMethods = calledClasses.get(calledClass);
          ConByMethodInfo info = (ConByMethodInfo) calledMethods.get(calledConHash);
          return info;
       }
 
-      private ConByMethodInfo createConByMethodInfo(String calledClass, Method callingMethod, long callingMethodHash, Constructor calledCon, long calledConHash) throws Exception
+      private ConByMethodInfo createConByMethodInfo(String calledClass, Method callingMethod, long callingMethodHash, Constructor<?> calledCon, long calledConHash) throws Exception
       {
          //The standard ConstructorCalledByXXXXInvocation class calls by reflection and needs access
          calledCon.setAccessible(true);
 
          // FIXME ClassLoader - how do we know the class is visible from the context classloader?
-         Class calledClazz = SecurityActions.getContextClassLoader().loadClass(calledClass);
+         Class<?> calledClazz = SecurityActions.getContextClassLoader().loadClass(calledClass);
          try
          {
             int index = calledClass.lastIndexOf('.');
@@ -2522,14 +2477,12 @@
          }
       }
 
-      private void bindConCalledByMethodInterceptorChain(ArrayList bindings, long callingHash, String cname, long calledHash) throws Exception
+      private void bindConCalledByMethodInterceptorChain(ArrayList<AdviceBinding> bindings, long callingHash, String cname, long calledHash) throws Exception
       {
          ConByMethodInfo info = getConCalledByMethod(callingHash, cname, calledHash);
          info.clear();
-         Iterator it = bindings.iterator();
-         while (it.hasNext())
+         for (AdviceBinding binding : bindings)
          {
-            AdviceBinding binding = (AdviceBinding) it.next();
             pointcutResolved(info, binding, new ConstructorCalledByMethodJoinpoint(info.getCallingMethod(), info.getConstructor()));
          }
          finalizeConCalledByMethodInterceptorChain(info);

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/ClassContainer.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/ClassContainer.java	2008-03-24 03:41:24 UTC (rev 71184)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/ClassContainer.java	2008-03-24 03:46:45 UTC (rev 71185)
@@ -28,7 +28,6 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
-import java.util.Iterator;
 import java.util.LinkedHashMap;
 
 import org.jboss.aop.advice.AdviceBinding;
@@ -64,7 +63,7 @@
       rebuildInterceptors();
    }
 
-   public void setClass(Class clazz)
+   public void setClass(Class<?> clazz)
    {
       this.clazz = clazz;
    }
@@ -81,7 +80,7 @@
 
    protected Field[] advisedFields;
 
-   private void populateFieldTable(ArrayList<Field> fields, final Class superclass)
+   private void populateFieldTable(ArrayList<Field> fields, final Class<?> superclass)
    {
       if (superclass == null) return;
       if (superclass.equals(Object.class)) return;
@@ -189,8 +188,16 @@
 
       for (int i = 0; i < classMetaDataBindings.size(); i++)
       {
-         ClassMetaDataBinding data = (ClassMetaDataBinding) classMetaDataBindings.get(i);
-         bindClassMetaData(data);
+         try
+         {
+            ClassMetaDataBinding data = classMetaDataBindings.get(i);
+            bindClassMetaData(data);
+         }
+         catch (ClassCastException e)
+         {
+            //This is for EJB3. It is putting the SerializedConcurrentAccess into the list 
+            logger.warn("Invalid object found in classMetaDataBindings map. The type was " + e.getMessage());
+         }
       }
    }
 
@@ -249,15 +256,13 @@
       initializeMethodChain();
       initializeConstructorChain();
 
-      LinkedHashMap bindings = manager.getBindings();
+      LinkedHashMap<String, AdviceBinding> bindings = manager.getBindings();
       synchronized (bindings)
       {
          if (bindings.size() > 0)
          {
-            Iterator it = bindings.values().iterator();
-            while (it.hasNext())
+            for (AdviceBinding binding : bindings.values())
             {
-               AdviceBinding binding = (AdviceBinding) it.next();
                if (AspectManager.verbose && logger.isDebugEnabled()) logger.debug("iterate binding " + binding.getName());
                resolveMethodPointcut(binding);
                resolveConstructorPointcut(binding);
@@ -276,15 +281,13 @@
       resetChain(this.methodInfos);
       resetChain(this.constructorInfos);
 
-      LinkedHashMap bindings = manager.getBindings();
+      LinkedHashMap<String, AdviceBinding> bindings = manager.getBindings();
       synchronized (bindings)
       {
          if (bindings.size() > 0)
          {
-            Iterator it = bindings.values().iterator();
-            while (it.hasNext())
+            for (AdviceBinding binding : bindings.values())
             {
-               AdviceBinding binding = (AdviceBinding) it.next();
                if (AspectManager.verbose && logger.isDebugEnabled()) logger.debug("iterate binding " + binding.getName());
                resolveMethodPointcut(binding);
                resolveConstructorPointcut(binding);

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/ClassInstanceAdvisor.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/ClassInstanceAdvisor.java	2008-03-24 03:41:24 UTC (rev 71184)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/ClassInstanceAdvisor.java	2008-03-24 03:46:45 UTC (rev 71185)
@@ -31,7 +31,6 @@
 import java.lang.ref.WeakReference;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Iterator;
 
 /**
  * Holds an object instance's metadata and attached interceptors
@@ -43,10 +42,10 @@
 {
    static final long serialVersionUID = -3057976129116723527L;
 
-   protected ArrayList insertedInterceptors = null;
-   protected ArrayList appendedInterceptors = null;
-   protected WeakReference instanceRef;
-   protected transient WeakReference classAdvisorRef;
+   protected ArrayList<Interceptor> insertedInterceptors = null;
+   protected ArrayList<Interceptor> appendedInterceptors = null;
+   protected WeakReference<Object> instanceRef;
+   protected transient WeakReference<Advisor> classAdvisorRef;
    public boolean hasInstanceAspects = false;
    /**
     * aspects is a weak hash map of AspectDefinitions so that perinstance advices can be undeployed/redeployed
@@ -61,7 +60,7 @@
 
    public ClassInstanceAdvisor(Object obj)
    {
-      this.instanceRef = new WeakReference(obj);
+      this.instanceRef = new WeakReference<Object>(obj);
       if (obj instanceof Advised)
       {
          Advised advised = (Advised) obj;
@@ -77,7 +76,7 @@
    
    private void setAdvisorAndInitialise(Advisor advizor)
    {
-      this.classAdvisorRef = new WeakReference(advizor);
+      this.classAdvisorRef = new WeakReference<Advisor>(advizor);
       
       if (advizor instanceof ClassAdvisor)
       {
@@ -113,10 +112,10 @@
 
    public Interceptor[] getInterceptors()
    {
-      ArrayList newlist = new ArrayList();
+      ArrayList<Interceptor> newlist = new ArrayList<Interceptor>();
       if (insertedInterceptors != null) newlist.addAll(insertedInterceptors);
       if (appendedInterceptors != null) newlist.addAll(appendedInterceptors);
-      return (Interceptor[]) newlist.toArray(new Interceptor[newlist.size()]);
+      return newlist.toArray(new Interceptor[newlist.size()]);
    }
 
    /**
@@ -125,19 +124,19 @@
    public Interceptor[] getInterceptors(Interceptor[] advisorChain)
    {
       if (insertedInterceptors == null && appendedInterceptors == null) return advisorChain;
-      ArrayList newlist = new ArrayList();
+      ArrayList<Interceptor> newlist = new ArrayList<Interceptor>();
       if (insertedInterceptors != null) newlist.addAll(insertedInterceptors);
       if (advisorChain != null)
       {
          newlist.addAll(Arrays.asList(advisorChain));
       }
       if (appendedInterceptors != null) newlist.addAll(appendedInterceptors);
-      return (Interceptor[]) newlist.toArray(new Interceptor[newlist.size()]);
+      return newlist.toArray(new Interceptor[newlist.size()]);
    }
 
    public void insertInterceptor(int index, Interceptor interceptor)
    {
-      ArrayList newList = new ArrayList();
+      ArrayList<Interceptor> newList = new ArrayList<Interceptor>();
       if (insertedInterceptors != null)
       {
          newList.addAll(insertedInterceptors);
@@ -153,7 +152,7 @@
 
    public void insertInterceptor(Interceptor interceptor)
    {
-      ArrayList newList = new ArrayList();
+      ArrayList<Interceptor> newList = new ArrayList<Interceptor>();
       if (insertedInterceptors != null)
       {
          newList.addAll(insertedInterceptors);
@@ -169,7 +168,7 @@
 
    public void appendInterceptor(Interceptor interceptor)
    {
-      ArrayList newList = new ArrayList();
+      ArrayList<Interceptor> newList = new ArrayList<Interceptor>();
       if (appendedInterceptors != null)
       {
          newList.addAll(appendedInterceptors);
@@ -185,7 +184,7 @@
 
    public void appendInterceptor(int index, Interceptor interceptor)
    {
-      ArrayList newList = new ArrayList();
+      ArrayList<Interceptor> newList = new ArrayList<Interceptor>();
       if (appendedInterceptors != null)
       {
          newList.addAll(appendedInterceptors);
@@ -222,10 +221,10 @@
       {
          for (int i = 0; i < insertedInterceptors.size(); i++)
          {
-            Interceptor interceptor = (Interceptor) insertedInterceptors.get(i);
+            Interceptor interceptor = insertedInterceptors.get(i);
             if (interceptor.getName().equals(name))
             {
-               ArrayList newList = new ArrayList();
+               ArrayList<Interceptor> newList = new ArrayList<Interceptor>();
                newList.addAll(insertedInterceptors);
                newList.remove(i);
                insertedInterceptors = newList;
@@ -237,10 +236,10 @@
       {
          for (int i = 0; i < appendedInterceptors.size(); i++)
          {
-            Interceptor interceptor = (Interceptor) appendedInterceptors.get(i);
+            Interceptor interceptor = appendedInterceptors.get(i);
             if (interceptor.getName().equals(name))
             {
-               ArrayList newList = new ArrayList();
+               ArrayList<Interceptor> newList = new ArrayList<Interceptor>();
                newList.addAll(appendedInterceptors);
                newList.remove(i);
                appendedInterceptors = newList;
@@ -270,10 +269,8 @@
          classAdvisor = ((ClassAdvisor) advised._getAdvisor());
       }
       int interceptorsAdded = 0;
-      Iterator it = stack.getInterceptorFactories().iterator();
-      while (it.hasNext())
+      for (InterceptorFactory factory : stack.getInterceptorFactories())
       {
-         InterceptorFactory factory = (InterceptorFactory) it.next();
          if (!factory.isDeployed()) continue;
          Interceptor interceptor = factory.create(classAdvisor, null);
          insertInterceptor(interceptor);
@@ -297,10 +294,8 @@
          classAdvisor = ((ClassAdvisor) advised._getAdvisor());
       }
       int interceptorsAdded = 0;
-      Iterator it = stack.getInterceptorFactories().iterator();
-      while (it.hasNext())
+      for (InterceptorFactory factory : stack.getInterceptorFactories())
       {
-         InterceptorFactory factory = (InterceptorFactory) it.next();
          if (!factory.isDeployed()) continue;
          Interceptor interceptor = factory.create(classAdvisor, null);
          appendInterceptor(interceptor);
@@ -324,10 +319,8 @@
          classAdvisor = ((ClassAdvisor) advised._getAdvisor());
       }
       int interceptorsRemoved = 0;
-      Iterator it = stack.getInterceptorFactories().iterator();
-      while (it.hasNext())
+      for (InterceptorFactory factory : stack.getInterceptorFactories())
       {
-         InterceptorFactory factory = (InterceptorFactory) it.next();
          if (!factory.isDeployed()) continue;
          Interceptor interceptor = factory.create(classAdvisor, null);
          interceptorsRemoved += internalRemoveInterceptor(interceptor.getName());
@@ -351,7 +344,7 @@
    protected void finalize()
    {
       ClassLoader classLoader = getClassAdvisor().getClazz().getClassLoader();
-      if (this.interceptorChainObserver == null || !getClassAdvisor().getManager().getRegisteredCLs().containsKey(classLoader))
+      if (this.interceptorChainObserver == null || !AspectManager.getRegisteredCLs().containsKey(classLoader))
       {
          return;
       }
@@ -362,7 +355,7 @@
    {
       if (classAdvisorRef != null)
       {
-         return (Advisor)classAdvisorRef.get();
+         return classAdvisorRef.get();
       }
       return null;
    }

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/ConByConInfo.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/ConByConInfo.java	2008-03-24 03:41:24 UTC (rev 71184)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/ConByConInfo.java	2008-03-24 03:46:45 UTC (rev 71185)
@@ -38,9 +38,9 @@
 public class ConByConInfo extends CallerConstructorInfo implements ConstructorCallByConstructor
 {
    private final int callingIndex;
-   private final Constructor calling;
+   private final Constructor<?> calling;
    
-   public ConByConInfo(Advisor advisor, Class calledClass, Class callingClass, int callingIndex, Constructor called, long calledConHash, Method wrappingMethod, Interceptor[] in)
+   public ConByConInfo(Advisor advisor, Class<?> calledClass, Class<?> callingClass, int callingIndex, Constructor<?> called, long calledConHash, Method wrappingMethod, Interceptor[] in)
    {
       super(advisor, calledClass, called, calledConHash, wrappingMethod, in, callingClass);
       this.callingIndex = callingIndex;
@@ -89,12 +89,12 @@
 
    //Use getCallingConstructor instead
    @Deprecated()
-   public Constructor getCalling()
+   public Constructor<?> getCalling()
    {
       return calling;
    }
    
-   public Constructor getCallingConstructor()
+   public Constructor<?> getCallingConstructor()
    {
       return calling;
    }

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/ConByMethodInfo.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/ConByMethodInfo.java	2008-03-24 03:41:24 UTC (rev 71184)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/ConByMethodInfo.java	2008-03-24 03:46:45 UTC (rev 71185)
@@ -28,7 +28,6 @@
 import org.jboss.aop.joinpoint.ConstructorCallByMethod;
 import org.jboss.aop.joinpoint.ConstructorCalledByMethodJoinpoint;
 import org.jboss.aop.joinpoint.Joinpoint;
-import org.jboss.aop.pointcut.Pointcut;
 
 /**
  * 
@@ -46,9 +45,8 @@
     * @param c
     * @param in
     */
-   public ConByMethodInfo(Advisor advisor, Class calledClass, Method callingMethod, long callingMethodHash, Constructor c, long calledConHash, Method wrappingMethod, Interceptor[] in)
+   public ConByMethodInfo(Advisor advisor, Class<?> calledClass, Method callingMethod, long callingMethodHash, Constructor<?> c, long calledConHash, Method wrappingMethod, Interceptor[] in)
    {
-      // FIXME ConByMethodJoinPont constructor
       super(advisor, calledClass, c, calledConHash, wrappingMethod, in, callingMethod.getDeclaringClass());
       this.callingMethodHash = callingMethodHash;
       this.callingMethod = callingMethod;

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/ConstructionInfo.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/ConstructionInfo.java	2008-03-24 03:41:24 UTC (rev 71184)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/ConstructionInfo.java	2008-03-24 03:46:45 UTC (rev 71185)
@@ -21,6 +21,7 @@
   */
 package org.jboss.aop;
 
+import java.lang.annotation.Annotation;
 import java.lang.reflect.Constructor;
 
 import org.jboss.aop.joinpoint.Construction;
@@ -37,7 +38,7 @@
  */
 public class ConstructionInfo extends JoinPointInfo implements Construction
 {
-   private Constructor constructor;
+   private Constructor<?> constructor;
    private int index;
 
    public ConstructionInfo()
@@ -45,7 +46,7 @@
       
    }
    
-   public ConstructionInfo(Class clazz, int index, long constructorHash, Advisor advisor)
+   public ConstructionInfo(Class<?> clazz, int index, long constructorHash, Advisor advisor)
    {
       super(advisor, clazz);
       try
@@ -89,12 +90,12 @@
       return sb.toString();
    }
 
-   public void setConstructor(Constructor constructor)
+   public void setConstructor(Constructor<?> constructor)
    {
       this.constructor = constructor;
    }
 
-   public Constructor getConstructor()
+   public Constructor<?> getConstructor()
    {
       return constructor;
    }
@@ -109,14 +110,14 @@
       return index;
    }
 
-   public Object resolveAnnotation(Class annotation)
+   public <T extends Annotation> T resolveAnnotation(Class<T> annotation)
    {
-      Object val = super.resolveAnnotation(annotation);
+      T val = super.resolveAnnotation(annotation);
       if (val != null) return val;
 
       if (getAdvisor() != null)
       {
-         val = getAdvisor().resolveAnnotation(constructor, annotation);
+         val = getAdvisor().resolveTypedAnnotation(constructor, annotation);
          if (val != null) return val;
       }
 

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/ConstructorInfo.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/ConstructorInfo.java	2008-03-24 03:41:24 UTC (rev 71184)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/ConstructorInfo.java	2008-03-24 03:46:45 UTC (rev 71185)
@@ -21,6 +21,7 @@
   */
 package org.jboss.aop;
 
+import java.lang.annotation.Annotation;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
 
@@ -39,14 +40,14 @@
 public class ConstructorInfo extends JoinPointInfo implements ConstructorExecution
 {
    private Method wrapper;
-   private Constructor constructor;
+   private Constructor<?> constructor;
    private int index;
    
    public ConstructorInfo()
    {
    }
    
-   public ConstructorInfo(Class clazz, int index, long wrapperHash, long constructorHash, Advisor advisor)
+   public ConstructorInfo(Class<?> clazz, int index, long wrapperHash, long constructorHash, Advisor advisor)
    {
       super(advisor, clazz);
       try
@@ -99,12 +100,12 @@
       return wrapper;
    }
 
-   public void setConstructor(Constructor constructor)
+   public void setConstructor(Constructor<?> constructor)
    {
       this.constructor = constructor;
    }
 
-   public Constructor getConstructor()
+   public Constructor<?> getConstructor()
    {
       return constructor;
    }
@@ -120,14 +121,14 @@
    }
    
 
-   public Object resolveAnnotation(Class annotation)
+   public <T extends Annotation> T resolveAnnotation(Class<T> annotation)
    {
-      Object val = super.resolveAnnotation(annotation);
+      T val = super.resolveAnnotation(annotation);
       if (val != null) return val;
 
       if (getAdvisor() != null)
       {
-         val = getAdvisor().resolveAnnotation(constructor, annotation);
+         val = getAdvisor().resolveTypedAnnotation(constructor, annotation);
          if (val != null) return val;
       }
 

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/Deployment.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/Deployment.java	2008-03-24 03:41:24 UTC (rev 71184)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/Deployment.java	2008-03-24 03:46:45 UTC (rev 71185)
@@ -28,6 +28,7 @@
 
 import java.io.File;
 import java.io.FilenameFilter;
+import java.io.InputStream;
 import java.net.URL;
 import java.util.Enumeration;
 import java.util.Iterator;
@@ -74,10 +75,10 @@
       {
          try
          {
-            Enumeration en = SecurityActions.getContextClassLoader().getResources("META-INF/jboss-aop.xml");
+            Enumeration<URL> en = SecurityActions.getContextClassLoader().getResources("META-INF/jboss-aop.xml");
             while (en.hasMoreElements())
             {
-               URL url = (URL) en.nextElement();
+               URL url = en.nextElement();
                if (AspectManager.verbose && logger.isDebugEnabled()) logger.debug("deploying  " + url);
                AspectXmlLoader.deployXML(url);
             }
@@ -113,7 +114,7 @@
          try
          {
             URL url = f.toURL();
-            Iterator it = ArchiveBrowser.getBrowser(url, new ClassFileFilter());
+            Iterator<InputStream> it = ArchiveBrowser.getBrowser(url, new ClassFileFilter());
             AspectAnnotationLoader loader = new AspectAnnotationLoader(AspectManager.instance());
             loader.deployInputStreamIterator(it);
          }

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/Domain.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/Domain.java	2008-03-24 03:41:24 UTC (rev 71184)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/Domain.java	2008-03-24 03:46:45 UTC (rev 71185)
@@ -21,6 +21,7 @@
   */
 package org.jboss.aop;
 
+import java.lang.ref.WeakReference;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.ArrayList;
@@ -32,8 +33,10 @@
 import org.jboss.aop.advice.AdviceBinding;
 import org.jboss.aop.advice.AdviceStack;
 import org.jboss.aop.advice.AspectDefinition;
+import org.jboss.aop.advice.DynamicCFlowDefinition;
 import org.jboss.aop.advice.InterceptorFactory;
 import org.jboss.aop.advice.PrecedenceDef;
+import org.jboss.aop.array.ArrayReplacement;
 import org.jboss.aop.introduction.AnnotationIntroduction;
 import org.jboss.aop.introduction.InterfaceIntroduction;
 import org.jboss.aop.metadata.ClassMetaDataBinding;
@@ -42,6 +45,7 @@
 import org.jboss.aop.pointcut.CFlowStack;
 import org.jboss.aop.pointcut.DynamicCFlow;
 import org.jboss.aop.pointcut.Pointcut;
+import org.jboss.aop.pointcut.PointcutInfo;
 import org.jboss.aop.pointcut.PointcutStats;
 import org.jboss.aop.pointcut.Typedef;
 import org.jboss.aop.pointcut.ast.ClassExpression;
@@ -97,11 +101,11 @@
       return parent.getManagerFQN() + name + "/";
    }
 
-   public static String getDomainName(final Class clazz, final boolean forInstance)
+   public static String getDomainName(final Class<?> clazz, final boolean forInstance)
    {
-      String name = (String)AccessController.doPrivileged(new PrivilegedAction() {
+      String name = AccessController.doPrivileged(new PrivilegedAction<String>() {
 
-         public Object run()
+         public String run()
          {
             StringBuffer sb = new StringBuffer();
             sb.append(clazz.getName());
@@ -147,20 +151,20 @@
    }
    
    @Override
-   public LinkedHashMap getBindings()
+   public LinkedHashMap<String, AdviceBinding> getBindings()
    {
       if (inheritsBindings)
       {
          if (!parentFirst)
          {
             // when child first, parent bindings go in first so that they can be overridden by child.
-            LinkedHashMap map = new LinkedHashMap(parent.getBindings());
+            LinkedHashMap<String, AdviceBinding> map = new LinkedHashMap<String, AdviceBinding>(parent.getBindings());
             map.putAll(this.bindings);
             return map;
          }
          else
          {
-            LinkedHashMap map = new LinkedHashMap(this.bindings);
+            LinkedHashMap<String, AdviceBinding> map = new LinkedHashMap<String, AdviceBinding>(this.bindings);
             map.putAll(parent.getBindings());
             return map;
          }
@@ -189,27 +193,28 @@
    }
    
    @Override
-   public synchronized void removeBindings(ArrayList binds)
+   public synchronized void removeBindings(ArrayList<String> binds)
    {
       super.removeBindings(binds);
       hasOwnBindings = bindings.size() > 0;
       hasOwnPointcuts = bindings.size() > 0;
    }
    
-   public LinkedHashMap getPointcuts()
+   @Override
+   public LinkedHashMap<String, Pointcut> getPointcuts()
    {
       if (inheritsBindings)
       {
          if (!parentFirst)
          {
             // when child first, parent bindings go in first so that they can be overridden by child.
-            LinkedHashMap map = new LinkedHashMap(parent.getPointcuts());
+            LinkedHashMap<String, Pointcut> map = new LinkedHashMap<String, Pointcut>(parent.getPointcuts());
             map.putAll(this.pointcuts);
             return map;
          }
          else
          {
-            LinkedHashMap map = new LinkedHashMap(this.pointcuts);
+            LinkedHashMap<String, Pointcut> map = new LinkedHashMap<String, Pointcut>(this.pointcuts);
             map.putAll(parent.getPointcuts());
             return map;
          }
@@ -237,20 +242,20 @@
    }
 
    @Override
-   public LinkedHashMap getPointcutInfos()
+   public LinkedHashMap<String, PointcutInfo> getPointcutInfos()
    {
       if (inheritsBindings)
       {
          if (!parentFirst)
          {
             // when child first, parent bindings go in first so that they can be overridden by child.
-            LinkedHashMap map = new LinkedHashMap(parent.getPointcutInfos());
+            LinkedHashMap<String, PointcutInfo> map = new LinkedHashMap<String, PointcutInfo>(parent.getPointcutInfos());
             map.putAll(this.pointcutInfos);
             return map;
          }
          else
          {
-            LinkedHashMap map = new LinkedHashMap(this.pointcutInfos);
+            LinkedHashMap<String, PointcutInfo> map = new LinkedHashMap<String, PointcutInfo>(this.pointcutInfos);
             map.putAll(parent.getPointcutInfos());
             return map;
          }
@@ -259,19 +264,19 @@
    }
 
    @Override
-   public List getAnnotationIntroductions()
+   public List<AnnotationIntroduction> getAnnotationIntroductions()
    {
 
       if (inheritsBindings)
       {
-         List result = new ArrayList();
+         List<AnnotationIntroduction> result = new ArrayList<AnnotationIntroduction>();
          if (!parentFirst)
          {
             // when child first, parent bindings go in first so that they can be overridden by child.
             result.addAll(parent.getAnnotationIntroductions());
             synchronized (annotationIntroductions)
             {
-               result = new ArrayList(annotationIntroductions.values());
+               result = new ArrayList<AnnotationIntroduction>(annotationIntroductions.values());
             }
             return result;
          }
@@ -279,7 +284,7 @@
          {
             synchronized (annotationIntroductions)
             {
-               result = new ArrayList(annotationIntroductions.values());
+               result = new ArrayList<AnnotationIntroduction>(annotationIntroductions.values());
             }
             result.addAll(parent.getAnnotationIntroductions());
             return result;
@@ -289,11 +294,12 @@
       return super.getAnnotationIntroductions();
    }
    
-   public Map getArrayReplacements()
+   @Override
+   public Map<String, ArrayReplacement> getArrayReplacements()
    {
       if (inheritsBindings)
       {
-         HashMap map = new HashMap();
+         HashMap<String, ArrayReplacement> map = new HashMap<String, ArrayReplacement>();
          if (!parentFirst)
          {
             // when child first, parent bindings go in first so that they can be overridden by child.
@@ -338,11 +344,11 @@
    }
    
    @Override
-   public List getAnnotationOverrides()
+   public List<AnnotationIntroduction> getAnnotationOverrides()
    {
       if (inheritsBindings)
       {
-         ArrayList list = new ArrayList();
+         ArrayList<AnnotationIntroduction> list = new ArrayList<AnnotationIntroduction>();
          if (!parentFirst)
          {
             // when child first, parent bindings go in first so that they can be overridden by child.
@@ -386,11 +392,11 @@
    }
    
    @Override
-   public Map getInterfaceIntroductions()
+   public Map<String, InterfaceIntroduction> getInterfaceIntroductions()
    {
       if (inheritsBindings)
       {
-         HashMap map = new HashMap();
+         HashMap<String, InterfaceIntroduction> map = new HashMap<String, InterfaceIntroduction>();
          if (!parentFirst)
          {
             // when child first, parent bindings go in first so that they can be overridden by child.
@@ -434,11 +440,11 @@
    }
    
    @Override
-   public Map getTypedefs()
+   public Map<String, Typedef> getTypedefs()
    {
       if (inheritsBindings)
       {
-         HashMap map = new HashMap();
+         HashMap<String, Typedef> map = new HashMap<String, Typedef>();
          if (!parentFirst)
          {
             // when child first, parent bindings go in first so that they can be overridden by child.
@@ -482,11 +488,11 @@
       hasOwnTypedefs = typedefs.size() > 0;
    }
 
-   public Map getInterceptorStacks()
+   public Map<String, AdviceStack> getInterceptorStacks()
    {
       if (inheritsBindings)
       {
-         HashMap map = new HashMap();
+         HashMap<String, AdviceStack> map = new HashMap<String, AdviceStack>();
          if (!parentFirst)
          {
             // when child first, parent bindings go in first so that they can be overridden by child.
@@ -510,11 +516,12 @@
       return super.getInterceptorStacks();
    }
 
-   public Map getClassMetaDataLoaders()
+   @Override
+   public Map<String, ClassMetaDataLoader> getClassMetaDataLoaders()
    {
       if (inheritsBindings)
       {
-         HashMap map = new HashMap();
+         HashMap<String, ClassMetaDataLoader> map = new HashMap<String, ClassMetaDataLoader>();
          if (!parentFirst)
          {
             // when child first, parent bindings go in first so that they can be overridden by child.
@@ -538,11 +545,12 @@
       return super.getClassMetaDataLoaders();
    }
 
-   public Map getCflowStacks()
+   @Override
+   public Map<String, CFlowStack> getCflowStacks()
    {
       if (inheritsBindings)
       {
-         HashMap map = new HashMap();
+         HashMap<String, CFlowStack> map = new HashMap<String, CFlowStack>();
          if (!parentFirst)
          {
             // when child first, parent bindings go in first so that they can be overridden by child.
@@ -566,11 +574,12 @@
       return super.getCflowStacks();
    }
 
-   public Map getDynamicCFlows()
+   @Override
+   public Map<String, DynamicCFlowDefinition> getDynamicCFlows()
    {
       if (inheritsBindings)
       {
-         HashMap map = new HashMap();
+         HashMap<String, DynamicCFlowDefinition> map = new HashMap<String, DynamicCFlowDefinition>();
          if (!parentFirst)
          {
             // when child first, parent bindings go in first so that they can be overridden by child.
@@ -594,11 +603,12 @@
       return super.getDynamicCFlows();
    }
 
-   public Map getPerVMAspects()
+   @Override
+   public Map<String, Object> getPerVMAspects()
    {
       if (inheritsBindings)
       {
-         HashMap map = new HashMap();
+         HashMap<String, Object> map = new HashMap<String, Object>();
          if (!parentFirst)
          {
             // when child first, parent bindings go in first so that they can be overridden by child.
@@ -623,20 +633,20 @@
    }
 
    @Override
-   public LinkedHashMap getPrecedenceDefs()
+   public LinkedHashMap<String, PrecedenceDef> getPrecedenceDefs()
    {
       if (inheritsDeclarations)
       {
          if (!parentFirst)
          {
             // when child first, parent bindings go in first so that they can be overridden by child.
-            LinkedHashMap map = new LinkedHashMap(parent.getPrecedenceDefs());
+            LinkedHashMap<String, PrecedenceDef> map = new LinkedHashMap<String, PrecedenceDef>(parent.getPrecedenceDefs());
             map.putAll(this.precedenceDefs);
             return map;
          }
          else
          {
-            LinkedHashMap map = new LinkedHashMap(this.precedenceDefs);
+            LinkedHashMap<String, PrecedenceDef> map = new LinkedHashMap<String, PrecedenceDef>(this.precedenceDefs);
             map.putAll(parent.getPrecedenceDefs());
             return map;
          }
@@ -664,11 +674,11 @@
    }
 
    @Override
-   public Map getClassMetaData()
+   public Map<String, ClassMetaDataBinding> getClassMetaData()
    {
       if (inheritsBindings)
       {
-         HashMap map = new HashMap();
+         HashMap<String, ClassMetaDataBinding> map = new HashMap<String, ClassMetaDataBinding>();
          if (!parentFirst)
          {
             // when child first, parent bindings go in first so that they can be overridden by child.
@@ -723,6 +733,7 @@
       hasOwnClassMetaData;
    }
 
+   @Override
    public InterceptorFactory getInterceptorFactory(String name)
    {
       InterceptorFactory factory = null;
@@ -737,6 +748,7 @@
       return parent.getInterceptorFactory(name);
    }
 
+   @Override
    public AdviceStack getAdviceStack(String name)
    {
       AdviceStack factory = null;
@@ -751,11 +763,13 @@
       return parent.getAdviceStack(name);
    }
 
+   @Override
    public Object getPerVMAspect(AspectDefinition def)
    {
       return getPerVMAspect(def.getName());
    }
 
+   @Override
    public Object getPerVMAspect(String def)
    {
       Object factory = null;
@@ -770,6 +784,7 @@
       return parent.getPerVMAspect(def);
    }
 
+   @Override
    public AspectDefinition getAspectDefinition(String name)
    {
       AspectDefinition factory = null;
@@ -784,6 +799,7 @@
       return parent.getAspectDefinition(name);
    }
 
+   @Override
    public Typedef getTypedef(String name)
    {
       Typedef factory = null;
@@ -798,6 +814,7 @@
       return parent.getTypedef(name);
    }
 
+   @Override
    public DomainDefinition getContainer(String name)
    {
       DomainDefinition container = null;
@@ -811,11 +828,10 @@
       return parent.getContainer(name);
    }
 
-
-
    /**
     * Find a pointcut of with a given name
     */
+   @Override
    public Pointcut getPointcut(String name)
    {
       Pointcut pointcut = null;
@@ -831,7 +847,7 @@
    }
 
    @Override
-   public void attachMetaData(Advisor advisor, Class clazz)
+   public void attachMetaData(Advisor advisor, Class<?> clazz)
    {
       if (inheritsBindings)
       {
@@ -853,6 +869,7 @@
       }
    }
 
+   @Override
    public CFlowStack getCFlowStack(String name)
    {
       if (inheritsDeclarations)
@@ -883,6 +900,7 @@
    }
 
 
+   @Override
    public DynamicCFlow getDynamicCFlow(String name)
    {
       if (inheritsBindings)
@@ -912,6 +930,7 @@
       }
    }
 
+   @Override
    public ClassMetaDataLoader findClassMetaDataLoader(String group)
    {
       if (inheritsDeclarations)
@@ -939,6 +958,7 @@
       return super.findClassMetaDataLoader(group);
    }
 
+   @Override
    public Map<String, LifecycleCallbackBinding> getLifecycleBindings()
    {
       if (inheritsBindings)
@@ -946,13 +966,13 @@
          if (!parentFirst)
          {
             // when child first, parent bindings go in first so that they can be overridden by child.
-            LinkedHashMap map = new LinkedHashMap(parent.getLifecycleBindings());
+            LinkedHashMap<String, LifecycleCallbackBinding> map = new LinkedHashMap<String, LifecycleCallbackBinding>(parent.getLifecycleBindings());
             map.putAll(super.getLifecycleBindings());
             return map;
          }
          else
          {
-            LinkedHashMap map = new LinkedHashMap(super.getLifecycleBindings());
+            LinkedHashMap<String, LifecycleCallbackBinding> map = new LinkedHashMap<String, LifecycleCallbackBinding>(super.getLifecycleBindings());
             map.putAll(parent.getLifecycleBindings());
             return map;
          }
@@ -965,91 +985,115 @@
    //////////////////////////////////////////////////////////////////////////
    //Methods that should delegate to the top AspectManager
 
+   @Override
    public InterceptionMarkers getInterceptionMarkers()
    {
       return parent.getInterceptionMarkers();
    }
 
    /** Managed by the top-level aspect manager */
-   protected Map getSubDomainsPerClass()
+   @Override
+   protected Map<Class<?>, WeakReference<Domain>> getSubDomainsPerClass()
    {
       return parent.getSubDomainsPerClass();
    }
 
    /** Only set on a per vm basis */
-   public ArrayList getExclude()
+   @Override
+   public ArrayList<String> getExclude()
    {
       return parent.getExclude();
    }
 
    /** Only set on a per vm basis */
-   public ArrayList getInclude()
+   @Override
+   public ArrayList<String> getInclude()
    {
       return parent.getInclude();
    }
 
    /** Only set on a per vm basis */
-   public ArrayList getIgnore()
+   @Override
+   public ArrayList<String> getIgnore()
    {
       return parent.getIgnore();
    }
 
    /** Only set on a per vm basis */
+   @Override
    public ClassExpression[] getIgnoreExpressions()
    {
       return parent.getIgnoreExpressions();
    }
-
+   
+   /** Only set on a per vm basis */
+   @Override
+   public List<String> getIncludedInvisibleAnnotations()
+   {
+      return parent.getIncludedInvisibleAnnotations();
+   }
+   
+   @Override
    public DynamicAOPStrategy getDynamicAOPStrategy()
    {
       return parent.getDynamicAOPStrategy();
    }
 
+   @Override
    public void setDynamicAOPStrategy(DynamicAOPStrategy strategy)
    {
       parent.setDynamicAOPStrategy(strategy);
    }
 
+   @Override
    protected void updatePointcutStats(Pointcut pointcut)
    {
       parent.updatePointcutStats(pointcut);
    }
 
+   @Override
    protected void updateStats(PointcutStats stats)
    {
       parent.updateStats(stats);
    }
 
+   @Override
    public boolean isExecution()
    {
       return parent.isExecution();
    }
 
+   @Override
    public boolean isConstruction()
    {
       return parent.isConstruction();
    }
 
+   @Override
    public boolean isCall()
    {
       return parent.isCall();
    }
 
+   @Override
    public boolean isWithin()
    {
       return parent.isWithin();
    }
 
+   @Override
    public boolean isWithincode()
    {
       return parent.isWithincode();
    }
 
+   @Override
    public boolean isGet()
    {
       return parent.isGet();
    }
 
+   @Override
    public boolean isSet()
    {
       return parent.isSet();

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/DynamicAOPStrategy.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/DynamicAOPStrategy.java	2008-03-24 03:41:24 UTC (rev 71184)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/DynamicAOPStrategy.java	2008-03-24 03:46:45 UTC (rev 71185)
@@ -52,7 +52,7 @@
     * @return the interceptor chain observer for <code>clazz</code>. May
     * return null if the strategy doesn't require an observer at all.
     */
-   InterceptorChainObserver getInterceptorChainObserver(Class clazz);
+   InterceptorChainObserver getInterceptorChainObserver(Class<?> clazz);
    
    /**
     * Notifies the strategy that one or more interceptor chains in the

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/FieldInfo.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/FieldInfo.java	2008-03-24 03:41:24 UTC (rev 71184)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/FieldInfo.java	2008-03-24 03:46:45 UTC (rev 71185)
@@ -21,6 +21,7 @@
   */
 package org.jboss.aop;
 
+import java.lang.annotation.Annotation;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.security.AccessController;
@@ -57,7 +58,7 @@
       this.read = read;
    }
    
-   public FieldInfo(Class clazz, int index, String fieldName, long wrapperHash, Advisor advisor, boolean read)
+   public FieldInfo(Class<?> clazz, int index, String fieldName, long wrapperHash, Advisor advisor, boolean read)
    {
       super(advisor, clazz);
 
@@ -156,24 +157,24 @@
       return read;
    }
 
-   public Object resolveAnnotation(Class annotation)
+   public <T extends Annotation> T resolveAnnotation(Class<T> annotation)
    {
-      Object val = super.resolveAnnotation(annotation);
+      T val = super.resolveAnnotation(annotation);
       if (val != null) return val;
 
       if (getAdvisor() != null)
       {
-         val = getAdvisor().resolveAnnotation(advisedField, annotation);
+         val = getAdvisor().resolveTypedAnnotation(advisedField, annotation);
          if (val != null) return val;
       }
 
       return null;
    }
 
-   private Field doGet(Class clazz, String name)throws NoSuchFieldException
+   private Field doGet(Class<?> clazz, String name)throws NoSuchFieldException
    {
       Field field = null;
-      Class superClass = clazz;
+      Class<?> superClass = clazz;
       while (superClass != null)
       {
          try
@@ -197,19 +198,19 @@
    
    interface GetDeclaredFieldAction
    {
-      Field get(FieldInfo target, Class clazz, String name) throws NoSuchFieldException;
+      Field get(FieldInfo target, Class<?> clazz, String name) throws NoSuchFieldException;
       
       GetDeclaredFieldAction PRIVILEGED = new GetDeclaredFieldAction()
       {
-         public Field get(final FieldInfo target, final Class clazz, final String name) throws NoSuchFieldException
+         public Field get(final FieldInfo target, final Class<?> clazz, final String name) throws NoSuchFieldException
          {
             try
             {
-               return (Field)AccessController.doPrivileged(new PrivilegedExceptionAction()
+               return AccessController.doPrivileged(new PrivilegedExceptionAction<Field>()
                {
-                  public Object run() throws Exception
+                  public Field run() throws Exception
                   {
-                     return target.doGet(clazz, name);//clazz.getDeclaredField(name);
+                     return target.doGet(clazz, name);
                   }
                });
             }
@@ -227,7 +228,7 @@
 
       GetDeclaredFieldAction NON_PRIVILEGED = new GetDeclaredFieldAction()
       {
-         public Field get(FieldInfo target, Class clazz, String name) throws NoSuchFieldException
+         public Field get(FieldInfo target, Class<?> clazz, String name) throws NoSuchFieldException
          {
             return target.doGet(clazz, name);//clazz.getDeclaredField(name);
          }

Deleted: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/GeneratedAdvised.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/GeneratedAdvised.java	2008-03-24 03:41:24 UTC (rev 71184)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/GeneratedAdvised.java	2008-03-24 03:46:45 UTC (rev 71185)
@@ -1,44 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.aop;
-
-/**
- * Interface implemented by all classes or interfaces
- * that are AOP enabled in the generated-advisor mode.
- * <br>
- * In other words, every class that is generated-advisor weaved by JBoss AOP
- * automatically implements  this interface, which allows the domain retrieval.
- * 
- * @author  <a href="kabir.khan at jboss.com">Kabir Khan</a>
- */
-public interface GeneratedAdvised
-{
-   /**
-    * Returns the domain that is associated with this advised object.
-    * This domain contains all the bindings and other AOP configuration that has
-    * been used to weave this instance. Changes performed dynamically on the domain
-    * will automatically become efective on this advised object.
-    * 
-    * @return the domain where this advised object belongs.
-    */
-   AspectManager getDomain();
-}
\ No newline at end of file

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/GeneratedAdvisorDomain.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/GeneratedAdvisorDomain.java	2008-03-24 03:41:24 UTC (rev 71184)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/GeneratedAdvisorDomain.java	2008-03-24 03:46:45 UTC (rev 71185)
@@ -28,12 +28,12 @@
 public class GeneratedAdvisorDomain extends Domain
 {
 
-   public GeneratedAdvisorDomain(AspectManager manager, String name, Class clazz)
+   public GeneratedAdvisorDomain(AspectManager manager, String name, Class<?> clazz)
    {
       this(manager, name, clazz, false);
    }
    
-   public GeneratedAdvisorDomain(AspectManager manager, String name, Class clazz, boolean instanceDomain)
+   public GeneratedAdvisorDomain(AspectManager manager, String name, Class<?> clazz, boolean instanceDomain)
    {
       super(manager, name, false);
       

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/GeneratedClassAdvisor.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/GeneratedClassAdvisor.java	2008-03-24 03:41:24 UTC (rev 71184)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/GeneratedClassAdvisor.java	2008-03-24 03:46:45 UTC (rev 71185)
@@ -79,12 +79,14 @@
    ArrayList<MethodInfo> overriddenMethods = new ArrayList<MethodInfo>(); 
 
    //TODO These are only needed for the class advisor really
-   //All joinpoint generators apart from field reads and constructions go in here
-   private volatile ConcurrentHashMap joinPointGenerators = UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP;
+   //All joinpoint generators apart from field reads, constructions and MethodCalledByXXX go in here
+   private volatile ConcurrentHashMap<Joinpoint, JoinPointGenerator> joinPointGenerators = UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP;
    //Needs its own map to avoid crashing with the field write generators
-   private volatile ConcurrentHashMap fieldReadJoinPoinGenerators = UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP;
+   private volatile ConcurrentHashMap<Joinpoint, FieldJoinPointGenerator> fieldReadJoinPoinGenerators = UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP;
    //Needs its own map to avoid crashing with the constructor generators
-   private volatile ConcurrentHashMap constructionJoinPointGenerators = UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP;
+   private volatile ConcurrentHashMap<Joinpoint, ConstructorJoinPointGenerator> constructionJoinPointGenerators = UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP;
+   //An extra level of indirection is needed for MethodCalledByCon and MethodCalledByMethod as compared to the main joinPointGenerators map
+   private volatile ConcurrentHashMap<Joinpoint, ConcurrentHashMap<Class<?>, JoinPointGenerator>> methodCalledByXXXJoinPointGenerators = UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP;
    
    ConcurrentHashMap<Joinpoint, Interceptor[]> oldInfos = UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP;
    ConcurrentHashMap<Joinpoint, Interceptor[]> oldFieldReadInfos = UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP;
@@ -120,19 +122,20 @@
       methodInfos = null;
       advisorStrategy = null;
       
-      Map subscribedSubDomains = getManager().getSubscribedSubDomains();
+      Map<Domain, Object> subscribedSubDomains = getManager().getSubscribedSubDomains();
       synchronized (subscribedSubDomains)
       {
-         for (Iterator it = subscribedSubDomains.keySet().iterator() ; it.hasNext() ; )
+         for (Iterator<Domain> it = subscribedSubDomains.keySet().iterator() ; it.hasNext() ; )
          {
-            GeneratedAdvisorDomain manager = (GeneratedAdvisorDomain)it.next();
-            Map advisors = manager.getAdvisors();
+            //TODO Not really sure what was attempted here
+            //GeneratedAdvisorDomain manager = (GeneratedAdvisorDomain)it.next();
+            //Map advisors = manager.getAdvisors();
             it.remove();
          }
       }
    }
 
-   protected void initialise(Class clazz, AspectManager manager)
+   protected void initialise(Class<?> clazz, AspectManager manager)
    {
       advisorStrategy.initialise(clazz, manager);
    }
@@ -260,9 +263,8 @@
    {
       if (overriddenMethods != null && overriddenMethods.size() > 0)
       {
-         for (Iterator it = overriddenMethods.iterator() ; it.hasNext() ; )
+         for(MethodInfo info : overriddenMethods)
          {
-            MethodInfo info = (MethodInfo)it.next();
             Method method = info.getMethod();
             PointcutMethodMatch match = binding.getPointcut().matchesExecution(this, method);
             
@@ -545,10 +547,12 @@
          synchronized(this.adviceBindings)
          {
             this.adviceBindings.addAll(classAdvisor.adviceBindings);
-            for (Iterator it = this.adviceBindings.iterator() ; it.hasNext() ; )
+            if (adviceBindings.size() > 0)
             {
-               AdviceBinding binding = (AdviceBinding)it.next();
-               binding.addAdvisor(this);
+               for (AdviceBinding binding : this.adviceBindings)
+               {
+                  binding.addAdvisor(this);
+               }
             }
          }
       }
@@ -611,15 +615,16 @@
          MethodJoinPointGenerator generator = getJoinPointGenerator(info);
          finalizeChainAndRebindJoinPoint(oldInfos, info, generator, OldInfoMaps.INFOS);
       }
-      methodInterceptors = newMethodInfos;
+      if (AspectManager.maintainAdvisorMethodInterceptors)
+      {
+         methodInterceptors = newMethodInfos;
+      }
       
       //Handle the overridden methods
       if (overriddenMethods != null && overriddenMethods.size() > 0)
       {
-         for (Iterator it = overriddenMethods.iterator() ; it.hasNext() ; )
+         for (MethodInfo info : overriddenMethods)
          {
-            MethodInfo info = (MethodInfo)it.next();
-
             MethodJoinPointGenerator generator = getJoinPointGenerator(info);
             finalizeChainAndRebindJoinPoint(oldInfos, info, generator, OldInfoMaps.INFOS);
          }
@@ -661,7 +666,7 @@
       //We are an instance advisor with no own data influencing the chains, copy these from the parent advisor
       for (int i = 0; i < newFieldInfos.length; i++)
       {
-         FieldInfo myInfo = (FieldInfo) newFieldInfos[i];
+         FieldInfo myInfo = newFieldInfos[i];
          myInfo.cloneChains(classFieldInfos[i]);
 
          if (updateOldInfo(oldFieldInfos, myInfo, oldInfoMapInstance))
@@ -677,7 +682,7 @@
       //We are either the class advisor or an instanceadvisor with own data so we need to do all the work
       for (int i = 0; i < newFieldInfos.length; i++)
       {
-         FieldInfo info = (FieldInfo)newFieldInfos[i];
+         FieldInfo info = newFieldInfos[i];
          FieldJoinPointGenerator generator = getJoinPointGenerator(info);
          finalizeChainAndRebindJoinPoint(oldFieldInfos, info, generator, oldInfoMapInstance);
       }
@@ -707,17 +712,6 @@
    @Override
    protected void finalizeMethodCalledByConInterceptorChain(MethodByConInfo info)
    {
-      //An extra level of indirection since we distinguish between callers of method depending on
-      //where the called method is defined (sub/super interfaces)
-      ConcurrentHashMap map = (ConcurrentHashMap)joinPointGenerators.get(info.getJoinpoint());
-      if (map == null)
-      {
-         map = new ConcurrentHashMap();
-         initJoinPointGeneratorsMap();
-         joinPointGenerators.put(info.getJoinpoint(), map);
-         map = (ConcurrentHashMap)joinPointGenerators.get(info.getJoinpoint());
-      }
-
       MethodByConJoinPointGenerator generator = getJoinPointGenerator(info);
       finalizeChainAndRebindJoinPoint(oldInfos, info, generator, OldInfoMaps.INFOS);
    }
@@ -812,7 +806,6 @@
       ArrayList<Interceptor> curr = info.getInterceptorChain();
       if (binding.getCFlow() != null)
       {
-         //TODO Handle CFlow
          InterceptorFactory[] factories = binding.getInterceptorFactories();
          for (int i = 0 ; i < factories.length ; i++)
          {
@@ -835,7 +828,7 @@
       GeneratedAdvisorInterceptor[] factories = null;
       if (list.size() > 0)
       {
-         factories = applyPrecedence((GeneratedAdvisorInterceptor[]) list.toArray(new GeneratedAdvisorInterceptor[list.size()]));
+         factories = applyPrecedence(list.toArray(new GeneratedAdvisorInterceptor[list.size()]));
       }
       info.setInterceptors(factories);
 
@@ -848,7 +841,7 @@
    @Override
    public String toString()
    {
-      Class clazz = this.getClass();
+      Class<?> clazz = this.getClass();
       StringBuffer sb = new StringBuffer("CLASS: " + clazz.getName());
 
       Field[] fields = clazz.getFields();
@@ -878,7 +871,7 @@
     * Generated ClassAdvisors and InstanceAdvisors will be different instances,
     * so keep track of what per_class_joinpoint aspects have been added where
     */
-   ConcurrentHashMap<AspectDefinition,Map<Joinpoint, Object>> perClassJoinpointAspectDefinitions =
+   ConcurrentHashMap<AspectDefinition, Map<Joinpoint, Object>> perClassJoinpointAspectDefinitions =
          new ConcurrentHashMap<AspectDefinition, Map<Joinpoint, Object>>();
 
 
@@ -965,13 +958,13 @@
    }
 
    @Override
-   public Set getPerInstanceAspectDefinitions()
+   public Set<AspectDefinition> getPerInstanceAspectDefinitions()
    {
       return advisorStrategy.getPerInstanceAspectDefinitions();
    }
 
    @Override
-   public Map getPerInstanceJoinpointAspectDefinitions()
+   public Map<AspectDefinition, Set<Joinpoint>> getPerInstanceJoinpointAspectDefinitions()
    {
       return advisorStrategy.getPerInstanceJoinpointAspectDefinitions();
    }
@@ -1097,18 +1090,13 @@
    {
       if (joinPointGenerators == UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP)
       {
-         lockWrite();
-         try
+         synchronized(lazyCollectionLock)
          {
             if (joinPointGenerators == UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP)
             {
-               joinPointGenerators = new ConcurrentHashMap();
+               joinPointGenerators = new ConcurrentHashMap<Joinpoint, JoinPointGenerator>();
             }
          }
-         finally
-         {
-            unlockWrite();
-         }
       }
    }
    
@@ -1116,18 +1104,13 @@
    {
       if (fieldReadJoinPoinGenerators == UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP)
       {
-         lockWrite();
-         try
+         synchronized(lazyCollectionLock)
          {
             if (fieldReadJoinPoinGenerators == UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP)
             {
-               fieldReadJoinPoinGenerators = new ConcurrentHashMap();
+               fieldReadJoinPoinGenerators = new ConcurrentHashMap<Joinpoint, FieldJoinPointGenerator>();
             }
          }
-         finally
-         {
-            unlockWrite();
-         }
       }
    }
    
@@ -1135,17 +1118,26 @@
    {
       if (constructionJoinPointGenerators == UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP)
       {
-         lockWrite();
-         try
+         synchronized(lazyCollectionLock)
          {
             if (constructionJoinPointGenerators == UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP)
             {
-               constructionJoinPointGenerators = new ConcurrentHashMap();
+               constructionJoinPointGenerators = new ConcurrentHashMap<Joinpoint, ConstructorJoinPointGenerator>();
             }
          }
-         finally
+      }
+   }
+   
+   protected void initMethodCalledByConJoinPointGeneratorsMap()
+   {
+      if (methodCalledByXXXJoinPointGenerators == UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP)
+      {
+         synchronized(lazyCollectionLock)
          {
-            unlockWrite();
+            if (methodCalledByXXXJoinPointGenerators == UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP)
+            {
+               methodCalledByXXXJoinPointGenerators = new ConcurrentHashMap<Joinpoint, ConcurrentHashMap<Class<?>, JoinPointGenerator>>();
+            }
          }
       }
    }
@@ -1154,18 +1146,13 @@
    {
       if (oldInfos == UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP)
       {
-         lockWrite();
-         try
+         synchronized(lazyCollectionLock)
          {
             if (oldInfos == UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP)
             {
                oldInfos = new ConcurrentHashMap<Joinpoint, Interceptor[]>();
             }
          }
-         finally
-         {
-            unlockWrite();
-         }
       }
       return oldInfos;
    }
@@ -1174,18 +1161,13 @@
    {
       if (oldFieldReadInfos == UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP)
       {
-         lockWrite();
-         try
+         synchronized(lazyCollectionLock)
          {
             if (oldFieldReadInfos == UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP)
             {
                oldFieldReadInfos = new ConcurrentHashMap<Joinpoint, Interceptor[]>();
             }
          }
-         finally
-         {
-            unlockWrite();
-         }
       }
       return oldFieldReadInfos;
    }
@@ -1194,18 +1176,13 @@
    {
       if (oldConstructionInfos == UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP)
       {
-         lockWrite();
-         try
+         synchronized(lazyCollectionLock)
          {
             if (oldConstructionInfos == UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP)
             {
                oldConstructionInfos = new ConcurrentHashMap<Joinpoint, Interceptor[]>();
             }
          }
-         finally
-         {
-            unlockWrite();
-         }
       }
       return oldConstructionInfos;
    }
@@ -1215,7 +1192,7 @@
     */
    private interface AdvisorStrategy
    {
-      void initialise(Class clazz, AspectManager manager);
+      void initialise(Class<?> clazz, AspectManager manager);
       void checkVersion();
       void createInterceptorChains() throws Exception;
       MethodJoinPointGenerator getJoinPointGenerator(MethodInfo info);
@@ -1232,8 +1209,8 @@
       void createMethodTables() throws Exception;
       void createFieldTable() throws Exception;
       void createConstructorTables() throws Exception;
-      Set getPerInstanceAspectDefinitions();
-      Map getPerInstanceJoinpointAspectDefinitions();
+      Set<AspectDefinition> getPerInstanceAspectDefinitions();
+      Map<AspectDefinition, Set<Joinpoint>> getPerInstanceJoinpointAspectDefinitions();
       void rebuildInterceptors();
       void resolveConstructorPointcut(AdviceBinding binding);
       void resolveConstructionPointcut(AdviceBinding binding);
@@ -1247,7 +1224,7 @@
    {
       GeneratedClassAdvisor parent;
 
-      public void initialise(Class clazz, AspectManager manager)
+      public void initialise(Class<?> clazz, AspectManager manager)
       {
          methodInfos = new MethodInterceptors(GeneratedClassAdvisor.this);
          initialiseMethods();
@@ -1318,12 +1295,12 @@
       {
          if (info.isRead())
          {
-            FieldJoinPointGenerator generator = (FieldJoinPointGenerator)fieldReadJoinPoinGenerators.get(info.getJoinpoint());
+            FieldJoinPointGenerator generator = fieldReadJoinPoinGenerators.get(info.getJoinpoint());
             if (generator == null)
             {
                generator = new FieldJoinPointGenerator(GeneratedClassAdvisor.this, info);
                initFieldReadJoinPointGeneratorsMap();
-               FieldJoinPointGenerator existing = (FieldJoinPointGenerator)fieldReadJoinPoinGenerators.putIfAbsent(info.getJoinpoint(), generator);
+               FieldJoinPointGenerator existing = fieldReadJoinPoinGenerators.putIfAbsent(info.getJoinpoint(), generator);
                if (existing != null)
                {
                   generator = existing;
@@ -1351,12 +1328,12 @@
       public ConstructorJoinPointGenerator getJoinPointGenerator(ConstructorInfo info)
       {
          //We are the class advisor
-         ConstructorJoinPointGenerator generator = (ConstructorJoinPointGenerator)constructionJoinPointGenerators.get(info.getJoinpoint());
+         ConstructorJoinPointGenerator generator = constructionJoinPointGenerators.get(info.getJoinpoint());
          if (generator == null)
          {
             generator = new ConstructorJoinPointGenerator(GeneratedClassAdvisor.this, info);
             initConstructionJoinPointGeneratorsMap();
-            ConstructorJoinPointGenerator existing = (ConstructorJoinPointGenerator)constructionJoinPointGenerators.putIfAbsent(info.getJoinpoint(), generator);
+            ConstructorJoinPointGenerator existing = constructionJoinPointGenerators.putIfAbsent(info.getJoinpoint(), generator);
             if (existing != null)
             {
                generator = existing;
@@ -1385,12 +1362,12 @@
       {
          //An extra level of indirection since we distinguish between callers of method depending on
          //where the called method is defined (sub/super interfaces)
-         ConcurrentHashMap map = (ConcurrentHashMap)joinPointGenerators.get(info.getJoinpoint());
+         ConcurrentHashMap<Class<?>, JoinPointGenerator> map = methodCalledByXXXJoinPointGenerators.get(info.getJoinpoint());
          if (map == null)
          {
-            map = new ConcurrentHashMap();
-            initJoinPointGeneratorsMap();
-            ConcurrentHashMap existing = (ConcurrentHashMap)joinPointGenerators.putIfAbsent(info.getJoinpoint(), map);
+            map = new ConcurrentHashMap<Class<?>, JoinPointGenerator>();
+            initMethodCalledByConJoinPointGeneratorsMap();
+            ConcurrentHashMap<Class<?>, JoinPointGenerator> existing = methodCalledByXXXJoinPointGenerators.putIfAbsent(info.getJoinpoint(), map);
             if (existing != null)
             {
                map = existing;
@@ -1447,12 +1424,12 @@
       {
          //An extra level of indirection since we distinguish between callers of method depending on
          //where the called method is defined (sub/super interfaces)
-         ConcurrentHashMap map = (ConcurrentHashMap)joinPointGenerators.get(info.getJoinpoint());
+         ConcurrentHashMap<Class<?>, JoinPointGenerator> map = methodCalledByXXXJoinPointGenerators.get(info.getJoinpoint());
          if (map == null)
          {
-            map = new ConcurrentHashMap();
-            initJoinPointGeneratorsMap();
-            ConcurrentHashMap exisiting = (ConcurrentHashMap)joinPointGenerators.putIfAbsent(info.getJoinpoint(), map);
+            map = new ConcurrentHashMap<Class<?>, JoinPointGenerator>();
+            initMethodCalledByConJoinPointGeneratorsMap();
+            ConcurrentHashMap<Class<?>, JoinPointGenerator> exisiting = methodCalledByXXXJoinPointGenerators.putIfAbsent(info.getJoinpoint(), map);
             if (exisiting != null)
             {
                map = exisiting;
@@ -1479,7 +1456,7 @@
 
       public Object getPerClassJoinpointAspect(AspectDefinition def, Joinpoint joinpoint)
       {
-         Map joinpoints = (Map) perClassJoinpointAspectDefinitions.get(def);
+         Map<Joinpoint, Object> joinpoints = perClassJoinpointAspectDefinitions.get(def);
          if (joinpoints != null)
          {
             return joinpoints.get(joinpoint);
@@ -1507,12 +1484,12 @@
          GeneratedClassAdvisor.super.createConstructorTables();
       }
       
-      public Set getPerInstanceAspectDefinitions()
+      public Set<AspectDefinition> getPerInstanceAspectDefinitions()
       {
          return GeneratedClassAdvisor.super.getPerInstanceAspectDefinitions();
       }
 
-      public Map getPerInstanceJoinpointAspectDefinitions()
+      public Map<AspectDefinition, Set<Joinpoint>> getPerInstanceJoinpointAspectDefinitions()
       {
          return GeneratedClassAdvisor.super.getPerInstanceJoinpointAspectDefinitions();
       }
@@ -1539,7 +1516,7 @@
          {
             ConstructorInfo info = newConstructorInfos[i];
             ConstructorJoinPointGenerator generator = getJoinPointGenerator(info);
-            Class clazz = info.getClazz();
+            Class<?> clazz = info.getClazz();
             if (clazz != null)
             finalizeChainAndRebindJoinPoint(oldInfos, info, generator, OldInfoMaps.INFOS);
          }
@@ -1579,7 +1556,7 @@
          GeneratedClassAdvisor.this.version = parent.version;         
       }
       
-      public void initialise(Class clazz, AspectManager manager)
+      public void initialise(Class<?> clazz, AspectManager manager)
       {
          initialiseInfosForInstance();
          
@@ -1711,12 +1688,12 @@
          conCalledByConInterceptors = new HashMap[constructors.length];
       }
 
-      public Set getPerInstanceAspectDefinitions()
+      public Set<AspectDefinition> getPerInstanceAspectDefinitions()
       {
          return parent.getPerInstanceAspectDefinitions();
       }
 
-      public Map getPerInstanceJoinpointAspectDefinitions()
+      public Map<AspectDefinition, Set<Joinpoint>> getPerInstanceJoinpointAspectDefinitions()
       {
          return parent.getPerInstanceJoinpointAspectDefinitions();
       }

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/GeneratedInstanceAdvisorMixin.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/GeneratedInstanceAdvisorMixin.java	2008-03-24 03:41:24 UTC (rev 71184)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/GeneratedInstanceAdvisorMixin.java	2008-03-24 03:46:45 UTC (rev 71185)
@@ -33,7 +33,6 @@
 import java.lang.ref.WeakReference;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Iterator;
 
 /**
  * Adapts the old instance advisor api to the new generated advisor stuff. 
@@ -48,7 +47,7 @@
 
    protected ArrayList<Interceptor> insertedInterceptors = null;
    protected ArrayList<Interceptor> appendedInterceptors = null;
-   protected WeakReference instanceRef;
+   protected WeakReference<Object> instanceRef;
    public boolean hasInstanceAspects = false;
    private InterceptorChainObserver interceptorChainObserver;
    InstanceAdvisorDelegate delegate;
@@ -59,7 +58,7 @@
 
    public GeneratedInstanceAdvisorMixin(Object instance, GeneratedClassAdvisor genadvisor)
    {
-      this.instanceRef = new WeakReference(instance);
+      this.instanceRef = new WeakReference<Object>(instance);
       delegate = new InstanceAdvisorDelegate(genadvisor, this);
       delegate.initialize();
       this.interceptorChainObserver = ((ClassAdvisor) genadvisor).getInterceptorChainObserver();
@@ -92,22 +91,22 @@
 
    public Interceptor[] getInterceptors()
    {
-      ArrayList newlist = new ArrayList();
-      if (insertedInterceptors != null) 
+      ArrayList<Interceptor> newlist = new ArrayList<Interceptor>();
+      if (insertedInterceptors != null && insertedInterceptors.size() > 0) 
       {
-         for (Iterator it = insertedInterceptors.iterator() ; it.hasNext() ; )
+         for (Interceptor icptr : insertedInterceptors)
          {
-            newlist.add(((GeneratedAdvisorInterceptor)it.next()).create(null, null));
+            newlist.add(((GeneratedAdvisorInterceptor)icptr).create(null, null));
          }
       }
-      if (appendedInterceptors != null) 
+      if (appendedInterceptors != null && appendedInterceptors.size() > 0) 
       {
-         for (Iterator it = appendedInterceptors.iterator() ; it.hasNext() ; )
+         for (Interceptor icptr : appendedInterceptors)
          {
-            newlist.add(((GeneratedAdvisorInterceptor)it.next()).create(null, null));
+            newlist.add(((GeneratedAdvisorInterceptor)icptr).create(null, null));
          }
       }
-      return (Interceptor[]) newlist.toArray(new Interceptor[newlist.size()]);
+      return newlist.toArray(new Interceptor[newlist.size()]);
    }
 
    /**
@@ -116,34 +115,34 @@
    public Interceptor[] getInterceptors(Interceptor[] advisorChain)
    {
       if (insertedInterceptors == null && appendedInterceptors == null) return advisorChain;
-      ArrayList newlist = new ArrayList();
-      if (insertedInterceptors != null) 
+      ArrayList<Interceptor> newlist = new ArrayList<Interceptor>();
+      if (insertedInterceptors != null && insertedInterceptors.size() > 0) 
       {
-         for (Iterator it = insertedInterceptors.iterator() ; it.hasNext() ; )
+         for (Interceptor icptr : insertedInterceptors)
          {
-            newlist.add(((GeneratedAdvisorInterceptor)it.next()).create(null, null));
+            newlist.add(((GeneratedAdvisorInterceptor)icptr).create(null, null));
          }
       }
       if (advisorChain != null)
       {
          newlist.addAll(Arrays.asList(advisorChain));
       }
-      if (appendedInterceptors != null) 
+      if (appendedInterceptors != null && appendedInterceptors.size() > 0) 
       {
-         for (Iterator it = appendedInterceptors.iterator() ; it.hasNext() ; )
+         for (Interceptor icptr : appendedInterceptors)
          {
-            newlist.add(((GeneratedAdvisorInterceptor)it.next()).create(null, null));
+            newlist.add(((GeneratedAdvisorInterceptor)icptr).create(null, null));
          }
       }
-      return (Interceptor[]) newlist.toArray(new Interceptor[newlist.size()]);
+      return newlist.toArray(new Interceptor[newlist.size()]);
    }
 
    public GeneratedAdvisorInterceptor[] getWrappers()
    {
-      ArrayList newlist = new ArrayList();
+      ArrayList<Interceptor> newlist = new ArrayList<Interceptor>();
       if (insertedInterceptors != null) newlist.addAll(insertedInterceptors);
       if (appendedInterceptors != null) newlist.addAll(appendedInterceptors);
-      return (GeneratedAdvisorInterceptor[]) newlist.toArray(new GeneratedAdvisorInterceptor[newlist.size()]);
+      return newlist.toArray(new GeneratedAdvisorInterceptor[newlist.size()]);
    }
 
    /**
@@ -154,20 +153,20 @@
    public Interceptor[] getWrappers(Interceptor[] advisorChain)
    {
       if (insertedInterceptors == null && appendedInterceptors == null) return advisorChain;
-      ArrayList newlist = new ArrayList();
+      ArrayList<Interceptor> newlist = new ArrayList<Interceptor>();
       if (insertedInterceptors != null) newlist.addAll(insertedInterceptors);
       if (advisorChain != null)
       {
          newlist.addAll(Arrays.asList(advisorChain));
       }
       if (appendedInterceptors != null) newlist.addAll(appendedInterceptors);
-      return (GeneratedAdvisorInterceptor[]) newlist.toArray(new GeneratedAdvisorInterceptor[newlist.size()]);
+      return newlist.toArray(new GeneratedAdvisorInterceptor[newlist.size()]);
    }
 
    public void insertInterceptor(int index, Interceptor interceptor)
    {
-      ArrayList newList = new ArrayList();
-      if (insertedInterceptors != null)
+      ArrayList<Interceptor> newList = new ArrayList<Interceptor>();
+      if (insertedInterceptors != null && insertedInterceptors.size() > 0)
       {
          newList.addAll(insertedInterceptors);
       }
@@ -182,8 +181,8 @@
 
    public void insertInterceptor(Interceptor interceptor)
    {
-      ArrayList newList = new ArrayList();
-      if (insertedInterceptors != null)
+      ArrayList<Interceptor> newList = new ArrayList<Interceptor>();
+      if (insertedInterceptors != null && insertedInterceptors.size() > 0)
       {
          newList.addAll(insertedInterceptors);
       }
@@ -199,7 +198,7 @@
    public void appendInterceptor(Interceptor interceptor)
    {
       ArrayList<Interceptor> newList = new ArrayList<Interceptor>();
-      if (appendedInterceptors != null)
+      if (appendedInterceptors != null && appendedInterceptors.size() > 0)
       {
          newList.addAll(appendedInterceptors);
       }
@@ -214,8 +213,8 @@
 
    public void appendInterceptor(int index, Interceptor interceptor)
    {
-      ArrayList newList = new ArrayList();
-      if (appendedInterceptors != null)
+      ArrayList<Interceptor> newList = new ArrayList<Interceptor>();
+      if (appendedInterceptors != null && appendedInterceptors.size() > 0)
       {
          newList.addAll(appendedInterceptors);
       }
@@ -249,12 +248,13 @@
       int interceptorsRemoved = 0;
       if (insertedInterceptors != null)
       {
-         for (int i = 0; i < insertedInterceptors.size(); i++)
+         int size = insertedInterceptors.size();
+         for (int i = 0; i < size ; i++)
          {
             GeneratedAdvisorInterceptor interceptor = (GeneratedAdvisorInterceptor) insertedInterceptors.get(i);
             if (interceptor.getName().equals(name))
             {
-               ArrayList newList = new ArrayList();
+               ArrayList<Interceptor> newList = new ArrayList<Interceptor>();
                newList.addAll(insertedInterceptors);
                newList.remove(i);
                insertedInterceptors = newList;
@@ -264,12 +264,13 @@
       }
       if (appendedInterceptors != null)
       {
-         for (int i = 0; i < appendedInterceptors.size(); i++)
+         int size = appendedInterceptors.size();
+         for (int i = 0; i < size ; i++)
          {
             GeneratedAdvisorInterceptor interceptor = (GeneratedAdvisorInterceptor) appendedInterceptors.get(i);
             if (interceptor.getName().equals(name))
             {
-               ArrayList newList = new ArrayList();
+               ArrayList<Interceptor> newList = new ArrayList<Interceptor>();
                newList.addAll(appendedInterceptors);
                newList.remove(i);
                appendedInterceptors = newList;
@@ -300,10 +301,8 @@
          classAdvisor = ((ClassAdvisor) advised._getAdvisor());
       }
       int interceptorsAdded = 0;
-      Iterator it = stack.getInterceptorFactories().iterator();
-      while (it.hasNext())
+      for (InterceptorFactory factory : stack.getInterceptorFactories())
       {
-         InterceptorFactory factory = (InterceptorFactory) it.next();
          if (!factory.isDeployed()) continue;
          Interceptor interceptor = factory.create(classAdvisor, null);
          insertInterceptor(interceptor);
@@ -328,10 +327,8 @@
          classAdvisor = ((ClassAdvisor) advised._getAdvisor());
       }
       int interceptorsAdded = 0;
-      Iterator it = stack.getInterceptorFactories().iterator();
-      while (it.hasNext())
+      for (InterceptorFactory factory : stack.getInterceptorFactories())
       {
-         InterceptorFactory factory = (InterceptorFactory) it.next();
          if (!factory.isDeployed()) continue;
          Interceptor interceptor = factory.create(classAdvisor, null);
          appendInterceptor(interceptor);
@@ -356,10 +353,8 @@
          classAdvisor = ((ClassAdvisor) advised._getAdvisor());
       }
       int interceptorsRemoved = 0;
-      Iterator it = stack.getInterceptorFactories().iterator();
-      while (it.hasNext())
+      for (InterceptorFactory factory : stack.getInterceptorFactories())
       {
-         InterceptorFactory factory = (InterceptorFactory) it.next();
          if (!factory.isDeployed()) continue;
          Interceptor interceptor = factory.create(classAdvisor, null);
          interceptorsRemoved += internalRemoveInterceptor(interceptor.getName());
@@ -381,7 +376,7 @@
    protected void finalize()
    {
       ClassLoader classLoader = delegate.getAdvisor().getClazz().getClassLoader();
-      if (this.interceptorChainObserver == null || !delegate.getAdvisor().getManager().getRegisteredCLs().containsKey(classLoader))
+      if (this.interceptorChainObserver == null || !AspectManager.getRegisteredCLs().containsKey(classLoader))
       {
          return;
       }

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/HotSwapStrategy.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/HotSwapStrategy.java	2008-03-24 03:41:24 UTC (rev 71184)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/HotSwapStrategy.java	2008-03-24 03:46:45 UTC (rev 71185)
@@ -29,7 +29,6 @@
 import java.security.PrivilegedExceptionAction;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.WeakHashMap;
 
 import javassist.ClassPool;
@@ -57,7 +56,7 @@
 public class HotSwapStrategy implements DynamicAOPStrategy
 {
    private HotSwapper hotSwapper;
-   private Collection joinpointUpdates;
+   private Collection<JoinpointStatusUpdate> joinpointUpdates;
    private Instrumentor instrumentor;
 
    /**
@@ -67,7 +66,7 @@
    public HotSwapStrategy(HotSwapper hotSwapper)
    {
       this.hotSwapper = hotSwapper;
-      this.joinpointUpdates = new ArrayList();
+      this.joinpointUpdates = new ArrayList<JoinpointStatusUpdate>();
       this.instrumentor = InstrumentorFactory.getInstrumentor(AspectManager.instance(), getJoinpointClassifier());
    }
    
@@ -84,7 +83,7 @@
       {
          if (!joinpointUpdates.isEmpty())
          {
-            instrumentor.interceptorChainsUpdated(new ArrayList(joinpointUpdates), hotSwapper);
+            instrumentor.interceptorChainsUpdated(new ArrayList<JoinpointStatusUpdate>(joinpointUpdates), hotSwapper);
             joinpointUpdates.clear();   
          }
       }
@@ -125,7 +124,7 @@
     * Returns an interceptor chain observer for <code>clazz</code>.
     * @see org.jboss.aop.DynamicAOPStrategy#getInterceptorChainObserver
     */
-   public InterceptorChainObserver getInterceptorChainObserver(Class clazz)
+   public InterceptorChainObserver getInterceptorChainObserver(Class<?> clazz)
    {
       ClassPool classPool = AspectManager.instance().findClassPool(clazz.getClassLoader());
       CtClass ctClass = null;
@@ -163,9 +162,9 @@
     */
    private class  DynamicTransformationTracker implements DynamicTransformationObserver
    {
-      private CtClass clazz;
-      private Collection fieldReads;
-      private Collection fieldWrites;
+      //private CtClass clazz;
+      private Collection<CtField> fieldReads;
+      private Collection<CtField> fieldWrites;
       private boolean constructor;
 
       /**
@@ -174,9 +173,9 @@
        */
       public DynamicTransformationTracker(CtClass clazz)
       {
-         this.clazz = clazz;
-         this.fieldReads = new ArrayList();
-         this.fieldWrites = new ArrayList();
+         //this.clazz = clazz;
+         this.fieldReads = new ArrayList<CtField>();
+         this.fieldWrites = new ArrayList<CtField>();
          this.constructor = false;
       }
       
@@ -238,7 +237,7 @@
       private JoinpointStatusUpdate.ClassJoinpoints newlyUnadvised;
       
       private int instanceInterceptors;
-      private WeakHashMap instanceAdvisors;
+      private WeakHashMap<InstanceAdvisor, Integer> instanceAdvisors;
       
       private CtClass clazz;
       private int fields;
@@ -247,7 +246,7 @@
       private Interceptor[][] fieldReadInterceptors;
       private Interceptor[][] fieldWriteInterceptors;
       private Interceptor[][] constructorInterceptors;
-      private TLongObjectHashMap methodInterceptors;
+      private MethodInterceptors methodInterceptors;
       private int[] constructorIndexMap;
       
       /**
@@ -257,17 +256,17 @@
       public JoinpointStatusUpdater(CtClass clazz)
       {
          this.clazz = clazz;
-         this.instanceAdvisors = new WeakHashMap();
+         this.instanceAdvisors = new WeakHashMap<InstanceAdvisor, Integer>();
       }
       
       /**
        * This method must be called before any other notification method is invoked.
        * @see org.jboss.aop.InterceptorChainObserver#initialInterceptorChains(Interceptor[][], Interceptor[][], Interceptor[][], TLongObjectHashMap)
        */
-      public synchronized void initialInterceptorChains(final Class reflectionClass, Interceptor[][] fieldReadInterceptors, Interceptor[][] fieldWriteInterceptors,
-            Interceptor[][] constructorInterceptors, TLongObjectHashMap methodInterceptors)
+      public synchronized void initialInterceptorChains(final Class<?> reflectionClass, Interceptor[][] fieldReadInterceptors, Interceptor[][] fieldWriteInterceptors,
+            Interceptor[][] constructorInterceptors, MethodInterceptors methodInterceptors)
       {
-         Constructor[] declaredConstructors = null;
+         Constructor<?>[] declaredConstructors = null;
          if (System.getSecurityManager() == null)
          {
             declaredConstructors = reflectionClass.getDeclaredConstructors();
@@ -277,9 +276,9 @@
             try
             {
                declaredConstructors = 
-                  AccessController.doPrivileged(new PrivilegedExceptionAction<Constructor[]>()
+                  AccessController.doPrivileged(new PrivilegedExceptionAction<Constructor<?>[]>()
                {
-                  public Constructor[] run() throws Exception
+                  public Constructor<?>[] run() throws Exception
                   {
                      return reflectionClass.getDeclaredConstructors();
                   }
@@ -297,7 +296,7 @@
          int javassistIndex = 0;
          for (int reflectionIndex = 0; reflectionIndex < declaredConstructors.length; reflectionIndex++)
          {
-            Class[] params = declaredConstructors[reflectionIndex].getParameterTypes();
+            Class<?>[] params = declaredConstructors[reflectionIndex].getParameterTypes();
             if (params.length > 0 && params[params.length-1].getName().equals("javassist.runtime.Inner"))
             {
                constructorIndexMap[reflectionIndex] = -1;
@@ -322,10 +321,10 @@
       
       /**
        * Notification method.
-       * @see InterceptorChainObserver#interceptorChainsUpdated(Interceptor[][], Interceptor[][], Interceptor[][], TLongObjectHashMap)
+       * @see InterceptorChainObserver#interceptorChainsUpdated(Interceptor[][], Interceptor[][], Interceptor[][], MethodInterceptors)
        */
       public synchronized void interceptorChainsUpdated(Interceptor[][] newFieldReadInterceptors, Interceptor[][] newFieldWriteInterceptors,
-            Interceptor[][] newConstructorInterceptors, TLongObjectHashMap newMethodInterceptors)
+            Interceptor[][] newConstructorInterceptors, MethodInterceptors newMethodInterceptors)
       {
          if (instanceInterceptors == 0)
          {
@@ -333,8 +332,8 @@
             for (int i = 0; i < methodKeys.length; i++)
             {
                long key = methodKeys[i];
-               MethodInfo oldMethodInfo = (MethodInfo) methodInterceptors.get(key);
-               MethodInfo newMethodInfo = (MethodInfo) newMethodInterceptors.get(key);
+               MethodInfo oldMethodInfo = methodInterceptors.getMethodInfo(key);
+               MethodInfo newMethodInfo = newMethodInterceptors.getMethodInfo(key);
                if (oldMethodInfo.getInterceptorChain().isEmpty() && !newMethodInfo.getInterceptorChain().isEmpty())
                {
                   newlyAdvised.methodExecutions.add(newMethodInfo);  
@@ -410,9 +409,8 @@
          if (this.instanceInterceptors == 0)
             return;
          this.instanceInterceptors = 0;
-         for (Iterator iterator = instanceAdvisors.values().iterator(); iterator.hasNext(); )
+         for (Integer interceptors : instanceAdvisors.values())
          {
-            Integer interceptors = (Integer) iterator.next();
             instanceInterceptors += interceptors.intValue();
          }
          if (this.instanceInterceptors > 0)
@@ -446,7 +444,7 @@
        * @param newlyAdvised collection to which the newly unadvised joinpoints will be added.
        */
       private void fillNewStateCollections(Interceptor[][] interceptors, Interceptor[][] newInterceptors,
-            Collection newlyAdvised, Collection newlyUnadvised, int[] indexMap)
+            Collection<Integer> newlyAdvised, Collection<Integer> newlyUnadvised, int[] indexMap)
       {
          if (instanceInterceptors > 0)
             return;
@@ -498,7 +496,7 @@
       {
          if (this.instanceAdvisors.containsKey(instanceAdvisor))
          {
-            Integer interceptors = (Integer) instanceAdvisors.get(instanceAdvisor);
+            Integer interceptors = instanceAdvisors.get(instanceAdvisor);
             instanceAdvisors.put(instanceAdvisor, new Integer(interceptors.intValue() + interceptorsAdded));
          }
          else
@@ -521,7 +519,7 @@
             for (int i = 0; i < methodKeys.length; i++)
             {
                long key = methodKeys[i];
-               MethodInfo methodInfo = (MethodInfo) this.methodInterceptors.get(key);
+               MethodInfo methodInfo = this.methodInterceptors.getMethodInfo(key);
                if (methodInfo.getInterceptorChain().isEmpty())
                {
                   joinpoints.methodExecutions.add(methodInfo);  
@@ -539,7 +537,7 @@
        * @param interceptors the interceptors chains applied to the joinponts.
        * @param joinpointsFound the collection to which the found joinpoints will be added.
        */
-      private void findUnadvisedJoinpoints(Interceptor[][] interceptors, Collection joinpointsFound)
+      private void findUnadvisedJoinpoints(Interceptor[][] interceptors, Collection<Integer> joinpointsFound)
       {
          for (int i = 0; i < interceptors.length; i++)
          {

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/InstanceAdvisorDelegate.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/InstanceAdvisorDelegate.java	2008-03-24 03:41:24 UTC (rev 71184)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/InstanceAdvisorDelegate.java	2008-03-24 03:46:45 UTC (rev 71185)
@@ -23,7 +23,6 @@
 
 import java.io.Serializable;
 import java.lang.ref.WeakReference;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 import java.util.WeakHashMap;
@@ -44,24 +43,24 @@
 {
    private static final long serialVersionUID = -5421366346785427537L;
    
-   protected transient WeakReference classAdvisor;
+   protected transient WeakReference<Advisor> classAdvisor;
    InstanceAdvisor instanceAdvisor;
-   protected transient WeakHashMap aspects;
-   protected transient WeakHashMap joinpointAspects;
+   protected transient WeakHashMap<AspectDefinition, Object> aspects;
+   protected transient WeakHashMap<AspectDefinition, ConcurrentHashMap<Joinpoint, Object>> joinpointAspects;
    protected SimpleMetaData metadata;
 
 
    public InstanceAdvisorDelegate(Advisor classAdvisor, InstanceAdvisor instanceAdvisor)
    {
       this.instanceAdvisor = instanceAdvisor;
-      this.classAdvisor = new WeakReference(classAdvisor);
+      this.classAdvisor = new WeakReference<Advisor>(classAdvisor);
    }
 
    public Advisor getAdvisor()
    {
       if (classAdvisor != null)
       {
-         return (Advisor)classAdvisor.get();
+         return classAdvisor.get();
       }
       return null;
    }
@@ -85,30 +84,27 @@
       if (instanceAdvisor instanceof Advisor)
       {
          Advisor ia = (Advisor)instanceAdvisor;
-         Set instanceDefs = ia.getPerInstanceAspectDefinitions();
+         Set<AspectDefinition> instanceDefs = ia.getPerInstanceAspectDefinitions();
          if (instanceDefs.size() > 0)
          {
-            aspects = new WeakHashMap();
-            for (Iterator it = instanceDefs.iterator() ; it.hasNext() ; )
+            aspects = new WeakHashMap<AspectDefinition, Object>();
+            for (AspectDefinition def : instanceDefs)
             {
-               AspectDefinition def = (AspectDefinition) it.next();
                ia.addPerInstanceAspect(def);
                Object aspect = def.getFactory().createPerInstance(getClassAdvisor(), instanceAdvisor);
                aspects.put(def, aspect);
             }
          }
       }
-      Set defs = getClassAdvisor().getPerInstanceAspectDefinitions();
+      Set<AspectDefinition> defs = getClassAdvisor().getPerInstanceAspectDefinitions();
       if (defs.size() > 0)
       {
          if (aspects == null)
          {
-            aspects = new WeakHashMap();
+            aspects = new WeakHashMap<AspectDefinition, Object>();
          }
-         Iterator it = defs.iterator();
-         while (it.hasNext())
+         for (AspectDefinition def : defs)
          {
-            AspectDefinition def = (AspectDefinition) it.next();
             Object aspect = def.getFactory().createPerInstance(getClassAdvisor(), instanceAdvisor);
             aspects.put(def, aspect);
          }
@@ -122,64 +118,61 @@
       if (instanceAdvisor instanceof Advisor)
       {
          Advisor ia = (Advisor)instanceAdvisor;
-         Map instanceJpAspects = ia.getPerInstanceJoinpointAspectDefinitions();
+         Map<AspectDefinition, Set<Joinpoint>> instanceJpAspects = ia.getPerInstanceJoinpointAspectDefinitions();
          
          if (instanceJpAspects.size() > 0)
          {
-            joinpointAspects = new WeakHashMap();
-            for (Iterator it = instanceJpAspects.keySet().iterator() ; it.hasNext() ; )
+            joinpointAspects = new WeakHashMap<AspectDefinition, ConcurrentHashMap<Joinpoint, Object>>();
+            for (AspectDefinition def : instanceJpAspects.keySet())
             {
-               AspectDefinition def = (AspectDefinition) it.next();
                initJoinpointAspect(def, instanceJpAspects);
-               Set joinpoints = (Set)instanceJpAspects.get(def);
+               Set<Joinpoint> joinpoints = instanceJpAspects.get(def);
                ia.addPerInstanceJoinpointAspect(joinpoints, def);
             }
          }
       }
       
-      Map jpAspects = getClassAdvisor().getPerInstanceJoinpointAspectDefinitions();
+      Map<AspectDefinition, Set<Joinpoint>> jpAspects = getClassAdvisor().getPerInstanceJoinpointAspectDefinitions();
       if (jpAspects.size() > 0)
       {
-         joinpointAspects = new WeakHashMap();
-         Iterator it = jpAspects.keySet().iterator();
-         while (it.hasNext())
+         joinpointAspects = new WeakHashMap<AspectDefinition, ConcurrentHashMap<Joinpoint, Object>>();
+         for (AspectDefinition def : jpAspects.keySet())
          {
-            AspectDefinition def = (AspectDefinition) it.next();
             initJoinpointAspect(def, jpAspects);
          }
       }
    }
    
-   private void initJoinpointAspect(AspectDefinition def, Map jpAspects)
+   private void initJoinpointAspect(AspectDefinition def, Map<AspectDefinition, Set<Joinpoint>> jpAspects)
    {
-      ConcurrentHashMap joins = new ConcurrentHashMap();
+      ConcurrentHashMap<Joinpoint, Object> joins = new ConcurrentHashMap<Joinpoint, Object>();
       joinpointAspects.put(def, joins);
-      Set joinpoints = (Set) jpAspects.get(def);
-      Iterator jps = joinpoints.iterator();
-      while (jps.hasNext())
+      Set<Joinpoint> joinpoints = jpAspects.get(def);
+      for (Joinpoint joinpoint : joinpoints)
       {
-         Object joinpoint = jps.next();
-         joins.put(joinpoint, def.getFactory().createPerJoinpoint(getClassAdvisor(), instanceAdvisor, (Joinpoint) joinpoint));
+         joins.put(joinpoint, def.getFactory().createPerJoinpoint(getClassAdvisor(), instanceAdvisor, joinpoint));
       }
    }
    
    public Object getPerInstanceAspect(String def)
    {
-      Iterator it = aspects.keySet().iterator();
-      while (it.hasNext())
+      for (AspectDefinition d : aspects.keySet())
       {
-         AspectDefinition d = (AspectDefinition) it.next();
          if (d.getName().equals(def)) return aspects.get(d);
       }
       return null;
    }
+
    public Object getPerInstanceAspect(AspectDefinition def)
    {
       // aspects is a weak hash map of AspectDefinitions so that perinstance advices can be undeployed/redeployed
       if (aspects == null)
       {
          initializeAspects();
-         return aspects.get(def);
+         if (aspects != null)
+         {
+            return aspects.get(def);
+         }
       }
       Object aspect = aspects.get(def);
       if (aspect == null)
@@ -193,7 +186,7 @@
                ClassAdvisor cadvisor = (ClassAdvisor) getClassAdvisor();
                cadvisor.getPerInstanceAspectDefinitions().add(def);
                aspect = def.getFactory().createPerInstance(null, null);
-               WeakHashMap copy = new WeakHashMap(aspects);
+               WeakHashMap<AspectDefinition, Object> copy = new WeakHashMap<AspectDefinition, Object>(aspects);
                copy.put(def, aspect);
                aspects = copy;
             }
@@ -222,11 +215,11 @@
                ClassAdvisor cadvisor = (ClassAdvisor) getClassAdvisor();
                cadvisor.addPerInstanceJoinpointAspect(joinpoint, def);
                aspect = def.getFactory().createPerJoinpoint(getClassAdvisor(), instanceAdvisor, joinpoint);
-               WeakHashMap copy = new WeakHashMap(joinpointAspects);
-               Map map = (Map) copy.get(def);
+               WeakHashMap<AspectDefinition, ConcurrentHashMap<Joinpoint, Object>> copy = new WeakHashMap<AspectDefinition, ConcurrentHashMap<Joinpoint, Object>>(joinpointAspects);
+               Map<Joinpoint, Object> map = copy.get(def);
                if (map == null)
                {
-                  map = new ConcurrentHashMap();
+                  map = new ConcurrentHashMap<Joinpoint, Object>();
                }
                map.put(joinpoint, aspect);
                joinpointAspects = copy;
@@ -239,7 +232,7 @@
    private Object getJoinpointAspect(AspectDefinition def, Joinpoint joinpoint)
    {
       if (joinpointAspects == null) return null;
-      Map map = (Map) joinpointAspects.get(def);
+      Map<Joinpoint, Object> map = joinpointAspects.get(def);
       Object aspect = map.get(joinpoint);
       return aspect;
    }

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/InterceptionMarkers.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/InterceptionMarkers.java	2008-03-24 03:41:24 UTC (rev 71184)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/InterceptionMarkers.java	2008-03-24 03:46:45 UTC (rev 71185)
@@ -30,13 +30,13 @@
  */
 public class InterceptionMarkers
 {
-   protected final ConcurrentHashMap convertableReference = new ConcurrentHashMap();
-   protected final ConcurrentHashMap hasFieldInterception = new ConcurrentHashMap();
-   protected final ConcurrentHashMap hasConstructorInterception = new ConcurrentHashMap();
+   protected final ConcurrentHashMap<String, String> convertableReference = new ConcurrentHashMap<String, String>();
+   protected final ConcurrentHashMap<String, String> hasFieldInterception = new ConcurrentHashMap<String, String>();
+   protected final ConcurrentHashMap<String, String> hasConstructorInterception = new ConcurrentHashMap<String, String>();
 
-   protected final ConcurrentHashMap skipConvertableReference = new ConcurrentHashMap();
-   protected final ConcurrentHashMap skipFieldInterception = new ConcurrentHashMap();
-   protected final ConcurrentHashMap skipConstructorInterception = new ConcurrentHashMap();
+   protected final ConcurrentHashMap<String, String> skipConvertableReference = new ConcurrentHashMap<String, String>();
+   protected final ConcurrentHashMap<String, String> skipFieldInterception = new ConcurrentHashMap<String, String>();
+   protected final ConcurrentHashMap<String, String> skipConstructorInterception = new ConcurrentHashMap<String, String>();
 
    public void addConstructionInterceptionMarker(String classname)
    {

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/InterceptorChainObserver.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/InterceptorChainObserver.java	2008-03-24 03:41:24 UTC (rev 71184)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/InterceptorChainObserver.java	2008-03-24 03:46:45 UTC (rev 71185)
@@ -21,8 +21,6 @@
   */
 package org.jboss.aop;
 
-import gnu.trove.TLongObjectHashMap;
-
 import org.jboss.aop.advice.Interceptor;
 
 /**
@@ -42,8 +40,8 @@
     * @param methodInterceptors interceptor chains to be applied at methods' executions.
     * @param clazz the reflection class whose joinpoints the interceptor chains will be applied to.
     */
-   public void initialInterceptorChains(Class clazz, Interceptor[][] fieldReadInterceptors, Interceptor[][] fieldWriteInterceptors,
-         Interceptor[][] constructorInterceptors, TLongObjectHashMap methodInterceptors);
+   public void initialInterceptorChains(Class<?> clazz, Interceptor[][] fieldReadInterceptors, Interceptor[][] fieldWriteInterceptors,
+         Interceptor[][] constructorInterceptors, MethodInterceptors methodInterceptors);
 
    /**
     * Notifies the observer that the class interceptor chains were updated.
@@ -53,7 +51,7 @@
     * @param newMethodInterceptors new interceptor chains to be applied at methods' executions.
     */
    public void interceptorChainsUpdated(Interceptor[][] newFieldReadInterceptors, Interceptor[][] newFieldWriteInterceptors,
-         Interceptor[][] newConstructorInterceptors, TLongObjectHashMap newMethodInterceptors);
+         Interceptor[][] newConstructorInterceptors, MethodInterceptors newMethodInterceptors);
    
    /**
     * Notifies that an interceptor was added to an instance of

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/Introduction.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/Introduction.java	2008-03-24 03:41:24 UTC (rev 71184)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/Introduction.java	2008-03-24 03:46:45 UTC (rev 71185)
@@ -35,7 +35,7 @@
 @Target({ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME)
 public @interface Introduction
 {
-   Class target() default java.lang.Class.class;
+   Class<?> target() default java.lang.Class.class;
    String typeExpression() default "";
-   Class[] interfaces();
+   Class<?>[] interfaces();
 }
\ No newline at end of file

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/JoinPointInfo.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/JoinPointInfo.java	2008-03-24 03:41:24 UTC (rev 71184)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/JoinPointInfo.java	2008-03-24 03:46:45 UTC (rev 71185)
@@ -21,6 +21,7 @@
   */
 package org.jboss.aop;
 
+import java.lang.annotation.Annotation;
 import java.lang.ref.WeakReference;
 import java.util.ArrayList;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
@@ -38,33 +39,35 @@
    static JoinPointRegistry REGISTRY;
    
    private ReentrantReadWriteLock interceptorChainLock = new ReentrantReadWriteLock();
-   
-   private Interceptor[] interceptors;
 
+   /** @deprecated Use the accessors. Only public for backwards compatiblity with EJB3*/
+   public Interceptor[] interceptors;
+
    private ArrayList<Interceptor> interceptorChain = new ArrayList<Interceptor>();
    
    private WeakReference<Advisor> advisor;
    
    protected volatile Joinpoint joinpoint;
    
-   protected WeakReference<Class> clazz;
+   protected WeakReference<Class<?>> clazz;
    
    private String adviceString;
 
    protected JoinPointInfo()
    {
-      this.clazz = new WeakReference<Class>(null);
+      this.clazz = new WeakReference<Class<?>>(null);
    }
    
-   protected JoinPointInfo(Advisor advisor, Class clazz)
+   protected JoinPointInfo(Advisor advisor, Class<?> clazz)
    {
+      this.clazz = new WeakReference<Class<?>>(clazz); 
       setAdvisor(advisor);
-      this.clazz = new WeakReference<Class>(clazz); 
    }
    
    /*
     * For copying
     */
+   @SuppressWarnings("deprecation")
    protected JoinPointInfo(JoinPointInfo other)
    {
       this.advisor = other.advisor;
@@ -77,6 +80,7 @@
       if (other.interceptorChain != null)this.interceptorChain.addAll(interceptorChain);
    }
 
+   @SuppressWarnings("deprecation")
    protected void clear()
    {
       interceptorChain.clear();
@@ -89,10 +93,10 @@
       {
          return null;
       }
-      return (Advisor)advisor.get();
+      return advisor.get();
    }
 
-   public Class getClazz()
+   public Class<?> getClazz()
    {
       return clazz.get(); 
    }
@@ -100,6 +104,10 @@
    public void setAdvisor(Advisor advisor) 
    {
       this.advisor = new WeakReference<Advisor>(advisor);
+      if (getClazz() == null && advisor != null)
+      {
+         this.clazz = new WeakReference<Class<?>>(advisor.getClazz());
+      }
    }
 
    public boolean hasAdvices()
@@ -158,6 +166,7 @@
       }
    }
 
+   @SuppressWarnings("deprecation")
    public Interceptor[] getInterceptors() {
       this.interceptorChainLock.readLock().lock();
       try
@@ -170,6 +179,7 @@
       }
    }
 
+   @SuppressWarnings("deprecation")
    public void setInterceptors(Interceptor[] interceptors) {
       this.interceptorChainLock.writeLock().lock();
       adviceString = null;
@@ -185,28 +195,29 @@
       return getAdvisor().getClassMetaData().getMetaData(key, attr);
    }
    
-   public Object resolveClassAnnotation(Class annotation)
+   public <T extends Annotation> T resolveClassAnnotation(Class<T> annotation)
    {
       Advisor advisor = getAdvisor();
       if (advisor != null)
       {
-         return advisor.resolveAnnotation(annotation);
+         return advisor.resolveTypedAnnotation(annotation);
       }
       return null;
    }
    
-   public Object resolveAnnotation(Class annotation)
+   public <T extends Annotation> T  resolveAnnotation(Class<T> annotation)
    {
       return null;
    }
    
+   @SuppressWarnings("deprecation")
    public void cloneChains(JoinPointInfo other)
    {
       this.interceptorChainLock.writeLock().lock();
       other.interceptorChainLock.readLock().lock();
       try
       {
-         interceptorChain = (ArrayList) other.interceptorChain.clone();
+         interceptorChain = (ArrayList<Interceptor>) other.interceptorChain.clone();
          if (other.interceptors == null)
          {
             interceptors = null;
@@ -223,6 +234,7 @@
       }
    }
    
+   @SuppressWarnings("deprecation")
    public String getAdviceString()
    {
       if (adviceString == null)

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/LoadInterceptedClassesStrategy.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/LoadInterceptedClassesStrategy.java	2008-03-24 03:41:24 UTC (rev 71184)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/LoadInterceptedClassesStrategy.java	2008-03-24 03:46:45 UTC (rev 71185)
@@ -60,7 +60,7 @@
     * in this strategy, no observer is required.
     * @see org.jboss.aop.DynamicAOPStrategy#getInterceptorChainObserver(Class)
     */
-   public InterceptorChainObserver getInterceptorChainObserver(Class clazz)
+   public InterceptorChainObserver getInterceptorChainObserver(Class<?> clazz)
    {
       return null;
    }

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/MethodByConInfo.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/MethodByConInfo.java	2008-03-24 03:41:24 UTC (rev 71184)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/MethodByConInfo.java	2008-03-24 03:46:45 UTC (rev 71185)
@@ -39,9 +39,9 @@
 {
 
    private final int callingIndex;
-   private final Constructor calling;
+   private final Constructor<?> calling;
    
-   public MethodByConInfo(Advisor advisor, Class calledClass, Class callingClass, int callingIndex, Method m, long calledMethodHash, Interceptor[] in)
+   public MethodByConInfo(Advisor advisor, Class<?> calledClass, Class<?> callingClass, int callingIndex, Method m, long calledMethodHash, Interceptor[] in)
    {
       // FIXME MethodByConInfo constructor
       super(advisor, calledClass, m, calledMethodHash, in, callingClass);
@@ -90,12 +90,12 @@
    }
 
    @Deprecated
-   public Constructor getCalling()
+   public Constructor<?> getCalling()
    {
       return calling;
    }
 
-   public Constructor getCallingConstructor()
+   public Constructor<?> getCallingConstructor()
    {
       return calling;
    }

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/MethodByMethodInfo.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/MethodByMethodInfo.java	2008-03-24 03:41:24 UTC (rev 71184)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/MethodByMethodInfo.java	2008-03-24 03:46:45 UTC (rev 71185)
@@ -27,7 +27,6 @@
 import org.jboss.aop.joinpoint.Joinpoint;
 import org.jboss.aop.joinpoint.MethodCallByMethod;
 import org.jboss.aop.joinpoint.MethodCalledByMethodJoinpoint;
-import org.jboss.aop.pointcut.Pointcut;
 
 /**
  * 
@@ -39,7 +38,7 @@
    private final long callingMethodHash;
    private final Method callingMethod;
    
-   public MethodByMethodInfo(Advisor advisor, Class calledClass, Method m, Method callingMethod, long callingMethodHash, long calledMethodHash, Interceptor[] in)
+   public MethodByMethodInfo(Advisor advisor, Class<?> calledClass, Method m, Method callingMethod, long callingMethodHash, long calledMethodHash, Interceptor[] in)
    {
       super(advisor, calledClass, m, calledMethodHash, in, callingMethod.getDeclaringClass());
       this.callingMethodHash = callingMethodHash;

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/MethodInfo.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/MethodInfo.java	2008-03-24 03:41:24 UTC (rev 71184)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/MethodInfo.java	2008-03-24 03:46:45 UTC (rev 71185)
@@ -21,12 +21,12 @@
   */
 package org.jboss.aop;
 
+import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
 
 import org.jboss.aop.joinpoint.Joinpoint;
 import org.jboss.aop.joinpoint.MethodExecution;
 import org.jboss.aop.joinpoint.MethodJoinpoint;
-import org.jboss.aop.pointcut.Pointcut;
 import org.jboss.aop.util.MethodHashing;
 
 /**
@@ -35,14 +35,16 @@
 public class MethodInfo extends JoinPointInfo implements MethodExecution
 {
    private Method advisedMethod;
-   private Method unadvisedMethod;
+   /** @deprecated Use the accessors. Only public for backwards compatiblity with EJB3*/
+   public Method unadvisedMethod;
    private long hash;
    
    public MethodInfo()
    {
    }
    
-   public MethodInfo(Class clazz, long hash, long unadvisedHash, Advisor advisor)
+   @SuppressWarnings("deprecation")
+   public MethodInfo(Class<?> clazz, long hash, long unadvisedHash, Advisor advisor)
    {
       super(advisor, clazz);
 
@@ -62,6 +64,7 @@
    /*
     * For copying
     */
+   @SuppressWarnings("deprecation")
    private MethodInfo(MethodInfo other)
    {
       super(other);
@@ -105,11 +108,13 @@
       this.hash = hash;
    }
 
+   @SuppressWarnings("deprecation")
    public Method getUnadvisedMethod() 
    {
       return unadvisedMethod;
    }
 
+   @SuppressWarnings("deprecation")
    public void setUnadvisedMethod(Method unadvisedMethod) {
       this.unadvisedMethod = unadvisedMethod;
    }
@@ -123,9 +128,9 @@
       return sb.toString();
    }
 
-   public Object resolveAnnotation(Class annotation)
+   public <T extends Annotation> T resolveAnnotation(Class<T> annotation)
    {
-      Object val = super.resolveAnnotation(annotation);
+      T val = super.resolveAnnotation(annotation);
       if (val != null)
       {
          return val;
@@ -134,7 +139,7 @@
       Advisor advisor = getAdvisor();
       if (advisor != null)
       {
-         return getAdvisor().resolveAnnotation(hash, advisedMethod, annotation);
+         return getAdvisor().resolveTypedAnnotation(hash, advisedMethod, annotation);
       }
       return null;
    }

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/MethodInterceptors.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/MethodInterceptors.java	2008-03-24 03:41:24 UTC (rev 71184)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/MethodInterceptors.java	2008-03-24 03:46:45 UTC (rev 71185)
@@ -28,7 +28,7 @@
  * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
  * @version $Revision$
  */
-class MethodInterceptors
+public class MethodInterceptors
 {
    Advisor advisor;
    TLongObjectHashMap infos = new TLongObjectHashMap();
@@ -40,7 +40,7 @@
 
    public long[] keys()
    {
-      return infos.keys();
+      return infos.keys ();
    }
    
    public MethodInfo getMethodInfo(long hash)
@@ -67,4 +67,9 @@
    {
       infos.clear();
    }
+   
+   public int size()
+   {
+      return infos.size();
+   }
 }

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/MethodMatchInfo.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/MethodMatchInfo.java	2008-03-24 03:41:24 UTC (rev 71184)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/MethodMatchInfo.java	2008-03-24 03:46:45 UTC (rev 71185)
@@ -40,8 +40,8 @@
    
    Advisor advisor;
    MethodInfo info;
-   ArrayList bindings;
-   ArrayList pointcutMethodMatches;
+   ArrayList<AdviceBinding> bindings;
+   ArrayList<PointcutMethodMatch> pointcutMethodMatches;
    
    MethodMatchInfo(Advisor advisor, MethodInfo info)
    {
@@ -53,11 +53,11 @@
    {
       if (bindings == null)
       {
-         bindings = new ArrayList();
+         bindings = new ArrayList<AdviceBinding>();
       }
       if (pointcutMethodMatches == null)
       {
-         pointcutMethodMatches = new ArrayList();
+         pointcutMethodMatches = new ArrayList<PointcutMethodMatch>();
       }
       bindings.add(binding);
       pointcutMethodMatches.add(pointcutMethodMatch);
@@ -73,11 +73,11 @@
       this.info = info;
    }
    
-   public ArrayList populateBindings()
+   public ArrayList<AdviceBinding> populateBindings()
    {
       if (bindings != null)
       {
-         ArrayList applicableBindings = new ArrayList();
+         ArrayList<AdviceBinding> applicableBindings = new ArrayList<AdviceBinding>();
          if (advisor.chainOverridingForInheritedMethods())
          {
             overridePopulateBindings(applicableBindings);
@@ -95,25 +95,25 @@
       return null;
    }
    
-   private void simplePopulateBindings(ArrayList applicableBindings)
+   private void simplePopulateBindings(ArrayList<AdviceBinding> applicableBindings)
    {
       int size = bindings.size();
       for (int i = 0 ; i < size ; i++)
       {
-         AdviceBinding binding = (AdviceBinding)bindings.get(i);
+         AdviceBinding binding = bindings.get(i);
          applyBinding(applicableBindings, binding);
       }
    }
    
-   private void overridePopulateBindings(ArrayList applicableBindings)
+   private void overridePopulateBindings(ArrayList<AdviceBinding> applicableBindings)
    {
       if (AspectManager.verbose && logger.isDebugEnabled()) logger.debug("populate bindings for " + info.getMethod() + " all bindings");
       int size = bindings.size();
       int minMatchLevel = 1000000;
       for (int i = 0 ; i < size ; i++)
       {
-         AdviceBinding binding = (AdviceBinding)bindings.get(i);
-         PointcutMethodMatch match = (PointcutMethodMatch)pointcutMethodMatches.get(i);
+         AdviceBinding binding = bindings.get(i);
+         PointcutMethodMatch match = pointcutMethodMatches.get(i);
          if (AspectManager.verbose && logger.isDebugEnabled()) logger.debug(match.getMatchLevel() + " " + match.getMatchedClass().getName() + " " + binding.getPointcut().getExpr() + " : " + binding.getInterceptorFactories().length);
          
          if (minMatchLevel > match.getMatchLevel() && !match.isInstanceOf())
@@ -125,8 +125,8 @@
       if (AspectManager.verbose && logger.isDebugEnabled()) logger.debug("populate bindings for " + info.getMethod() + " actual bindings");
       for (int i = 0 ; i < size ; i++)
       {
-         AdviceBinding binding = (AdviceBinding)bindings.get(i);
-         PointcutMethodMatch match = (PointcutMethodMatch)pointcutMethodMatches.get(i);
+         AdviceBinding binding = bindings.get(i);
+         PointcutMethodMatch match = pointcutMethodMatches.get(i);
          
          if (match.isInstanceOf() || match.getMatchLevel() == minMatchLevel)
          {
@@ -136,7 +136,7 @@
       }
    }
    
-   private void applyBinding(ArrayList applicableBindings, AdviceBinding binding)
+   private void applyBinding(ArrayList<AdviceBinding> applicableBindings, AdviceBinding binding)
    {
       applicableBindings.add(binding);
       binding.addAdvisor(advisor);

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/Mixin.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/Mixin.java	2008-03-24 03:41:24 UTC (rev 71184)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/Mixin.java	2008-03-24 03:46:45 UTC (rev 71185)
@@ -34,8 +34,8 @@
 @Target({ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME)
 public @interface Mixin
 {
-   Class target() default java.lang.Class.class;
+   Class<?> target() default java.lang.Class.class;
    String typeExpression() default "";
-   Class[] interfaces();
+   Class<?>[] interfaces();
    boolean isTransient() default true;
 }
\ No newline at end of file

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/ReflectiveAspectBinder.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/ReflectiveAspectBinder.java	2008-03-24 03:41:24 UTC (rev 71184)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/ReflectiveAspectBinder.java	2008-03-24 03:46:45 UTC (rev 71185)
@@ -34,13 +34,14 @@
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
 import org.jboss.aop.advice.AdviceBinding;
+import org.jboss.aop.advice.AspectDefinition;
+import org.jboss.aop.advice.InterceptorFactory;
 import org.jboss.aop.introduction.AnnotationIntroduction;
 import org.jboss.aop.microcontainer.lifecycle.LifecycleCallbackBinding;
 import org.jboss.aop.microcontainer.lifecycle.LifecycleCallbackDefinition;
@@ -48,8 +49,6 @@
 import org.jboss.aop.pointcut.PointcutMethodMatch;
 import org.jboss.aop.proxy.container.InstanceProxyContainer;
 import org.jboss.aop.util.Advisable;
-import org.jboss.aop.util.logging.AOPLogger;
-import org.jboss.logging.Logger;
 import org.jboss.util.MethodHashing;
 
 /**
@@ -59,12 +58,12 @@
  */
 public class ReflectiveAspectBinder
 {
-   protected Class clazz;
-   protected HashSet aspects = new HashSet();
-   protected HashMap methodAdvices = new HashMap();
-   protected HashMap constructorAdvices = new HashMap();
-   protected HashMap fieldReadAdvices = new HashMap();
-   protected HashMap fieldWriteAdvices = new HashMap();
+   protected Class<?> clazz;
+   protected HashSet<AspectDefinition> aspects = new HashSet<AspectDefinition>();
+   protected HashMap<Method, ArrayList<InterceptorFactory>> methodAdvices = new HashMap<Method, ArrayList<InterceptorFactory>>();
+   protected HashMap<Constructor<?>, ArrayList<InterceptorFactory>> constructorAdvices = new HashMap<Constructor<?>, ArrayList<InterceptorFactory>>();
+   protected HashMap<Field, ArrayList<InterceptorFactory>> fieldReadAdvices = new HashMap<Field, ArrayList<InterceptorFactory>>();
+   protected HashMap<Field, ArrayList<InterceptorFactory>> fieldWriteAdvices = new HashMap<Field, ArrayList<InterceptorFactory>>();
    protected Advisor advisor;
    protected boolean isInstanceContainer;
    TLongObjectHashMap methodMap = new TLongObjectHashMap();
@@ -74,23 +73,23 @@
    boolean initialisedAspects;
    boolean intitialisedLifecycleCallbacks;
    
-   public ReflectiveAspectBinder(Class clazz, Advisor advisor)
+   public ReflectiveAspectBinder(Class<?> clazz, Advisor advisor)
    {
       this.clazz = clazz;
       this.advisor = advisor;
       isInstanceContainer = InstanceProxyContainer.class == advisor.getClass();
    }
 
-   public Class getClazz()
+   public Class<?> getClazz()
    {
       return clazz;
    }
 
-   public HashSet getAspects()
+   public HashSet<AspectDefinition> getAspects()
    {
       if (!initialisedAspects)
       {
-         Map bindings = advisor.getManager().getBindings();
+         Map<String, AdviceBinding> bindings = advisor.getManager().getBindings();
          bindMethodAdvices(clazz, bindings);
          bindConstructorAdvices(bindings);
          bindFieldAdvices(bindings);
@@ -107,27 +106,27 @@
       return lifecycleCallbacks;
    }
    
-   public HashMap getMethodAdvices()
+   public HashMap<Method, ArrayList<InterceptorFactory>> getMethodAdvices()
    {
       return methodAdvices;
    }
 
-   public HashMap getConstructorAdvices()
+   public HashMap<Constructor<?>, ArrayList<InterceptorFactory>> getConstructorAdvices()
    {
       return constructorAdvices;
    }
 
-   public HashMap getFieldReadAdvices()
+   public HashMap<Field, ArrayList<InterceptorFactory>> getFieldReadAdvices()
    {
       return fieldReadAdvices;
    }
 
-   public HashMap getFieldWriteAdvices()
+   public HashMap<Field, ArrayList<InterceptorFactory>> getFieldWriteAdvices()
    {
       return fieldWriteAdvices;
    }
 
-   public void createMethodMap(final Class superClass)
+   public void createMethodMap(final Class<?> superClass)
    {
       try
       {
@@ -137,9 +136,9 @@
          }
          createMethodMap(superClass.getSuperclass());
          
-         Method[] methods = (Method[]) AccessController.doPrivileged(new PrivilegedExceptionAction() 
+         Method[] methods = AccessController.doPrivileged(new PrivilegedExceptionAction<Method[]>() 
          {
-            public Object run() throws Exception
+            public Method[] run() throws Exception
             {
                return superClass.getDeclaredMethods();
             }
@@ -165,7 +164,7 @@
       }
    }
    
-   protected void bindMethodAdvices(Class superClass, Map bindings)
+   protected void bindMethodAdvices(Class<?> superClass, Map<String, AdviceBinding> bindings)
    {
       createMethodMap(superClass); 
       if (methodMap != null)
@@ -178,11 +177,11 @@
       }
    }
 
-   protected void bindConstructorAdvices(Map bindings)
+   protected void bindConstructorAdvices(Map<String, AdviceBinding> bindings)
    {
-      Constructor[] cons = (Constructor[]) AccessController.doPrivileged(new PrivilegedAction() 
+      Constructor<?>[] cons = AccessController.doPrivileged(new PrivilegedAction<Constructor<?>[]>() 
       {
-         public Object run()
+         public Constructor<?>[] run()
          {
             return clazz.getDeclaredConstructors();
          }
@@ -193,11 +192,11 @@
       }
    }
 
-   protected void bindFieldAdvices(Map bindings)
+   protected void bindFieldAdvices(Map<String, AdviceBinding> bindings)
    {
-      Field[] fields = (Field[]) AccessController.doPrivileged(new PrivilegedAction() 
+      Field[] fields = AccessController.doPrivileged(new PrivilegedAction<Field[]>() 
       {
-         public Object run()
+         public Field[] run()
          {
             return clazz.getDeclaredFields();
          }
@@ -215,21 +214,18 @@
       return ((Boolean) ai.getTarget().jjtAccept(matcher, null)).booleanValue();
    }
 
-   protected void bindMethodAdvice(Method mi, Map bindings)
+   protected void bindMethodAdvice(Method mi, Map<String, AdviceBinding> bindings)
    {
-      Iterator it = bindings.values().iterator();
-      ArrayList advices = (ArrayList)methodAdvices.get(mi);
-      while (it.hasNext())
+      ArrayList<InterceptorFactory> advices = methodAdvices.get(mi);
+      for (AdviceBinding binding : bindings.values())
       {
-
-         AdviceBinding binding = (AdviceBinding)it.next();
          PointcutMethodMatch pmatch= binding.getPointcut().matchesExecution(advisor, mi);
          
          if (pmatch != null && pmatch.isMatch())
          {
             if (advices == null)
             {
-               advices = new ArrayList();
+               advices = new ArrayList<InterceptorFactory>();
                methodAdvices.put(mi, advices);
             }
             advices.addAll(Arrays.asList(binding.getInterceptorFactories()));
@@ -241,19 +237,16 @@
       }
    }
 
-   protected void bindConstructorAdvice(Constructor mi, Map bindings)
+   protected void bindConstructorAdvice(Constructor<?> mi, Map<String, AdviceBinding> bindings)
    {
-      Iterator it = bindings.values().iterator();
-      ArrayList advices = (ArrayList)constructorAdvices.get(mi);
-      while (it.hasNext())
+      ArrayList<InterceptorFactory> advices = constructorAdvices.get(mi);
+      for (AdviceBinding binding : bindings.values())
       {
-
-         AdviceBinding binding = (AdviceBinding)it.next();
          if (binding.getPointcut().matchesExecution(advisor, mi))
          {
             if (advices == null)
             {
-               advices = new ArrayList();
+               advices = new ArrayList<InterceptorFactory>();
                constructorAdvices.put(mi, advices);
             }
             advices.addAll(Arrays.asList(binding.getInterceptorFactories()));
@@ -265,20 +258,16 @@
       }
    }
 
-   protected void bindFieldGetAdvice(Field mi, Map bindings)
+   protected void bindFieldGetAdvice(Field mi, Map<String, AdviceBinding> bindings)
    {
-      Map repositoryBindings = advisor.getManager().getBindings();
-      Iterator it = repositoryBindings.values().iterator();
-      ArrayList advices = (ArrayList)fieldReadAdvices.get(mi);
-      while (it.hasNext())
+      ArrayList<InterceptorFactory> advices = fieldReadAdvices.get(mi);
+      for (AdviceBinding binding : bindings.values())
       {
-
-         AdviceBinding binding = (AdviceBinding)it.next();
          if (binding.getPointcut().matchesGet(advisor, mi))
          {
             if (advices == null)
             {
-               advices = new ArrayList();
+               advices = new ArrayList<InterceptorFactory>();
                fieldReadAdvices.put(mi, advices);
             }
             advices.addAll(Arrays.asList(binding.getInterceptorFactories()));
@@ -290,20 +279,16 @@
       }
    }
 
-   protected void bindFieldSetAdvice(Field mi, Map bindings)
+   protected void bindFieldSetAdvice(Field mi, Map<String, AdviceBinding> bindings)
    {
-      Map repositoryBindings = advisor.getManager().getBindings();
-      Iterator it = repositoryBindings.values().iterator();
-      ArrayList advices = (ArrayList)fieldWriteAdvices.get(mi);
-      while (it.hasNext())
+      ArrayList<InterceptorFactory> advices = fieldWriteAdvices.get(mi);
+      for (AdviceBinding binding : bindings.values())
       {
-
-         AdviceBinding binding = (AdviceBinding)it.next();
          if (binding.getPointcut().matchesSet(advisor, mi))
          {
             if (advices == null)
             {
-               advices = new ArrayList();
+               advices = new ArrayList<InterceptorFactory>();
                fieldWriteAdvices.put(mi, advices);
             }
             advices.addAll(Arrays.asList(binding.getInterceptorFactories()));

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/SecurityActions.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/SecurityActions.java	2008-03-24 03:41:24 UTC (rev 71184)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/SecurityActions.java	2008-03-24 03:46:45 UTC (rev 71185)
@@ -47,7 +47,7 @@
          {
             try
             {
-               AccessController.doPrivileged(new PrivilegedExceptionAction()
+               AccessController.doPrivileged(new PrivilegedExceptionAction<Object>()
                {
                   public Object run() throws Exception
                   {
@@ -94,7 +94,7 @@
          {
             try
             {
-               AccessController.doPrivileged(new PrivilegedExceptionAction()
+               AccessController.doPrivileged(new PrivilegedExceptionAction<Object>()
                {
                   public Object run() throws Exception
                   {
@@ -151,29 +151,29 @@
    
    interface GetDeclaredConstructorsAction 
    {
-      Constructor[] getDeclaredConstructors(Class clazz);
+      Constructor<?>[] getDeclaredConstructors(Class<?> clazz);
       
       GetDeclaredConstructorsAction NON_PRIVILEGED = new GetDeclaredConstructorsAction() {
 
-         public Constructor[] getDeclaredConstructors(Class clazz)
+         public Constructor<?>[] getDeclaredConstructors(Class<?> clazz)
          {
             return clazz.getDeclaredConstructors();
          }};
 
          GetDeclaredConstructorsAction PRIVILEGED = new GetDeclaredConstructorsAction() {
 
-            public Constructor[] getDeclaredConstructors(final Class clazz)
+            public Constructor<?>[] getDeclaredConstructors(final Class<?> clazz)
             {
-               return AccessController.doPrivileged(new PrivilegedAction<Constructor[]>() {
+               return AccessController.doPrivileged(new PrivilegedAction<Constructor<?>[]>() {
 
-                  public Constructor[] run()
+                  public Constructor<?>[] run()
                   {
                      return clazz.getDeclaredConstructors();
                   }});
             }};
    }
    
-   static Constructor[] getDeclaredConstructors(Class clazz)
+   static Constructor<?>[] getDeclaredConstructors(Class<?> clazz)
    {
       if (System.getSecurityManager() == null)
       {
@@ -188,18 +188,18 @@
    
    interface GetClassLoaderAction 
    {
-      ClassLoader getClassLoader(Class clazz);
+      ClassLoader getClassLoader(Class<?> clazz);
       
       GetClassLoaderAction NON_PRIVILEGED = new GetClassLoaderAction() {
 
-         public ClassLoader getClassLoader(Class clazz)
+         public ClassLoader getClassLoader(Class<?> clazz)
          {
             return clazz.getClassLoader();
          }};
 
      GetClassLoaderAction PRIVILEGED = new GetClassLoaderAction() {
 
-         public ClassLoader getClassLoader(final Class clazz)
+         public ClassLoader getClassLoader(final Class<?> clazz)
          {
             return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
 
@@ -210,7 +210,7 @@
          }};
    }
    
-   static ClassLoader getClassLoader(Class clazz)
+   static ClassLoader getClassLoader(Class<?> clazz)
    {
       if (System.getSecurityManager() == null)
       {

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/WeavingStrategySupport.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/WeavingStrategySupport.java	2008-03-24 03:41:24 UTC (rev 71184)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/WeavingStrategySupport.java	2008-03-24 03:46:45 UTC (rev 71185)
@@ -29,9 +29,9 @@
 public abstract class WeavingStrategySupport implements WeavingStrategy
 {
    
-   private static ThreadLocal REENTRY = new ThreadLocal()
+   private static ThreadLocal<Boolean> REENTRY = new ThreadLocal<Boolean>()
    {
-      protected Object initialValue()
+      protected Boolean initialValue()
       {
          return Boolean.FALSE;
       }
@@ -44,7 +44,7 @@
     */
    protected static boolean isReEntry()
    {
-      return ((Boolean) REENTRY.get()).booleanValue();
+      return REENTRY.get().booleanValue();
    }
 
    /**




More information about the jboss-cvs-commits mailing list