Parcourir la source

fixes for 149560: (1) correct the bcel code for creating clinit call (2) don't let singleton aspects be implemented as late type mungers, the clinit manipulation breaks.

tags/BEFORE_133532
aclement il y a 18 ans
Parent
révision
945a257776

+ 20
- 0
tests/bugs153/pr149560/AnnStyle.java Voir le fichier

@@ -0,0 +1,20 @@
import org.aspectj.lang.annotation.*;
import org.aspectj.lang.*;

@Aspect
class MyAspect {
@After("staticinitialization(*)")
public void x(JoinPoint.StaticPart thisJoinPointStaticPart) {
System.out.println("after initialization "+thisJoinPointStaticPart);
}
}

public aspect AnnStyle {

static {
}

public static void main(String []argv) {
System.out.println("InstanceExists?"+Aspects.hasAspect(MyAspect.class));
}
}

+ 17
- 0
tests/bugs153/pr149560/CodeStyle.java Voir le fichier

@@ -0,0 +1,17 @@
import org.aspectj.lang.*;

aspect MyAspect {
after(): staticinitialization(*) {
System.out.println("after initialization "+thisJoinPointStaticPart);
}
}

public aspect CodeStyle {

static {
}

public static void main(String []argv) {
System.out.println("InstanceExists?"+Aspects.hasAspect(MyAspect.class));
}
}

+ 3
- 1
tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java Voir le fichier

@@ -27,7 +27,9 @@ public class Ajc153Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
// public void testArgnamesAndJavac_pr148381() { runTest("argNames and javac");}
// public void testCFlowXMLAspectLTW_pr149096() { runTest("cflow xml concrete aspect"); }
// public void testAmbiguousBinding_pr121805() { runTest("ambiguous binding");}
public void testIncorrectDeprecatedAnnotationProcessing_pr154332() { runTest("incorrect deprecated annotation processing");}
public void testIncorrectStaticinitializationWeaving_pr149560_1() { runTest("incorrect staticinitialization weaving - codestyle");}
public void testIncorrectStaticinitializationWeaving_pr149560_2() { runTest("incorrect staticinitialization weaving - annstyle");}
public void testIncorrectDeprecatedAnnotationProcessing_pr154332() { runTest("incorrect deprecated annotation processing");}
public void testPipeliningProblemWithAnnotationsDecp_pr153380_1() { runTest("pipelining decps");}
public void testUnwantedPointcutWarning_pr148219() { runTest("unwanted warning for pointcut");}
public void testDecpAndCflowadderMungerClash_pr152631() { runTest("decp and cflowadder munger clash");}

+ 28
- 0
tests/src/org/aspectj/systemtest/ajc153/ajc153.xml Voir le fichier

@@ -305,4 +305,32 @@
</run>
</ajc-test>
<ajc-test dir="bugs153/pr149560" title="incorrect staticinitialization weaving - codestyle">
<compile files="CodeStyle.java" options="-1.5 -showWeaveInfo">
<message kind="weave" text="Join point 'staticinitialization(void MyAspect.&lt;clinit&gt;())' in Type 'MyAspect' (CodeStyle.java:3) advised by after advice from 'MyAspect' (CodeStyle.java:4)"/>
<message kind="weave" test="Join point 'staticinitialization(void CodeStyle.&lt;clini&gt;())' in Type 'CodeStyle' (CodeStyle.java:9) advised by after advice from 'MyAspect' (CodeStyle.java:4)"/>
</compile>
<run class="CodeStyle">
<stdout>
<line text="after initialization staticinitialization(MyAspect.&lt;clinit&gt;)"/>
<line text="after initialization staticinitialization(CodeStyle.&lt;clinit&gt;)"/>
<line text="InstanceExists?true"/>
</stdout>
</run>
</ajc-test>
<ajc-test dir="bugs153/pr149560" title="incorrect staticinitialization weaving - annstyle">
<compile files="AnnStyle.java" options="-1.5 -showWeaveInfo">
<message kind="weave" text="Join point 'staticinitialization(void MyAspect.&lt;clinit&gt;())' in Type 'MyAspect' (AnnStyle.java:5) advised by after advice from 'MyAspect' (AnnStyle.java:7)"/>
<message kind="weave" test="Join point 'staticinitialization(void AnnStyle.&lt;clini&gt;())' in Type 'AnnStyle' (AnnStyle.java:12) advised by after advice from 'MyAspect' (AnnStyle.java:7)"/>
</compile>
<run class="AnnStyle">
<stdout>
<line text="after initialization staticinitialization(MyAspect.&lt;clinit&gt;)"/>
<line text="after initialization staticinitialization(AnnStyle.&lt;clinit&gt;)"/>
<line text="InstanceExists?true"/>
</stdout>
</run>
</ajc-test>
</suite>

+ 4
- 4
tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java Voir le fichier

@@ -658,16 +658,16 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa
assertTrue("Should be zero but reports "+EclipseFactory.debug_mungerCount,EclipseFactory.debug_mungerCount==0);
alter("PR141956","inc1");
build("PR141956");
assertTrue("Should be only one but reports "+EclipseFactory.debug_mungerCount,EclipseFactory.debug_mungerCount==1);
assertTrue("Should be two but reports "+EclipseFactory.debug_mungerCount,EclipseFactory.debug_mungerCount==2);
alter("PR141956","inc1");
build("PR141956");
assertTrue("Should be only one but reports "+EclipseFactory.debug_mungerCount,EclipseFactory.debug_mungerCount==1);
assertTrue("Should be two but reports "+EclipseFactory.debug_mungerCount,EclipseFactory.debug_mungerCount==2);
alter("PR141956","inc1");
build("PR141956");
assertTrue("Should be only one but reports "+EclipseFactory.debug_mungerCount,EclipseFactory.debug_mungerCount==1);
assertTrue("Should be two but reports "+EclipseFactory.debug_mungerCount,EclipseFactory.debug_mungerCount==2);
alter("PR141956","inc1");
build("PR141956");
assertTrue("Should be only one but reports "+EclipseFactory.debug_mungerCount,EclipseFactory.debug_mungerCount==1);
assertTrue("Should be two but reports "+EclipseFactory.debug_mungerCount,EclipseFactory.debug_mungerCount==2);
}


+ 1
- 1
weaver/src/org/aspectj/weaver/bcel/BcelPerClauseAspectAdder.java Voir le fichier

@@ -264,7 +264,7 @@ public class BcelPerClauseAspectAdder extends BcelTypeMunger {
clinit.getBody().append(il);

clinit.addExceptionHandler(
tryStart, handler, handler, new ObjectType("java.lang.Throwable"), false
tryStart, handler.getPrev(), handler, new ObjectType("java.lang.Throwable"), false
);
}


+ 9
- 3
weaver/src/org/aspectj/weaver/patterns/PerSingleton.java Voir le fichier

@@ -107,9 +107,15 @@ public class PerSingleton extends PerClause {
if (inAspect.isAnnotationStyleAspect() && !inAspect.isAbstract()) {
//TODO will those change be ok if we add a serializable aspect ?
// dig: "can't be Serializable/Cloneable unless -XserializableAspects"
inAspect.crosscuttingMembers.addLateTypeMunger(
inAspect.getWorld().makePerClauseAspect(inAspect, getKind())
);
if (getKind()==SINGLETON) { // pr149560
inAspect.crosscuttingMembers.addTypeMunger(
inAspect.getWorld().makePerClauseAspect(inAspect, getKind())
);
} else {
inAspect.crosscuttingMembers.addLateTypeMunger(
inAspect.getWorld().makePerClauseAspect(inAspect, getKind())
);
}
}

//ATAJ inline around advice support

Chargement…
Annuler
Enregistrer