aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/aspectj/lib/aspectjrt.jarbin114473 -> 114560 bytes
-rw-r--r--lib/test/aspectjrt.jarbin114473 -> 114560 bytes
-rw-r--r--runtime/src/org/aspectj/runtime/reflect/SignatureImpl.java36
-rw-r--r--runtime/testsrc/org/aspectj/runtime/reflect/JoinPointImplTest.java2
-rw-r--r--runtime/testsrc/org/aspectj/runtime/reflect/SignatureTest.java23
5 files changed, 47 insertions, 14 deletions
diff --git a/lib/aspectj/lib/aspectjrt.jar b/lib/aspectj/lib/aspectjrt.jar
index 01aac1180..80d738327 100644
--- a/lib/aspectj/lib/aspectjrt.jar
+++ b/lib/aspectj/lib/aspectjrt.jar
Binary files differ
diff --git a/lib/test/aspectjrt.jar b/lib/test/aspectjrt.jar
index 01aac1180..80d738327 100644
--- a/lib/test/aspectjrt.jar
+++ b/lib/test/aspectjrt.jar
Binary files differ
diff --git a/runtime/src/org/aspectj/runtime/reflect/SignatureImpl.java b/runtime/src/org/aspectj/runtime/reflect/SignatureImpl.java
index 68473c218..68079b444 100644
--- a/runtime/src/org/aspectj/runtime/reflect/SignatureImpl.java
+++ b/runtime/src/org/aspectj/runtime/reflect/SignatureImpl.java
@@ -206,26 +206,38 @@ abstract class SignatureImpl implements Signature {
}
// separate implementation so we don't need SoftReference to hold the field...
- private static final class CacheImpl implements Cache {
+ private static final class CacheImpl implements Cache {
private java.lang.ref.SoftReference toStringCacheRef;
- public CacheImpl() {
- toStringCacheRef = new java.lang.ref.SoftReference(new String[3]);
+
+ public CacheImpl() {
+ makeCache();
}
-
+
public String get(int cacheOffset) {
- String[] cachedArray = array();
- if (cachedArray == null) {
- return null;
- }
- return cachedArray[cacheOffset];
+ String[] cachedArray = array();
+ if (cachedArray == null) {
+ return null;
+ }
+ return cachedArray[cacheOffset];
}
public void set(int cacheOffset, String result) {
- array()[cacheOffset] = result;
+ String[] cachedArray = array();
+ if (cachedArray == null) {
+ cachedArray = makeCache();
+ }
+ cachedArray[cacheOffset] = result;
}
-
+
private String[] array() {
- return (String[])toStringCacheRef.get();
+ return (String[]) toStringCacheRef.get();
}
+
+ private String[] makeCache() {
+ String[] array = new String[3];
+ toStringCacheRef = new java.lang.ref.SoftReference(array);
+ return array;
+ }
+
}
}
diff --git a/runtime/testsrc/org/aspectj/runtime/reflect/JoinPointImplTest.java b/runtime/testsrc/org/aspectj/runtime/reflect/JoinPointImplTest.java
index 98a5a2374..2a17ad998 100644
--- a/runtime/testsrc/org/aspectj/runtime/reflect/JoinPointImplTest.java
+++ b/runtime/testsrc/org/aspectj/runtime/reflect/JoinPointImplTest.java
@@ -15,8 +15,6 @@ 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 {
diff --git a/runtime/testsrc/org/aspectj/runtime/reflect/SignatureTest.java b/runtime/testsrc/org/aspectj/runtime/reflect/SignatureTest.java
index 6cb43f7e0..7a66a5b39 100644
--- a/runtime/testsrc/org/aspectj/runtime/reflect/SignatureTest.java
+++ b/runtime/testsrc/org/aspectj/runtime/reflect/SignatureTest.java
@@ -10,6 +10,9 @@
*******************************************************************************/
package org.aspectj.runtime.reflect;
+import java.lang.ref.Reference;
+import java.lang.reflect.Field;
+
import junit.framework.TestCase;
/**
@@ -31,4 +34,24 @@ public class SignatureTest extends TestCase {
assertSame(longString,msi.toLongString()); // should be cached.
assertTrue("String representations should be different",!(shortString.equals(middleString) || middleString.equals(longString) || longString.equals(shortString)));
}
+
+ public void testClearCache() throws Exception {
+ MethodSignatureImpl msi = new MethodSignatureImpl(0,"test",SignatureTest.class,new Class[] { String.class, Integer.TYPE }, new String[] { "s", "i" }, new Class[] {}, Runnable.class);
+ String shortString = msi.toShortString();
+ assertSame(shortString,msi.toShortString());
+
+ Field field = SignatureImpl.class.getDeclaredField("stringCache");
+ field.setAccessible(true);
+ Object res = field.get(msi);
+
+ field = res.getClass().getDeclaredField("toStringCacheRef");
+ field.setAccessible(true);
+ Reference ref = (Reference)field.get(res);
+
+ ref.clear();
+ assertEquals(shortString,msi.toShortString());
+
+ String longString = msi.toLongString();
+ assertSame(longString,msi.toLongString()); // should be cached.
+ }
}