diff options
author | acolyer <acolyer> | 2005-08-30 11:39:23 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2005-08-30 11:39:23 +0000 |
commit | 2ec1f35b5c9f4374970fbe33f1be86dc615253ab (patch) | |
tree | 75da6fd3b5bfa1d3bae91ad547a5c2f0ddbd9b50 /tests/bugs150 | |
parent | 27e68f3b3ae82408e8e046a40ab69d9e4996ff5a (diff) | |
download | aspectj-2ec1f35b5c9f4374970fbe33f1be86dc615253ab.tar.gz aspectj-2ec1f35b5c9f4374970fbe33f1be86dc615253ab.zip |
tests for pr108425 and pr108104
Diffstat (limited to 'tests/bugs150')
-rw-r--r-- | tests/bugs150/ShapeCommandMap.java | 73 | ||||
-rw-r--r-- | tests/bugs150/pr108245.aj | 40 | ||||
-rw-r--r-- | tests/bugs150/pr108425/package1/Bean.java | 16 | ||||
-rw-r--r-- | tests/bugs150/pr108425/package2/Bean.java | 17 | ||||
-rw-r--r-- | tests/bugs150/pr108425/package2/propertyChanger.java | 9 | ||||
-rw-r--r-- | tests/bugs150/pr108425/package3/pr108425.aj | 18 |
6 files changed, 173 insertions, 0 deletions
diff --git a/tests/bugs150/ShapeCommandMap.java b/tests/bugs150/ShapeCommandMap.java new file mode 100644 index 000000000..38d820841 --- /dev/null +++ b/tests/bugs150/ShapeCommandMap.java @@ -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"); + } +} diff --git a/tests/bugs150/pr108245.aj b/tests/bugs150/pr108245.aj new file mode 100644 index 000000000..8c19ca435 --- /dev/null +++ b/tests/bugs150/pr108245.aj @@ -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); + } + +}
\ No newline at end of file diff --git a/tests/bugs150/pr108425/package1/Bean.java b/tests/bugs150/pr108425/package1/Bean.java new file mode 100644 index 000000000..c5ded617f --- /dev/null +++ b/tests/bugs150/pr108425/package1/Bean.java @@ -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; + } +}
\ No newline at end of file diff --git a/tests/bugs150/pr108425/package2/Bean.java b/tests/bugs150/pr108425/package2/Bean.java new file mode 100644 index 000000000..0e00d4dc7 --- /dev/null +++ b/tests/bugs150/pr108425/package2/Bean.java @@ -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; + } +}
\ No newline at end of file diff --git a/tests/bugs150/pr108425/package2/propertyChanger.java b/tests/bugs150/pr108425/package2/propertyChanger.java new file mode 100644 index 000000000..24cc0c58f --- /dev/null +++ b/tests/bugs150/pr108425/package2/propertyChanger.java @@ -0,0 +1,9 @@ +package package2; + +import java.lang.annotation.*; +import java.lang.*; + +@Retention( RetentionPolicy.RUNTIME ) +@Target({ ElementType.METHOD }) +public @interface propertyChanger { +}
\ No newline at end of file diff --git a/tests/bugs150/pr108425/package3/pr108425.aj b/tests/bugs150/pr108425/package3/pr108425.aj new file mode 100644 index 000000000..55301431c --- /dev/null +++ b/tests/bugs150/pr108425/package3/pr108425.aj @@ -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); + } + +}
\ No newline at end of file |