aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bugs167
diff options
context:
space:
mode:
authoraclement <aclement>2009-12-01 18:22:25 +0000
committeraclement <aclement>2009-12-01 18:22:25 +0000
commit41c8b34427a22eed17fd72df52fd646df78fe472 (patch)
treef77c75209abde4b086898e5611a2354ecb0a2e62 /tests/bugs167
parent4cfcd37ea6daa646b33c955abd558bdfbe378f1a (diff)
downloadaspectj-41c8b34427a22eed17fd72df52fd646df78fe472.tar.gz
aspectj-41c8b34427a22eed17fd72df52fd646df78fe472.zip
296533: generics info in generated accessor names
Diffstat (limited to 'tests/bugs167')
-rw-r--r--tests/bugs167/pr296533/testing/AbstractCache.aj43
-rw-r--r--tests/bugs167/pr296533/testing/Resource.java15
-rw-r--r--tests/bugs167/pr296533/testing/ResourceCache.aj10
-rw-r--r--tests/bugs167/pr296533/testing/ResourceManager.java8
-rw-r--r--tests/bugs167/pr296533/testing/TestRunner.java24
5 files changed, 100 insertions, 0 deletions
diff --git a/tests/bugs167/pr296533/testing/AbstractCache.aj b/tests/bugs167/pr296533/testing/AbstractCache.aj
new file mode 100644
index 000000000..5f92189c2
--- /dev/null
+++ b/tests/bugs167/pr296533/testing/AbstractCache.aj
@@ -0,0 +1,43 @@
+package testing;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public abstract aspect AbstractCache<Key,Value> {
+
+ public abstract pointcut cachePoint(Key key);
+
+ private Map<Object,Object> cache = new HashMap<Object,Object>();
+ private Integer hitCount = 0;
+ private Integer missCount = 0;
+
+ Value around(Key key) : cachePoint(key){
+ Value value = get(key);
+ if(value == null){
+ value = proceed(key);
+ put(key,value);
+ missCount++;
+ } else {
+ hitCount++;
+ }
+ return value;
+ }
+
+ @SuppressWarnings("unchecked")
+ private Value get(Key key){
+ return (Value) cache.get(key);
+ }
+
+ private void put(Key key, Value value) {
+ cache.put(key, value);
+ }
+
+ public Integer getHitCount() {
+ return hitCount;
+ }
+
+ public Integer getMissCount() {
+ return missCount;
+ }
+
+}
diff --git a/tests/bugs167/pr296533/testing/Resource.java b/tests/bugs167/pr296533/testing/Resource.java
new file mode 100644
index 000000000..2c2f44b7c
--- /dev/null
+++ b/tests/bugs167/pr296533/testing/Resource.java
@@ -0,0 +1,15 @@
+package testing;
+
+public class Resource {
+
+ private final String id;
+
+ public Resource(String id){
+ this.id = id;
+ }
+
+ public String getId(){
+ return id;
+ }
+}
+
diff --git a/tests/bugs167/pr296533/testing/ResourceCache.aj b/tests/bugs167/pr296533/testing/ResourceCache.aj
new file mode 100644
index 000000000..27aa5a9da
--- /dev/null
+++ b/tests/bugs167/pr296533/testing/ResourceCache.aj
@@ -0,0 +1,10 @@
+package testing;
+
+public aspect ResourceCache extends AbstractCache<String,Resource> {
+
+ public pointcut cachePoint(String key):
+ args(key) &&
+ execution(public Resource ResourceManager.lookupResource(String));
+
+
+}
diff --git a/tests/bugs167/pr296533/testing/ResourceManager.java b/tests/bugs167/pr296533/testing/ResourceManager.java
new file mode 100644
index 000000000..80a9fe165
--- /dev/null
+++ b/tests/bugs167/pr296533/testing/ResourceManager.java
@@ -0,0 +1,8 @@
+package testing;
+
+public class ResourceManager {
+
+ public Resource lookupResource(String resourceId){
+ return new Resource(resourceId);
+ }
+}
diff --git a/tests/bugs167/pr296533/testing/TestRunner.java b/tests/bugs167/pr296533/testing/TestRunner.java
new file mode 100644
index 000000000..4263cfe11
--- /dev/null
+++ b/tests/bugs167/pr296533/testing/TestRunner.java
@@ -0,0 +1,24 @@
+package testing;
+
+import java.lang.reflect.Method;
+
+public class TestRunner {
+
+ public static void main(String[] args) {
+ ResourceManager manager = new ResourceManager();
+ ResourceCache cache = ResourceCache.aspectOf();
+
+ Resource r1_1 = manager.lookupResource("1");
+ Resource r1_2 = manager.lookupResource("1");
+ Resource r1_3 = manager.lookupResource("1");
+ Resource r1_4 = manager.lookupResource("1");
+ Resource r1_5 = manager.lookupResource("1");
+
+ Resource r2_1 = manager.lookupResource("2");
+ Resource r2_2 = manager.lookupResource("2");
+
+ System.out.println("Cache hits: " + cache.getHitCount());
+ System.out.println("Cache hits: " + cache.getMissCount());
+ }
+
+}