@@ -0,0 +1,73 @@ | |||
/* | |||
* Created on Jan 7, 2005 | |||
* | |||
* @author Mohan Radhakrishnan | |||
*/ | |||
//package com.blueprint.ui.util; | |||
import java.lang.ref.ReferenceQueue; | |||
import java.lang.ref.SoftReference; | |||
import java.util.AbstractMap; | |||
import java.util.HashMap; | |||
import java.util.LinkedHashSet; | |||
import java.util.Map; | |||
import java.util.Set; | |||
/* | |||
* Undo/redo for each shape. This can be used to maintain | |||
* a list of changes to rollback. Since the calls to the | |||
* model tier are direct and the reverse calls to update the | |||
* UI are Commands, this list is for the latter. | |||
*/ | |||
public class ShapeCommandMap<K,V> extends AbstractMap<K,V> { | |||
private final Map<K, SoftReference<V>> internalMap = new HashMap<K, SoftReference<V>>(); | |||
private final ReferenceQueue<V> queue = new ReferenceQueue<V>(); | |||
public V put( K key, V value ){ | |||
//remove stale entries | |||
SoftReference<V> ref = new SoftReference<V>( value, queue ); | |||
SoftReference<V> s = internalMap.put( key, ref ); | |||
return ( s != null ? s.get() : null ); | |||
} | |||
/*public V get( K key ){ | |||
//remove stale entries | |||
SoftReference<V> value = internalMap.get( key ); | |||
return ( value != null ? value.get() : null ); | |||
}*/ | |||
public Set<Entry<K,V>> entrySet(){ | |||
Set<Entry<K,V>> commands = new LinkedHashSet<Entry<K,V>>(); | |||
for( final Entry<K,SoftReference<V>> entry : internalMap.entrySet() ){ | |||
final V value = entry.getValue().get(); | |||
commands.add( new Entry<K,V>(){ | |||
public K getKey(){ | |||
return entry.getKey(); | |||
} | |||
public V getValue(){ | |||
return value; | |||
} | |||
public V setValue( V v ){ | |||
entry.setValue( | |||
new SoftReference<V>( v, queue ) ); | |||
return value; | |||
} | |||
}); | |||
} | |||
return commands; | |||
} | |||
} | |||
aspect TriggerBug { | |||
public void foo() { | |||
ShapeCommandMap<String,String> map = new ShapeCommandMap<String,String>(); | |||
map.put("hi","there"); | |||
} | |||
before() : execution(* getValue(..)) { | |||
System.out.println("a matching call"); | |||
} | |||
} |
@@ -0,0 +1,40 @@ | |||
import java.io.Serializable; | |||
import java.lang.annotation.*; | |||
import java.lang.*; | |||
class Bean implements Serializable{ | |||
private String name; | |||
public String getName() { | |||
return name; | |||
} | |||
@propertyChanger() | |||
public void setName( String name ) { | |||
this.name = name; | |||
} | |||
} | |||
@Retention( RetentionPolicy.RUNTIME ) | |||
@Target({ ElementType.METHOD }) | |||
@interface propertyChanger { | |||
} | |||
aspect pr108245 { | |||
public static void main(String[] args) { | |||
Bean b = new Bean(); | |||
b.setName("hasBean"); | |||
} | |||
pointcut callSetter( Bean b ) | |||
: call( @propertyChanger * *(..) ) && target( b ); | |||
before(Bean b) : callSetter(b) { | |||
System.out.println("before " + b); | |||
} | |||
} |
@@ -0,0 +1,16 @@ | |||
package package1; | |||
import java.io.Serializable; | |||
public class Bean implements Serializable{ | |||
private String name; | |||
public String getName() { | |||
return name; | |||
} | |||
public void setName( String name ) { | |||
this.name = name; | |||
} | |||
} |
@@ -0,0 +1,17 @@ | |||
package package2; | |||
import java.io.Serializable; | |||
public class Bean implements Serializable{ | |||
private String name; | |||
public String getName() { | |||
return name; | |||
} | |||
@propertyChanger() | |||
public void setName( String name ) { | |||
this.name = name; | |||
} | |||
} |
@@ -0,0 +1,9 @@ | |||
package package2; | |||
import java.lang.annotation.*; | |||
import java.lang.*; | |||
@Retention( RetentionPolicy.RUNTIME ) | |||
@Target({ ElementType.METHOD }) | |||
public @interface propertyChanger { | |||
} |
@@ -0,0 +1,18 @@ | |||
package package3; | |||
import package2.*; | |||
public aspect pr108425 { | |||
public static void main(String[] args) { | |||
Bean b = new Bean(); | |||
b.setName("hasBean"); | |||
} | |||
pointcut callSetter( Bean b ) | |||
: call( @propertyChanger * *(..) ) && target( b ); | |||
before(Bean b) : callSetter(b) { | |||
System.out.println("before " + b); | |||
} | |||
} |
@@ -289,6 +289,14 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase { | |||
public void testSignatureMatchingInMultipleOverrideScenario() { | |||
runTest("signature matching in override scenario"); | |||
} | |||
public void testWildcardAnnotationMatching_pr108245() { | |||
runTest("wildcard annotation matching - pr108245"); | |||
} | |||
public void testInnerTypesAndTypeVariables() { | |||
runTest("inner types and type variables"); | |||
} | |||
// helper methods..... | |||
@@ -145,6 +145,16 @@ | |||
<message kind="warning" line = "21" text="servlet request"></message> | |||
</compile> | |||
</ajc-test> | |||
<ajc-test dir="bugs150/pr108425" pr="108245" title="wildcard annotation matching - pr108245"> | |||
<compile files="package1/Bean.java,package2/Bean.java,package2/propertyChanger.java,package3/pr108425.aj" options="-1.5"> | |||
</compile> | |||
</ajc-test> | |||
<ajc-test dir="bugs150/" pr="108104" title="inner types and type variables"> | |||
<compile files="ShapeCommandMap.java" options="-1.5"> | |||
</compile> | |||
</ajc-test> | |||
<ajc-test dir="bugs150/pr106130" pr="106130" title="test weaving with > 256 locals"> | |||
<compile files="AroundLotsOfVars.java LotsOfVars.java" options="-preserveAllLocals"/> |