]> source.dussan.org Git - aspectj.git/commitdiff
296533: generics info in generated accessor names
authoraclement <aclement>
Tue, 1 Dec 2009 18:22:25 +0000 (18:22 +0000)
committeraclement <aclement>
Tue, 1 Dec 2009 18:22:25 +0000 (18:22 +0000)
tests/bugs167/pr296533/testing/AbstractCache.aj [new file with mode: 0644]
tests/bugs167/pr296533/testing/Resource.java [new file with mode: 0644]
tests/bugs167/pr296533/testing/ResourceCache.aj [new file with mode: 0644]
tests/bugs167/pr296533/testing/ResourceManager.java [new file with mode: 0644]
tests/bugs167/pr296533/testing/TestRunner.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc167/Ajc167Tests.java
tests/src/org/aspectj/systemtest/ajc167/ajc167.xml

diff --git a/tests/bugs167/pr296533/testing/AbstractCache.aj b/tests/bugs167/pr296533/testing/AbstractCache.aj
new file mode 100644 (file)
index 0000000..5f92189
--- /dev/null
@@ -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 (file)
index 0000000..2c2f44b
--- /dev/null
@@ -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 (file)
index 0000000..27aa5a9
--- /dev/null
@@ -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 (file)
index 0000000..80a9fe1
--- /dev/null
@@ -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 (file)
index 0000000..4263cfe
--- /dev/null
@@ -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());
+       }
+
+}
index 8e59dd28f239eec177285f5daa19ffb422bdec14..b0804967a4ee7b3a1f1607df07ab05a49d3f16d0 100644 (file)
@@ -18,6 +18,10 @@ import org.aspectj.testing.XMLBasedAjcTestCase;
 
 public class Ajc167Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
 
+       public void testGenericAspectSignatures_296533() {
+               runTest("generic aspect signatures");
+       }
+
        public void testOptimizingAnnotationStringValueBinding() {
                runTest("optimizing string anno value binding");
        }
@@ -29,11 +33,10 @@ public class Ajc167Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
        public void testOptimizingAnnotationBindingPerfTest() {
                runTest("optimizing annotation binding - 2");
        }
-/*
-       public void testPerThisLTW_295092() {
-               runTest("perthis ltw");
-       }
-*/
+
+       /*
+        * public void testPerThisLTW_295092() { runTest("perthis ltw"); }
+        */
 
        public void testNpeOnBrokenCode_296054() {
                runTest("npe on broken code");
index 9fad6062df296e5aed08c532fb3991d843b4f659..c1acde861dedcf88d84c989038e82c649314c00c 100644 (file)
@@ -3,6 +3,16 @@
 <suite>
 
 
+  <ajc-test dir="bugs167/pr296533" title="generic aspect signatures">
+     <compile files="testing/AbstractCache.aj testing/Resource.java testing/ResourceCache.aj testing/ResourceManager.java testing/TestRunner.java" options="-1.5"/>
+     <run class="testing.TestRunner">
+       <stdout>
+         <line text="Cache hits: 5"/>
+         <line text="Cache hits: 2"/>
+       </stdout>
+     </run>
+  </ajc-test>
+
   <ajc-test dir="bugs167/pr296501" title="optimizing string anno value binding">
      <compile files="StringBinding.java" options="-1.5"/>
      <run class="StringBinding">