return ret;
}
+ public boolean copySourceContext() {
+ return true;
+ }
+
}
\ No newline at end of file
import java.lang.reflect.Modifier;
-import org.aspectj.weaver.bcel.LazyClassGen;
-
public class NameMangler {
// public static final char[] AJC_DOLLAR_PREFIX = { 'a', 'j', 'c', '$' };
return enclosingType.getName() + "$AjcClosure" + index;
}
- public static String aroundCallbackMethodName(Member shadowSig, LazyClassGen enclosingType) {
+ public static String aroundCallbackMethodName(Member shadowSig, String suffixTag) {
StringBuffer ret = new StringBuffer();
- ret.append(getExtractableName(shadowSig)).append("_aroundBody").append(enclosingType.getNewGeneratedNameTag());
+ ret.append(getExtractableName(shadowSig)).append("_aroundBody").append(suffixTag);
return ret.toString();
}
import java.util.Map;
import org.aspectj.bridge.ISourceLocation;
-import org.aspectj.weaver.bcel.BcelObjectType;
import org.aspectj.weaver.patterns.Declare;
import org.aspectj.weaver.patterns.PerClause;
public void setDelegate(ReferenceTypeDelegate delegate) {
// Don't copy from BcelObjectType to EclipseSourceType - the context may
// be tidied (result null'd) after previous weaving
- if (this.delegate != null && !(this.delegate instanceof BcelObjectType)
+ if (this.delegate != null && this.delegate.copySourceContext()
&& this.delegate.getSourceContext() != SourceContextImpl.UNKNOWN_SOURCE_CONTEXT)
((AbstractReferenceTypeDelegate) delegate).setSourceContext(this.delegate.getSourceContext());
this.delegate = delegate;
import org.aspectj.weaver.patterns.PerClause;
/**
- * Abstraction over a type - a reference type is Object and a descendant of
- * Object, other types (int/etc) are considered primitive types. Abstract
- * implementation provided by AbstractReferenceTypeDelegate.
+ * Abstraction over a type - a reference type is Object and a descendant of Object, other types (int/etc) are considered primitive
+ * types. Abstract implementation provided by AbstractReferenceTypeDelegate.
*/
public interface ReferenceTypeDelegate {
public ResolvedType getOuterClass();
+ public boolean copySourceContext();
+
}
\ No newline at end of file
import java.util.Set;
import java.util.WeakHashMap;
-import org.aspectj.asm.AsmManager;
import org.aspectj.bridge.IMessageHandler;
import org.aspectj.bridge.ISourceLocation;
import org.aspectj.bridge.Message;
import org.aspectj.bridge.MessageUtil;
import org.aspectj.bridge.IMessage.Kind;
import org.aspectj.bridge.context.PinpointingMessageHandler;
+import org.aspectj.util.IStructureModel;
import org.aspectj.weaver.UnresolvedType.TypeKind;
import org.aspectj.weaver.patterns.DeclarePrecedence;
import org.aspectj.weaver.patterns.Pointcut;
/** All of the type and shadow mungers known to us */
private final CrosscuttingMembersSet crosscuttingMembersSet = new CrosscuttingMembersSet(this);
- /** Model holds ASM relationships */
- private AsmManager model = null;
+ /** The structure model for the compilation */
+ private IStructureModel model = null;
/** for processing Xlint messages */
private Lint lint = new Lint(this);
return crosscuttingMembersSet;
}
- public AsmManager getModel() {
+ public IStructureModel getModel() {
return model;
}
- public void setModel(AsmManager model) {
+ public void setModel(IStructureModel model) {
this.model = model;
}
mg.addAnnotation(decaM.getAnnotationX());
AsmRelationshipProvider.getDefault().addDeclareAnnotationMethodRelationship(decaM.getSourceLocation(),
- clazz.getName(), mg.getMemberView(), world.getModel());// getMethod());
+ clazz.getName(), mg.getMemberView(), world.getModelAsAsmManager());// getMethod());
reportMethodCtorWeavingMessage(clazz, mg.getMemberView(), decaM, mg.getDeclarationLineNumber());
isChanged = true;
modificationOccured = true;
mg.addAnnotation(decaM.getAnnotationX());
AsmRelationshipProvider.getDefault().addDeclareAnnotationMethodRelationship(
- decaM.getSourceLocation(), clazz.getName(), mg.getMemberView(), world.getModel());// getMethod());
+ decaM.getSourceLocation(), clazz.getName(), mg.getMemberView(),
+ world.getModelAsAsmManager());// getMethod());
isChanged = true;
modificationOccured = true;
forRemoval.add(decaM);
if (doesAlreadyHaveAnnotation(annotationHolder, itdIsActually, decaF, reportedErrors))
continue; // skip this one...
annotationHolder.addAnnotation(decaF.getAnnotationX());
- AsmRelationshipProvider.getDefault().addDeclareAnnotationRelationship(world.getModel(),
+ AsmRelationshipProvider.getDefault().addDeclareAnnotationRelationship(world.getModelAsAsmManager(),
decaF.getSourceLocation(), itdIsActually.getSourceLocation());
isChanged = true;
modificationOccured = true;
if (doesAlreadyHaveAnnotation(annotationHolder, itdIsActually, decaF, reportedErrors))
continue; // skip this one...
annotationHolder.addAnnotation(decaF.getAnnotationX());
- AsmRelationshipProvider.getDefault().addDeclareAnnotationRelationship(world.getModel(),
+ AsmRelationshipProvider.getDefault().addDeclareAnnotationRelationship(world.getModelAsAsmManager(),
decaF.getSourceLocation(), itdIsActually.getSourceLocation());
isChanged = true;
modificationOccured = true;
}
annotationHolder.addAnnotation(decaMC.getAnnotationX());
isChanged = true;
- AsmRelationshipProvider.getDefault().addDeclareAnnotationRelationship(world.getModel(),
+ AsmRelationshipProvider.getDefault().addDeclareAnnotationRelationship(world.getModelAsAsmManager(),
decaMC.getSourceLocation(), unMangledInterMethod.getSourceLocation());
reportMethodCtorWeavingMessage(clazz, unMangledInterMethod, decaMC, -1);
modificationOccured = true;
continue; // skip this one...
annotationHolder.addAnnotation(decaMC.getAnnotationX());
unMangledInterMethod.addAnnotation(decaMC.getAnnotationX());
- AsmRelationshipProvider.getDefault().addDeclareAnnotationRelationship(world.getModel(),
+ AsmRelationshipProvider.getDefault().addDeclareAnnotationRelationship(world.getModelAsAsmManager(),
decaMC.getSourceLocation(), unMangledInterMethod.getSourceLocation());
isChanged = true;
modificationOccured = true;
}
}
- AsmRelationshipProvider.getDefault().addDeclareAnnotationFieldRelationship(world.getModel(),
- decaF.getSourceLocation(), clazz.getName(), aBcelField);// .getFieldAsIs());
+ AsmRelationshipProvider.getDefault().addDeclareAnnotationFieldRelationship(
+ world.getModelAsAsmManager(), decaF.getSourceLocation(), clazz.getName(), aBcelField);// .getFieldAsIs());
reportFieldAnnotationWeavingMessage(clazz, fields, fieldCounter, decaF);
isChanged = true;
modificationOccured = true;
continue; // skip this one...
}
aBcelField.addAnnotation(decaF.getAnnotationX());
- AsmRelationshipProvider.getDefault().addDeclareAnnotationFieldRelationship(world.getModel(),
- decaF.getSourceLocation(), clazz.getName(), aBcelField);// .getFieldAsIs());
+ AsmRelationshipProvider.getDefault().addDeclareAnnotationFieldRelationship(
+ world.getModelAsAsmManager(), decaF.getSourceLocation(), clazz.getName(), aBcelField);// .getFieldAsIs());
isChanged = true;
modificationOccured = true;
forRemoval.add(decaF);
typeMungers = new ArrayList();
declares = new ArrayList();
processAttributes(l, pointcuts, false);
- l = AtAjAttributes.readAj5ClassAttributes(getResolvedTypeX().getWorld().getModel(), javaClass, getResolvedTypeX(),
- getResolvedTypeX().getSourceContext(), msgHandler, isCodeStyleAspect);
+ l = AtAjAttributes.readAj5ClassAttributes(((BcelWorld) getResolvedTypeX().getWorld()).getModelAsAsmManager(), javaClass,
+ getResolvedTypeX(), getResolvedTypeX().getSourceContext(), msgHandler, isCodeStyleAspect);
AjAttribute.Aspect deferredAspectAttribute = processAttributes(l, pointcuts, true);
if (pointcuts.size() == 0) {
return hasBeenWoven;
}
+ public boolean copySourceContext() {
+ return false;
+ }
}
// now generate the aroundBody method
// eg. "private static final void method_aroundBody0(M, M, String, org.aspectj.lang.JoinPoint)"
- LazyMethodGen extractedMethod = extractMethod(NameMangler.aroundCallbackMethodName(getSignature(), getEnclosingClass()),
- Modifier.PRIVATE, munger);
+ LazyMethodGen extractedMethod = extractMethod(NameMangler.aroundCallbackMethodName(getSignature(), new Integer(
+ getEnclosingClass().getNewGeneratedNameTag()).toString()), Modifier.PRIVATE, munger);
// now extract the advice into its own method
- String adviceMethodName = NameMangler.aroundCallbackMethodName(getSignature(), getEnclosingClass()) + "$advice";
+ String adviceMethodName = NameMangler.aroundCallbackMethodName(getSignature(), new Integer(getEnclosingClass()
+ .getNewGeneratedNameTag()).toString())
+ + "$advice";
List argVarList = new ArrayList();
List proceedVarList = new ArrayList();
int linenumber = getSourceLine();
// MOVE OUT ALL THE INSTRUCTIONS IN MY SHADOW INTO ANOTHER METHOD!
- LazyMethodGen callbackMethod = extractMethod(NameMangler.aroundCallbackMethodName(getSignature(), getEnclosingClass()), 0,
- munger);
+ LazyMethodGen callbackMethod = extractMethod(NameMangler.aroundCallbackMethodName(getSignature(), new Integer(
+ getEnclosingClass().getNewGeneratedNameTag()).toString()), 0, munger);
BcelVar[] adviceVars = munger.getExposedStateAsBcelVars(true);
}
if (changed && worthReporting) {
- AsmRelationshipProvider.getDefault().addRelationship(getWorld().getModel(), weaver.getLazyClassGen().getType(), munger,
- getAspectType());
+ AsmRelationshipProvider.getDefault().addRelationship(((BcelWorld) getWorld()).getModelAsAsmManager(),
+ weaver.getLazyClassGen().getType(), munger, getAspectType());
}
// TAG: WeavingMessage
if (world.getModel() != null /* AsmManager.isCreatingModel() */&& !isBatchWeave) {
// remove all relationships where this file being woven is the
// target of the relationship
- world.getModel().removeRelationshipsTargettingThisType(classFile.getClassName());
+ world.getModelAsAsmManager().removeRelationshipsTargettingThisType(classFile.getClassName());
}
}
boolean problemReported = verifyTargetIsOK(decA, onType, annoX, reportProblems);
if (!problemReported) {
- AsmRelationshipProvider.getDefault().addDeclareAnnotationRelationship(world.getModel(), decA.getSourceLocation(),
- onType.getSourceLocation());
+ AsmRelationshipProvider.getDefault().addDeclareAnnotationRelationship(world.getModelAsAsmManager(),
+ decA.getSourceLocation(), onType.getSourceLocation());
// TAG: WeavingMessage
if (!getWorld().getMessageHandler().isIgnoring(IMessage.WEAVEINFO)) {
getWorld().getMessageHandler().handleMessage(
import org.aspectj.apache.bcel.util.ClassPath;
import org.aspectj.apache.bcel.util.NonCachingClassLoaderRepository;
import org.aspectj.apache.bcel.util.Repository;
+import org.aspectj.asm.AsmManager;
import org.aspectj.asm.IRelationship;
import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.IMessageHandler;
if (getModel() != null) {
// System.err.println("munger: " + munger + " on " + this);
- AsmRelationshipProvider.adviceMunger(getModel(), shadow, munger);
+ AsmRelationshipProvider.adviceMunger(getModelAsAsmManager(), shadow, munger);
}
}
}
if (getModel() != null) {
- AsmRelationshipProvider.checkerMunger(getModel(), shadow, checker);
+ AsmRelationshipProvider.checkerMunger(getModelAsAsmManager(), shadow, checker);
}
}
+ public AsmManager getModelAsAsmManager() {
+ return (AsmManager) getModel(); // For now... always an AsmManager in a bcel environment
+ }
+
}
\ No newline at end of file
return SourceContextImpl.UNKNOWN_SOURCE_CONTEXT;
}
+ public boolean copySourceContext() {
+ return true;
+ }
}