summaryrefslogtreecommitdiffstats
path: root/org.aspectj.ajdt.core
diff options
context:
space:
mode:
authorjhugunin <jhugunin>2003-03-11 19:06:21 +0000
committerjhugunin <jhugunin>2003-03-11 19:06:21 +0000
commitbb66774ab4a5afb36d36bc8274ff265f10d666db (patch)
tree74791661e026330bd526f31b5e1a33b8565309dc /org.aspectj.ajdt.core
parentae0ef30e2a9c8a4ef7ff59219b15b5109c956d22 (diff)
downloadaspectj-bb66774ab4a5afb36d36bc8274ff265f10d666db.tar.gz
aspectj-bb66774ab4a5afb36d36bc8274ff265f10d666db.zip
further work on binary aspects (aspect path) tested and implemented correct behavior
for obvious forms of abstract aspects now
Diffstat (limited to 'org.aspectj.ajdt.core')
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java2
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java29
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java3
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InlineAccessFieldBinding.java8
-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--org.aspectj.ajdt.core/testdata/src1/binary/client/Client.java1
-rw-r--r--org.aspectj.ajdt.core/testdata/src1/binary/client/Client1.java32
-rw-r--r--org.aspectj.ajdt.core/testdata/src1/binary/client/MyAspect.aj6
-rw-r--r--org.aspectj.ajdt.core/testdata/src1/binary/client/MyAspect1.aj6
-rw-r--r--org.aspectj.ajdt.core/testdata/src1/binary/lib/AbstractA.aj21
-rw-r--r--org.aspectj.ajdt.core/testdata/src1/binary/lib/ConcreteA.aj4
-rw-r--r--org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BinaryFormsTestCase.java55
13 files changed, 143 insertions, 42 deletions
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);
}