From bb66774ab4a5afb36d36bc8274ff265f10d666db Mon Sep 17 00:00:00 2001 From: jhugunin Date: Tue, 11 Mar 2003 19:06:21 +0000 Subject: [PATCH] further work on binary aspects (aspect path) tested and implemented correct behavior for obvious forms of abstract aspects now --- .../compiler/ast/AccessForInlineVisitor.java | 2 +- .../compiler/ast/AspectDeclaration.java | 29 +++++----- .../compiler/lookup/EclipseSourceType.java | 3 + .../lookup/InlineAccessFieldBinding.java | 8 +-- .../lookup/PrivilegedFieldBinding.java | 8 +-- .../compiler/lookup/PrivilegedHandler.java | 10 ++-- .../testdata/src1/binary/client/Client.java | 1 + .../testdata/src1/binary/client/Client1.java | 32 +++++++++++ .../testdata/src1/binary/client/MyAspect.aj | 6 ++ .../testdata/src1/binary/client/MyAspect1.aj | 6 ++ .../testdata/src1/binary/lib/AbstractA.aj | 21 +++++++ .../testdata/src1/binary/lib/ConcreteA.aj | 4 +- .../compiler/batch/BinaryFormsTestCase.java | 55 +++++++++++++++---- .../aspectj/weaver/ConcreteTypeMunger.java | 2 +- .../weaver/PerObjectInterfaceTypeMunger.java | 2 +- .../aspectj/weaver/ResolvedTypeMunger.java | 13 +++-- .../src/org/aspectj/weaver/ResolvedTypeX.java | 9 +++ .../aspectj/weaver/bcel/BcelObjectType.java | 23 ++------ 18 files changed, 168 insertions(+), 66 deletions(-) create mode 100644 org.aspectj.ajdt.core/testdata/src1/binary/client/Client1.java create mode 100644 org.aspectj.ajdt.core/testdata/src1/binary/client/MyAspect.aj create mode 100644 org.aspectj.ajdt.core/testdata/src1/binary/client/MyAspect1.aj create mode 100644 org.aspectj.ajdt.core/testdata/src1/binary/lib/AbstractA.aj diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java index 0cb2ef29e..166a44cd8 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java @@ -59,7 +59,7 @@ public class AccessForInlineVisitor extends AbstractSyntaxTreeVisitorAdapter { public AccessForInlineVisitor(AspectDeclaration inAspect, PrivilegedHandler handler) { this.inAspect = inAspect; - this.world = inAspect.world; + this.world = inAspect.factory; this.handler = handler; } 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 565a419d3..c92cd026b 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 @@ -47,7 +47,7 @@ public class AspectDeclaration extends MemberTypeDeclaration { public ResolvedTypeX.Name typeX; - public EclipseFactory world; //??? should use this consistently + public EclipseFactory factory; //??? should use this consistently // for better error messages in 1.0 to 1.1 transition @@ -171,12 +171,12 @@ public class AspectDeclaration extends MemberTypeDeclaration { if (perClause == null) { // we've already produced an error for this } else if (perClause.getKind() == PerClause.SINGLETON) { - binding.addField(world.makeFieldBinding(AjcMemberMaker.perSingletonField( + binding.addField(factory.makeFieldBinding(AjcMemberMaker.perSingletonField( typeX))); methods[0] = new AspectClinit((Clinit)methods[0], compilationResult, false, true); } else if (perClause.getKind() == PerClause.PERCFLOW) { binding.addField( - world.makeFieldBinding( + factory.makeFieldBinding( AjcMemberMaker.perCflowField( typeX))); methods[0] = new AspectClinit((Clinit)methods[0], compilationResult, true, false); @@ -583,7 +583,7 @@ public class AspectDeclaration extends MemberTypeDeclaration { codeStream.aload_0(); AstUtil.generateParameterLoads(accessMethod.parameters, codeStream); codeStream.invokespecial( - world.makeMethodBinding(method)); + factory.makeMethodBinding(method)); AstUtil.generateReturn(accessMethod.returnType, codeStream); // body ends here }}); @@ -600,7 +600,7 @@ public class AspectDeclaration extends MemberTypeDeclaration { } private void generateInlineAccessors(ClassFile classFile, final InlineAccessFieldBinding accessField, final ResolvedMember field) { - final FieldBinding fieldBinding = world.makeFieldBinding(field); + final FieldBinding fieldBinding = factory.makeFieldBinding(field); generateMethod(classFile, accessField.reader, new BodyGenerator() { public void generate(CodeStream codeStream) { @@ -645,9 +645,9 @@ public class AspectDeclaration extends MemberTypeDeclaration { AstUtil.generateParameterLoads(accessMethod.parameters, codeStream); if (method.isStatic()) { - codeStream.invokestatic(world.makeMethodBinding(method)); + codeStream.invokestatic(factory.makeMethodBinding(method)); } else { - codeStream.invokevirtual(world.makeMethodBinding(method)); + codeStream.invokevirtual(factory.makeMethodBinding(method)); } AstUtil.generateReturn(accessMethod.returnType, codeStream); @@ -724,19 +724,12 @@ public class AspectDeclaration extends MemberTypeDeclaration { checkSpec(classScope); if (ignoreFurtherInvestigation) return; - world = EclipseFactory.fromScopeLookupEnvironment(scope); -// concreteName = world.lookupConcreteName(binding); -// typeX = concreteName.getResolvedTypeX(); - + factory = EclipseFactory.fromScopeLookupEnvironment(scope); if (isPrivileged) { binding.privilegedHandler = new PrivilegedHandler(this); } -// CrosscuttingMembers xcut = new CrosscuttingMembers(typeX); -// concreteName.crosscuttingMembers = xcut; - //typeX.crosscuttingMembers = xcut; - //XXXxcut.setPerClause(buildPerClause(scope)); buildPerClause(scope); if (methods != null) { @@ -752,7 +745,11 @@ public class AspectDeclaration extends MemberTypeDeclaration { } //??? timing is weird - world.getWorld().getCrosscuttingMembersSet().addOrReplaceAspect(typeX); + factory.getWorld().getCrosscuttingMembersSet().addOrReplaceAspect(typeX); + + if (typeX.getSuperclass().isAspect() && !typeX.getSuperclass().isExposedToWeaver()) { + factory.getWorld().getCrosscuttingMembersSet().addOrReplaceAspect(typeX.getSuperclass()); + } } diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java index f36c6eeff..dbb985ab0 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java @@ -59,7 +59,10 @@ public class EclipseSourceType extends ResolvedTypeX.ConcreteName { public boolean isAspect() { return binding.scope.referenceContext instanceof AspectDeclaration; + } + public boolean isWovenBy(ResolvedTypeX aspectType) { + return false; } public ResolvedTypeX getSuperclass() { diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InlineAccessFieldBinding.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InlineAccessFieldBinding.java index 61f37145a..13e91184f 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InlineAccessFieldBinding.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InlineAccessFieldBinding.java @@ -44,13 +44,13 @@ public class InlineAccessFieldBinding extends FieldBinding { super(baseField, baseField.declaringClass); this.reader = new SimpleSyntheticAccessMethodBinding( - inAspect.world.makeMethodBinding( + inAspect.factory.makeMethodBinding( AjcMemberMaker.inlineAccessMethodForFieldGet( - inAspect.typeX, inAspect.world.makeResolvedMember(baseField) + inAspect.typeX, inAspect.factory.makeResolvedMember(baseField) ))); - this.writer = new SimpleSyntheticAccessMethodBinding(inAspect.world.makeMethodBinding( + this.writer = new SimpleSyntheticAccessMethodBinding(inAspect.factory.makeMethodBinding( AjcMemberMaker.inlineAccessMethodForFieldSet( - inAspect.typeX, inAspect.world.makeResolvedMember(baseField) + inAspect.typeX, inAspect.factory.makeResolvedMember(baseField) ))); this.constant = AstNode.NotAConstant; 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 67d2aaa36..a2bfe7d77 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 @@ -33,13 +33,13 @@ public class PrivilegedFieldBinding extends FieldBinding { super(baseField, baseField.declaringClass); this.reader = new SimpleSyntheticAccessMethodBinding( - inAspect.world.makeMethodBinding( + inAspect.factory.makeMethodBinding( AjcMemberMaker.privilegedAccessMethodForFieldGet( - inAspect.typeX, inAspect.world.makeResolvedMember(baseField) + inAspect.typeX, inAspect.factory.makeResolvedMember(baseField) ))); - this.writer = new SimpleSyntheticAccessMethodBinding(inAspect.world.makeMethodBinding( + this.writer = new SimpleSyntheticAccessMethodBinding(inAspect.factory.makeMethodBinding( AjcMemberMaker.privilegedAccessMethodForFieldSet( - inAspect.typeX, inAspect.world.makeResolvedMember(baseField) + inAspect.typeX, inAspect.factory.makeResolvedMember(baseField) ))); this.constant = AstNode.NotAConstant; 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 89e8c8f4b..f6b482b68 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 @@ -44,7 +44,7 @@ public class PrivilegedHandler implements IPrivilegedHandler { } public FieldBinding getPrivilegedAccessField(FieldBinding baseField, AstNode location) { - ResolvedMember key = inAspect.world.makeResolvedMember(baseField); + ResolvedMember key = inAspect.factory.makeResolvedMember(baseField); if (accessors.containsKey(key)) return (FieldBinding)accessors.get(key); FieldBinding ret = new PrivilegedFieldBinding(inAspect, baseField); checkWeaveAccess(key.getDeclaringType(), location); @@ -53,14 +53,14 @@ public class PrivilegedHandler implements IPrivilegedHandler { } public MethodBinding getPrivilegedAccessMethod(MethodBinding baseMethod, AstNode location) { - ResolvedMember key = inAspect.world.makeResolvedMember(baseMethod); + ResolvedMember key = inAspect.factory.makeResolvedMember(baseMethod); if (accessors.containsKey(key)) return (MethodBinding)accessors.get(key); MethodBinding ret; if (baseMethod.isConstructor()) { ret = baseMethod; } else { - ret = inAspect.world.makeMethodBinding( + ret = inAspect.factory.makeMethodBinding( AjcMemberMaker.privilegedAccessMethodForMethod(inAspect.typeX, key) ); } @@ -73,14 +73,14 @@ public class PrivilegedHandler implements IPrivilegedHandler { public void notePrivilegedTypeAccess(ReferenceBinding type, AstNode location) { ResolvedMember key = new ResolvedMember(Member.STATIC_INITIALIZATION, - inAspect.world.fromEclipse(type), 0, ResolvedTypeX.VOID, "", TypeX.NONE); + inAspect.factory.fromEclipse(type), 0, ResolvedTypeX.VOID, "", TypeX.NONE); checkWeaveAccess(key.getDeclaringType(), location); accessors.put(key, key); } private void checkWeaveAccess(TypeX typeX, AstNode location) { - World world = inAspect.world.getWorld(); + World world = inAspect.factory.getWorld(); Lint.Kind check = world.getLint().typeNotExposedToWeaver; if (check.isEnabled()) { if (!world.resolve(typeX).isExposedToWeaver()) { diff --git a/org.aspectj.ajdt.core/testdata/src1/binary/client/Client.java b/org.aspectj.ajdt.core/testdata/src1/binary/client/Client.java index 181b78628..5a495ed8e 100644 --- a/org.aspectj.ajdt.core/testdata/src1/binary/client/Client.java +++ b/org.aspectj.ajdt.core/testdata/src1/binary/client/Client.java @@ -9,6 +9,7 @@ public class Client { System.out.println(c.value); ConcreteA.Marker m = c; System.out.println(m.value); + System.out.println(ConcreteA.getPrivateValue(c)); try { new Client(); } catch (SoftException se) { diff --git a/org.aspectj.ajdt.core/testdata/src1/binary/client/Client1.java b/org.aspectj.ajdt.core/testdata/src1/binary/client/Client1.java new file mode 100644 index 000000000..426c3cd2b --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/binary/client/Client1.java @@ -0,0 +1,32 @@ +package client; + +import lib.AbstractA; +import org.aspectj.lang.*; + +public class Client1 { + public static void main(String[] args) { + C1 c = new C1(); + System.out.println(c.value); + AbstractA.Marker m = c; + System.out.println(m.value); + System.out.println(AbstractA.getPrivateValue(c)); + + FooMarkMe f = new FooMarkMe(); + System.out.println(f.value); + + m = f; + } + +} + +class C1 implements AbstractA.Marker { + public void m() { + System.out.println("hello"); + } +} + +class FooMarkMe { + public void m() { + System.out.println("hello"); + } +} diff --git a/org.aspectj.ajdt.core/testdata/src1/binary/client/MyAspect.aj b/org.aspectj.ajdt.core/testdata/src1/binary/client/MyAspect.aj new file mode 100644 index 000000000..317ecc973 --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/binary/client/MyAspect.aj @@ -0,0 +1,6 @@ +package client; +import lib.AbstractA; + +aspect MyAspect extends AbstractA { + protected pointcut scope(); +} \ No newline at end of file diff --git a/org.aspectj.ajdt.core/testdata/src1/binary/client/MyAspect1.aj b/org.aspectj.ajdt.core/testdata/src1/binary/client/MyAspect1.aj new file mode 100644 index 000000000..bec3ad781 --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/binary/client/MyAspect1.aj @@ -0,0 +1,6 @@ +package client; +import lib.AbstractA; + +aspect MyAspect1 extends AbstractA { + protected pointcut scope(): within(client.*); +} \ No newline at end of file diff --git a/org.aspectj.ajdt.core/testdata/src1/binary/lib/AbstractA.aj b/org.aspectj.ajdt.core/testdata/src1/binary/lib/AbstractA.aj new file mode 100644 index 000000000..a8a69ab55 --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/binary/lib/AbstractA.aj @@ -0,0 +1,21 @@ +package lib; + +public abstract aspect AbstractA { + public interface Marker {} + + public String Marker.value = "public"; + private String Marker.pValue = "private"; + + public static String getPrivateValue(Marker m) { return m.pValue; } + + protected abstract pointcut scope(); + + declare error: scope() && within(Marker+) && call(* java.io.PrintStream.println(*)): + "use a proper logger"; + + before(Marker m): this(m) && execution(new(..)) { + System.err.println("making a Marker: " + m + " with " + m.pValue); + } + + declare parents: *..*MarkMe implements Marker; +} \ No newline at end of file diff --git a/org.aspectj.ajdt.core/testdata/src1/binary/lib/ConcreteA.aj b/org.aspectj.ajdt.core/testdata/src1/binary/lib/ConcreteA.aj index 02a09c87d..15a3d5cc6 100644 --- a/org.aspectj.ajdt.core/testdata/src1/binary/lib/ConcreteA.aj +++ b/org.aspectj.ajdt.core/testdata/src1/binary/lib/ConcreteA.aj @@ -4,7 +4,9 @@ public aspect ConcreteA { public interface Marker {} public String Marker.value = "public"; - //private String Marker.pValue = "private"; + private String Marker.pValue = "private"; + + public static String getPrivateValue(Marker m) { return m.pValue; } public static class MyException extends Exception {} diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BinaryFormsTestCase.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BinaryFormsTestCase.java index 07fb71dae..c98a12a11 100644 --- a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BinaryFormsTestCase.java +++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BinaryFormsTestCase.java @@ -38,6 +38,7 @@ public class BinaryFormsTestCase extends CommandTestCase { args.add("out"); args.add("testdata/src1/binary/lib/ConcreteA.aj"); + args.add("testdata/src1/binary/lib/AbstractA.aj"); CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS); @@ -52,34 +53,66 @@ public class BinaryFormsTestCase extends CommandTestCase { args.add("out"); args.add("testdata/src1/binary/client/Client.java"); + args.add("testdata/src1/binary/client/Client1.java"); CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS); TestUtil.runMain("out;out/lib.jar", "client.Client"); - } - - - public void XXXtestJar1() throws IOException { - List args = new ArrayList(); - args.add("-outjar"); - args.add("out/megatrace.jar"); + TestUtil.runMain("out;out/lib.jar", "client.Client1"); + + args = new ArrayList(); + args.add("-aspectpath"); + args.add("out/lib.jar"); args.add("-classpath"); args.add("../runtime/bin"); - args.add("testdata/src1/trace/MegaTrace.java"); - args.add("testdata/src1/trace/ExecTrace.java"); + args.add("-d"); + args.add("out"); + + args.add("testdata/src1/binary/client/MyAspect.aj"); + args.add("testdata/src1/binary/client/Client1.java"); CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS); + TestUtil.runMain("out;out/lib.jar", "client.Client1"); + args = new ArrayList(); args.add("-aspectpath"); - args.add("out/megatrace.jar"); + args.add("out/lib.jar"); args.add("-classpath"); args.add("../runtime/bin"); - args.add("testdata/src1/tracep1/TraceTest.java"); + args.add("-d"); + args.add("out"); + + args.add("testdata/src1/binary/client/MyAspect1.aj"); + args.add("testdata/src1/binary/client/Client1.java"); + + CommandTestCase.runCompiler(args, new int[] {24, 30}); + + args = new ArrayList(); + args.add("-classpath"); + args.add("../runtime/bin;out/lib.jar"); + + args.add("-d"); + args.add("out"); + + args.add("testdata/src1/binary/client/Client1.java"); + + CommandTestCase.runCompiler(args, new int[] {9, 11, 15, 17}); + + args = new ArrayList(); + args.add("-classpath"); + args.add("../runtime/bin;out/lib.jar"); + args.add("-Xlint:error"); + + args.add("-d"); + args.add("out"); + + args.add("testdata/src1/binary/client/MyAspect.aj"); + args.add("testdata/src1/binary/client/Client1.java"); CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS); } diff --git a/weaver/src/org/aspectj/weaver/ConcreteTypeMunger.java b/weaver/src/org/aspectj/weaver/ConcreteTypeMunger.java index 7eda16abb..d268f2fba 100644 --- a/weaver/src/org/aspectj/weaver/ConcreteTypeMunger.java +++ b/weaver/src/org/aspectj/weaver/ConcreteTypeMunger.java @@ -49,7 +49,7 @@ public abstract class ConcreteTypeMunger implements PartialOrder.PartialComparab public boolean matches(ResolvedTypeX onType) { if (munger == null) throw new RuntimeException("huh: " + this); - return munger.matches(onType); + return munger.matches(onType, aspectType); } public ResolvedMember getMatchingSyntheticMember(Member member) { diff --git a/weaver/src/org/aspectj/weaver/PerObjectInterfaceTypeMunger.java b/weaver/src/org/aspectj/weaver/PerObjectInterfaceTypeMunger.java index 1064d7e83..504f03001 100644 --- a/weaver/src/org/aspectj/weaver/PerObjectInterfaceTypeMunger.java +++ b/weaver/src/org/aspectj/weaver/PerObjectInterfaceTypeMunger.java @@ -59,7 +59,7 @@ public class PerObjectInterfaceTypeMunger extends ResolvedTypeMunger { return testPointcut; } - public boolean matches(ResolvedTypeX matchType) { + public boolean matches(ResolvedTypeX matchType, ResolvedTypeX aspectType) { //??? this matches many more types than are needed return !matchType.isInterface(); } diff --git a/weaver/src/org/aspectj/weaver/ResolvedTypeMunger.java b/weaver/src/org/aspectj/weaver/ResolvedTypeMunger.java index b2365c388..8944e788f 100644 --- a/weaver/src/org/aspectj/weaver/ResolvedTypeMunger.java +++ b/weaver/src/org/aspectj/weaver/ResolvedTypeMunger.java @@ -49,14 +49,17 @@ public abstract class ResolvedTypeMunger { } - public boolean matches(ResolvedTypeX matchType) { + public boolean matches(ResolvedTypeX matchType, ResolvedTypeX aspectType) { ResolvedTypeX onType = matchType.getWorld().resolve(signature.getDeclaringType()); //System.err.println("matching: " + this + " to " + matchType + " onType = " + onType); if (matchType.equals(onType)) { - if (!onType.isExposedToWeaver() && - matchType.getWorld().getLint().typeNotExposedToWeaver.isEnabled()) - { - matchType.getWorld().getLint().typeNotExposedToWeaver.signal(matchType.getName(), signature.getSourceLocation()); + if (!onType.isExposedToWeaver()) { + if (!onType.isWovenBy(aspectType)) { + if (matchType.getWorld().getLint().typeNotExposedToWeaver.isEnabled()) { + matchType.getWorld().getLint().typeNotExposedToWeaver.signal( + matchType.getName(), signature.getSourceLocation()); + } + } } return true; } diff --git a/weaver/src/org/aspectj/weaver/ResolvedTypeX.java b/weaver/src/org/aspectj/weaver/ResolvedTypeX.java index 2d7183881..6249a9b21 100644 --- a/weaver/src/org/aspectj/weaver/ResolvedTypeX.java +++ b/weaver/src/org/aspectj/weaver/ResolvedTypeX.java @@ -564,6 +564,10 @@ public abstract class ResolvedTypeX extends TypeX { public boolean isExposedToWeaver() { return delegate.isExposedToWeaver(); //??? where does this belong } + + public boolean isWovenBy(ResolvedTypeX aspectType) { + return delegate.isWovenBy(aspectType); + } public ResolvedMember[] getDeclaredFields() { return delegate.getDeclaredFields(); @@ -646,6 +650,7 @@ public abstract class ResolvedTypeX extends TypeX { public abstract ISourceLocation getSourceLocation(); + public abstract boolean isWovenBy(ResolvedTypeX aspectType); public ISourceContext getSourceContext() { return sourceContext; @@ -1213,4 +1218,8 @@ public abstract class ResolvedTypeX extends TypeX { public ISourceLocation getSourceLocation() { return null; } public boolean isExposedToWeaver() { return false; } + public boolean isWovenBy(ResolvedTypeX aspectType) { + return false; + } + } diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java b/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java index d26e63a38..05d7248b1 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java @@ -146,8 +146,6 @@ public class BcelObjectType extends ResolvedTypeX.ConcreteName { ret[len] = d; pointcuts = ret; } - - public boolean isAspect() { return perClause != null; @@ -191,11 +189,6 @@ public class BcelObjectType extends ResolvedTypeX.ConcreteName { return perClause; } - - - - - JavaClass getJavaClass() { return javaClass; } @@ -213,16 +206,12 @@ public class BcelObjectType extends ResolvedTypeX.ConcreteName { isObject = (javaClass.getSuperclassNameIndex() == 0); unpackAspectAttributes(); } - - - /** - * Switch to a new JavaClass and clear all caches - */ - void replaceJavaClass(JavaClass jc) { - if (this.javaClass == jc) return; - - this.javaClass = jc; - resetState(); + + //XXX we've lost information so that we don't know who wove into this + // class, only that someone did. For better error messages we should + // probably expand the information in weaverState + public boolean isWovenBy(ResolvedTypeX aspectType) { + return weaverState == WeaverStateKind.Woven; } public WeaverStateKind getWeaverState() { -- 2.39.5