summaryrefslogtreecommitdiffstats
path: root/weaver
diff options
context:
space:
mode:
authoraclement <aclement>2006-10-18 14:46:29 +0000
committeraclement <aclement>2006-10-18 14:46:29 +0000
commitdb68044fe8ea0f43a5e090a67b9410f4c334bff6 (patch)
tree02010767f1a7500610a58abfe41e71c6539ea6f5 /weaver
parent1a2eef067f87e9037bd39f20d4c682c642689de8 (diff)
downloadaspectj-db68044fe8ea0f43a5e090a67b9410f4c334bff6.tar.gz
aspectj-db68044fe8ea0f43a5e090a67b9410f4c334bff6.zip
test and fix for 123423: getWithinTypeName() for ptw aspects
Diffstat (limited to 'weaver')
-rw-r--r--weaver/src/org/aspectj/weaver/AjcMemberMaker.java14
-rw-r--r--weaver/src/org/aspectj/weaver/NameMangler.java1
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelPerClauseAspectAdder.java18
3 files changed, 32 insertions, 1 deletions
diff --git a/weaver/src/org/aspectj/weaver/AjcMemberMaker.java b/weaver/src/org/aspectj/weaver/AjcMemberMaker.java
index 382780014..8ca2c511b 100644
--- a/weaver/src/org/aspectj/weaver/AjcMemberMaker.java
+++ b/weaver/src/org/aspectj/weaver/AjcMemberMaker.java
@@ -189,6 +189,20 @@ public class AjcMemberMaker {
);
return rm;
}
+
+ // PTWIMPL ResolvedMember for getWithinTypeName() method
+ public static ResolvedMember perTypeWithinGetWithinTypeNameMethod(UnresolvedType declaringType, boolean inJava5Mode) {
+ // public String getWithinTypeName()
+ ResolvedMemberImpl rm = new ResolvedMemberImpl(
+ Member.METHOD,
+ declaringType,
+ Modifier.PUBLIC,
+ UnresolvedType.JAVA_LANG_STRING, // return value
+ NameMangler.PERTYPEWITHIN_GETWITHINTYPENAME_METHOD,
+ UnresolvedType.NONE
+ );
+ return rm;
+ }
public static ResolvedMember perTypeWithinCreateAspectInstance(UnresolvedType declaringType) {
// public static a.X ajc$createAspectInstance(java.lang.String)
diff --git a/weaver/src/org/aspectj/weaver/NameMangler.java b/weaver/src/org/aspectj/weaver/NameMangler.java
index faf06df83..47531910a 100644
--- a/weaver/src/org/aspectj/weaver/NameMangler.java
+++ b/weaver/src/org/aspectj/weaver/NameMangler.java
@@ -47,6 +47,7 @@ public class NameMangler {
public static final String PERTYPEWITHIN_GETINSTANCE_METHOD = PREFIX + "getInstance";
public static final String PERTYPEWITHIN_CREATEASPECTINSTANCE_METHOD = PREFIX + "createAspectInstance";
public static final String PERTYPEWITHIN_WITHINTYPEFIELD = PREFIX + "withinType";
+ public static final String PERTYPEWITHIN_GETWITHINTYPENAME_METHOD = "getWithinTypeName";
public static final String AJC_PRE_CLINIT_NAME = PREFIX + "preClinit";
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelPerClauseAspectAdder.java b/weaver/src/org/aspectj/weaver/bcel/BcelPerClauseAspectAdder.java
index 38d385691..a3aa3926d 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelPerClauseAspectAdder.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelPerClauseAspectAdder.java
@@ -124,6 +124,7 @@ public class BcelPerClauseAspectAdder extends BcelTypeMunger {
generatePerTWHasAspectMethod(gen);
generatePerTWGetInstanceMethod(gen);
generatePerTWCreateAspectInstanceMethod(gen);
+ generatePerTWGetWithinTypeNameMethod(gen);
} else {
throw new Error("should not happen - not such kind " + kind.getName());
}
@@ -177,7 +178,7 @@ public class BcelPerClauseAspectAdder extends BcelTypeMunger {
// pr144602 - don't need to do this, PerObjectInterface munger will do it
// } else if (kind == PerClause.PEROBJECT) {
// ResolvedMember perObjectFieldInfo = AjcMemberMaker.perObjectField(aspectType, aspectType);
-// classGen.addField(makeFieldGen(classGen, perObjectFieldInfo).getField(), null);
+// classGen.addField(makeFieldGen(classGen, perObjectFieldInfo).(), null);
// // if lazy generation of the inner interface MayHaveAspect works on LTW (see previous note)
// // it should be done here.
} else if (kind == PerClause.PERCFLOW) {
@@ -471,6 +472,21 @@ public class BcelPerClauseAspectAdder extends BcelTypeMunger {
);
}
+ // Create 'public String getWithinTypeName() { return ajc$withinType;}'
+ private void generatePerTWGetWithinTypeNameMethod(LazyClassGen classGen) {
+ InstructionFactory factory = classGen.getFactory();
+ LazyMethodGen method = makeMethodGen(classGen, AjcMemberMaker.perTypeWithinGetWithinTypeNameMethod(aspectType,classGen.getWorld().isInJava5Mode()));
+ flagAsSynthetic(method, false);
+ classGen.addMethodGen(method);
+ // 0: aload_0
+ // 1: getfield #14; //Field ajc$withinType:Ljava/lang/String;
+ // 4: areturn
+ InstructionList il = method.getBody();
+ il.append(InstructionConstants.ALOAD_0);
+ il.append(Utility.createGet(factory, AjcMemberMaker.perTypeWithinWithinTypeField(aspectType, aspectType)));
+ il.append(InstructionConstants.ARETURN);
+ }
+
private void generatePerTWHasAspectMethod(LazyClassGen classGen) {
InstructionFactory factory = classGen.getFactory();
LazyMethodGen method = makeMethodGen(classGen, AjcMemberMaker.perTypeWithinHasAspectMethod(aspectType,classGen.getWorld().isInJava5Mode()));