[jboss-cvs] JBossAS SVN: r59218 - in projects/aop/branches/arrays/aop/src: main/org/jboss/aop/array main/org/jboss/aop/instrument resources/test/array test/org/jboss/test/aop/array

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat Dec 23 18:27:50 EST 2006


Author: kabir.khan at jboss.com
Date: 2006-12-23 18:27:35 -0500 (Sat, 23 Dec 2006)
New Revision: 59218

Added:
   projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ArrayElementInvocation.java
   projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ArrayElementReadInvocation.java
   projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ArrayElementWriteInvocation.java
   projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ArrayRegistry.java
   projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ArrayRegistryEntry.java
   projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ElementArrayRegistryEntry.java
   projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/FieldArrayRegistryEntry.java
   projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/IntArrayElementReadInvocation.java
   projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/IntArrayElementWriteInvocation.java
   projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ObjectArrayElementReadInvocation.java
   projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ObjectArrayElementWriteInvocation.java
   projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/TestArrayElementInterceptor.java
   projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/ArrayTestCase.bak
   projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/ClassWithArrayFieldCaller.bak
   projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/Main.bak
Removed:
   projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/ArrayTestCase.java
   projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/ClassWithArrayFieldCaller.java
   projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/Main.java
Modified:
   projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ArrayAdvisor.java
   projects/aop/branches/arrays/aop/src/main/org/jboss/aop/instrument/FieldAccessTransformer.java
   projects/aop/branches/arrays/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorFieldAccessTransformer.java
   projects/aop/branches/arrays/aop/src/main/org/jboss/aop/instrument/Instrumentor.java
   projects/aop/branches/arrays/aop/src/main/org/jboss/aop/instrument/NonOptimizedFieldAccessTransformer.java
   projects/aop/branches/arrays/aop/src/main/org/jboss/aop/instrument/OptimizedFieldAccessTransformer.java
   projects/aop/branches/arrays/aop/src/resources/test/array/jboss-aop.xml
   projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/AOPArrayTestCase.java
   projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/AOPTransformer.java
   projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/ClassWithArrayFields.java
Log:
Get array interception sorking for int arrays and basics for multidim arrays

Modified: projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ArrayAdvisor.java
===================================================================
--- projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ArrayAdvisor.java	2006-12-23 20:56:17 UTC (rev 59217)
+++ projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ArrayAdvisor.java	2006-12-23 23:27:35 UTC (rev 59218)
@@ -21,6 +21,8 @@
 */ 
 package org.jboss.aop.array;
 
+import org.jboss.aop.advice.Interceptor;
+
 /**
  * 
  * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
@@ -28,6 +30,8 @@
  */
 public class ArrayAdvisor
 {
+   //TODO Make configurable
+   static Interceptor[] interceptors = new Interceptor[] {new TestArrayElementInterceptor()};
    public static Object array;
    public static String value;
    public static int index;
@@ -39,118 +43,157 @@
       index = -1;
    }
    
-   private static void recordAccess(Object array, int index, String value)
+   public static void updateArrayField(Object target, String fieldName, Object oldValue, Object newValue)
    {
-      System.out.println("Accessing array");
-      ArrayAdvisor.array = array;
-      ArrayAdvisor.index = index;
-      ArrayAdvisor.value = value;
+      ArrayRegistry registry = ArrayRegistry.getInstance();
+      registry.removeFieldReference(target, fieldName, oldValue);
+      registry.addFieldReference(target, fieldName, newValue);
    }
    
    //Write operations
-   public static void arrayWrite(boolean[] array, int index, boolean value)
+//   public static void arrayWrite(boolean[] array, int index, boolean value)
+//   {
+//      array[index] = value; 
+//   }
+//
+//   public static void arrayWrite(short[] array, int index, short value)
+//   {
+//      array[index] = value; 
+//   }
+//
+   public static void arrayWriteInt(Object array, int index, int value) throws Throwable
    {
-      recordAccess(array, index, String.valueOf(value));
-      array[index] = value; 
+      if (ArrayRegistry.getInstance().isRegistered(array))
+      {
+         System.out.println("---------> Writing" + array + " advised");
+         IntArrayElementWriteInvocation invocation = new IntArrayElementWriteInvocation(interceptors, ((int[])array), index, value);
+         invocation.invokeNext();
+      }
+      else
+      {
+         ((int[])array)[index] = value;
+      }
    }
 
-   public static void arrayWrite(short[] array, int index, short value)
+   public static void arrayWriteObject(Object array, int index, Object value) throws Throwable
    {
-      recordAccess(array, index, String.valueOf(value));
-      array[index] = value; 
+      ArrayRegistry registry = ArrayRegistry.getInstance();
+      if (registry.isRegistered(array))
+      {
+         System.out.println("---------> Writing" + array + " advised");
+         
+         if (value.getClass().isArray())
+         {
+            Object oldValue = ((Object[])array)[index];
+            registry.removeElementReference(array, index, oldValue);
+            registry.addElementReference(array, index, value);
+         
+         }
+         ObjectArrayElementWriteInvocation invocation = new ObjectArrayElementWriteInvocation(interceptors, (Object[])array, index, value);
+         invocation.invokeNext();
+      }
+      else
+      {
+         System.out.println("---------> Writing" + array + " not advised");
+         ((Object[])array)[index] = value;
+      }
    }
-
-   public static void arrayWrite(int[] array, int index, int value)
-   {
-      recordAccess(array, index, String.valueOf(value));
-      array[index] = value; 
-   }
    
-   public static void arrayWrite(long[] array, int index, long value)
-   {
-      recordAccess(array, index, String.valueOf(value));
-      array[index] = value; 
-   }
-   
-   public static void arrayWrite(float[] array, int index, float value)
-   {
-      recordAccess(array, index, String.valueOf(value));
-      array[index] = value; 
-   }
-   
-   public static void arrayWrite(double[] array, int index, double value)
-   {
-      recordAccess(array, index, String.valueOf(value));
-      array[index] = value; 
-   }
-   
-   public static void arrayWrite(char[] array, int index, char value)
-   {
-      recordAccess(array, index, String.valueOf(value));
-      array[index] = value; 
-   }
-   
-   public static void arrayWrite(Object[] array, int index, Object value)
-   {
-      recordAccess(array, index, String.valueOf(value));
-      array[index] = value; 
-   }
+//   
+//   public static void arrayWrite(long[] array, int index, long value)
+//   {
+//      array[index] = value; 
+//   }
+//   
+//   public static void arrayWrite(float[] array, int index, float value)
+//   {
+//      array[index] = value; 
+//   }
+//   
+//   public static void arrayWrite(double[] array, int index, double value)
+//   {
+//      array[index] = value; 
+//   }
+//   
+//   public static void arrayWrite(char[] array, int index, char value)
+//   {
+//      array[index] = value; 
+//   }
+//   
+//   public static void arrayWrite(Object[] array, int index, Object value)
+//   {
+//      array[index] = value; 
+//   }
 
    //Read operations
-   public static boolean arrayRead(boolean[] array, int index)
+//   public static boolean arrayRead(boolean[] array, int index)
+//   {
+//      
+//      boolean value = array[index];
+//      return value;
+//   }
+//
+//   public static short arrayRead(short[] array, int index)
+//   {
+//      short value = array[index];
+//      return value;
+//   }
+//
+   public static int arrayReadInt(Object array, int index) throws Throwable
    {
-      
-      boolean value = array[index];
-      recordAccess(array, index, String.valueOf(value));
-      return value;
+      if (ArrayRegistry.getInstance().isRegistered(array))
+      {
+         IntArrayElementReadInvocation invocation = new IntArrayElementReadInvocation(interceptors, (int[])array, index);
+         return ((Integer)invocation.invokeNext()).intValue();
+      }
+      else
+      {
+         return ((int[])array)[index];
+      }
    }
 
-   public static short arrayRead(short[] array, int index)
+   public static Object arrayReadObject(Object array, int index) throws Throwable
    {
-      short value = array[index];
-      recordAccess(array, index, String.valueOf(value));
-      return value;
+      if (ArrayRegistry.getInstance().isRegistered(array))
+      {
+         ObjectArrayElementReadInvocation invocation = new ObjectArrayElementReadInvocation(interceptors, (Object[])array, index);
+         return invocation.invokeNext();
+      }
+      else
+      {
+         return ((Object[])array)[index];
+      }
    }
 
-   public static int arrayRead(int[] array, int index)
-   {
-      int value = array[index];
-      recordAccess(array, index, String.valueOf(value));
-      return value;
-   }
-   
-   public static long arrayRead(long[] array, int index)
-   {
-      long value = array[index];
-      recordAccess(array, index, String.valueOf(value));
-      return value;
-   }
-   
-   public static float arrayRead(float[] array, int index)
-   {
-      float value = array[index];
-      recordAccess(array, index, String.valueOf(value));
-      return value;
-   }
-   
-   public static double arrayRead(double[] array, int index)
-   {
-      double value = array[index];
-      recordAccess(array, index, String.valueOf(value));
-      return value;
-   }
-   
-   public static char arrayRead(char[] array, int index)
-   {
-      char value = array[index];
-      recordAccess(array, index, String.valueOf(value));
-      return value;
-   }
-   
-   public static Object arrayRead(Object[] array, int index)
-   {
-      Object value = array[index];
-      recordAccess(array, index, String.valueOf(value));
-      return value;
-   }
+//   
+//   public static long arrayRead(long[] array, int index)
+//   {
+//      long value = array[index];
+//      return value;
+//   }
+//   
+//   public static float arrayRead(float[] array, int index)
+//   {
+//      float value = array[index];
+//      return value;
+//   }
+//   
+//   public static double arrayRead(double[] array, int index)
+//   {
+//      double value = array[index];
+//      return value;
+//   }
+//   
+//   public static char arrayRead(char[] array, int index)
+//   {
+//      char value = array[index];
+//      return value;
+//   }
+//   
+//   public static Object arrayRead(Object[] array, int index)
+//   {
+//      Object value = array[index];
+//      return value;
+//   }
+
 }

Added: projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ArrayElementInvocation.java
===================================================================
--- projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ArrayElementInvocation.java	2006-12-23 20:56:17 UTC (rev 59217)
+++ projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ArrayElementInvocation.java	2006-12-23 23:27:35 UTC (rev 59218)
@@ -0,0 +1,167 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.array;
+
+import java.util.Map;
+
+import org.jboss.aop.Advisor;
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.InvocationBase;
+import org.jboss.aop.metadata.MetaDataResolver;
+import org.jboss.util.NotImplementedException;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class ArrayElementInvocation extends InvocationBase
+{
+   int index;
+   
+   public ArrayElementInvocation(Interceptor[] interceptors, Object array, int index)
+   {
+      // FIXME ArrayElementInvocation constructor
+      super(interceptors);
+      super.setTargetObject(array);
+      this.index = index;
+   }
+
+   public int getIndex()
+   {
+      return index;
+   }
+   /**
+    * Invoke on the next interceptor in the chain.  If this is already
+    * the end of the chain, reflection will call the constructor, field, or
+    * method you are invoking on.
+    */
+   public Object invokeNext() throws Throwable
+   {
+      if (interceptors != null && currentInterceptor < interceptors.length)
+      {
+         try
+         {
+            return interceptors[currentInterceptor++].invoke(this);
+         }
+         finally
+         {
+            // so that interceptors like clustering can reinvoke down the chain
+            currentInterceptor--;
+         }
+      }
+
+      return invokeTarget();
+   }
+
+   public abstract Object invokeTarget();
+
+
+   @Override
+   public void addResponseAttachment(Object key, Object val)
+   {
+      throw new NotImplementedException();
+   }
+
+   @Override
+   public Advisor getAdvisor()
+   {
+      throw new NotImplementedException();
+   }
+
+   @Override
+   public int getCurrentInterceptor()
+   {
+      throw new NotImplementedException();
+   }
+
+   @Override
+   public MetaDataResolver getInstanceResolver()
+   {
+      throw new NotImplementedException();
+   }
+
+   @Override
+   public Object getResponseAttachment(Object key)
+   {
+      throw new NotImplementedException();
+   }
+
+   @Override
+   public Map getResponseContextInfo()
+   {
+      throw new NotImplementedException();
+   }
+
+   @Override
+   public Object resolveAnnotation(Class annotation)
+   {
+      throw new NotImplementedException();
+   }
+
+   @Override
+   public Object resolveAnnotation(Class[] annotations)
+   {
+      throw new NotImplementedException();
+   }
+
+   @Override
+   public Object resolveClassAnnotation(Class annotation)
+   {
+      throw new NotImplementedException();
+   }
+
+   @Override
+   public Object resolveClassMetaData(Object key, Object attr)
+   {
+      throw new NotImplementedException();
+   }
+
+   @Override
+   public void setAdvisor(Advisor advisor)
+   {
+      throw new NotImplementedException();
+   }
+
+   @Override
+   public void setInstanceResolver(MetaDataResolver instanceResolver)
+   {
+      throw new NotImplementedException();
+   }
+
+   @Override
+   public void setResponseContextInfo(Map responseContextInfo)
+   {
+      throw new NotImplementedException();
+   }
+
+   public Invocation copy()
+   {
+      throw new NotImplementedException();
+   }
+
+   public Invocation getWrapper(Interceptor[] newchain)
+   {
+      throw new NotImplementedException();
+   }
+}

Added: projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ArrayElementReadInvocation.java
===================================================================
--- projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ArrayElementReadInvocation.java	2006-12-23 20:56:17 UTC (rev 59217)
+++ projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ArrayElementReadInvocation.java	2006-12-23 23:27:35 UTC (rev 59218)
@@ -0,0 +1,38 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.array;
+
+import org.jboss.aop.advice.Interceptor;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class ArrayElementReadInvocation extends ArrayElementInvocation
+{
+   public ArrayElementReadInvocation(Interceptor[] interceptors, Object array, int index)
+   {
+      // FIXME ArrayElementReadInvocation constructor
+      super(interceptors, array, index);
+   }
+}

Added: projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ArrayElementWriteInvocation.java
===================================================================
--- projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ArrayElementWriteInvocation.java	2006-12-23 20:56:17 UTC (rev 59217)
+++ projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ArrayElementWriteInvocation.java	2006-12-23 23:27:35 UTC (rev 59218)
@@ -0,0 +1,39 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.array;
+
+import org.jboss.aop.advice.Interceptor;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class ArrayElementWriteInvocation extends ArrayElementInvocation
+{
+   public ArrayElementWriteInvocation(Interceptor[] interceptors, Object array, int index)
+   {
+      super(interceptors, array, index);
+   }
+
+   public abstract Object getValue();
+}

Added: projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ArrayRegistry.java
===================================================================
--- projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ArrayRegistry.java	2006-12-23 20:56:17 UTC (rev 59217)
+++ projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ArrayRegistry.java	2006-12-23 23:27:35 UTC (rev 59218)
@@ -0,0 +1,254 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.array;
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.WeakHashMap;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ArrayRegistry
+{
+   private static ArrayRegistry singleton = new ArrayRegistry();
+   private ReadWriteLock lock = new ReentrantReadWriteLock();
+   private WeakHashMap<Object, WeakHashMap<Object, ArrayRegistryEntry>> cache = new WeakHashMap<Object, WeakHashMap<Object, ArrayRegistryEntry>>();
+   
+   public static ArrayRegistry getInstance()
+   {
+      return singleton;
+   }
+   
+   private ArrayRegistry()
+   {
+      
+   }
+   
+   public void addFieldReference(Object owner, String fieldName, Object array)
+   {
+      System.out.println("----> Adding " + array + " to " + owner);
+      if (array == null)
+      {
+         return;
+      }
+      Lock writeLock = lock.writeLock();
+      writeLock.lock();
+      try
+      {
+         WeakHashMap<Object, ArrayRegistryEntry> arrayReferences = cache.get(array);
+         if (arrayReferences == null)
+         {
+            arrayReferences = new WeakHashMap<Object, ArrayRegistryEntry>();
+            cache.put(array, arrayReferences);
+         }
+         arrayReferences.put(owner, new FieldArrayRegistryEntry(owner, fieldName, array));
+         addNestedArrays(array);
+      }
+      finally
+      {
+         writeLock.unlock();
+      }
+   }
+   
+   public void removeFieldReference(Object owner, String field, Object array)
+   {
+      if (array == null)
+      {
+         return;
+      }
+
+      Lock writeLock = lock.writeLock();
+      writeLock.lock();
+      try
+      {
+         WeakHashMap<Object, ArrayRegistryEntry> arrayReferences = cache.get(array);
+         if (arrayReferences != null)
+         {
+            arrayReferences.remove(owner);
+         }
+         removeNestedArrays(owner, array);
+      }
+      finally
+      {
+         writeLock.unlock();
+      }
+   }
+
+   public void addElementReference(Object owner, int index, Object array)
+   {
+      System.out.println("----> Adding " + array + " to " + owner);
+      if (array == null)
+      {
+         return;
+      }
+      Lock writeLock = lock.writeLock();
+      writeLock.lock();
+      try
+      {
+         WeakHashMap<Object, ArrayRegistryEntry> arrayReferences = cache.get(array);
+         if (arrayReferences == null)
+         {
+            arrayReferences = new WeakHashMap<Object, ArrayRegistryEntry>();
+            cache.put(array, arrayReferences);
+         }
+         arrayReferences.put(owner, new ElementArrayRegistryEntry(owner, index, array));
+         addNestedArrays(array);
+      }
+      finally
+      {
+         writeLock.unlock();
+      }
+   }
+   
+   public void removeElementReference(Object owner, int index, Object array)
+   {
+      System.out.println("----> Removing " + array + " from " + owner);
+      if (array == null)
+      {
+         return;
+      }
+
+      Lock writeLock = lock.writeLock();
+      writeLock.lock();
+      try
+      {
+         WeakHashMap<Object, ArrayRegistryEntry> arrayReferences = cache.get(array);
+         if (arrayReferences != null)
+         {
+            arrayReferences.remove(owner);
+         }
+         removeNestedArrays(owner, array);
+      }
+      finally
+      {
+         writeLock.unlock();
+      }
+   }
+
+   public boolean isRegistered(Object array)
+   {
+      Lock readLock = lock.readLock();
+      readLock.lock();
+      
+      try
+      {
+         WeakHashMap<Object, ArrayRegistryEntry> arrayReferences = cache.get(array);
+         if (arrayReferences == null || arrayReferences.size() == 0)
+         {
+            return false;
+         }
+         return true;
+      }
+      finally
+      {
+         readLock.unlock();
+      }
+   }
+   
+   public Set getOwners(Object owner, Object array)
+   {
+      Lock readLock = lock.readLock();
+      readLock.lock();
+      
+      try
+      {
+         WeakHashMap<Object, ArrayRegistryEntry> arrayReferences = cache.get(array);
+         if (arrayReferences != null)
+         {
+            HashSet set = new HashSet();
+            set.addAll(arrayReferences.keySet());
+            return set;
+         }
+         return null;
+      }
+      finally
+      {
+         readLock.unlock();
+      }
+   }
+
+   private void addNestedArrays(Object array)
+   {
+      if (array == null)
+      {
+         return;
+      }
+      if (isArray(array))
+      {
+         for (int i = 0 ; i < ((Object[])array).length ; i++)
+         {
+            addElementReference(array, i, ((Object[])array)[i]);
+            addNestedArrays(((Object[])array)[i]);
+         }
+      }
+   }
+   
+   private void removeNestedArrays(Object owner, Object array)
+   {
+      if (array == null)
+      {
+         return;
+      }
+      if (isArray(array))
+      {
+         for (int i = 0 ; i < ((Object[])array).length ; i++)
+         {
+            removeElementReference(array, i, ((Object[])array)[i]);
+            removeNestedArrays(array, ((Object[])array)[i]);
+         }
+      }
+   }
+   
+   private boolean isArray(Object array)
+   {
+      Class componentType = array.getClass().getComponentType();
+      return componentType.isArray();
+   }
+   
+   public void dumpCache()
+   {
+//      System.out.println(cache);
+   }
+//    
+//   public static void main(String[] args)
+//   {
+//      ArrayRegistry registry = getInstance();
+//      
+//      System.out.println("============== 1 dim");
+//      int[] dim1 = new int[] {1,2,3};
+//      registry.addNestedArrays(dim1);
+//      
+//      System.out.println("============== 2 dim");
+//      int[][] dim2 = new int[][] {new int[] {1,2}, new int[] {1,2}};
+//      registry.addNestedArrays(dim2);
+//      
+//      System.out.println("============== 3 dim");
+//      int[][][] dim3 = new int[][][] {new int[][] {new int[] {1,2},new int[] {1,2}}, new int[][] {new int[] {1,2},new int[] {1,2}}};
+//      registry.addNestedArrays(dim3);
+//   }
+}

Added: projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ArrayRegistryEntry.java
===================================================================
--- projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ArrayRegistryEntry.java	2006-12-23 20:56:17 UTC (rev 59217)
+++ projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ArrayRegistryEntry.java	2006-12-23 23:27:35 UTC (rev 59218)
@@ -0,0 +1,69 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.array;
+
+import java.lang.ref.WeakReference;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class ArrayRegistryEntry
+{
+   /** WeakReference to the object or array containing the reference */
+   WeakReference owner;
+   
+   /** WeakReference to the referenced array */
+   WeakReference array;
+   
+   /** True if the object referencing the array is a "normal" object, false if it ia an array */
+   boolean ownerIsRoot;
+   
+   ArrayRegistryEntry(Object owner, boolean ownerIsRoot, Object array)
+   {
+      this.owner = new WeakReference(owner);
+      this.array = new WeakReference(array);
+      this.ownerIsRoot = ownerIsRoot;
+      if (ownerIsRoot && owner.getClass().isArray()) {
+         throw new RuntimeException("Owner is root and an array was passed in");
+      }
+      if (!ownerIsRoot && !owner.getClass().isArray()) {
+         throw new RuntimeException("Owner is not root and no array was passed in");
+      }
+   }
+
+   public WeakReference getArray()
+   {
+      return array;
+   }
+
+   public WeakReference getOwner()
+   {
+      return owner;
+   }
+
+   public boolean isOwnerRoot()
+   {
+      return ownerIsRoot;
+   }
+}

Added: projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ElementArrayRegistryEntry.java
===================================================================
--- projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ElementArrayRegistryEntry.java	2006-12-23 20:56:17 UTC (rev 59217)
+++ projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ElementArrayRegistryEntry.java	2006-12-23 23:27:35 UTC (rev 59218)
@@ -0,0 +1,38 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.array;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ElementArrayRegistryEntry extends ArrayRegistryEntry
+{
+   int index;
+   
+   ElementArrayRegistryEntry(Object owner, int index, Object array)
+   {
+      super(owner, false, array);
+      this.index = index; 
+   }
+}

Added: projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/FieldArrayRegistryEntry.java
===================================================================
--- projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/FieldArrayRegistryEntry.java	2006-12-23 20:56:17 UTC (rev 59217)
+++ projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/FieldArrayRegistryEntry.java	2006-12-23 23:27:35 UTC (rev 59218)
@@ -0,0 +1,44 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.array;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class FieldArrayRegistryEntry extends ArrayRegistryEntry
+{
+   String fieldName;
+   
+   FieldArrayRegistryEntry(Object owner, String fieldName, Object array)
+   {
+      // FIXME FieldArrayRegistryEntry constructor
+      super(owner, true, array);
+      this.fieldName = fieldName;
+   }
+   
+   public String getFieldName()
+   {
+      return fieldName;
+   }
+}

Added: projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/IntArrayElementReadInvocation.java
===================================================================
--- projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/IntArrayElementReadInvocation.java	2006-12-23 20:56:17 UTC (rev 59217)
+++ projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/IntArrayElementReadInvocation.java	2006-12-23 23:27:35 UTC (rev 59218)
@@ -0,0 +1,46 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.array;
+
+import org.jboss.aop.advice.Interceptor;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class IntArrayElementReadInvocation extends ArrayElementReadInvocation
+{
+   private static final long serialVersionUID = 407921822383443705L;
+   int[] array;
+   
+   public IntArrayElementReadInvocation(Interceptor[] interceptors, int[] target, int index)
+   {
+      super(interceptors, target, index);
+      array = target;
+   }
+
+   public Object invokeTarget()
+   {
+      return new Integer(array[index]);
+   }
+}

Added: projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/IntArrayElementWriteInvocation.java
===================================================================
--- projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/IntArrayElementWriteInvocation.java	2006-12-23 20:56:17 UTC (rev 59217)
+++ projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/IntArrayElementWriteInvocation.java	2006-12-23 23:27:35 UTC (rev 59218)
@@ -0,0 +1,61 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.array;
+
+import org.jboss.aop.advice.Interceptor;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class IntArrayElementWriteInvocation extends ArrayElementWriteInvocation
+{
+   private static final long serialVersionUID = -3311231820298166088L;
+   int[] array;
+   int value;
+   
+   public IntArrayElementWriteInvocation(Interceptor[] interceptors, int[] target, int index, int value)
+   {
+      super(interceptors, target, index);
+      this.value = value;
+      this.array = target;
+   }
+
+   @Override
+   public Object invokeTarget()
+   {
+      array[index] = value;
+      return null;
+   }
+
+   @Override
+   public Object getValue()
+   {
+      return new Integer(value);
+   }
+
+   public int getIntValue()
+   {
+      return value;
+   }
+}

Added: projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ObjectArrayElementReadInvocation.java
===================================================================
--- projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ObjectArrayElementReadInvocation.java	2006-12-23 20:56:17 UTC (rev 59217)
+++ projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ObjectArrayElementReadInvocation.java	2006-12-23 23:27:35 UTC (rev 59218)
@@ -0,0 +1,46 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.array;
+
+import org.jboss.aop.advice.Interceptor;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ObjectArrayElementReadInvocation extends ArrayElementReadInvocation
+{
+   private static final long serialVersionUID = 2579696791090966825L;
+   Object[] array;
+   
+   public ObjectArrayElementReadInvocation(Interceptor[] interceptors, Object[] target, int index)
+   {
+      super(interceptors, target, index);
+      array = target;
+   }
+
+   public Object invokeTarget()
+   {
+      return array[index];
+   }
+}

Added: projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ObjectArrayElementWriteInvocation.java
===================================================================
--- projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ObjectArrayElementWriteInvocation.java	2006-12-23 20:56:17 UTC (rev 59217)
+++ projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ObjectArrayElementWriteInvocation.java	2006-12-23 23:27:35 UTC (rev 59218)
@@ -0,0 +1,56 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.array;
+
+import org.jboss.aop.advice.Interceptor;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ObjectArrayElementWriteInvocation extends ArrayElementWriteInvocation
+{
+   private static final long serialVersionUID = 4256767659280908515L;
+   Object[] array;
+   Object value;
+   
+   public ObjectArrayElementWriteInvocation(Interceptor[] interceptors, Object[] target, int index, Object value)
+   {
+      super(interceptors, target, index);
+      this.value = value;
+      this.array = target;
+   }
+
+   @Override
+   public Object invokeTarget()
+   {
+      array[index] = value;
+      return null;
+   }
+
+   @Override
+   public Object getValue()
+   {
+      return value;
+   }
+}

Added: projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/TestArrayElementInterceptor.java
===================================================================
--- projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/TestArrayElementInterceptor.java	2006-12-23 20:56:17 UTC (rev 59217)
+++ projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/TestArrayElementInterceptor.java	2006-12-23 23:27:35 UTC (rev 59218)
@@ -0,0 +1,64 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.array;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestArrayElementInterceptor implements Interceptor
+{
+   public static int index;
+   public static Object value;
+   
+   public static void clear()
+   {
+      index = -1;
+      value = null;
+   }
+   
+   public String getName()
+   {
+      return this.getClass().getName();
+   }
+
+   public Object invoke(Invocation invocation) throws Throwable
+   {
+      if (invocation instanceof ArrayElementReadInvocation)
+      {
+         index = ((ArrayElementReadInvocation)invocation).getIndex();
+         value = null;
+      }
+      else if (invocation instanceof ArrayElementWriteInvocation)
+      {
+         index = ((ArrayElementWriteInvocation)invocation).getIndex();
+         value = ((ArrayElementWriteInvocation)invocation).getValue();
+      } 
+      
+      return invocation.invokeNext();
+   }
+
+}

Modified: projects/aop/branches/arrays/aop/src/main/org/jboss/aop/instrument/FieldAccessTransformer.java
===================================================================
--- projects/aop/branches/arrays/aop/src/main/org/jboss/aop/instrument/FieldAccessTransformer.java	2006-12-23 20:56:17 UTC (rev 59217)
+++ projects/aop/branches/arrays/aop/src/main/org/jboss/aop/instrument/FieldAccessTransformer.java	2006-12-23 23:27:35 UTC (rev 59218)
@@ -74,7 +74,7 @@
 
    // Public --------------------------------------------------------
 
-   protected void buildFieldWrappers(CtClass clazz, ClassAdvisor advisor) throws NotFoundException, CannotCompileException
+   protected void buildFieldWrappers(CtClass clazz, ClassAdvisor advisor, boolean shouldReplaceArrayAccess) throws NotFoundException, CannotCompileException
    {
       List fields = Instrumentor.getAdvisableFields(clazz);
 
@@ -97,7 +97,7 @@
             skipFieldInterception = false;
          }
          
-         doBuildFieldWrappers(clazz, field, fieldIndex, classificationGet[index], classificationSet[index]);
+         doBuildFieldWrappers(clazz, field, fieldIndex, shouldReplaceArrayAccess, classificationGet[index], classificationSet[index]);
       }
       
       if (skipFieldInterception)
@@ -116,7 +116,17 @@
       return classification != JoinpointClassification.NOT_INSTRUMENTED;
    }
    
-   protected abstract void doBuildFieldWrappers(CtClass clazz, CtField field, int index, JoinpointClassification classificationGet, JoinpointClassification classificationSet) throws NotFoundException, CannotCompileException;
+   protected abstract void doBuildFieldWrappers(CtClass clazz, CtField field, int index, boolean shouldReplaceArrayAccess, JoinpointClassification classificationGet, JoinpointClassification classificationSet) throws NotFoundException, CannotCompileException;
+   
+   protected String getArrayWriteRegistration(boolean shouldReplaceArrayAccess, CtField field, String oldValue, String newValue) throws NotFoundException
+   {
+      if (field.getType().isArray() && shouldReplaceArrayAccess)
+      {
+         String target = Modifier.isStatic(field.getModifiers()) ? "java.lang.Class.forName(" + field.getType().getName() + ")" : "this";  
+         return "org.jboss.aop.array.ArrayAdvisor.updateArrayField(" + target + ", \"" + field.getName() + "\", " + oldValue + ", " + newValue + ");";
+      }
+      return "";
+   }
    /**
     * replace field access for possible public/protected fields that are intercepted
     * don't need to replace access for private fields.

Modified: projects/aop/branches/arrays/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorFieldAccessTransformer.java
===================================================================
--- projects/aop/branches/arrays/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorFieldAccessTransformer.java	2006-12-23 20:56:17 UTC (rev 59217)
+++ projects/aop/branches/arrays/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorFieldAccessTransformer.java	2006-12-23 23:27:35 UTC (rev 59218)
@@ -47,7 +47,7 @@
       super(instrumentor);
    }
 
-   protected void doBuildFieldWrappers(CtClass clazz, CtField field, int index, JoinpointClassification classificationGet, JoinpointClassification classificationSet) throws NotFoundException, CannotCompileException
+   protected void doBuildFieldWrappers(CtClass clazz, CtField field, int index, boolean shouldReplaceArrayAccess, JoinpointClassification classificationGet, JoinpointClassification classificationSet) throws NotFoundException, CannotCompileException
    {
       instrumentor.setupBasics(clazz);
       boolean wrappedGet = classificationGet.equals(JoinpointClassification.WRAPPED);
@@ -106,7 +106,7 @@
 
       // executeWrapping
       replaceFieldAccessInternally(clazz, field, wrappedGet, wrappedSet, index);
-      buildWrappers(clazz, field, wrappedGet, wrappedSet, index);
+      buildWrappers(clazz, field, shouldReplaceArrayAccess, wrappedGet, wrappedSet, index);
    }
 
    protected String addFieldReadInfoFieldToGeneratedAdvisor(CtField field, int index)throws NotFoundException, CannotCompileException
@@ -298,7 +298,7 @@
       return code;
    }
 
-   private String getAdvisorWriteWrapperBody(CtClass clazz, CtField field, int index)
+   private String getAdvisorWriteWrapperBody(CtClass clazz, CtField field, int index, boolean shouldReplaceArrayAccess)
    throws NotFoundException, CannotCompileException
    {
       boolean isStatic = Modifier.isStatic(field.getModifiers());
@@ -307,15 +307,17 @@
       String generatorName = FieldJoinPointGenerator.getJoinPointGeneratorFieldName(field.getName(), false);
       if (isStatic)
       {
+         String fieldString = clazz.getName() + "." + field.getName();
          code =
             "{" +
+            "    " + getArrayWriteRegistration(shouldReplaceArrayAccess, field, fieldString, "$2") +
             "   if (" + infoName + " == null && " + generatorName + " != null)" +
             "   {" +
             "   " + generatorName + "." + JoinPointGenerator.GENERATE_JOINPOINT_CLASS + "(this.getClass().getClassLoader());" +
             "   }" +
             "   if (" + infoName + " == null)" +
             "   { " +
-            "   " + clazz.getName() + "." + field.getName() + " = $2;" +
+            "   " + fieldString + " = $2;" +
             "   }" +
             "   else" +
             "   {" +
@@ -325,15 +327,17 @@
       }
       else
       {
+         String fieldString = "((" + clazz.getName() + ")$1)." + field.getName();
          code =
             "{" +
+            "    " + getArrayWriteRegistration(shouldReplaceArrayAccess, field, fieldString, "$2") +
             "   if (" + infoName + " == null && " + generatorName + " != null)" +
             "   {" +
             "   " + generatorName + "." + JoinPointGenerator.GENERATE_JOINPOINT_CLASS + "(this.getClass().getClassLoader());" +
             "   }" +
             "   if (" + infoName + " == null)" +
             "   { " +
-            "   ((" + clazz.getName() + ")$1)." + field.getName() + " = $2;" +
+            "       " + fieldString + " = $2;" +
             "   }" +
             "   else" +
             "   {" +
@@ -376,7 +380,7 @@
 
 
 
-   private void buildWrappers(CtClass clazz, CtField field, boolean doGet, boolean doSet, int index) throws NotFoundException, CannotCompileException
+   private void buildWrappers(CtClass clazz, CtField field, boolean shouldReplaceArrayAccess, boolean doGet, boolean doSet, int index) throws NotFoundException, CannotCompileException
    {
       if (doGet)
       {
@@ -401,7 +405,7 @@
       if (doSet)
       {
          //Set wrapper code in advisor
-         String code = getAdvisorWriteWrapperBody(clazz, field, index);
+         String code = getAdvisorWriteWrapperBody(clazz, field, index, shouldReplaceArrayAccess);
          CtMethod method = getGenadvisor().getDeclaredMethod(advisorFieldWrite(getGenadvisor(), field.getName()));
          try
          {

Modified: projects/aop/branches/arrays/aop/src/main/org/jboss/aop/instrument/Instrumentor.java
===================================================================
--- projects/aop/branches/arrays/aop/src/main/org/jboss/aop/instrument/Instrumentor.java	2006-12-23 20:56:17 UTC (rev 59217)
+++ projects/aop/branches/arrays/aop/src/main/org/jboss/aop/instrument/Instrumentor.java	2006-12-23 23:27:35 UTC (rev 59218)
@@ -59,6 +59,7 @@
 import javassist.bytecode.AnnotationsAttribute;
 import javassist.bytecode.FieldInfo;
 import javassist.bytecode.MethodInfo;
+import javassist.convert.TransformAccessArrayField.DefaultMethodNames;
 
 /**
  * Transforms byte code, making a class advisable. Implements
@@ -665,7 +666,8 @@
 
          converted = convertReferences(clazz) || converted;
          
-         converted = converted || replaceArrayAccess(clazz, advisor);
+         boolean shouldReplaceArrayAccess = replaceArrayAccess(clazz, advisor);
+         converted = converted || shouldReplaceArrayAccess;
          
          // need to instrument no matter what so that
          // previously declared field and constructor interceptions
@@ -677,7 +679,8 @@
 
          // create static wrapper methods after
          // clazz.instrument because the wrappers may call cons or fields
-         fieldAccessTransformer.buildFieldWrappers(clazz, advisor);
+         fieldAccessTransformer.buildFieldWrappers(clazz, advisor, shouldReplaceArrayAccess);
+         
          if (constructorAccessConverted)
          {
             constructorExecutionTransformer.codeConverted();
@@ -947,24 +950,24 @@
 
    private boolean replaceArrayAccess(CtClass clazz, Advisor advisor) throws Exception
    {
-      boolean shouldReplace = false;
+      boolean shouldReplaceArrayAccess = false;
       Map arrayReplacements = manager.getArrayReplacements();
       for (Iterator it = arrayReplacements.values().iterator() ; it.hasNext() ; )
       {
          ArrayReplacement arrayReplacement = (ArrayReplacement)it.next();
          if (arrayReplacement.matches(advisor, clazz))
          {
-            shouldReplace = true;
+            shouldReplaceArrayAccess = true;
             break;
          }
       }
-      
-      if (shouldReplace)
+
+      if (shouldReplaceArrayAccess)
       {
          System.out.println("---> Should replace access for " + clazz.getName());
-         converter.replaceArrayAccess(classPool.get(ArrayAdvisor.class.getName()), "arrayRead", "arrayWrite");
+         converter.replaceArrayAccess(classPool.get(ArrayAdvisor.class.getName()), new DefaultMethodNames());
       }
-      return shouldReplace;
+      return shouldReplaceArrayAccess;
    }
    
    /**

Modified: projects/aop/branches/arrays/aop/src/main/org/jboss/aop/instrument/NonOptimizedFieldAccessTransformer.java
===================================================================
--- projects/aop/branches/arrays/aop/src/main/org/jboss/aop/instrument/NonOptimizedFieldAccessTransformer.java	2006-12-23 20:56:17 UTC (rev 59217)
+++ projects/aop/branches/arrays/aop/src/main/org/jboss/aop/instrument/NonOptimizedFieldAccessTransformer.java	2006-12-23 23:27:35 UTC (rev 59218)
@@ -50,7 +50,7 @@
       super(instrumentor);
    }
    
-   protected void doBuildFieldWrappers(CtClass clazz, CtField field, int fieldIndex, JoinpointClassification classificationGet, JoinpointClassification classificationSet)
+   protected void doBuildFieldWrappers(CtClass clazz, CtField field, int fieldIndex, boolean shouldReplaceArrayAccess, JoinpointClassification classificationGet, JoinpointClassification classificationSet)
    throws NotFoundException, CannotCompileException
    {
       instrumentor.setupBasics(clazz);

Modified: projects/aop/branches/arrays/aop/src/main/org/jboss/aop/instrument/OptimizedFieldAccessTransformer.java
===================================================================
--- projects/aop/branches/arrays/aop/src/main/org/jboss/aop/instrument/OptimizedFieldAccessTransformer.java	2006-12-23 20:56:17 UTC (rev 59217)
+++ projects/aop/branches/arrays/aop/src/main/org/jboss/aop/instrument/OptimizedFieldAccessTransformer.java	2006-12-23 23:27:35 UTC (rev 59218)
@@ -43,7 +43,7 @@
       super(instrumentor);
    }
 
-   protected void doBuildFieldWrappers(CtClass clazz, CtField field, int fieldIndex, JoinpointClassification classificationGet, JoinpointClassification classificationSet) throws NotFoundException, CannotCompileException
+   protected void doBuildFieldWrappers(CtClass clazz, CtField field, int fieldIndex, boolean shouldReplaceArrayAccess, JoinpointClassification classificationGet, JoinpointClassification classificationSet) throws NotFoundException, CannotCompileException
    {
       instrumentor.setupBasics(clazz);
       boolean wrappedGet = classificationGet.equals(JoinpointClassification.WRAPPED);

Modified: projects/aop/branches/arrays/aop/src/resources/test/array/jboss-aop.xml
===================================================================
--- projects/aop/branches/arrays/aop/src/resources/test/array/jboss-aop.xml	2006-12-23 20:56:17 UTC (rev 59217)
+++ projects/aop/branches/arrays/aop/src/resources/test/array/jboss-aop.xml	2006-12-23 23:27:35 UTC (rev 59218)
@@ -1,3 +1,6 @@
 <aop>
    <arrayreplacement class="org.jboss.test.aop.array.AOPArrayTestCase"/>
-</aop>
\ No newline at end of file
+   <arrayreplacement expr="class(org.jboss.test.aop.array.ClassWithArrayFields)"/>
+   <prepare expr="field(* org.jboss.test.aop.array.ClassWithArrayFields->*)"/>
+</aop>
+

Modified: projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/AOPArrayTestCase.java
===================================================================
--- projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/AOPArrayTestCase.java	2006-12-23 20:56:17 UTC (rev 59217)
+++ projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/AOPArrayTestCase.java	2006-12-23 23:27:35 UTC (rev 59218)
@@ -24,6 +24,7 @@
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
+import org.jboss.aop.array.TestArrayElementInterceptor;
 import org.jboss.test.aop.AOPTestWithSetup;
 
 /**
@@ -33,8 +34,6 @@
  */
 public class AOPArrayTestCase extends AOPTestWithSetup
 {
-   ClassWithArrayFields obj = new ClassWithArrayFields();
-   
    public AOPArrayTestCase(String name)
    {
       super(name);
@@ -47,15 +46,122 @@
       return suite;
    }
 
-   public void testIntWrite()
+   public void testIntArray()
    {
+      ClassWithArrayFields obj = new ClassWithArrayFields();
+      TestArrayElementInterceptor.clear();
       obj.ifield[1] = 100; 
+      assertEquals(1, TestArrayElementInterceptor.index);
+      assertNotNull(TestArrayElementInterceptor.value);
+      assertEquals(100, ((Integer)TestArrayElementInterceptor.value).intValue());
+
+      obj.ifield[2] = 123;
+      
+      TestArrayElementInterceptor.clear();
+      int val = obj.ifield[2];
+      assertEquals(123, val);
+      assertEquals(2, TestArrayElementInterceptor.index);
+      assertNull(TestArrayElementInterceptor.value);
    }
    
-   public void testIntRead()
+   public void testCrap()
    {
-      obj.ifield[1] = 100;
-      int val = obj.ifield[1];
-      assertEquals(100, val);
+      ClassWithArrayFields obj = new ClassWithArrayFields();
+      System.out.println("created");
+      int[] orig = obj.iifield[0];
+      System.out.println("backed up");
+      int[] x = new int[] {45};
+      
+      obj.iifield[0] = x;
+      orig[1] = 1;
    }
+   
+   public void testMultiDimensionalTopLevelArray()
+   {
+      ClassWithArrayFields obj = new ClassWithArrayFields();
+      System.out.println("----------> Constructed");
+      
+      //Create replacement array for top level, this is not registered yet so should be unadvised
+      TestArrayElementInterceptor.clear();
+      int[][] replacement0 = new int[][] {new int[]{11,22}, new int[] {33,44}};
+      assertEquals(-1, TestArrayElementInterceptor.index);
+      assertNull(TestArrayElementInterceptor.value);
+      System.out.println("----------> Created");
+
+      //Store reference to array to be replaced
+      TestArrayElementInterceptor.clear();
+      int[][] original_0 = obj.iiifield[0];
+      assertEquals(0, TestArrayElementInterceptor.index);
+      
+      //Replace array in top-level array, interception should happen now
+      TestArrayElementInterceptor.clear();
+      obj.iiifield[0] = replacement0;
+      assertEquals(0, TestArrayElementInterceptor.index);
+      assertNotNull(TestArrayElementInterceptor.value);
+      assertEquals(replacement0, TestArrayElementInterceptor.value);
+      System.out.println("----------> Replaced");
+      
+      TestArrayElementInterceptor.clear();
+      int i = obj.iiifield[0][0][1];
+      assertEquals(1, TestArrayElementInterceptor.index);
+      assertEquals(22, i);
+      
+      TestArrayElementInterceptor.clear();
+      obj.iiifield[0][0][1] = 99;
+      assertEquals(1, TestArrayElementInterceptor.index);
+      assertEquals(99, ((Integer)TestArrayElementInterceptor.value).intValue());
+      
+      //The original array should no longer be registered
+      TestArrayElementInterceptor.clear();
+      i = original_0[0][1];
+      assertEquals(2, i);
+      assertEquals(-1, TestArrayElementInterceptor.index);
+      assertNull(TestArrayElementInterceptor.value);
+      original_0[0][1] = 100;
+      assertEquals(-1, TestArrayElementInterceptor.index);
+      assertNull(TestArrayElementInterceptor.value);
+   }
+
+   public void testMultiDimensionalNestedArray()
+   {
+      ClassWithArrayFields obj = new ClassWithArrayFields();
+
+      //Create replacement for nested array 
+      TestArrayElementInterceptor.clear();
+      int[] replacement_0_1 = new int[] {111,222, 333};
+      assertEquals(-1, TestArrayElementInterceptor.index);
+      assertNull(TestArrayElementInterceptor.value);
+
+      //Store reference to array to be replaced
+      TestArrayElementInterceptor.clear();
+      int[] original_0_1 = obj.iiifield[0][1];
+      assertEquals(1, TestArrayElementInterceptor.index);
+
+      //Replace nested array, interception should happen now
+      TestArrayElementInterceptor.clear();
+      obj.iiifield[0][1] = replacement_0_1;
+      assertEquals(1, TestArrayElementInterceptor.index);
+      assertNotNull(TestArrayElementInterceptor.value);
+      assertEquals(replacement_0_1, TestArrayElementInterceptor.value);
+      
+      TestArrayElementInterceptor.clear();
+      int i = obj.iiifield[0][1][2];
+      assertEquals(2, TestArrayElementInterceptor.index);
+      assertEquals(333, i);
+
+      TestArrayElementInterceptor.clear();
+      obj.iiifield[0][0][1] = 99;
+      assertEquals(1, TestArrayElementInterceptor.index);
+      assertEquals(99, ((Integer)TestArrayElementInterceptor.value).intValue());
+      
+      //The original array should no longer be registered
+      TestArrayElementInterceptor.clear();
+      original_0_1[1] = 100;
+      assertEquals(-1, TestArrayElementInterceptor.index);
+      assertNull(TestArrayElementInterceptor.value);
+      i = original_0_1[0];
+      assertEquals(-1, TestArrayElementInterceptor.index);
+      assertNull(TestArrayElementInterceptor.value);
+   }
+   
 }

Modified: projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/AOPTransformer.java
===================================================================
--- projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/AOPTransformer.java	2006-12-23 20:56:17 UTC (rev 59217)
+++ projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/AOPTransformer.java	2006-12-23 23:27:35 UTC (rev 59218)
@@ -38,6 +38,7 @@
 import javassist.CtMethod;
 import javassist.CtNewMethod;
 import javassist.Modifier;
+import javassist.convert.TransformAccessArrayField.DefaultMethodNames;
 
 /**
  * Comment
@@ -282,7 +283,7 @@
          if (arrayClasses.contains(clazz.getName()))
          {
             replaced = true;
-            converter.replaceArrayAccess(pool.get(ArrayAdvisor.class.getName()), "arrayRead", "arrayWrite");
+            converter.replaceArrayAccess(pool.get(ArrayAdvisor.class.getName()), new DefaultMethodNames());
          }
 
          if (replaced)

Added: projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/ArrayTestCase.bak
===================================================================
--- projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/ArrayTestCase.bak	2006-12-23 20:56:17 UTC (rev 59217)
+++ projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/ArrayTestCase.bak	2006-12-23 23:27:35 UTC (rev 59218)
@@ -0,0 +1,91 @@
+/*
+  * 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.test.aop.array;
+
+import org.jboss.test.aop.AOPTestWithSetup;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+
+/**
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision: 45977 $
+ */
+public class ArrayTestCase extends AOPTestWithSetup
+{
+   Main main = new Main();
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("ArrayTestCase");
+      suite.addTestSuite(ArrayTestCase.class);
+      return suite;
+   }
+
+   public ArrayTestCase(String name)
+   {
+      super(name);
+      AOPTransformer.addSimpleField("org.jboss.test.aop.array.ClassWithSimpleFields", "field");
+      AOPTransformer.addSimpleField("org.jboss.test.aop.array.ClassWithSimpleFields", "staticfield");
+
+      AOPTransformer.addArrayClass("org.jboss.test.aop.array.ClassWithArrayFields");
+      AOPTransformer.addArrayClass("org.jboss.test.aop.array.ClassWithArrayFieldCaller");
+   }
+
+   public void testSimpleField() throws Exception
+   {
+      main.testSimpleField();
+   }
+
+   
+   public void testArrayWrite() throws Exception
+   {
+      main.testArrayWrite();
+   }
+   
+   public void testArrayRead() throws Exception
+   {
+      main.testArrayRead();
+   }
+//   
+//   public void testArrayReadWriteSelf() throws Exception
+//   {
+//      main.testArrayReadWriteSelf();
+//   }
+//
+//   public void testArrayReadWriteFromNonAdvised() throws Exception
+//   {
+//      main.testArrayReadWriteFromNonAdvised();
+//   }
+//
+//   
+//   public void testArrayField() throws Exception
+//   {
+//      main.testArrayField();
+//   }
+}

Deleted: projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/ArrayTestCase.java
===================================================================
--- projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/ArrayTestCase.java	2006-12-23 20:56:17 UTC (rev 59217)
+++ projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/ArrayTestCase.java	2006-12-23 23:27:35 UTC (rev 59218)
@@ -1,91 +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.test.aop.array;
-
-import org.jboss.test.aop.AOPTestWithSetup;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-
-
-/**
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision: 45977 $
- */
-public class ArrayTestCase extends AOPTestWithSetup
-{
-   Main main = new Main();
-   public static void main(String[] args)
-   {
-      TestRunner.run(suite());
-   }
-
-   public static Test suite()
-   {
-      TestSuite suite = new TestSuite("ArrayTestCase");
-      suite.addTestSuite(ArrayTestCase.class);
-      return suite;
-   }
-
-   public ArrayTestCase(String name)
-   {
-      super(name);
-      AOPTransformer.addSimpleField("org.jboss.test.aop.array.ClassWithSimpleFields", "field");
-      AOPTransformer.addSimpleField("org.jboss.test.aop.array.ClassWithSimpleFields", "staticfield");
-
-      AOPTransformer.addArrayClass("org.jboss.test.aop.array.ClassWithArrayFields");
-      AOPTransformer.addArrayClass("org.jboss.test.aop.array.ClassWithArrayFieldCaller");
-   }
-
-   public void testSimpleField() throws Exception
-   {
-      main.testSimpleField();
-   }
-
-   
-   public void testArrayWrite() throws Exception
-   {
-      main.testArrayWrite();
-   }
-   
-   public void testArrayRead() throws Exception
-   {
-      main.testArrayRead();
-   }
-//   
-//   public void testArrayReadWriteSelf() throws Exception
-//   {
-//      main.testArrayReadWriteSelf();
-//   }
-//
-//   public void testArrayReadWriteFromNonAdvised() throws Exception
-//   {
-//      main.testArrayReadWriteFromNonAdvised();
-//   }
-//
-//   
-//   public void testArrayField() throws Exception
-//   {
-//      main.testArrayField();
-//   }
-}

Added: projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/ClassWithArrayFieldCaller.bak
===================================================================
--- projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/ClassWithArrayFieldCaller.bak	2006-12-23 20:56:17 UTC (rev 59217)
+++ projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/ClassWithArrayFieldCaller.bak	2006-12-23 23:27:35 UTC (rev 59218)
@@ -0,0 +1,97 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.test.aop.array;
+
+import java.lang.reflect.Array;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassWithArrayFieldCaller
+{
+   ClassWithArrayFields obj = new ClassWithArrayFields();
+   
+   public void testArrayWrite() throws Exception
+   {
+      ArrayAdvisor.clear();
+      obj.setValue(1, 100);
+      checkStatus(obj.ifield, 1, String.valueOf(100));
+      
+      ArrayAdvisor.clear();
+      obj.ifield[0] = 75;
+      checkStatus(obj.ifield, 0, String.valueOf(75));
+   }
+   
+   public void testArrayRead() throws Exception
+   {
+      obj.ifield[0] = 100;
+      obj.ifield[1] = 200;
+      
+      ArrayAdvisor.clear();
+      int val = obj.getValue(0);
+      if (val != 100) throw new RuntimeException("Wrong val " + 100);
+      checkStatus(obj.ifield, 0, String.valueOf(100));
+      
+      ArrayAdvisor.clear();
+      val = obj.ifield[1];
+      checkStatus(obj.ifield, 1, String.valueOf(200));
+   }
+
+   public void testDifferentTypes() throws Exception
+   {
+//      ArrayAdvisor.clear();
+//      obj.afield[1] = "Hello";
+//      checkStatus(obj.afield, 1, "Hello");
+//      ArrayAdvisor.clear();
+//      Object aval = obj.afield[1];
+//      if (!aval.equals("Hello")) throw new RuntimeException("Wrong val " + aval);
+//      checkStatus(obj.afield, 1, "Hello");
+//      
+//      ArrayAdvisor.clear();
+//      obj.bfield[2] = true;
+//
+//      ArrayAdvisor.clear();
+//      obj.cfield[1] = 'x';
+//      
+//      ArrayAdvisor.clear();
+//      obj.dfield[2] = 69.0d;
+//      
+//      
+//      ArrayAdvisor.clear();
+//      obj.ffield[1] = 3.9f;
+//      
+//      ArrayAdvisor.clear();
+//      obj.lfield[2] = 100L;
+//      
+//      ArrayAdvisor.clear();
+//      obj.sfield[1] = 5;
+   }
+  
+   private void checkStatus(Object array, int index, String value)
+   {
+      if (array != ArrayAdvisor.array) throw new RuntimeException("Wrong array " + ArrayAdvisor.array);
+      if (index != ArrayAdvisor.index) throw new RuntimeException("Wrong index " + ArrayAdvisor.index);
+      if (!value.equals(ArrayAdvisor.value)) throw new RuntimeException("Wrong string " + ArrayAdvisor.index);
+   }
+}
\ No newline at end of file

Deleted: projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/ClassWithArrayFieldCaller.java
===================================================================
--- projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/ClassWithArrayFieldCaller.java	2006-12-23 20:56:17 UTC (rev 59217)
+++ projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/ClassWithArrayFieldCaller.java	2006-12-23 23:27:35 UTC (rev 59218)
@@ -1,97 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source.
-* Copyright 2006, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file 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.test.aop.array;
-
-import java.lang.reflect.Array;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class ClassWithArrayFieldCaller
-{
-   ClassWithArrayFields obj = new ClassWithArrayFields();
-   
-   public void testArrayWrite() throws Exception
-   {
-      ArrayAdvisor.clear();
-      obj.setValue(1, 100);
-      checkStatus(obj.ifield, 1, String.valueOf(100));
-      
-      ArrayAdvisor.clear();
-      obj.ifield[0] = 75;
-      checkStatus(obj.ifield, 0, String.valueOf(75));
-   }
-   
-   public void testArrayRead() throws Exception
-   {
-      obj.ifield[0] = 100;
-      obj.ifield[1] = 200;
-      
-      ArrayAdvisor.clear();
-      int val = obj.getValue(0);
-      if (val != 100) throw new RuntimeException("Wrong val " + 100);
-      checkStatus(obj.ifield, 0, String.valueOf(100));
-      
-      ArrayAdvisor.clear();
-      val = obj.ifield[1];
-      checkStatus(obj.ifield, 1, String.valueOf(200));
-   }
-
-   public void testDifferentTypes() throws Exception
-   {
-//      ArrayAdvisor.clear();
-//      obj.afield[1] = "Hello";
-//      checkStatus(obj.afield, 1, "Hello");
-//      ArrayAdvisor.clear();
-//      Object aval = obj.afield[1];
-//      if (!aval.equals("Hello")) throw new RuntimeException("Wrong val " + aval);
-//      checkStatus(obj.afield, 1, "Hello");
-//      
-//      ArrayAdvisor.clear();
-//      obj.bfield[2] = true;
-//
-//      ArrayAdvisor.clear();
-//      obj.cfield[1] = 'x';
-//      
-//      ArrayAdvisor.clear();
-//      obj.dfield[2] = 69.0d;
-//      
-//      
-//      ArrayAdvisor.clear();
-//      obj.ffield[1] = 3.9f;
-//      
-//      ArrayAdvisor.clear();
-//      obj.lfield[2] = 100L;
-//      
-      ArrayAdvisor.clear();
-      obj.sfield[1] = 5;
-   }
-  
-   private void checkStatus(Object array, int index, String value)
-   {
-      if (array != ArrayAdvisor.array) throw new RuntimeException("Wrong array " + ArrayAdvisor.array);
-      if (index != ArrayAdvisor.index) throw new RuntimeException("Wrong index " + ArrayAdvisor.index);
-      if (!value.equals(ArrayAdvisor.value)) throw new RuntimeException("Wrong string " + ArrayAdvisor.index);
-   }
-}
\ No newline at end of file

Modified: projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/ClassWithArrayFields.java
===================================================================
--- projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/ClassWithArrayFields.java	2006-12-23 20:56:17 UTC (rev 59217)
+++ projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/ClassWithArrayFields.java	2006-12-23 23:27:35 UTC (rev 59218)
@@ -21,6 +21,8 @@
 */ 
 package org.jboss.test.aop.array;
 
+import java.util.Arrays;
+
 /**
  * 
  * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
@@ -28,28 +30,55 @@
  */
 public class ClassWithArrayFields
 {
-   
-   
-   public Object[] afield = new Object[] {"1", "2", "3"};
-   public boolean[] bfield = new boolean[] {true, false};
-   public char[] cfield = new char[] {'a', 'b', 'c'};
-   public double[] dfield = new double[] {1.5d, 1.9d};
-   public float[] ffield = new float[] {1.5f, 1.9f};
+//   public Object[] afield = new Object[] {"1", "2", "3"};
+//   public boolean[] bfield = new boolean[] {true, false};
+//   public char[] cfield = new char[] {'a', 'b', 'c'};
+//   public double[] dfield = new double[] {1.5d, 1.9d};
+//   public float[] ffield = new float[] {1.5f, 1.9f};
    public int[] ifield = new int[] {0, 0, 0};
-   public long[] lfield = new long[] {0L, 0L, 0L};
-   public short[] sfield = new short[] {0, 0, 0};
-   
-   
-   public void setValue(int index, int value)
+   public int[][] iifield = new int[][]{new int[] {0, 0}, new int[] {0, 0}};
+   public int[][][] iiifield = new int[][][] {
+         new int[][] {
+               new int[] {1,2,3}, 
+               new int[] {4,5,6},
+               new int[] {7,8,9}
+         },
+         new int[][] {
+               new int[] {1,2,3}, 
+               new int[] {4,5,6},
+               new int[] {7,8,9}
+         },         
+   };
+
+   public ClassWithArrayFields()
    {
-      ifield[index] = value;
+
    }
-   
-   public int getValue(int index)
+   public static void main(String[] args)
    {
-      return ifield[index];
+//      ClassWithArrayFields tgt = new ClassWithArrayFields();
+//      for (int i = 0 ; i < tgt.iiifield.length ; i++) {
+//         for (int j = 0 ; j < tgt.iiifield[i].length ; j++) {
+//            for (int k = 0 ; k < tgt.iiifield[i][j].length ; k++) {
+//               System.out.println(tgt.iiifield[i][j][k]);
+//            }
+//         }
+//      }
    }
+//   public long[] lfield = new long[] {0L, 0L, 0L};
+//   public short[] sfield = new short[] {0, 0, 0};
    
+   
+//   public void setValue(int index, int value)
+//   {
+//      ifield[index] = value;
+//   }
+//   
+//   public int getValue(int index)
+//   {
+//      return ifield[index];
+//   }
+   
    public void test(short s)
    {
       test(s);

Added: projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/Main.bak
===================================================================
--- projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/Main.bak	2006-12-23 20:56:17 UTC (rev 59217)
+++ projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/Main.bak	2006-12-23 23:27:35 UTC (rev 59218)
@@ -0,0 +1,68 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.test.aop.array;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class Main
+{
+   public Main()
+   {
+   }
+
+   public static void main(String[] args)throws Exception
+   {
+      Main main = new Main();
+      main.testSimpleField();
+      main.testArrayField();
+   }
+
+   public void testSimpleField() throws Exception
+   {
+      ClassWithSimpleFieldCaller caller = new ClassWithSimpleFieldCaller();
+      caller.testSimple();
+      caller.testSimpleStatic();
+   }
+
+   
+   public void testArrayField() throws Exception
+   {
+//      ClassWithArrayFieldCaller caller = new ClassWithArrayFieldCaller();
+//      caller.testArray();
+//      caller.testArrayStatic();
+   }
+   
+   public void testArrayWrite() throws Exception
+   {
+      ClassWithArrayFieldCaller caller = new ClassWithArrayFieldCaller();
+      caller.testArrayWrite();
+   }
+   
+   public void testArrayRead() throws Exception
+   {
+      ClassWithArrayFieldCaller caller = new ClassWithArrayFieldCaller();
+      caller.testArrayRead();
+   }
+}

Deleted: projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/Main.java
===================================================================
--- projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/Main.java	2006-12-23 20:56:17 UTC (rev 59217)
+++ projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/Main.java	2006-12-23 23:27:35 UTC (rev 59218)
@@ -1,68 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source.
-* Copyright 2006, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file 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.test.aop.array;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class Main
-{
-   public Main()
-   {
-   }
-
-   public static void main(String[] args)throws Exception
-   {
-      Main main = new Main();
-      main.testSimpleField();
-      main.testArrayField();
-   }
-
-   public void testSimpleField() throws Exception
-   {
-      ClassWithSimpleFieldCaller caller = new ClassWithSimpleFieldCaller();
-      caller.testSimple();
-      caller.testSimpleStatic();
-   }
-
-   
-   public void testArrayField() throws Exception
-   {
-//      ClassWithArrayFieldCaller caller = new ClassWithArrayFieldCaller();
-//      caller.testArray();
-//      caller.testArrayStatic();
-   }
-   
-   public void testArrayWrite() throws Exception
-   {
-      ClassWithArrayFieldCaller caller = new ClassWithArrayFieldCaller();
-      caller.testArrayWrite();
-   }
-   
-   public void testArrayRead() throws Exception
-   {
-      ClassWithArrayFieldCaller caller = new ClassWithArrayFieldCaller();
-      caller.testArrayRead();
-   }
-}




More information about the jboss-cvs-commits mailing list