From: aclement Date: Tue, 21 Oct 2008 15:25:26 +0000 (+0000) Subject: 246125: move dependencies on bcel out of org.aspectj.weaver.ast org.aspectj.weaver... X-Git-Tag: V1_6_3rc1~158 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2395fc9e8f1b0b4a5fe9c15861d5afb5d8bd9858;p=aspectj.git 246125: move dependencies on bcel out of org.aspectj.weaver.ast org.aspectj.weaver.patterns --- diff --git a/weaver/src/org/aspectj/weaver/PoliceExtensionUse.java b/weaver/src/org/aspectj/weaver/PoliceExtensionUse.java new file mode 100644 index 000000000..e35a9b8a3 --- /dev/null +++ b/weaver/src/org/aspectj/weaver/PoliceExtensionUse.java @@ -0,0 +1,80 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.weaver; + +import org.aspectj.bridge.IMessage; +import org.aspectj.bridge.MessageUtil; +import org.aspectj.weaver.patterns.AbstractPatternNodeVisitor; +import org.aspectj.weaver.patterns.AndPointcut; +import org.aspectj.weaver.patterns.KindedPointcut; +import org.aspectj.weaver.patterns.NotPointcut; +import org.aspectj.weaver.patterns.OrPointcut; +import org.aspectj.weaver.patterns.Pointcut; + +/** + * Walks a pointcut and determines if the synchronization related designators have been used: lock() or unlock() + */ +public class PoliceExtensionUse extends AbstractPatternNodeVisitor { + + private boolean synchronizationDesignatorEncountered; + private World world; + private Pointcut p; + + public PoliceExtensionUse(World w, Pointcut p) { + this.world = w; + this.p = p; + this.synchronizationDesignatorEncountered = false; + } + + public boolean synchronizationDesignatorEncountered() { + return synchronizationDesignatorEncountered; + } + + public Object visit(KindedPointcut node, Object data) { + if (world == null) + return super.visit(node, data); // error scenario can sometimes lead to this LazyClassGen.toLongString() + if (node.getKind() == Shadow.SynchronizationLock || node.getKind() == Shadow.SynchronizationUnlock) + synchronizationDesignatorEncountered = true; + // Check it! + if (!world.isJoinpointSynchronizationEnabled()) { + if (node.getKind() == Shadow.SynchronizationLock) { + IMessage m = MessageUtil.warn( + "lock() pointcut designator cannot be used without the option -Xjoinpoints:synchronization", p + .getSourceLocation()); + world.getMessageHandler().handleMessage(m); + } else if (node.getKind() == Shadow.SynchronizationUnlock) { + IMessage m = MessageUtil.warn( + "unlock() pointcut designator cannot be used without the option -Xjoinpoints:synchronization", p + .getSourceLocation()); + world.getMessageHandler().handleMessage(m); + } + } + return super.visit(node, data); + } + + public Object visit(AndPointcut node, Object data) { + node.getLeft().accept(this, data); + node.getRight().accept(this, data); + return node; + } + + public Object visit(NotPointcut node, Object data) { + node.getNegatedPointcut().accept(this, data); + return node; + } + + public Object visit(OrPointcut node, Object data) { + node.getLeft().accept(this, data); + node.getRight().accept(this, data); + return node; + } + +} \ No newline at end of file diff --git a/weaver/src/org/aspectj/weaver/ast/Var.java b/weaver/src/org/aspectj/weaver/ast/Var.java index 3b2450d16..230cfeac6 100644 --- a/weaver/src/org/aspectj/weaver/ast/Var.java +++ b/weaver/src/org/aspectj/weaver/ast/Var.java @@ -10,7 +10,6 @@ * PARC initial implementation * ******************************************************************/ - package org.aspectj.weaver.ast; import org.aspectj.weaver.ResolvedType; @@ -20,9 +19,9 @@ public class Var extends Expr { public Var(ResolvedType variableType) { super(); - this.variableType = variableType; + this.variableType = variableType; } - + public ResolvedType getType() { return variableType; } @@ -30,8 +29,19 @@ public class Var extends Expr { public String toString() { return "(Var " + variableType + ")"; } - - public void accept(IExprVisitor v) { - v.visit(this); - } + + public void accept(IExprVisitor v) { + v.visit(this); + } + + /** + * For an annotation this will return a variable that can access a specific field of the annotation (of the specified type) TODO + * what kind of behaviour happens for two annotation fields of the same type? + * + * @param formalType + * @return + */ + public Var getAccessorForValue(ResolvedType formalType) { + throw new IllegalStateException("Only makes sense for annotation variables"); + } } diff --git a/weaver/src/org/aspectj/weaver/bcel/PoliceExtensionUse.java b/weaver/src/org/aspectj/weaver/bcel/PoliceExtensionUse.java deleted file mode 100644 index 5323c77f6..000000000 --- a/weaver/src/org/aspectj/weaver/bcel/PoliceExtensionUse.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 IBM - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Andy Clement - initial API and implementation - *******************************************************************************/ -package org.aspectj.weaver.bcel; - -import org.aspectj.bridge.IMessage; -import org.aspectj.bridge.MessageUtil; -import org.aspectj.weaver.Shadow; -import org.aspectj.weaver.World; -import org.aspectj.weaver.patterns.AbstractPatternNodeVisitor; -import org.aspectj.weaver.patterns.AndPointcut; -import org.aspectj.weaver.patterns.KindedPointcut; -import org.aspectj.weaver.patterns.NotPointcut; -import org.aspectj.weaver.patterns.OrPointcut; -import org.aspectj.weaver.patterns.Pointcut; - -/** - * Walks a pointcut and determines if the synchronization related designators have been used: lock() or unlock() - */ -public class PoliceExtensionUse extends AbstractPatternNodeVisitor { - - private boolean synchronizationDesignatorEncountered; - private World world; - private Pointcut p; - - public PoliceExtensionUse(World w, Pointcut p) { - this.world = w; - this.p = p; - this.synchronizationDesignatorEncountered = false; - } - - public boolean synchronizationDesignatorEncountered() { - return synchronizationDesignatorEncountered; - } - - public Object visit(KindedPointcut node, Object data) { - if (world == null) - return super.visit(node, data); // error scenario can sometimes lead to this LazyClassGen.toLongString() - if (node.getKind() == Shadow.SynchronizationLock || node.getKind() == Shadow.SynchronizationUnlock) - synchronizationDesignatorEncountered = true; - // Check it! - if (!world.isJoinpointSynchronizationEnabled()) { - if (node.getKind() == Shadow.SynchronizationLock) { - IMessage m = MessageUtil.warn( - "lock() pointcut designator cannot be used without the option -Xjoinpoints:synchronization", p - .getSourceLocation()); - world.getMessageHandler().handleMessage(m); - } else if (node.getKind() == Shadow.SynchronizationUnlock) { - IMessage m = MessageUtil.warn( - "unlock() pointcut designator cannot be used without the option -Xjoinpoints:synchronization", p - .getSourceLocation()); - world.getMessageHandler().handleMessage(m); - } - } - return super.visit(node, data); - } - - public Object visit(AndPointcut node, Object data) { - node.getLeft().accept(this, data); - node.getRight().accept(this, data); - return node; - } - - public Object visit(NotPointcut node, Object data) { - node.getNegatedPointcut().accept(this, data); - return node; - } - - public Object visit(OrPointcut node, Object data) { - node.getLeft().accept(this, data); - node.getRight().accept(this, data); - return node; - } - -} \ No newline at end of file diff --git a/weaver/src/org/aspectj/weaver/patterns/AnnotationPointcut.java b/weaver/src/org/aspectj/weaver/patterns/AnnotationPointcut.java index 028fbc776..184615b6a 100644 --- a/weaver/src/org/aspectj/weaver/patterns/AnnotationPointcut.java +++ b/weaver/src/org/aspectj/weaver/patterns/AnnotationPointcut.java @@ -23,6 +23,7 @@ import org.aspectj.util.FuzzyBoolean; import org.aspectj.weaver.AjcMemberMaker; import org.aspectj.weaver.AnnotatedElement; import org.aspectj.weaver.BCException; +import org.aspectj.weaver.ConcreteTypeMunger; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.Member; @@ -39,8 +40,6 @@ import org.aspectj.weaver.World; import org.aspectj.weaver.ast.Literal; import org.aspectj.weaver.ast.Test; import org.aspectj.weaver.ast.Var; -import org.aspectj.weaver.bcel.AnnotationAccessVar; -import org.aspectj.weaver.bcel.BcelTypeMunger; /** * (at)Annotation((at)Foo) or (at)Annotation(foo)
@@ -139,7 +138,7 @@ public class AnnotationPointcut extends NameBindingPointcut { // FIXME asc should include supers with getInterTypeMungersIncludingSupers ? List mungers = rMember.getDeclaringType().resolve(shadow.getIWorld()).getInterTypeMungers(); for (Iterator iter = mungers.iterator(); iter.hasNext();) { - BcelTypeMunger typeMunger = (BcelTypeMunger) iter.next(); + ConcreteTypeMunger typeMunger = (ConcreteTypeMunger) iter.next(); if (typeMunger.getMunger() instanceof NewFieldTypeMunger) { ResolvedMember fakerm = typeMunger.getSignature(); if (fakerm.equals(member)) { @@ -209,7 +208,7 @@ public class AnnotationPointcut extends NameBindingPointcut { UnresolvedType annoType = btp.getAnnotationType(); // TODO 2 need to sort out appropriate creation of the AnnotationAccessFieldVar - what happens for // reflective (ReflectionShadow) access to types? - AnnotationAccessVar var = (AnnotationAccessVar) shadow.getKindedAnnotationVar(annoType); + Var var = shadow.getKindedAnnotationVar(annoType); if (var == null) { throw new BCException("Unexpected problem locating annotation at join point '" + shadow + "'"); } diff --git a/weaver/src/org/aspectj/weaver/patterns/Pointcut.java b/weaver/src/org/aspectj/weaver/patterns/Pointcut.java index 424d623f4..784b3df17 100644 --- a/weaver/src/org/aspectj/weaver/patterns/Pointcut.java +++ b/weaver/src/org/aspectj/weaver/patterns/Pointcut.java @@ -25,6 +25,7 @@ import org.aspectj.weaver.BCException; import org.aspectj.weaver.Checker; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; +import org.aspectj.weaver.PoliceExtensionUse; import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.Shadow; import org.aspectj.weaver.ShadowMunger; @@ -32,7 +33,6 @@ import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.World; import org.aspectj.weaver.ast.Literal; import org.aspectj.weaver.ast.Test; -import org.aspectj.weaver.bcel.PoliceExtensionUse; /** * The lifecycle of Pointcuts is modeled by Pointcut.State. It has three things: