[jboss-cvs] JBossAS SVN: r59223 - in projects/aop/branches/arrays: aop/src/main/org/jboss/aop/array aop/src/main/org/jboss/aop/instrument aop/src/test/org/jboss/test/aop/array build
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun Dec 24 08:56:43 EST 2006
Author: kabir.khan at jboss.com
Date: 2006-12-24 08:56:30 -0500 (Sun, 24 Dec 2006)
New Revision: 59223
Added:
projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/BooleanArrayElementReadInvocation.java
projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/BooleanArrayElementWriteInvocation.java
projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ByteArrayElementReadInvocation.java
projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ByteArrayElementWriteInvocation.java
projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ByteBooleanConverter.java
projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/CharArrayElementReadInvocation.java
projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/CharArrayElementWriteInvocation.java
projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/DoubleArrayElementReadInvocation.java
projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/DoubleArrayElementWriteInvocation.java
projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/FloatArrayElementReadInvocation.java
projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/FloatArrayElementWriteInvocation.java
projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/LongArrayElementReadInvocation.java
projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/LongArrayElementWriteInvocation.java
projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ShortArrayElementReadInvocation.java
projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ShortArrayElementWriteInvocation.java
projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/ClassWithUnadvisedArrayFields.java
Removed:
projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/ArrayAdvisor.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/array/ArrayRegistry.java
projects/aop/branches/arrays/aop/src/main/org/jboss/aop/instrument/Instrumentor.java
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/ClassWithArrayFields.java
projects/aop/branches/arrays/build/build-thirdparty.xml
Log:
We are now able to intercept element accesses in all kinds of arrays.
Make use javassist snapshot
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-24 13:53:26 UTC (rev 59222)
+++ projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ArrayAdvisor.java 2006-12-24 13:56:30 UTC (rev 59223)
@@ -55,21 +55,20 @@
ArrayRegistry registry = ArrayRegistry.getInstance();
if (registry.isRegistered(array))
{
- System.out.println("---------> Writing" + array + " advised");
+ //The old value might be an array, remove references to that
+ Object oldValue = ((Object[])array)[index];
+ registry.removeElementReference(array, index, oldValue);
+ //The new value might be an array
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;
}
}
@@ -78,7 +77,6 @@
{
if (ArrayRegistry.getInstance().isRegistered(array))
{
- System.out.println("---------> Writing" + array + " advised");
IntArrayElementWriteInvocation invocation = new IntArrayElementWriteInvocation(interceptors, ((int[])array), index, value);
invocation.invokeNext();
}
@@ -88,57 +86,99 @@
}
}
- //Write operations
-// 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 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;
-// }
+ public static void arrayWriteByteOrBoolean(Object array, int index, byte value) throws Throwable
+ {
+ if (ArrayRegistry.getInstance().isRegistered(array))
+ {
+ if (array instanceof boolean[])
+ {
+ BooleanArrayElementWriteInvocation invocation = new BooleanArrayElementWriteInvocation(interceptors, ((boolean[])array), index, ByteBooleanConverter.toBoolean(value));
+ invocation.invokeNext();
+ }
+ else
+ {
+ ByteArrayElementWriteInvocation invocation = new ByteArrayElementWriteInvocation(interceptors, ((byte[])array), index, value);
+ invocation.invokeNext();
+ }
+ }
+ else
+ {
+ if (array instanceof boolean[])
+ {
+ ((boolean[])array)[index] = ByteBooleanConverter.toBoolean(value);
+ }
+ else
+ {
+ ((byte[])array)[index] = value;
+ }
+ }
+ }
- //Read operations
-// 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 void arrayWriteChar(Object array, int index, char value) throws Throwable
+ {
+ if (ArrayRegistry.getInstance().isRegistered(array))
+ {
+ CharArrayElementWriteInvocation invocation = new CharArrayElementWriteInvocation(interceptors, ((char[])array), index, value);
+ invocation.invokeNext();
+ }
+ else
+ {
+ ((char[])array)[index] = value;
+ }
+ }
+
+ public static void arrayWriteDouble(Object array, int index, double value) throws Throwable
+ {
+ if (ArrayRegistry.getInstance().isRegistered(array))
+ {
+ DoubleArrayElementWriteInvocation invocation = new DoubleArrayElementWriteInvocation(interceptors, ((double[])array), index, value);
+ invocation.invokeNext();
+ }
+ else
+ {
+ ((double[])array)[index] = value;
+ }
+ }
+
+ public static void arrayWriteShort(Object array, int index, short value) throws Throwable
+ {
+ if (ArrayRegistry.getInstance().isRegistered(array))
+ {
+ ShortArrayElementWriteInvocation invocation = new ShortArrayElementWriteInvocation(interceptors, ((short[])array), index, value);
+ invocation.invokeNext();
+ }
+ else
+ {
+ ((short[])array)[index] = value;
+ }
+ }
+
+ public static void arrayWriteFloat(Object array, int index, float value) throws Throwable
+ {
+ if (ArrayRegistry.getInstance().isRegistered(array))
+ {
+ FloatArrayElementWriteInvocation invocation = new FloatArrayElementWriteInvocation(interceptors, ((float[])array), index, value);
+ invocation.invokeNext();
+ }
+ else
+ {
+ ((float[])array)[index] = value;
+ }
+ }
+
+ public static void arrayWriteLong(Object array, int index, long value) throws Throwable
+ {
+ if (ArrayRegistry.getInstance().isRegistered(array))
+ {
+ LongArrayElementWriteInvocation invocation = new LongArrayElementWriteInvocation(interceptors, ((long[])array), index, value);
+ invocation.invokeNext();
+ }
+ else
+ {
+ ((long[])array)[index] = value;
+ }
+ }
+
public static Object arrayReadObject(Object array, int index) throws Throwable
{
if (ArrayRegistry.getInstance().isRegistered(array))
@@ -165,35 +205,97 @@
}
}
-//
-// 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;
-// }
+ public static byte arrayReadByteOrBoolean(Object array, int index) throws Throwable
+ {
+ if (ArrayRegistry.getInstance().isRegistered(array))
+ {
+ if (array instanceof boolean[])
+ {
+ BooleanArrayElementReadInvocation invocation = new BooleanArrayElementReadInvocation(interceptors, (boolean[])array, index);
+ boolean b = ((Boolean)invocation.invokeNext()).booleanValue();
+ return ByteBooleanConverter.toByte(b);
+ }
+ else
+ {
+ ByteArrayElementReadInvocation invocation = new ByteArrayElementReadInvocation(interceptors, (byte[])array, index);
+ return ((Byte)invocation.invokeNext()).byteValue();
+ }
+ }
+ else
+ {
+ if (array instanceof boolean[])
+ {
+ return ByteBooleanConverter.toByte(((boolean[])array)[index]);
+ }
+ else
+ {
+ return ((byte[])array)[index];
+ }
+ }
+ }
+ public static char arrayReadChar(Object array, int index) throws Throwable
+ {
+ if (ArrayRegistry.getInstance().isRegistered(array))
+ {
+ CharArrayElementReadInvocation invocation = new CharArrayElementReadInvocation(interceptors, (char[])array, index);
+ return ((Character)invocation.invokeNext()).charValue();
+ }
+ else
+ {
+ return ((char[])array)[index];
+ }
+ }
+
+ public static double arrayReadDouble(Object array, int index) throws Throwable
+ {
+ if (ArrayRegistry.getInstance().isRegistered(array))
+ {
+ DoubleArrayElementReadInvocation invocation = new DoubleArrayElementReadInvocation(interceptors, (double[])array, index);
+ return ((Double)invocation.invokeNext()).doubleValue();
+ }
+ else
+ {
+ return ((double[])array)[index];
+ }
+ }
+
+ public static float arrayReadFloat(Object array, int index) throws Throwable
+ {
+ if (ArrayRegistry.getInstance().isRegistered(array))
+ {
+ FloatArrayElementReadInvocation invocation = new FloatArrayElementReadInvocation(interceptors, (float[])array, index);
+ return ((Float)invocation.invokeNext()).floatValue();
+ }
+ else
+ {
+ return ((float[])array)[index];
+ }
+ }
+
+ public static long arrayReadLong(Object array, int index) throws Throwable
+ {
+ if (ArrayRegistry.getInstance().isRegistered(array))
+ {
+ LongArrayElementReadInvocation invocation = new LongArrayElementReadInvocation(interceptors, (long[])array, index);
+ return ((Long)invocation.invokeNext()).longValue();
+ }
+ else
+ {
+ return ((long[])array)[index];
+ }
+ }
+
+ public static short arrayReadShort(Object array, int index) throws Throwable
+ {
+ if (ArrayRegistry.getInstance().isRegistered(array))
+ {
+ ShortArrayElementReadInvocation invocation = new ShortArrayElementReadInvocation(interceptors, (short[])array, index);
+ return ((Short)invocation.invokeNext()).shortValue();
+ }
+ else
+ {
+ return ((short[])array)[index];
+ }
+ }
}
Modified: 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-24 13:53:26 UTC (rev 59222)
+++ projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ArrayRegistry.java 2006-12-24 13:56:30 UTC (rev 59223)
@@ -51,7 +51,6 @@
public void addFieldReference(Object owner, String fieldName, Object array)
{
- System.out.println("----> Adding " + array + " to " + owner);
if (array == null)
{
return;
@@ -117,7 +116,6 @@
public void addElementReference(Object owner, int index, Object array)
{
- System.out.println("----> Adding " + array + " to " + owner);
if (array == null)
{
return;
@@ -151,7 +149,6 @@
public void removeElementReference(Object owner, int index, Object array)
{
- System.out.println("----> Removing " + array + " from " + owner);
if (array == null)
{
return;
@@ -256,31 +253,14 @@
}
}
- private boolean isArray(Object array)
+ private boolean isArray(Object arrayCandidate)
{
- Class componentType = array.getClass().getComponentType();
- return componentType.isArray();
+ Class candidateClass = arrayCandidate.getClass();
+ if (candidateClass.isArray())
+ {
+ Class componentType = candidateClass.getComponentType();
+ return componentType.isArray();
+ }
+ return false;
}
-
- 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/BooleanArrayElementReadInvocation.java
===================================================================
--- projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/BooleanArrayElementReadInvocation.java 2006-12-24 13:53:26 UTC (rev 59222)
+++ projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/BooleanArrayElementReadInvocation.java 2006-12-24 13:56:30 UTC (rev 59223)
@@ -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 BooleanArrayElementReadInvocation extends ArrayElementReadInvocation
+{
+ private static final long serialVersionUID = 4894358007089083877L;
+ boolean[] array;
+
+ public BooleanArrayElementReadInvocation(Interceptor[] interceptors, boolean[] target, int index)
+ {
+ super(interceptors, target, index);
+ array = target;
+ }
+
+ public Object invokeTarget()
+ {
+ return new Boolean(array[index]);
+ }
+}
Added: projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/BooleanArrayElementWriteInvocation.java
===================================================================
--- projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/BooleanArrayElementWriteInvocation.java 2006-12-24 13:53:26 UTC (rev 59222)
+++ projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/BooleanArrayElementWriteInvocation.java 2006-12-24 13:56:30 UTC (rev 59223)
@@ -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 BooleanArrayElementWriteInvocation extends ArrayElementWriteInvocation
+{
+ private static final long serialVersionUID = -8806734067322751711L;
+ boolean[] array;
+ boolean value;
+
+ public BooleanArrayElementWriteInvocation(Interceptor[] interceptors, boolean[] target, int index, boolean 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 Boolean(value);
+ }
+
+ public boolean getBooleanValue()
+ {
+ return value;
+ }
+}
Added: projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ByteArrayElementReadInvocation.java
===================================================================
--- projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ByteArrayElementReadInvocation.java 2006-12-24 13:53:26 UTC (rev 59222)
+++ projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ByteArrayElementReadInvocation.java 2006-12-24 13:56:30 UTC (rev 59223)
@@ -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 ByteArrayElementReadInvocation extends ArrayElementReadInvocation
+{
+ private static final long serialVersionUID = 407921822383443705L;
+ byte[] array;
+
+ public ByteArrayElementReadInvocation(Interceptor[] interceptors, byte[] target, int index)
+ {
+ super(interceptors, target, index);
+ array = target;
+ }
+
+ public Object invokeTarget()
+ {
+ return new Byte(array[index]);
+ }
+}
Added: projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ByteArrayElementWriteInvocation.java
===================================================================
--- projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ByteArrayElementWriteInvocation.java 2006-12-24 13:53:26 UTC (rev 59222)
+++ projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ByteArrayElementWriteInvocation.java 2006-12-24 13:56:30 UTC (rev 59223)
@@ -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 ByteArrayElementWriteInvocation extends ArrayElementWriteInvocation
+{
+ private static final long serialVersionUID = -3311231820298166088L;
+ byte[] array;
+ byte value;
+
+ public ByteArrayElementWriteInvocation(Interceptor[] interceptors, byte[] target, int index, byte 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 Byte(value);
+ }
+
+ public byte getByteValue()
+ {
+ return value;
+ }
+}
Added: projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ByteBooleanConverter.java
===================================================================
--- projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ByteBooleanConverter.java 2006-12-24 13:53:26 UTC (rev 59222)
+++ projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ByteBooleanConverter.java 2006-12-24 13:56:30 UTC (rev 59223)
@@ -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;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ByteBooleanConverter
+{
+ private static final byte BOOLEAN_FALSE = 0;
+ private static final byte BOOLEAN_TRUE = 1;
+
+ public static byte toByte(boolean b)
+ {
+ return (b) ? BOOLEAN_TRUE : BOOLEAN_FALSE;
+ }
+
+ public static boolean toBoolean(byte b)
+ {
+ if (b == BOOLEAN_FALSE) return false;
+ else if (b == BOOLEAN_TRUE) return true;
+
+ throw new RuntimeException("Invalid byte " + b + " cannot be converted to a boolean");
+ }
+}
Added: projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/CharArrayElementReadInvocation.java
===================================================================
--- projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/CharArrayElementReadInvocation.java 2006-12-24 13:53:26 UTC (rev 59222)
+++ projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/CharArrayElementReadInvocation.java 2006-12-24 13:56:30 UTC (rev 59223)
@@ -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 CharArrayElementReadInvocation extends ArrayElementReadInvocation
+{
+ private static final long serialVersionUID = -8421466785835226302L;
+ char[] array;
+
+ public CharArrayElementReadInvocation(Interceptor[] interceptors, char[] target, int index)
+ {
+ super(interceptors, target, index);
+ array = target;
+ }
+
+ public Object invokeTarget()
+ {
+ return new Character(array[index]);
+ }
+}
Added: projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/CharArrayElementWriteInvocation.java
===================================================================
--- projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/CharArrayElementWriteInvocation.java 2006-12-24 13:53:26 UTC (rev 59222)
+++ projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/CharArrayElementWriteInvocation.java 2006-12-24 13:56:30 UTC (rev 59223)
@@ -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 CharArrayElementWriteInvocation extends ArrayElementWriteInvocation
+{
+ private static final long serialVersionUID = -7731135396849504354L;
+ char[] array;
+ char value;
+
+ public CharArrayElementWriteInvocation(Interceptor[] interceptors, char[] target, int index, char 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 Character(value);
+ }
+
+ public char getCharValue()
+ {
+ return value;
+ }
+}
Added: projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/DoubleArrayElementReadInvocation.java
===================================================================
--- projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/DoubleArrayElementReadInvocation.java 2006-12-24 13:53:26 UTC (rev 59222)
+++ projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/DoubleArrayElementReadInvocation.java 2006-12-24 13:56:30 UTC (rev 59223)
@@ -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 DoubleArrayElementReadInvocation extends ArrayElementReadInvocation
+{
+ private static final long serialVersionUID = 4414714543578046462L;
+ double[] array;
+
+ public DoubleArrayElementReadInvocation(Interceptor[] interceptors, double[] target, int index)
+ {
+ super(interceptors, target, index);
+ array = target;
+ }
+
+ public Object invokeTarget()
+ {
+ return new Double(array[index]);
+ }
+}
Added: projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/DoubleArrayElementWriteInvocation.java
===================================================================
--- projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/DoubleArrayElementWriteInvocation.java 2006-12-24 13:53:26 UTC (rev 59222)
+++ projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/DoubleArrayElementWriteInvocation.java 2006-12-24 13:56:30 UTC (rev 59223)
@@ -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 DoubleArrayElementWriteInvocation extends ArrayElementWriteInvocation
+{
+ private static final long serialVersionUID = 4952638087031381514L;
+ double[] array;
+ double value;
+
+ public DoubleArrayElementWriteInvocation(Interceptor[] interceptors, double[] target, int index, double 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 Double(value);
+ }
+
+ public double getDoubleValue()
+ {
+ return value;
+ }
+}
Added: projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/FloatArrayElementReadInvocation.java
===================================================================
--- projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/FloatArrayElementReadInvocation.java 2006-12-24 13:53:26 UTC (rev 59222)
+++ projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/FloatArrayElementReadInvocation.java 2006-12-24 13:56:30 UTC (rev 59223)
@@ -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 FloatArrayElementReadInvocation extends ArrayElementReadInvocation
+{
+ private static final long serialVersionUID = 1588317122571729022L;
+ float[] array;
+
+ public FloatArrayElementReadInvocation(Interceptor[] interceptors, float[] target, int index)
+ {
+ super(interceptors, target, index);
+ array = target;
+ }
+
+ public Object invokeTarget()
+ {
+ return new Float(array[index]);
+ }
+}
Added: projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/FloatArrayElementWriteInvocation.java
===================================================================
--- projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/FloatArrayElementWriteInvocation.java 2006-12-24 13:53:26 UTC (rev 59222)
+++ projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/FloatArrayElementWriteInvocation.java 2006-12-24 13:56:30 UTC (rev 59223)
@@ -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 FloatArrayElementWriteInvocation extends ArrayElementWriteInvocation
+{
+ private static final long serialVersionUID = 2124265298388536292L;
+ float[] array;
+ float value;
+
+ public FloatArrayElementWriteInvocation(Interceptor[] interceptors, float[] target, int index, float 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 Float(value);
+ }
+
+ public float getFloatValue()
+ {
+ return value;
+ }
+}
Added: projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/LongArrayElementReadInvocation.java
===================================================================
--- projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/LongArrayElementReadInvocation.java 2006-12-24 13:53:26 UTC (rev 59222)
+++ projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/LongArrayElementReadInvocation.java 2006-12-24 13:56:30 UTC (rev 59223)
@@ -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 LongArrayElementReadInvocation extends ArrayElementReadInvocation
+{
+ private static final long serialVersionUID = -6196706501416214971L;
+ long[] array;
+
+ public LongArrayElementReadInvocation(Interceptor[] interceptors, long[] target, int index)
+ {
+ super(interceptors, target, index);
+ array = target;
+ }
+
+ public Object invokeTarget()
+ {
+ return new Long(array[index]);
+ }
+}
Added: projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/LongArrayElementWriteInvocation.java
===================================================================
--- projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/LongArrayElementWriteInvocation.java 2006-12-24 13:53:26 UTC (rev 59222)
+++ projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/LongArrayElementWriteInvocation.java 2006-12-24 13:56:30 UTC (rev 59223)
@@ -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 LongArrayElementWriteInvocation extends ArrayElementWriteInvocation
+{
+ private static final long serialVersionUID = -609480261599580470L;
+ long[] array;
+ long value;
+
+ public LongArrayElementWriteInvocation(Interceptor[] interceptors, long[] target, int index, long 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 Long(value);
+ }
+
+ public long getLongValue()
+ {
+ return value;
+ }
+}
Added: projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ShortArrayElementReadInvocation.java
===================================================================
--- projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ShortArrayElementReadInvocation.java 2006-12-24 13:53:26 UTC (rev 59222)
+++ projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ShortArrayElementReadInvocation.java 2006-12-24 13:56:30 UTC (rev 59223)
@@ -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 ShortArrayElementReadInvocation extends ArrayElementReadInvocation
+{
+ private static final long serialVersionUID = -6743791579057380824L;
+ short[] array;
+
+ public ShortArrayElementReadInvocation(Interceptor[] interceptors, short[] target, int index)
+ {
+ super(interceptors, target, index);
+ array = target;
+ }
+
+ public Object invokeTarget()
+ {
+ return new Short(array[index]);
+ }
+}
Added: projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ShortArrayElementWriteInvocation.java
===================================================================
--- projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ShortArrayElementWriteInvocation.java 2006-12-24 13:53:26 UTC (rev 59222)
+++ projects/aop/branches/arrays/aop/src/main/org/jboss/aop/array/ShortArrayElementWriteInvocation.java 2006-12-24 13:56:30 UTC (rev 59223)
@@ -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 ShortArrayElementWriteInvocation extends ArrayElementWriteInvocation
+{
+ private static final long serialVersionUID = -8003520567342434348L;
+ short[] array;
+ short value;
+
+ public ShortArrayElementWriteInvocation(Interceptor[] interceptors, short[] target, int index, short 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 Short(value);
+ }
+
+ public float getShortValue()
+ {
+ return value;
+ }
+}
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-24 13:53:26 UTC (rev 59222)
+++ projects/aop/branches/arrays/aop/src/main/org/jboss/aop/instrument/Instrumentor.java 2006-12-24 13:56:30 UTC (rev 59223)
@@ -964,7 +964,7 @@
if (shouldReplaceArrayAccess)
{
- System.out.println("---> Should replace access for " + clazz.getName());
+ if (AspectManager.verbose) System.out.println("[debug] Replacing array access in " + clazz.getName());
converter.replaceArrayAccess(classPool.get(ArrayAdvisor.class.getName()), new DefaultMethodNames());
}
return shouldReplaceArrayAccess;
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-24 13:53:26 UTC (rev 59222)
+++ projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/AOPArrayTestCase.java 2006-12-24 13:56:30 UTC (rev 59223)
@@ -47,24 +47,162 @@
return suite;
}
+ public void testObjectArray()
+ {
+ ClassWithArrayFields obj = new ClassWithArrayFields();
+ TestArrayElementInterceptor.clear();
+ obj.objects[2] = "X";
+ assertEquals(2, TestArrayElementInterceptor.index);
+ assertEquals("X", TestArrayElementInterceptor.value);
+
+ TestArrayElementInterceptor.clear();
+ Object o = obj.objects[0];
+ assertEquals("1", o);
+ assertEquals(0, TestArrayElementInterceptor.index);
+ }
+
public void testIntArray()
{
ClassWithArrayFields obj = new ClassWithArrayFields();
TestArrayElementInterceptor.clear();
- obj.ifield[1] = 100;
+ obj.ints[1] = 100;
assertEquals(1, TestArrayElementInterceptor.index);
assertNotNull(TestArrayElementInterceptor.value);
assertEquals(100, ((Integer)TestArrayElementInterceptor.value).intValue());
- obj.ifield[2] = 123;
+ obj.ints[2] = 123;
TestArrayElementInterceptor.clear();
- int val = obj.ifield[2];
+ int val = obj.ints[2];
assertEquals(123, val);
assertEquals(2, TestArrayElementInterceptor.index);
assertNull(TestArrayElementInterceptor.value);
}
+ public void testByteArray()
+ {
+ ClassWithArrayFields obj = new ClassWithArrayFields();
+ TestArrayElementInterceptor.clear();
+ obj.bytes[1] = 100;
+ assertEquals(1, TestArrayElementInterceptor.index);
+ assertNotNull(TestArrayElementInterceptor.value);
+ assertEquals(100, ((Byte)TestArrayElementInterceptor.value).byteValue());
+
+ obj.bytes[2] = 123;
+
+ TestArrayElementInterceptor.clear();
+ byte val = obj.bytes[2];
+ assertEquals(123, val);
+ assertEquals(2, TestArrayElementInterceptor.index);
+ assertNull(TestArrayElementInterceptor.value);
+ }
+
+ public void testBooleanArray()
+ {
+ ClassWithArrayFields obj = new ClassWithArrayFields();
+ TestArrayElementInterceptor.clear();
+ obj.booleans[1] = false;
+ assertEquals(1, TestArrayElementInterceptor.index);
+ assertNotNull(TestArrayElementInterceptor.value);
+ assertEquals(false, ((Boolean)TestArrayElementInterceptor.value).booleanValue());
+
+ TestArrayElementInterceptor.clear();
+ boolean val = obj.booleans[1];
+ assertEquals(false, val);
+ assertEquals(1, TestArrayElementInterceptor.index);
+ assertNull(TestArrayElementInterceptor.value);
+ }
+
+ public void testCharArray()
+ {
+ ClassWithArrayFields obj = new ClassWithArrayFields();
+ TestArrayElementInterceptor.clear();
+ obj.chars[1] = 'z';
+ assertEquals(1, TestArrayElementInterceptor.index);
+ assertNotNull(TestArrayElementInterceptor.value);
+ assertEquals('z', ((Character)TestArrayElementInterceptor.value).charValue());
+
+ obj.chars[2] = 'x';
+
+ TestArrayElementInterceptor.clear();
+ char val = obj.chars[2];
+ assertEquals('x', val);
+ assertEquals(2, TestArrayElementInterceptor.index);
+ assertNull(TestArrayElementInterceptor.value);
+ }
+
+ public void testDoubleArray()
+ {
+ ClassWithArrayFields obj = new ClassWithArrayFields();
+ TestArrayElementInterceptor.clear();
+ obj.doubles[1] = 2.1d;
+ assertEquals(1, TestArrayElementInterceptor.index);
+ assertNotNull(TestArrayElementInterceptor.value);
+ assertEquals(2.1d, ((Double)TestArrayElementInterceptor.value).doubleValue());
+
+ obj.doubles[2] = 9.9d;
+
+ TestArrayElementInterceptor.clear();
+ double val = obj.doubles[2];
+ assertEquals(9.9d, val);
+ assertEquals(2, TestArrayElementInterceptor.index);
+ assertNull(TestArrayElementInterceptor.value);
+ }
+
+ public void testFloatArray()
+ {
+ ClassWithArrayFields obj = new ClassWithArrayFields();
+ TestArrayElementInterceptor.clear();
+ obj.floats[1] = 2.1f;
+ assertEquals(1, TestArrayElementInterceptor.index);
+ assertNotNull(TestArrayElementInterceptor.value);
+ assertEquals(2.1f, ((Float)TestArrayElementInterceptor.value).floatValue());
+
+ obj.floats[2] = 9.9f;
+
+ TestArrayElementInterceptor.clear();
+ double val = obj.floats[2];
+ assertEquals(9.9f, val);
+ assertEquals(2, TestArrayElementInterceptor.index);
+ assertNull(TestArrayElementInterceptor.value);
+ }
+
+ public void testLongArray()
+ {
+ ClassWithArrayFields obj = new ClassWithArrayFields();
+ TestArrayElementInterceptor.clear();
+ obj.longs[1] = 100L;
+ assertEquals(1, TestArrayElementInterceptor.index);
+ assertNotNull(TestArrayElementInterceptor.value);
+ assertEquals(100L, ((Long)TestArrayElementInterceptor.value).longValue());
+
+ obj.longs[2] = 200L;
+
+ TestArrayElementInterceptor.clear();
+ double val = obj.longs[2];
+ assertEquals(200L, val);
+ assertEquals(2, TestArrayElementInterceptor.index);
+ assertNull(TestArrayElementInterceptor.value);
+ }
+
+ public void testShortArray()
+ {
+ ClassWithArrayFields obj = new ClassWithArrayFields();
+ TestArrayElementInterceptor.clear();
+ obj.shorts[1] = 50;
+ assertEquals(1, TestArrayElementInterceptor.index);
+ assertNotNull(TestArrayElementInterceptor.value);
+ assertEquals(50, ((Short)TestArrayElementInterceptor.value).shortValue());
+
+ obj.shorts[2] = 100;
+
+ TestArrayElementInterceptor.clear();
+ double val = obj.shorts[2];
+ assertEquals(100, val);
+ assertEquals(2, TestArrayElementInterceptor.index);
+ assertNull(TestArrayElementInterceptor.value);
+ }
+
public void testMultiDimensionalTopLevelArray()
{
ClassWithArrayFields obj = new ClassWithArrayFields();
@@ -77,23 +215,23 @@
//Store reference to array to be replaced
TestArrayElementInterceptor.clear();
- int[][] original_0 = obj.iiifield[0];
+ int[][] original_0 = obj.ints3d[0];
assertEquals(0, TestArrayElementInterceptor.index);
//Replace array in top-level array, interception should happen now
TestArrayElementInterceptor.clear();
- obj.iiifield[0] = replacement0;
+ obj.ints3d[0] = replacement0;
assertEquals(0, TestArrayElementInterceptor.index);
assertNotNull(TestArrayElementInterceptor.value);
assertEquals(replacement0, TestArrayElementInterceptor.value);
TestArrayElementInterceptor.clear();
- int i = obj.iiifield[0][0][1];
+ int i = obj.ints3d[0][0][1];
assertEquals(1, TestArrayElementInterceptor.index);
assertEquals(22, i);
TestArrayElementInterceptor.clear();
- obj.iiifield[0][0][1] = 99;
+ obj.ints3d[0][0][1] = 99;
assertEquals(1, TestArrayElementInterceptor.index);
assertEquals(99, ((Integer)TestArrayElementInterceptor.value).intValue());
@@ -120,23 +258,23 @@
//Store reference to array to be replaced
TestArrayElementInterceptor.clear();
- int[] original_0_1 = obj.iiifield[0][1];
+ int[] original_0_1 = obj.ints3d[0][1];
assertEquals(1, TestArrayElementInterceptor.index);
//Replace nested array, interception should happen now
TestArrayElementInterceptor.clear();
- obj.iiifield[0][1] = replacement_0_1;
+ obj.ints3d[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];
+ int i = obj.ints3d[0][1][2];
assertEquals(2, TestArrayElementInterceptor.index);
assertEquals(333, i);
TestArrayElementInterceptor.clear();
- obj.iiifield[0][0][1] = 99;
+ obj.ints3d[0][0][1] = 99;
assertEquals(1, TestArrayElementInterceptor.index);
assertEquals(99, ((Integer)TestArrayElementInterceptor.value).intValue());
@@ -302,5 +440,86 @@
i = original[1];
assertEquals(-1, TestArrayElementInterceptor.index);
}
+
+ public void testObjectArrayWithArrayAsObjectEntry()
+ {
+ int[] replacement = new int[] {1,2,3};
+ ClassWithArrayFields obj = new ClassWithArrayFields();
+
+ //Add an array as one of the elements in the object array
+ TestArrayElementInterceptor.clear();
+ obj.objects[0] = replacement;
+ assertEquals(0, TestArrayElementInterceptor.index);
+ assertEquals(replacement, TestArrayElementInterceptor.value);
+
+ //The sub array should be advised
+ TestArrayElementInterceptor.clear();
+ replacement[1] = 5;
+ assertEquals(1, TestArrayElementInterceptor.index);
+ assertEquals(5, ((Integer)TestArrayElementInterceptor.value).intValue());
+
+ //Put in a string object
+ TestArrayElementInterceptor.clear();
+ obj.objects[0] = "X";
+ assertEquals(0, TestArrayElementInterceptor.index);
+ assertEquals("X", TestArrayElementInterceptor.value);
+
+ //The nested array no longer is associated with array and should be unadvised
+ TestArrayElementInterceptor.clear();
+ replacement[1] = 10;
+ assertEquals(-1, TestArrayElementInterceptor.index);
+ assertEquals(null, TestArrayElementInterceptor.value);
+
+ }
+ public void testUnadvisedArrayFields()
+ {
+ ClassWithUnadvisedArrayFields obj = new ClassWithUnadvisedArrayFields();
+
+ TestArrayElementInterceptor.clear();
+ obj.objects[0] = "X";
+ assertEquals("X", obj.objects[0]);
+ assertEquals(-1, TestArrayElementInterceptor.index);
+
+ TestArrayElementInterceptor.clear();
+ obj.bytes[0] = 1;
+ assertEquals(1, obj.bytes[0]);
+ assertEquals(-1, TestArrayElementInterceptor.index);
+
+ TestArrayElementInterceptor.clear();
+ obj.booleans[0] = true;
+ assertEquals(true, obj.booleans[0]);
+ assertEquals(-1, TestArrayElementInterceptor.index);
+
+ TestArrayElementInterceptor.clear();
+ obj.chars[0] = 'z';
+ assertEquals('z', obj.chars[0]);
+ assertEquals(-1, TestArrayElementInterceptor.index);
+
+ TestArrayElementInterceptor.clear();
+ obj.doubles[0] = 9.9d;
+ assertEquals(9.9d, obj.doubles[0]);
+ assertEquals(-1, TestArrayElementInterceptor.index);
+
+ TestArrayElementInterceptor.clear();
+ obj.floats[0] = 9.9f;
+ assertEquals(9.9f, obj.floats[0]);
+ assertEquals(-1, TestArrayElementInterceptor.index);
+
+ TestArrayElementInterceptor.clear();
+ obj.ints[0] = 100;
+ assertEquals(100, obj.ints[0]);
+ assertEquals(-1, TestArrayElementInterceptor.index);
+
+ TestArrayElementInterceptor.clear();
+ obj.longs[0] = 100;
+ assertEquals(100, obj.longs[0]);
+ assertEquals(-1, TestArrayElementInterceptor.index);
+
+ TestArrayElementInterceptor.clear();
+ obj.shorts[0] = 100;
+ assertEquals(100, obj.shorts[0]);
+ assertEquals(-1, TestArrayElementInterceptor.index);
+
+ }
}
Deleted: projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/ArrayAdvisor.java
===================================================================
--- projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/ArrayAdvisor.java 2006-12-24 13:53:26 UTC (rev 59222)
+++ projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/ArrayAdvisor.java 2006-12-24 13:56:30 UTC (rev 59223)
@@ -1,157 +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 ArrayAdvisor
-{
- public static Object array;
- public static String value;
- public static int index;
-
- public static void clear()
- {
- array = null;
- value = null;
- index = -1;
- }
-
- private static void recordAccess(Object array, int index, String value)
- {
- ArrayAdvisor.array = array;
- ArrayAdvisor.index = index;
- ArrayAdvisor.value = value;
- }
-
- //Write operations
- public static void arrayWrite(boolean[] array, int index, boolean value)
- {
- recordAccess(array, index, String.valueOf(value));
- array[index] = value;
- }
-
- public static void arrayWrite(short[] array, int index, short value)
- {
- recordAccess(array, index, String.valueOf(value));
- 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;
- }
-
- //Read operations
- public static boolean arrayRead(boolean[] array, int index)
- {
-
- boolean value = array[index];
- recordAccess(array, index, String.valueOf(value));
- return value;
- }
-
- public static short arrayRead(short[] array, int index)
- {
- short value = array[index];
- recordAccess(array, index, String.valueOf(value));
- return value;
- }
-
- 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;
- }
-
-
-}
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-24 13:53:26 UTC (rev 59222)
+++ projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/ClassWithArrayFields.java 2006-12-24 13:56:30 UTC (rev 59223)
@@ -30,14 +30,14 @@
*/
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 int[] ifield = new int[] {0, 0, 0};
- public int[][] iifield = new int[][]{new int[] {0, 0}, new int[] {0, 0}};
- public int[][][] iiifield = new int[][][] {
+ public Object[] objects = new Object[] {"1", "2", "3"};
+ public byte[] bytes = new byte[] {1, 2, 3};
+ public boolean[] booleans = new boolean[] {true, true, true};
+ public char[] chars = new char[] {'a', 'b', 'c'};
+ public double[] doubles = new double[] {1.5d, 1.9d, 6.9d};
+ public float[] floats = new float[] {1.5f, 1.9f, 6.9f};
+ public int[] ints = new int[] {0, 0, 0};
+ public int[][][] ints3d = new int[][][] {
new int[][] {
new int[] {1,2,3},
new int[] {4,5,6},
@@ -49,38 +49,11 @@
new int[] {7,8,9}
},
};
-
+ public long[] longs = new long[] {1L, 2L, 3L};
+ public short[] shorts = new short[] {1,2,3};
+
public ClassWithArrayFields()
{
}
- public static void main(String[] args)
- {
-// 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/ClassWithUnadvisedArrayFields.java
===================================================================
--- projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/ClassWithUnadvisedArrayFields.java 2006-12-24 13:53:26 UTC (rev 59222)
+++ projects/aop/branches/arrays/aop/src/test/org/jboss/test/aop/array/ClassWithUnadvisedArrayFields.java 2006-12-24 13:56:30 UTC (rev 59223)
@@ -0,0 +1,41 @@
+/*
+* 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 ClassWithUnadvisedArrayFields
+{
+ public Object[] objects = new Object[] {"1", "2", "3"};
+ public byte[] bytes = new byte[] {1, 2, 3};
+ public boolean[] booleans = new boolean[] {true, true, true};
+ public char[] chars = new char[] {'a', 'b', 'c'};
+ public double[] doubles = new double[] {1.5d, 1.9d, 6.9d};
+ public float[] floats = new float[] {1.5f, 1.9f, 6.9f};
+ public int[] ints = new int[] {0, 0, 0};
+ public long[] longs = new long[] {1L, 2L, 3L};
+ public short[] shorts = new short[] {1,2,3};
+
+}
Modified: projects/aop/branches/arrays/build/build-thirdparty.xml
===================================================================
--- projects/aop/branches/arrays/build/build-thirdparty.xml 2006-12-24 13:53:26 UTC (rev 59222)
+++ projects/aop/branches/arrays/build/build-thirdparty.xml 2006-12-24 13:56:30 UTC (rev 59223)
@@ -45,7 +45,7 @@
-->
<componentref name="apache-log4j" version="1.2.8"/>
<componentref name="dom4j" version="1.6.1jboss"/>
- <componentref name="javassist" version="3.4.GA"/>
+ <componentref name="javassist" version="snapshot"/>
<componentref name="jboss/backport-concurrent" version="2.1.0.GA"/>
<componentref name="jboss/common-core" version="2.0.1.GA"/>
<componentref name="jboss/common-logging-jdk" version="2.0.1.GA"/>
More information about the jboss-cvs-commits
mailing list