Ver código fonte

tests and fix for pr114054 (erroneous handling of negation in per-object perclauses)

tags/V1_5_0RC1
acolyer 18 anos atrás
pai
commit
a4caeb9526

+ 30
- 0
tests/bugs150/Pr114054.aj Ver arquivo

@@ -0,0 +1,30 @@
public class Pr114054 {
public static boolean passed;
public static void main(String[] args) {
SampleSeries me = new SampleSeries();
me.okSeries();
me.open();
me.close();
if (!passed) {
throw new Error("failed to advise...");
}
}
static class SampleSeries {
void open() {}
void close() {}
void okSeries() {open(); close();}
}
static aspect AAAA
// comment this out, and !call(...) works
pertarget(tracked())
{
protected final pointcut tracked() :
call(void SampleSeries.*())
// comment this out, and pertarget works...
&& !call(void SampleSeries.*Series())
;
before() : tracked() {
Pr114054.passed = true;
}
}
}

+ 4
- 0
tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java Ver arquivo

@@ -739,6 +739,10 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
runTest("returning(Object) binding");
}
public void testPerTargetAndNegation() {
runTest("pertarget and negated pointcut");
}
/*
* Load-time weaving bugs
*/

+ 5
- 0
tests/src/org/aspectj/systemtest/ajc150/ajc150.xml Ver arquivo

@@ -37,6 +37,11 @@
</run>
</ajc-test>
<ajc-test dir="bugs150" pr="114054" title="pertarget and negated pointcut">
<compile files="Pr114054.aj" options=""/>
<run class="Pr114054"/>
</ajc-test>
<ajc-test dir="bugs150" pr="104220" title="adviceexecution join point toString forms">
<compile files="Pr104220.aj"/>
<run class="Pr104220">

+ 8
- 5
weaver/src/org/aspectj/weaver/patterns/PerThisOrTargetPointcutVisitor.java Ver arquivo

@@ -113,11 +113,14 @@ public class PerThisOrTargetPointcutVisitor extends IdentityPointcutVisitor {
}

public Object visit(NotPointcut node, Object data) {
TypePattern negated = getPerTypePointcut(node.getNegatedPointcut());
if (MAYBE.equals(negated)) {
return MAYBE;
}
return new NotTypePattern(negated);
// TypePattern negated = getPerTypePointcut(node.getNegatedPointcut());
// if (MAYBE.equals(negated)) {
// return MAYBE;
// }
// return new NotTypePattern(negated);
// AMC - the only safe thing to return here is maybe...
// see for example pr114054
return MAYBE;
}

public Object visit(ThisOrTargetAnnotationPointcut node, Object data) {

Carregando…
Cancelar
Salvar