public Object getThis() { return _this; }
public Object getTarget() { return target; }
- public Object[] getArgs() { return args; }
+ public Object[] getArgs() {
+ if (args == null) { args = new Object[0]; }
+ Object[] argsCopy = new Object[args.length];
+ System.arraycopy(args,0,argsCopy,0,args.length);
+ return argsCopy;
+ }
public org.aspectj.lang.JoinPoint.StaticPart getStaticPart() { return staticPart; }
import java.io.*;
import org.aspectj.lang.*;
+import org.aspectj.runtime.reflect.JoinPointImplTest;
import org.aspectj.runtime.reflect.SignatureTest;
import junit.framework.*;
TestSuite suite = new TestSuite(RuntimeModuleTests.class.getName());
suite.addTestSuite(RuntimeModuleTests.class); // minimum 1 test (testNothing)
suite.addTestSuite(SignatureTest.class);
+ suite.addTestSuite(JoinPointImplTest.class);
return suite;
}
--- /dev/null
+/*
+ * Created on 09-Aug-2004
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.aspectj.runtime.reflect;
+
+import junit.framework.TestCase;
+
+/**
+ * @author colyer
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class JoinPointImplTest extends TestCase {
+
+ public void testGetArgs() {
+ String arg1 = "abc";
+ StringBuffer arg2 = new StringBuffer("def");
+ Object arg3 = new Object();
+ Object[] args = new Object[] { arg1, arg2, arg3 };
+ JoinPointImpl jpi = new JoinPointImpl(null,null,null,args);
+
+ Object[] retrievedArgs = jpi.getArgs();
+ assertEquals("First arg unchanged",arg1,retrievedArgs[0]);
+ assertEquals("Second arg unchanged",arg2,retrievedArgs[1]);
+ assertEquals("Third arg unchanged",arg3,retrievedArgs[2]);
+ retrievedArgs[0] = "xyz";
+ ((StringBuffer)retrievedArgs[1]).append("ghi");
+ retrievedArgs[2] = "jkl";
+ Object[] afterUpdateArgs = jpi.getArgs();
+ assertEquals("Object reference not changed",arg1,afterUpdateArgs[0]);
+ assertEquals("Object reference unchanged",arg2,afterUpdateArgs[1]);
+ assertEquals("state of referenced object updated","defghi",afterUpdateArgs[1].toString());
+ assertEquals("Object reference not changed",arg3,afterUpdateArgs[2]);
+ }
+
+}