summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoracolyer <acolyer>2005-12-19 12:22:26 +0000
committeracolyer <acolyer>2005-12-19 12:22:26 +0000
commit4676acbde531b3c00f5572ff4053435e9ba9b1eb (patch)
tree965cf14b15fe462f62de90df4091c311b40d0e3c
parentbc1fcf9581621da51498b251f053b29fb70b9c05 (diff)
downloadaspectj-4676acbde531b3c00f5572ff4053435e9ba9b1eb.tar.gz
aspectj-4676acbde531b3c00f5572ff4053435e9ba9b1eb.zip
merge of changes from 1.5.0 branch into HEAD
-rw-r--r--aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/AjTypeImpl.java22
-rw-r--r--aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareParents.java10
-rw-r--r--docs/devGuideDB/ajc.xml3
-rw-r--r--docs/devGuideDB/antsupport.xml2
-rw-r--r--lib/aspectj/lib/aspectjrt.jarbin109128 -> 109157 bytes
-rw-r--r--lib/test/aspectjrt.jarbin109128 -> 109157 bytes
-rw-r--r--tests/bugs150/pr121197.aj57
-rw-r--r--tests/java5/ataspectj/annotationGen/ITDTest.aj2
-rw-r--r--tests/java5/reflection/AtAspectJDeclareParents.aj4
-rw-r--r--tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java4
-rw-r--r--tests/src/org/aspectj/systemtest/ajc150/ajc150.xml6
-rw-r--r--weaver/src/org/aspectj/weaver/AjAttribute.java11
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java36
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java20
14 files changed, 139 insertions, 38 deletions
diff --git a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/AjTypeImpl.java b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/AjTypeImpl.java
index 482ccebb9..99f1e66ab 100644
--- a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/AjTypeImpl.java
+++ b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/AjTypeImpl.java
@@ -661,8 +661,10 @@ public class AjTypeImpl<T> implements AjType<T> {
if (isAspect()) {
for (Field f : clazz.getDeclaredFields()) {
if (!f.getType().isInterface()) continue;
- if (!Modifier.isPublic(f.getModifiers()) || !Modifier.isStatic(f.getModifiers())) continue;
- if (f.isAnnotationPresent(org.aspectj.lang.annotation.DeclareParents.class)) {
+ if (f.isAnnotationPresent(org.aspectj.lang.annotation.DeclareParents.class)) {
+ Class<org.aspectj.lang.annotation.DeclareParents> decPAnnClass = org.aspectj.lang.annotation.DeclareParents.class;
+ org.aspectj.lang.annotation.DeclareParents decPAnn = f.getAnnotation(decPAnnClass);
+ if (decPAnn.defaultImpl() == decPAnnClass) continue; // doesn't contribute members...
for (Method itdM : f.getType().getDeclaredMethods()) {
if (!Modifier.isPublic(itdM.getModifiers()) && publicOnly) continue;
InterTypeMethodDeclaration itdm = new InterTypeMethodDeclarationImpl(
@@ -951,21 +953,7 @@ public class AjTypeImpl<T> implements AjType<T> {
private void addAnnotationStyleDeclareParents(List<DeclareParents> toList) {
for (Field f : clazz.getDeclaredFields()) {
- if (f.isAnnotationPresent(org.aspectj.lang.annotation.DeclareImplements.class)) {
- if (!f.getType().isInterface()) continue;
- org.aspectj.lang.annotation.DeclareImplements ann = f.getAnnotation(org.aspectj.lang.annotation.DeclareImplements.class);
- String parentType = f.getType().getName();
- DeclareParentsImpl decp = new DeclareParentsImpl(
- ann.value(),
- parentType,
- false,
- this
- );
- toList.add(decp);
- }
- if (f.isAnnotationPresent(org.aspectj.lang.annotation.DeclareParents.class)
- && Modifier.isStatic(f.getModifiers())
- && Modifier.isPublic(f.getModifiers())) {
+ if (f.isAnnotationPresent(org.aspectj.lang.annotation.DeclareParents.class)) {
if (!f.getType().isInterface()) continue;
org.aspectj.lang.annotation.DeclareParents ann = f.getAnnotation(org.aspectj.lang.annotation.DeclareParents.class);
String parentType = f.getType().getName();
diff --git a/aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareParents.java b/aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareParents.java
index e26e8c778..fe7267849 100644
--- a/aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareParents.java
+++ b/aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareParents.java
@@ -28,4 +28,14 @@ public @interface DeclareParents {
*/
String value();
+ /**
+ * Optional class defining default implementation
+ * of interface members (equivalent to defining
+ * a set of interface member ITDs for the
+ * public methods of the interface).
+ */
+ Class defaultImpl() default DeclareParents.class;
+
+ // note - a default of "null" is not allowed,
+ // hence the strange default given above.
}
diff --git a/docs/devGuideDB/ajc.xml b/docs/devGuideDB/ajc.xml
index 135d8278f..0aa7bae93 100644
--- a/docs/devGuideDB/ajc.xml
+++ b/docs/devGuideDB/ajc.xml
@@ -456,12 +456,15 @@
(Experimental) Create class files that can't be subsequently rewoven by AspectJ.
</para></listitem>
</varlistentry>
+ <!-- not documenting this feature yet -->
+ <!--
<varlistentry>
<term>-XhasMember</term>
<listitem><para>
(Experimental) Allow hasmethod() and hasfield type patterns in declare parents and declare @type.
</para></listitem>
</varlistentry>
+ -->
<varlistentry>
<term>-Xajruntimelevel:1.2, ajruntimelevel:1.5</term>
<listitem><para>
diff --git a/docs/devGuideDB/antsupport.xml b/docs/devGuideDB/antsupport.xml
index 00fef5249..a21268ad0 100644
--- a/docs/devGuideDB/antsupport.xml
+++ b/docs/devGuideDB/antsupport.xml
@@ -432,7 +432,7 @@
own entries. The other permitted ones (currently) are
serializableAspects, incrementalFile, lazyTjp,
reweavable, notReweavable, noInline,
- noWeave,hasMember,
+ noWeave,
ajruntimelevel:1.2, and ajruntimelevel:1.5.
Of these, some were deprecated in AspectJ 5
(reweavable, noWeave, etc.).
diff --git a/lib/aspectj/lib/aspectjrt.jar b/lib/aspectj/lib/aspectjrt.jar
index f8d847b2f..297c989ac 100644
--- a/lib/aspectj/lib/aspectjrt.jar
+++ b/lib/aspectj/lib/aspectjrt.jar
Binary files differ
diff --git a/lib/test/aspectjrt.jar b/lib/test/aspectjrt.jar
index f8d847b2f..297c989ac 100644
--- a/lib/test/aspectjrt.jar
+++ b/lib/test/aspectjrt.jar
Binary files differ
diff --git a/tests/bugs150/pr121197.aj b/tests/bugs150/pr121197.aj
new file mode 100644
index 000000000..29fed9c52
--- /dev/null
+++ b/tests/bugs150/pr121197.aj
@@ -0,0 +1,57 @@
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+import org.aspectj.lang.annotation.After;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Before;
+import org.aspectj.lang.annotation.Pointcut;
+
+@Aspect( "perthis( readOperations() || writeOperations() )" )
+public abstract class pr121197 {
+ @Pointcut( "" )
+ protected abstract void readOperations();
+
+ @Pointcut( "" )
+ protected abstract void writeOperations();
+
+ private ReadWriteLock _lock = new ReentrantReadWriteLock();
+
+ @Before( "readOperations()" )
+ public void beforeReading() {
+ _lock.readLock().lock();
+ }
+
+ @After( "readOperations()" )
+ public void afterReading() {
+ _lock.readLock().unlock();
+ }
+
+ @Before( "writeOperations()" )
+ public void beforeWriting() {
+ _lock.writeLock().lock();
+ }
+
+ @After( "writeOperations()" )
+ public void afterWriting() {
+ _lock.writeLock().unlock();
+ }
+
+}
+
+@Aspect
+class ModelThreadSafety extends pr121197 {
+ @Pointcut( "execution( * C.read*(..) )" )
+ @Override
+ protected void readOperations() {}
+
+ @Pointcut( "execution( * C.write*(..) )" )
+ @Override
+ protected void writeOperations() { }
+}
+
+class C {
+
+ public void readSomething() {}
+ public void writeSomething() {}
+
+}
diff --git a/tests/java5/ataspectj/annotationGen/ITDTest.aj b/tests/java5/ataspectj/annotationGen/ITDTest.aj
index dc8089f70..46e7feed5 100644
--- a/tests/java5/ataspectj/annotationGen/ITDTest.aj
+++ b/tests/java5/ataspectj/annotationGen/ITDTest.aj
@@ -186,7 +186,7 @@ class A {}
@Aspect
class X {
- @org.aspectj.lang.annotation.DeclareParents("org.xyz..*")
+ @org.aspectj.lang.annotation.DeclareParents(value="org.xyz..*",defaultImpl=Mixin.class)
public static I myMixin = new Mixin();
diff --git a/tests/java5/reflection/AtAspectJDeclareParents.aj b/tests/java5/reflection/AtAspectJDeclareParents.aj
index d60f6a3c6..fddf12a56 100644
--- a/tests/java5/reflection/AtAspectJDeclareParents.aj
+++ b/tests/java5/reflection/AtAspectJDeclareParents.aj
@@ -2,8 +2,8 @@ import org.aspectj.lang.annotation.*;
public aspect AtAspectJDeclareParents {
- @DeclareParents("C")
- public static I mixin = new Impl();
+ @DeclareParents(value="C",defaultImpl=Impl.class)
+ private I implementedInterface;
}
diff --git a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java
index cf89ee0ca..4d575a58e 100644
--- a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java
+++ b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java
@@ -859,6 +859,10 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
runTest("modifier overrides");
}
+ public void testAbstractPerThisInAtAspectJ() {
+ runTest("abstract perthis in @AspectJ");
+ }
+
// helper methods.....
public SyntheticRepository createRepos(File cpentry) {
diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml
index ab876223d..f33b01ff6 100644
--- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml
+++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml
@@ -2,6 +2,12 @@
<!-- AspectJ v1.5.0 Tests -->
<suite>
+
+ <ajc-test dir="bugs150" title="abstract perthis in @AspectJ">
+ <compile files="pr121197.aj" options="-1.5"/>
+ </ajc-test>
+
+
<ajc-test dir="bugs150" title="access to private ITD from nested type">
<compile files="pr118698.aj"/>
<run class="pr118698"/>
diff --git a/weaver/src/org/aspectj/weaver/AjAttribute.java b/weaver/src/org/aspectj/weaver/AjAttribute.java
index e3a4c2457..56e8a94ad 100644
--- a/weaver/src/org/aspectj/weaver/AjAttribute.java
+++ b/weaver/src/org/aspectj/weaver/AjAttribute.java
@@ -24,6 +24,7 @@ import org.aspectj.bridge.MessageUtil;
import org.aspectj.bridge.Version;
import org.aspectj.util.FileUtil;
import org.aspectj.weaver.patterns.Declare;
+import org.aspectj.weaver.patterns.IScope;
import org.aspectj.weaver.patterns.PerClause;
import org.aspectj.weaver.patterns.Pointcut;
@@ -559,6 +560,7 @@ public abstract class AjAttribute {
return AttributeName;
}
private PerClause perClause;
+ private IScope resolutionScope;
public Aspect(PerClause perClause) {
this.perClause = perClause;
@@ -568,10 +570,19 @@ public abstract class AjAttribute {
//XXXperClause.concretize(inAspect);
return perClause;
}
+
+ public PerClause reifyFromAtAspectJ(ResolvedType inAspect) {
+ perClause.resolve(resolutionScope);
+ return perClause;
+ }
public void write(DataOutputStream s) throws IOException {
perClause.write(s);
}
+
+ public void setResolutionScope(IScope binding) {
+ this.resolutionScope = binding;
+ }
}
public static class PrivilegedAttribute extends AjAttribute {
diff --git a/weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java b/weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java
index a488376a2..e07f44c42 100644
--- a/weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java
+++ b/weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java
@@ -338,6 +338,7 @@ public class AtAjAttributes {
}
struct.ajAttributes.addAll(fstruct.ajAttributes);
}
+
return struct.ajAttributes;
}
@@ -462,7 +463,8 @@ public class AtAjAttributes {
// Note: field annotation are for ITD and DEOW - processed at class level directly
return Collections.EMPTY_LIST;
}
-
+
+
/**
* Read @Aspect
*
@@ -507,7 +509,8 @@ public class AtAjAttributes {
perClause.setLocation(struct.context, struct.context.getOffset(), struct.context.getOffset()+1);//FIXME AVASM
// FIXME asc see related comment way about about the version...
struct.ajAttributes.add(new AjAttribute.WeaverVersionInfo());
- struct.ajAttributes.add(new AjAttribute.Aspect(perClause));
+ AjAttribute.Aspect aspectAttribute = new AjAttribute.Aspect(perClause);
+ struct.ajAttributes.add(aspectAttribute);
FormalBinding[] bindings = new org.aspectj.weaver.patterns.FormalBinding[0];
final IScope binding;
binding = new BindingScope(
@@ -515,7 +518,14 @@ public class AtAjAttributes {
struct.context,
bindings
);
- perClause.resolve(binding);
+
+// // we can't resolve here since the perclause typically refers to pointcuts
+// // defined in the aspect that we haven't told the BcelObjectType about yet.
+//
+// perClause.resolve(binding);
+
+ // so we prepare to do it later...
+ aspectAttribute.setResolutionScope(binding);
return true;
}
}
@@ -531,25 +541,25 @@ public class AtAjAttributes {
*/
private static PerClause parsePerClausePointcut(String perClauseString, AjAttributeStruct struct) {
final String pointcutString;
- Pointcut poincut = null;
+ Pointcut pointcut = null;
TypePattern typePattern = null;
final PerClause perClause;
if (perClauseString.startsWith(PerClause.KindAnnotationPrefix.PERCFLOW.getName())) {
pointcutString = PerClause.KindAnnotationPrefix.PERCFLOW.extractPointcut(perClauseString);
- poincut = parsePointcut(pointcutString, struct, false);
- perClause = new PerCflow(poincut, false);
+ pointcut = parsePointcut(pointcutString, struct, false);
+ perClause = new PerCflow(pointcut, false);
} else if (perClauseString.startsWith(PerClause.KindAnnotationPrefix.PERCFLOWBELOW.getName())) {
pointcutString = PerClause.KindAnnotationPrefix.PERCFLOWBELOW.extractPointcut(perClauseString);
- poincut = parsePointcut(pointcutString, struct, false);
- perClause = new PerCflow(poincut, true);
+ pointcut = parsePointcut(pointcutString, struct, false);
+ perClause = new PerCflow(pointcut, true);
} else if (perClauseString.startsWith(PerClause.KindAnnotationPrefix.PERTARGET.getName())) {
pointcutString = PerClause.KindAnnotationPrefix.PERTARGET.extractPointcut(perClauseString);
- poincut = parsePointcut(pointcutString, struct, false);
- perClause = new PerObject(poincut, false);
+ pointcut = parsePointcut(pointcutString, struct, false);
+ perClause = new PerObject(pointcut, false);
} else if (perClauseString.startsWith(PerClause.KindAnnotationPrefix.PERTHIS.getName())) {
pointcutString = PerClause.KindAnnotationPrefix.PERTHIS.extractPointcut(perClauseString);
- poincut = parsePointcut(pointcutString, struct, false);
- perClause = new PerObject(poincut, true);
+ pointcut = parsePointcut(pointcutString, struct, false);
+ perClause = new PerObject(pointcut, true);
} else if (perClauseString.startsWith(PerClause.KindAnnotationPrefix.PERTYPEWITHIN.getName())) {
pointcutString = PerClause.KindAnnotationPrefix.PERTYPEWITHIN.extractPointcut(perClauseString);
typePattern = parseTypePattern(pointcutString, struct);
@@ -564,7 +574,7 @@ public class AtAjAttributes {
if (!PerClause.SINGLETON.equals(perClause.getKind())
&& !PerClause.PERTYPEWITHIN.equals(perClause.getKind())
- && poincut == null) {
+ && pointcut == null) {
// we could not parse the pointcut
return null;
}
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java b/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java
index 59dcea110..8ee6ab638 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java
@@ -273,20 +273,31 @@ public class BcelObjectType extends AbstractReferenceTypeDelegate {
List l = BcelAttributes.readAjAttributes(javaClass.getClassName(),javaClass.getAttributes(), getResolvedTypeX().getSourceContext(),getResolvedTypeX().getWorld().getMessageHandler(),AjAttribute.WeaverVersionInfo.UNKNOWN);
processAttributes(l,pointcuts,false);
l = AtAjAttributes.readAj5ClassAttributes(javaClass, getResolvedTypeX(), getResolvedTypeX().getSourceContext(), getResolvedTypeX().getWorld().getMessageHandler(),isCodeStyleAspect);
- processAttributes(l,pointcuts,true);
+ AjAttribute.Aspect deferredAspectAttribute = processAttributes(l,pointcuts,true);
this.pointcuts = (ResolvedPointcutDefinition[])
pointcuts.toArray(new ResolvedPointcutDefinition[pointcuts.size()]);
+
+ if (deferredAspectAttribute != null) {
+ // we can finally process the aspect and its associated perclause...
+ perClause = deferredAspectAttribute.reifyFromAtAspectJ(this.getResolvedTypeX());
+ }
+
}
- private void processAttributes(List attributeList, List pointcuts, boolean fromAnnotations) {
+ private AjAttribute.Aspect processAttributes(List attributeList, List pointcuts, boolean fromAnnotations) {
+ AjAttribute.Aspect deferredAspectAttribute = null;
for (Iterator iter = attributeList.iterator(); iter.hasNext();) {
AjAttribute a = (AjAttribute) iter.next();
//System.err.println("unpacking: " + this + " and " + a);
if (a instanceof AjAttribute.Aspect) {
- perClause = ((AjAttribute.Aspect)a).reify(this.getResolvedTypeX());
- if (!fromAnnotations) isCodeStyleAspect = true;
+ if (fromAnnotations) {
+ deferredAspectAttribute = (AjAttribute.Aspect) a;
+ } else {
+ perClause = ((AjAttribute.Aspect)a).reify(this.getResolvedTypeX());
+ isCodeStyleAspect = true;
+ }
} else if (a instanceof AjAttribute.PointcutDeclarationAttribute) {
pointcuts.add(((AjAttribute.PointcutDeclarationAttribute)a).reify());
} else if (a instanceof AjAttribute.WeaverState) {
@@ -307,6 +318,7 @@ public class BcelObjectType extends AbstractReferenceTypeDelegate {
throw new BCException("bad attribute " + a);
}
}
+ return deferredAspectAttribute;
}
public PerClause getPerClause() {