aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhugunin <jhugunin>2002-12-18 05:08:49 +0000
committerjhugunin <jhugunin>2002-12-18 05:08:49 +0000
commitd38aec6e4f0ffea34a3f46d0148c69a69408e699 (patch)
tree49fa3c9bfe1a4367c749e2adab0a7d5ec95128ac
parent80f6a5625488080cd0eeb32d54d71d4b6c9ef9a8 (diff)
downloadaspectj-d38aec6e4f0ffea34a3f46d0148c69a69408e699.tar.gz
aspectj-d38aec6e4f0ffea34a3f46d0148c69a69408e699.zip
more bug fixes for if and privileged
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/IfMethodDeclaration.java5
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeConstructorDeclaration.java2
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java2
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/SuperFixerVisitor.java3
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseWorld.java2
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/PrivilegedFieldBinding.java8
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/PrivilegedHandler.java10
-rw-r--r--weaver/src/org/aspectj/weaver/CrosscuttingMembers.java6
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java11
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java6
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/IfPointcut.java67
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/TypePatternList.java15
12 files changed, 100 insertions, 37 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/IfMethodDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/IfMethodDeclaration.java
index 1bca70dfb..fc96e272d 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/IfMethodDeclaration.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/IfMethodDeclaration.java
@@ -16,6 +16,7 @@ package org.aspectj.ajdt.internal.compiler.ast;
import org.aspectj.ajdt.internal.compiler.lookup.EclipseWorld;
import org.aspectj.weaver.*;
import org.aspectj.weaver.patterns.IfPointcut;
+import org.eclipse.jdt.internal.compiler.*;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.lookup.*;
@@ -36,6 +37,10 @@ public class IfMethodDeclaration extends MethodDeclaration {
// do nothing, we're already fully parsed
}
+ protected int generateInfoAttributes(ClassFile classFile) {
+ return classFile.generateMethodInfoAttribute(binding, AstUtil.getAjSyntheticAttribute());
+ }
+
public void resolveStatements(ClassScope upperScope) {
super.resolveStatements(upperScope);
if (binding != null) {
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeConstructorDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeConstructorDeclaration.java
index 275a3bc04..286161689 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeConstructorDeclaration.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeConstructorDeclaration.java
@@ -222,7 +222,7 @@ public class InterTypeConstructorDeclaration extends InterTypeDeclaration {
private AjAttribute makeAttribute(EclipseWorld world) {
- if (explicitConstructorCall != null) {
+ if (explicitConstructorCall != null && !(explicitConstructorCall.binding instanceof ProblemMethodBinding)) {
MethodBinding explicitConstructor = explicitConstructorCall.binding;
if (explicitConstructor.alwaysNeedsAccessMethod()) {
explicitConstructor = explicitConstructor.getAccessMethod();
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java
index 8190809ea..8b54aaf1e 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java
@@ -98,7 +98,7 @@ public class InterTypeMethodDeclaration extends InterTypeDeclaration {
public void generateCode(ClassScope classScope, ClassFile classFile) {
if (ignoreFurtherInvestigation) {
- System.err.println("no code for " + this);
+ //System.err.println("no code for " + this);
return;
}
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/SuperFixerVisitor.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/SuperFixerVisitor.java
index ab564f9f4..6e4afab54 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/SuperFixerVisitor.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/SuperFixerVisitor.java
@@ -46,6 +46,9 @@ public class SuperFixerVisitor extends AbstractSyntaxTreeVisitorAdapter {
if (call.codegenBinding == null) return;
MethodBinding superBinding = call.codegenBinding;
+ if (superBinding instanceof ProblemMethodBinding) {
+ return;
+ }
char[] accessName;
boolean isSuper;
if (call.isSuperAccess() && !call.binding.isStatic()) {
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseWorld.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseWorld.java
index f7e74ddc2..7ada86e4f 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseWorld.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseWorld.java
@@ -141,7 +141,7 @@ public class EclipseWorld extends World {
public static ResolvedMember makeResolvedMember(MethodBinding binding) {
return new ResolvedMember(
- Member.METHOD,
+ binding.isConstructor() ? Member.CONSTRUCTOR : Member.METHOD,
fromBinding(binding.declaringClass),
binding.modifiers,
fromBinding(binding.returnType),
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/PrivilegedFieldBinding.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/PrivilegedFieldBinding.java
index bd5ac958a..d8e7107ee 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/PrivilegedFieldBinding.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/PrivilegedFieldBinding.java
@@ -19,6 +19,7 @@ import org.aspectj.ajdt.internal.compiler.ast.*;
import org.aspectj.ajdt.internal.compiler.ast.AstUtil;
import org.aspectj.weaver.*;
import org.aspectj.weaver.NameMangler;
+import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
import org.eclipse.jdt.internal.compiler.impl.Constant;
import org.eclipse.jdt.internal.compiler.lookup.*;
@@ -43,6 +44,9 @@ public class PrivilegedFieldBinding extends FieldBinding {
AjcMemberMaker.privilegedAccessMethodForFieldSet(
inAspect.typeX, inAspect.world.makeResolvedMember(baseField)
)));
+
+ this.constant = AstNode.NotAConstant;
+ this.baseField = baseField;
}
@@ -59,8 +63,10 @@ public class PrivilegedFieldBinding extends FieldBinding {
public boolean alwaysNeedsAccessMethod(boolean isReadAccess) { return true; }
-
+ public FieldBinding getFieldBindingForLookup() { return baseField; }
+
+ public String toString() { return "PrivilegedWrapper(" + baseField + ")"; }
// public ReferenceBinding getTargetType() {
// return introducedField.declaringClass;
// }
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/PrivilegedHandler.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/PrivilegedHandler.java
index 640df12b0..ecf773c76 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/PrivilegedHandler.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/PrivilegedHandler.java
@@ -40,9 +40,15 @@ public class PrivilegedHandler implements IPrivilegedHandler {
public MethodBinding getPrivilegedAccessMethod(MethodBinding baseMethod) {
ResolvedMember key = inAspect.world.makeResolvedMember(baseMethod);
if (accessors.containsKey(key)) return (MethodBinding)accessors.get(key);
- MethodBinding ret = inAspect.world.makeMethodBinding(
+
+ MethodBinding ret;
+ if (baseMethod.isConstructor()) {
+ ret = baseMethod;
+ } else {
+ ret = inAspect.world.makeMethodBinding(
AjcMemberMaker.privilegedAccessMethodForMethod(inAspect.typeX, key)
- );
+ );
+ }
//new PrivilegedMethodBinding(inAspect, baseMethod);
accessors.put(key, ret);
diff --git a/weaver/src/org/aspectj/weaver/CrosscuttingMembers.java b/weaver/src/org/aspectj/weaver/CrosscuttingMembers.java
index 8635cdaf6..24c21cc6a 100644
--- a/weaver/src/org/aspectj/weaver/CrosscuttingMembers.java
+++ b/weaver/src/org/aspectj/weaver/CrosscuttingMembers.java
@@ -95,7 +95,11 @@ public class CrosscuttingMembers {
} else if (declare instanceof DeclareDominates) {
declareDominates.add(declare);
} else if (declare instanceof DeclareParents) {
- declareParents.add(declare);
+ DeclareParents dp = (DeclareParents)declare;
+ for (Iterator i = dp.getParents().collectAccessTypeMungers(world).iterator(); i.hasNext(); ) {
+ addTypeMunger(world.concreteTypeMunger((PrivilegedAccessMunger)i.next(), inAspect));
+ }
+ declareParents.add(dp);
} else if (declare instanceof DeclareSoft) {
DeclareSoft d = (DeclareSoft)declare;
Pointcut concretePointcut = d.getPointcut().concretize(inAspect, 0);
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java
index 63ab93d0c..bee6db29f 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java
@@ -72,6 +72,17 @@ public class BcelTypeMunger extends ConcreteTypeMunger {
addMethodDispatch(gen, member,
AjcMemberMaker.privilegedAccessMethodForMethod(aspectType, member));
return true;
+ } else if (member.getKind() == Member.CONSTRUCTOR) {
+ for (Iterator i = gen.getMethodGens().iterator(); i.hasNext(); ) {
+ LazyMethodGen m = (LazyMethodGen)i.next();
+ if (m.getMemberView() != null && m.getMemberView().getKind() == Member.CONSTRUCTOR) {
+ // m.getMemberView().equals(member)) {
+ m.forcePublic();
+ //return true;
+ }
+ }
+ return true;
+ //throw new BCException("no match for " + member + " in " + gen);
} else if (member.getKind() == Member.STATIC_INITIALIZATION) {
gen.forcePublic();
return true;
diff --git a/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java b/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java
index 35648dc5f..326f5426b 100644
--- a/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java
+++ b/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java
@@ -38,7 +38,7 @@ import org.aspectj.weaver.*;
*/
public final class LazyMethodGen {
- private final int accessFlags;
+ private int accessFlags;
private final Type returnType;
private final String name;
private final Type[] argumentTypes;
@@ -1060,4 +1060,8 @@ public final class LazyMethodGen {
return memberView;
}
+ public void forcePublic() {
+ accessFlags = Utility.makePublic(accessFlags);
+ }
+
}
diff --git a/weaver/src/org/aspectj/weaver/patterns/IfPointcut.java b/weaver/src/org/aspectj/weaver/patterns/IfPointcut.java
index 8a5d54ea9..1f0bac258 100644
--- a/weaver/src/org/aspectj/weaver/patterns/IfPointcut.java
+++ b/weaver/src/org/aspectj/weaver/patterns/IfPointcut.java
@@ -73,34 +73,39 @@ public class IfPointcut extends Pointcut {
return "if(" + testMethod + ")";
}
+ private boolean findingResidue = false;
public Test findResidue(Shadow shadow, ExposedState state) {
- if (residueSource == null) return Literal.TRUE; //???
-
- ExposedState myState = new ExposedState(baseArgsCount);
- //System.out.println(residueSource);
- residueSource.findResidue(shadow, myState); // don't care about Test
-
- //System.out.println(myState);
-
- List args = new ArrayList();
- for (int i=0; i < baseArgsCount; i++) {
- args.add(myState.get(i));
- }
-
- // handle thisJoinPoint parameters
- if ((extraParameterFlags & Advice.ThisJoinPoint) != 0) {
- args.add(shadow.getThisJoinPointVar());
- }
-
- if ((extraParameterFlags & Advice.ThisJoinPointStaticPart) != 0) {
- args.add(shadow.getThisJoinPointStaticPartVar());
- }
-
- if ((extraParameterFlags & Advice.ThisEnclosingJoinPointStaticPart) != 0) {
- args.add(shadow.getThisEnclosingJoinPointStaticPartVar());
- }
-
- return Test.makeCall(testMethod, (Expr[])args.toArray(new Expr[args.size()]));
+ if (findingResidue) return Literal.TRUE;
+ findingResidue = true;
+ try {
+ ExposedState myState = new ExposedState(baseArgsCount);
+ //System.out.println(residueSource);
+ residueSource.findResidue(shadow, myState); // don't care about Test
+
+ //System.out.println(myState);
+
+ List args = new ArrayList();
+ for (int i=0; i < baseArgsCount; i++) {
+ args.add(myState.get(i));
+ }
+
+ // handle thisJoinPoint parameters
+ if ((extraParameterFlags & Advice.ThisJoinPoint) != 0) {
+ args.add(shadow.getThisJoinPointVar());
+ }
+
+ if ((extraParameterFlags & Advice.ThisJoinPointStaticPart) != 0) {
+ args.add(shadow.getThisJoinPointStaticPartVar());
+ }
+
+ if ((extraParameterFlags & Advice.ThisEnclosingJoinPointStaticPart) != 0) {
+ args.add(shadow.getThisEnclosingJoinPointStaticPartVar());
+ }
+
+ return Test.makeCall(testMethod, (Expr[])args.toArray(new Expr[args.size()]));
+ } finally {
+ findingResidue = false;
+ }
}
@@ -108,10 +113,14 @@ public class IfPointcut extends Pointcut {
return this.concretize1(inAspect, bindings);
}
+ private IfPointcut partiallyConcretized = null;
public Pointcut concretize1(ResolvedTypeX inAspect, IntMap bindings) {
+ //System.err.println("concretize: " + this + " already: " + partiallyConcretized);
+ if (partiallyConcretized != null) {
+ return partiallyConcretized;
+ }
IfPointcut ret = new IfPointcut(testMethod, extraParameterFlags);
- if (this.state == CONCRETE) return ret;
- this.state = CONCRETE;
+ partiallyConcretized = ret;
if (bindings.directlyInAdvice()) {
Advice advice = bindings.getEnclosingAdvice();
ret.baseArgsCount = advice.getBaseParameterCount();
diff --git a/weaver/src/org/aspectj/weaver/patterns/TypePatternList.java b/weaver/src/org/aspectj/weaver/patterns/TypePatternList.java
index c4ccc1bd9..c3a741578 100644
--- a/weaver/src/org/aspectj/weaver/patterns/TypePatternList.java
+++ b/weaver/src/org/aspectj/weaver/patterns/TypePatternList.java
@@ -14,6 +14,7 @@
package org.aspectj.weaver.patterns;
import java.io.*;
+import java.lang.reflect.Modifier;
import java.util.*;
import org.aspectj.weaver.*;
@@ -231,4 +232,18 @@ public class TypePatternList extends PatternNode {
return typePatterns;
}
+ public Collection collectAccessTypeMungers(World world) {
+ ArrayList ret = new ArrayList();
+ for (int i=0; i<typePatterns.length; i++) {
+ TypeX t = typePatterns[i].getExactType();
+ ResolvedTypeX rt = t.resolve(world);
+ if (!Modifier.isPublic(rt.getModifiers())) {
+ ret.add(new PrivilegedAccessMunger(new ResolvedMember(
+ Member.STATIC_INITIALIZATION, rt, 0, ResolvedTypeX.VOID, "", TypeX.NONE
+ )));
+ }
+ }
+ return ret;
+ }
+
}