summaryrefslogtreecommitdiffstats
path: root/org.aspectj.ajdt.core/src
diff options
context:
space:
mode:
authoraclement <aclement>2004-08-09 10:26:53 +0000
committeraclement <aclement>2004-08-09 10:26:53 +0000
commit851da68a07bcbfac4414fadc1b9f3bc02fa810a5 (patch)
tree8774e959f018037db9891f447e4f7070c0cc8a71 /org.aspectj.ajdt.core/src
parent299d24a82619057d3746db391afb238c213d56e5 (diff)
downloadaspectj-851da68a07bcbfac4414fadc1b9f3bc02fa810a5.tar.gz
aspectj-851da68a07bcbfac4414fadc1b9f3bc02fa810a5.zip
Fix for Bug 71377: Cannot advise private method call in around advice
Diffstat (limited to 'org.aspectj.ajdt.core/src')
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java46
1 files changed, 39 insertions, 7 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java
index 432e4f76c..df0c5aeeb 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java
@@ -288,10 +288,38 @@ public class AspectDeclaration extends TypeDeclaration {
}
private void generateMethod(ClassFile classFile, MethodBinding methodBinding, BodyGenerator gen) {
+ generateMethod(classFile,methodBinding,null,gen);
+ }
+
+ protected List makeEffectiveSignatureAttribute(ResolvedMember sig,Shadow.Kind kind,boolean weaveBody) {
+ List l = new ArrayList(1);
+ l.add(new EclipseAttributeAdapter(
+ new AjAttribute.EffectiveSignatureAttribute(sig, kind, weaveBody)));
+ return l;
+ }
+
+ /*
+ * additionalAttributes allows us to pass some optional attributes we want to attach to the method we generate.
+ * Currently this is used for inline accessor methods that have been generated to allow private field references or
+ * private method calls to be inlined (PR71377). In these cases the optional attribute is an effective signature
+ * attribute which means calls to these methods are able to masquerade as any join point (a field set, field get or
+ * method call). The effective signature attribute is 'unwrapped' in BcelClassWeaver.matchInvokeInstruction()
+ */
+ private void generateMethod(ClassFile classFile, MethodBinding methodBinding, List additionalAttributes/*ResolvedMember realMember*/, BodyGenerator gen) {
// EclipseFactory world = EclipseFactory.fromScopeLookupEnvironment(this.scope);
classFile.generateMethodInfoHeader(methodBinding);
int methodAttributeOffset = classFile.contentsOffset;
- int attributeNumber = classFile.generateMethodInfoAttribute(methodBinding, AstUtil.getAjSyntheticAttribute());
+
+ int attributeNumber;
+ if (additionalAttributes!=null) { // mini optimization
+ List attrs = new ArrayList();
+ attrs.addAll(AstUtil.getAjSyntheticAttribute());
+ attrs.addAll(additionalAttributes);
+ attributeNumber = classFile.generateMethodInfoAttribute(methodBinding, attrs);
+ } else {
+ attributeNumber = classFile.generateMethodInfoAttribute(methodBinding, AstUtil.getAjSyntheticAttribute());
+ }
+
int codeAttributeOffset = classFile.contentsOffset;
classFile.generateCodeAttributeHeader();
CodeStream codeStream = classFile.codeStream;
@@ -644,9 +672,11 @@ public class AspectDeclaration extends TypeDeclaration {
}
private void generateInlineAccessors(ClassFile classFile, final InlineAccessFieldBinding accessField, final ResolvedMember field) {
- final FieldBinding fieldBinding = factory.makeFieldBinding(field);
- generateMethod(classFile, accessField.reader,
- new BodyGenerator() {
+ final FieldBinding fieldBinding = factory.makeFieldBinding(field);
+
+ generateMethod(classFile, accessField.reader,
+ makeEffectiveSignatureAttribute(field,Shadow.FieldGet,false),
+ new BodyGenerator() {
public void generate(CodeStream codeStream) {
// body starts here
if (field.isStatic()) {
@@ -661,7 +691,8 @@ public class AspectDeclaration extends TypeDeclaration {
}});
generateMethod(classFile, accessField.writer,
- new BodyGenerator() {
+ makeEffectiveSignatureAttribute(field,Shadow.FieldSet,false),
+ new BodyGenerator() {
public void generate(CodeStream codeStream) {
// body starts here
if (field.isStatic()) {
@@ -681,8 +712,9 @@ public class AspectDeclaration extends TypeDeclaration {
private void generateInlineAccessMethod(ClassFile classFile, final MethodBinding accessMethod, final ResolvedMember method) {
- generateMethod(classFile, accessMethod,
- new BodyGenerator() {
+ generateMethod(classFile, accessMethod,
+ makeEffectiveSignatureAttribute(method, Shadow.MethodCall, false),
+ new BodyGenerator() {
public void generate(CodeStream codeStream) {
// body starts here