aboutsummaryrefslogtreecommitdiffstats
path: root/runtime/src
diff options
context:
space:
mode:
authoraclement <aclement>2006-06-03 08:27:06 +0000
committeraclement <aclement>2006-06-03 08:27:06 +0000
commitf821ca3dae5681758d23a2a0531d0d42f017152e (patch)
tree3491c922fb391517009f0ffec94535bbbdaa9a77 /runtime/src
parent73d96a5cf3bb38a2fbda7f8ae00a7725c9728ec6 (diff)
downloadaspectj-f821ca3dae5681758d23a2a0531d0d42f017152e.tar.gz
aspectj-f821ca3dae5681758d23a2a0531d0d42f017152e.zip
test and fix for 145086
Diffstat (limited to 'runtime/src')
-rw-r--r--runtime/src/org/aspectj/runtime/reflect/SignatureImpl.java36
1 files changed, 24 insertions, 12 deletions
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;
+ }
+
}
}