diff options
author | acolyer <acolyer> | 2005-11-21 22:05:46 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2005-11-21 22:05:46 +0000 |
commit | 735d94f91a02e08bf5a1a86185b9318de4bd4319 (patch) | |
tree | cb061b2d84a35814df99d88569ff89ce5a2ba172 | |
parent | e5c3e7214edf3cd2ec84bc1e2b20ba93887b013a (diff) | |
download | aspectj-735d94f91a02e08bf5a1a86185b9318de4bd4319.tar.gz aspectj-735d94f91a02e08bf5a1a86185b9318de4bd4319.zip |
tests and fix for pr114332 - reflection api not detecting abstract itdms.
-rw-r--r-- | aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/AjTypeImpl.java | 2 | ||||
-rw-r--r-- | aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/InterTypeConstructorDeclarationImpl.java | 19 | ||||
-rw-r--r-- | aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/InterTypeDeclarationImpl.java | 2 | ||||
-rw-r--r-- | aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/InterTypeFieldDeclarationImpl.java | 12 | ||||
-rw-r--r-- | aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/InterTypeMethodDeclarationImpl.java | 22 | ||||
-rw-r--r-- | lib/aspectj/lib/aspectjrt.jar | bin | 107918 -> 108854 bytes | |||
-rw-r--r-- | lib/test/aspectjrt.jar | bin | 107918 -> 108854 bytes | |||
-rw-r--r-- | tests/java5/reflection/Billing.aj | 29 | ||||
-rw-r--r-- | tests/java5/reflection/ReflectBilling.java | 18 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java | 4 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc150/ajc150.xml | 14 |
11 files changed, 120 insertions, 2 deletions
diff --git a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/AjTypeImpl.java b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/AjTypeImpl.java index 1301a951d..60db9a2ba 100644 --- a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/AjTypeImpl.java +++ b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/AjTypeImpl.java @@ -585,7 +585,7 @@ public class AjTypeImpl<T> implements AjType<T> { List<InterTypeMethodDeclaration> itdms = new ArrayList<InterTypeMethodDeclaration>(); Method[] baseMethods = clazz.getDeclaredMethods(); for (Method m : baseMethods) { - if (!m.getName().contains("ajc$interMethod$")) continue; + if (!m.getName().contains("ajc$interMethodDispatch1$")) continue; if (m.isAnnotationPresent(ajcITD.class)) { ajcITD ann = m.getAnnotation(ajcITD.class); InterTypeMethodDeclaration itdm = diff --git a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/InterTypeConstructorDeclarationImpl.java b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/InterTypeConstructorDeclarationImpl.java index 7a84c7d12..9b80263a3 100644 --- a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/InterTypeConstructorDeclarationImpl.java +++ b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/InterTypeConstructorDeclarationImpl.java @@ -77,5 +77,24 @@ public class InterTypeConstructorDeclarationImpl extends } return ret; } + + public String toString() { + StringBuffer sb = new StringBuffer(); + sb.append(java.lang.reflect.Modifier.toString(getModifiers())); + sb.append(" "); + sb.append(this.targetTypeName); + sb.append(".new"); + sb.append("("); + AjType<?>[] pTypes = getParameterTypes(); + for(int i = 0; i < (pTypes.length - 1); i++) { + sb.append(pTypes[i].toString()); + sb.append(", "); + } + if (pTypes.length > 0) { + sb.append(pTypes[pTypes.length -1].toString()); + } + sb.append(")"); + return sb.toString(); + } } diff --git a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/InterTypeDeclarationImpl.java b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/InterTypeDeclarationImpl.java index a3def1030..b4bb23aab 100644 --- a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/InterTypeDeclarationImpl.java +++ b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/InterTypeDeclarationImpl.java @@ -21,7 +21,7 @@ import org.aspectj.lang.reflect.InterTypeDeclaration; public class InterTypeDeclarationImpl implements InterTypeDeclaration { private AjType<?> declaringType; - private String targetTypeName; + protected String targetTypeName; private AjType<?> targetType; private int modifiers; diff --git a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/InterTypeFieldDeclarationImpl.java b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/InterTypeFieldDeclarationImpl.java index 5cca0b360..2370919c0 100644 --- a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/InterTypeFieldDeclarationImpl.java +++ b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/InterTypeFieldDeclarationImpl.java @@ -74,5 +74,17 @@ public class InterTypeFieldDeclarationImpl extends InterTypeDeclarationImpl public Type getGenericType() { return this.genericType; } + + public String toString() { + StringBuffer sb = new StringBuffer(); + sb.append(java.lang.reflect.Modifier.toString(getModifiers())); + sb.append(" "); + sb.append(getType().toString()); + sb.append(" "); + sb.append(this.targetTypeName); + sb.append("."); + sb.append(getName()); + return sb.toString(); + } } diff --git a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/InterTypeMethodDeclarationImpl.java b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/InterTypeMethodDeclarationImpl.java index 25688441d..2ed2f89cf 100644 --- a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/InterTypeMethodDeclarationImpl.java +++ b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/InterTypeMethodDeclarationImpl.java @@ -122,5 +122,27 @@ public class InterTypeMethodDeclarationImpl extends InterTypeDeclarationImpl } return ret; } + + public String toString() { + StringBuffer sb = new StringBuffer(); + sb.append(java.lang.reflect.Modifier.toString(getModifiers())); + sb.append(" "); + sb.append(getReturnType().toString()); + sb.append(" "); + sb.append(this.targetTypeName); + sb.append("."); + sb.append(getName()); + sb.append("("); + AjType<?>[] pTypes = getParameterTypes(); + for(int i = 0; i < (pTypes.length - 1); i++) { + sb.append(pTypes[i].toString()); + sb.append(", "); + } + if (pTypes.length > 0) { + sb.append(pTypes[pTypes.length -1].toString()); + } + sb.append(")"); + return sb.toString(); + } } diff --git a/lib/aspectj/lib/aspectjrt.jar b/lib/aspectj/lib/aspectjrt.jar Binary files differindex 6ef865ea7..a47f9eb9d 100644 --- a/lib/aspectj/lib/aspectjrt.jar +++ b/lib/aspectj/lib/aspectjrt.jar diff --git a/lib/test/aspectjrt.jar b/lib/test/aspectjrt.jar Binary files differindex 6ef865ea7..a47f9eb9d 100644 --- a/lib/test/aspectjrt.jar +++ b/lib/test/aspectjrt.jar diff --git a/tests/java5/reflection/Billing.aj b/tests/java5/reflection/Billing.aj new file mode 100644 index 000000000..0c9923ea4 --- /dev/null +++ b/tests/java5/reflection/Billing.aj @@ -0,0 +1,29 @@ +public aspect Billing { + + public Customer Connection.payer; + + /** + * Connections give the appropriate call rate + */ + public abstract long Connection.callRate(); + + public long LongDistance.callRate() { return 1; } + public long Local.callRate() { return 2; } + + /** + * Customers have a bill paying aspect with state + */ + public long Customer.totalCharge = 0; + + public void Customer.addCharge(long charge){ + totalCharge += charge; + } +} + +class Customer {} + +abstract class Connection {} + +class LongDistance extends Connection {} + +class Local extends Connection {} diff --git a/tests/java5/reflection/ReflectBilling.java b/tests/java5/reflection/ReflectBilling.java new file mode 100644 index 000000000..c93292cb1 --- /dev/null +++ b/tests/java5/reflection/ReflectBilling.java @@ -0,0 +1,18 @@ +import org.aspectj.lang.reflect.*; + +public class ReflectBilling { + + public static void main(String[] args) { + AjType<Billing> billingType = AjTypeSystem.getAjType(Billing.class); + InterTypeMethodDeclaration[] itdms = billingType.getDeclaredITDMethods(); + for(InterTypeMethodDeclaration itdm : itdms) { + System.out.println(itdm); + } + InterTypeFieldDeclaration[] itdfs = billingType.getDeclaredITDFields(); + for(InterTypeFieldDeclaration itdf : itdfs) { + System.out.println(itdf); + } + } + + +}
\ No newline at end of file diff --git a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java index ff1f25e62..a0cf54cff 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java @@ -721,6 +721,10 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase { public void testPointcutParsingOfCompiledPointcuts() { runTest("pointcut parsing with ajc compiled pointcut references"); } + + public void testReflectionOfAbstractITDs() { + runTest("reflection on abstract ITDs (Billing example)"); + } /* * Load-time weaving bugs diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml index ec3a692c8..7920840f4 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml @@ -66,6 +66,20 @@ <compile files="PointcutLibrary.aj,ReflectOnAjcCompiledPointcuts.java" options="-1.5"></compile> <run class="ReflectOnAjcCompiledPointcuts" classpath="../lib/bcel/bcel.jar"/> </ajc-test> + + <ajc-test dir="java5/reflection" pr="114322" title="reflection on abstract ITDs (Billing example)"> + <compile files="ReflectBilling.java,Billing.aj" options="-1.5"/> + <run class="ReflectBilling"> + <stdout> + <line text="public abstract long Connection.callRate()"/> + <line text="public long LongDistance.callRate()"/> + <line text="public long Local.callRate()"/> + <line text="public void Customer.addCharge(long)"/> + <line text="public Customer Connection.payer"/> + <line text="public long Customer.totalCharge"/> + </stdout> + </run> + </ajc-test> <ajc-test dir="bugs150/pr114436" title="ClassFormatError binary weaving perthis"> <compile files="SimpleTrace.aj,ConcreteSimpleTracing.aj" outjar="aspects.jar"/> |