소스 검색

aspects are reweavable by default, fixed issue in (AJC + LTW + Inlining + @AJ)

tags/PRE_ANDY
avasseur 19 년 전
부모
커밋
33c5c59a9e
25개의 변경된 파일313개의 추가작업 그리고 132개의 파일을 삭제
  1. 9
    2
      loadtime/src/org/aspectj/weaver/loadtime/Aj.java
  2. 3
    0
      loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java
  3. 12
    3
      loadtime/src/org/aspectj/weaver/loadtime/Options.java
  4. 1
    1
      org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/AjcTestCase.java
  5. 1
    1
      tests/java5/ataspectj/ajc-ant.xml
  6. 2
    69
      tests/java5/ataspectj/ataspectj/AroundInlineMungerTest.java
  7. 92
    0
      tests/java5/ataspectj/ataspectj/AroundInlineMungerTestAspects.java
  8. 4
    2
      tests/java5/ataspectj/ataspectj/TestHelper.java
  9. 7
    0
      tests/java5/ataspectj/ataspectj/aop-aroundinlinemungertest.xml
  10. 1
    1
      tests/java5/ataspectj/ataspectj/aop.xml
  11. 33
    9
      tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java
  12. 4
    1
      tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjSyntaxTests.java
  13. 49
    16
      tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml
  14. 6
    4
      tests/src/org/aspectj/systemtest/ajc150/ataspectj/syntax.xml
  15. 10
    0
      weaver/src/org/aspectj/weaver/bcel/BcelAccessForInlineMunger.java
  16. 8
    0
      weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java
  17. 5
    5
      weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java
  18. 13
    6
      weaver/src/org/aspectj/weaver/bcel/BcelShadow.java
  19. 17
    2
      weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java
  20. 4
    2
      weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java
  21. 25
    1
      weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java
  22. 2
    2
      weaver/src/org/aspectj/weaver/patterns/PerCflow.java
  23. 2
    2
      weaver/src/org/aspectj/weaver/patterns/PerObject.java
  24. 1
    1
      weaver/src/org/aspectj/weaver/patterns/PerSingleton.java
  25. 2
    2
      weaver/src/org/aspectj/weaver/patterns/PerTypeWithin.java

+ 9
- 2
loadtime/src/org/aspectj/weaver/loadtime/Aj.java 파일 보기

@@ -14,6 +14,7 @@ package org.aspectj.weaver.loadtime;
import java.io.File;
import java.io.FileOutputStream;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;
import java.util.WeakHashMap;

@@ -99,8 +100,14 @@ public class Aj implements ClassPreProcessor {
new Integer(bytes.length)
}
);
} catch (Throwable t) {
t.printStackTrace();
} catch (InvocationTargetException e) {
if (e.getTargetException() instanceof LinkageError) {
;//is already defined (happens for X$ajcMightHaveAspect interfaces since aspects are reweaved)
} else {
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
}


+ 3
- 0
loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java 파일 보기

@@ -121,6 +121,9 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor {
URL xml = (URL) xmls.nextElement();
definitions.add(DocumentParser.parse(xml));
}
// still go thru if definitions is empty since we will configure
// the default message handler in there
registerOptions(weaver, loader, definitions);
registerAspectExclude(weaver, loader, definitions);
registerAspects(weaver, loader, definitions);

+ 12
- 3
loadtime/src/org/aspectj/weaver/loadtime/Options.java 파일 보기

@@ -44,13 +44,14 @@ public class Options {
//FIXME dump option - dump what - dump before/after ?

public static WeaverOption parse(String options, ClassLoader laoder) {
if (LangUtil.isEmpty(options)) {
return new WeaverOption();
}
// the first option wins
List flags = LangUtil.anySplit(options, " ");
Collections.reverse(flags);

WeaverOption weaverOption = new WeaverOption();
weaverOption.messageHandler = new DefaultMessageHandler();//default


// do a first round on the message handler since it will report the options themselves
for (Iterator iterator = flags.iterator(); iterator.hasNext();) {
@@ -99,7 +100,7 @@ public class Options {
} else {
weaverOption.messageHandler.handleMessage(
new Message(
"Cannot configure weaver with option " + arg + ": unknown option",
"Cannot configure weaver with option '" + arg + "': unknown option",
IMessage.WARNING,
null,
null
@@ -132,5 +133,13 @@ public class Options {
boolean noInline;
boolean showWeaveInfo;
IMessageHandler messageHandler;

public WeaverOption() {
messageHandler = new DefaultMessageHandler();//default

//temp alex
messageHandler.dontIgnore(IMessage.WEAVEINFO);
messageHandler.dontIgnore(IMessage.INFO);
}
}
}

+ 1
- 1
org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/AjcTestCase.java 파일 보기

@@ -576,7 +576,7 @@ public class AjcTestCase extends TestCase {
fail("main method in class " + className + " is not public");
} catch (InvocationTargetException invTgt) {
// the main method threw an exception...
fail("Exception thrown by " + className + ".main(String[]) :" + invTgt.getTargetException());
fail("Exception thrown by " + className + ".main(String[]) :" + invTgt.getTargetException());
} finally {
System.setOut(systemOut);
System.setErr(systemErr);

+ 1
- 1
tests/java5/ataspectj/ajc-ant.xml 파일 보기

@@ -34,7 +34,7 @@
<java fork="yes" classname="ataspectj.AroundInlineMungerTest" failonerror="yes">
<classpath refid="aj.path"/>
<jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
<jvmarg value="-Daj5.def=ataspectj/aop.xml"/>
<jvmarg value="-Daj5.def=ataspectj/aop-aroundinlinemungertest.xml"/>
</java>
</target>


+ 2
- 69
tests/java5/ataspectj/ataspectj/AroundInlineMungerTest.java 파일 보기

@@ -32,77 +32,10 @@ public class AroundInlineMungerTest extends TestCase {

public void testAccessNonPublicFromAroundAdvice() {
target();
assertEquals(3, Open.aroundCount);
assertEquals(6, Open.beforeCount);
assertEquals(3, AroundInlineMungerTestAspects.Open.aroundCount);
assertEquals(6, AroundInlineMungerTestAspects.Open.beforeCount);
}

public void target() {}

public static class OpenBase {
protected void superMethod() {}
}

public static class OpenSubBase extends OpenBase {}

// aspect will be prepared for inlining
@Aspect
public static class Open extends OpenSubBase {

public static int aroundCount = 0;
public static int beforeCount = 0;

private int i;
private static int I;

@Around("execution(* ataspectj.AroundInlineMungerTest.target())")
public Object around1(ProceedingJoinPoint jp) throws Throwable {
aroundCount++;
priv(1, 2L, 3);
super.superMethod();
new Inner().priv();//fails to be wrapped so this advice will not be inlined but previous call were still prepared
return jp.proceed();
}

// this advice to test around advice body call/get/set advising
@Before("(call(* ataspectj.AroundInlineMungerTest.Open.priv(..))" +
" || get(int ataspectj.AroundInlineMungerTest.Open.i)" +
" || set(int ataspectj.AroundInlineMungerTest.Open.i)" +
" || get(int ataspectj.AroundInlineMungerTest.Open.I)" +
" || set(int ataspectj.AroundInlineMungerTest.Open.I)" +
" )&& this(ataspectj.AroundInlineMungerTest.Open)")
public void before1() {
beforeCount++;
}

@Around("execution(* ataspectj.AroundInlineMungerTest.target())")
public Object around2(ProceedingJoinPoint jp) throws Throwable {
aroundCount++;
super.superMethod();
new Inner().priv();//fails to be wrapped so next calls won't be prepared but previous was
priv(1, 2L, 3);
return jp.proceed();
}

@Around("execution(* ataspectj.AroundInlineMungerTest.target())")
public Object around3(ProceedingJoinPoint jp) throws Throwable {
aroundCount++;
// all those field access will be wrapped
int li = i;
i = li;
int lI = I;
I = lI;
return jp.proceed();
}

// -- some private member for which access will be wrapped so that around advice can be inlined

private void priv(int i, long j, int k) {
long l = i + j + k;
}

private static class Inner {
private Inner() {}
private void priv() {};
}
}
}

+ 92
- 0
tests/java5/ataspectj/ataspectj/AroundInlineMungerTestAspects.java 파일 보기

@@ -0,0 +1,92 @@
/*******************************************************************************
* Copyright (c) 2005 Contributors.
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Eclipse Public License v1.0
* which accompanies this distribution and is available at
* http://eclipse.org/legal/epl-v10.html
*
* Contributors:
* Alexandre Vasseur initial implementation
*******************************************************************************/
package ataspectj;

import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.ProceedingJoinPoint;

/**
* @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
*/
public class AroundInlineMungerTestAspects {

public static class OpenBase {
protected void superMethod() {}
}

public static class OpenSubBase extends OpenBase {}

// aspect will be prepared for inlining
@Aspect
public static class Open extends OpenSubBase {

public static int aroundCount = 0;
public static int beforeCount = 0;

private int i;
private static int I;

@Around("execution(* ataspectj.AroundInlineMungerTest.target())")
public Object around1(ProceedingJoinPoint jp) throws Throwable {
aroundCount++;
priv(1, 2L, 3);
super.superMethod();
new Open.Inner().priv();//fails to be wrapped so this advice will not be inlined but previous call were still prepared
return jp.proceed();
}

// this advice to test around advice body call/get/set advising
@Before("(call(* ataspectj.AroundInlineMungerTestAspects.Open.priv(..))" +
" || get(int ataspectj.AroundInlineMungerTestAspects.Open.i)" +
" || set(int ataspectj.AroundInlineMungerTestAspects.Open.i)" +
" || get(int ataspectj.AroundInlineMungerTestAspects.Open.I)" +
" || set(int ataspectj.AroundInlineMungerTestAspects.Open.I)" +
" )&& this(ataspectj.AroundInlineMungerTestAspects.Open)")
public void before1() {
beforeCount++;
}

@Around("execution(* ataspectj.AroundInlineMungerTest.target())")
public Object around2(ProceedingJoinPoint jp) throws Throwable {
aroundCount++;
super.superMethod();
new Open.Inner().priv();//fails to be wrapped so next calls won't be prepared but previous was
priv(1, 2L, 3);
return jp.proceed();
}

@Around("execution(* ataspectj.AroundInlineMungerTest.target())")
public Object around3(ProceedingJoinPoint jp) throws Throwable {
aroundCount++;
// all those field access will be wrapped
int li = i;
i = li;
int lI = I;
I = lI;
return jp.proceed();
}

// -- some private member for which access will be wrapped so that around advice can be inlined

private void priv(int i, long j, int k) {
long l = i + j + k;
}

private static class Inner {
private Inner() {}
private void priv() {};
}
}

}

+ 4
- 2
tests/java5/ataspectj/ataspectj/TestHelper.java 파일 보기

@@ -40,13 +40,15 @@ public class TestHelper extends DefaultMessageHandler {
Enumeration e = rr.failures();
while (e.hasMoreElements()) {
sb.append("JUnit Failure: ");
sb.append(((TestFailure)e.nextElement()).thrownException().toString());
TestFailure failure = (TestFailure)e.nextElement();
sb.append(failure.thrownException().toString());
sb.append("\n");
}
e = rr.errors();
while (e.hasMoreElements()) {
sb.append("JUnit Error: ");
sb.append(((TestFailure)e.nextElement()).thrownException().toString());
TestFailure failure = (TestFailure)e.nextElement();
sb.append(failure.thrownException().toString());
sb.append("\n");
}
throw new RuntimeException(sb.toString());

+ 7
- 0
tests/java5/ataspectj/ataspectj/aop-aroundinlinemungertest.xml 파일 보기

@@ -0,0 +1,7 @@
<?xml version="1.0"?>
<aspectj>
<weaver options="-XmessageHolderClass:ataspectj.TestHelper"/>
<aspects>
<aspect name="ataspectj.AroundInlineMungerTestAspects.Open"/>
</aspects>
</aspectj>

+ 1
- 1
tests/java5/ataspectj/ataspectj/aop.xml 파일 보기

@@ -21,6 +21,6 @@
<aspect name="ataspectj.PerClauseTestAspects.TestAspectPerCflow"/>
<aspect name="ataspectj.PerClauseTestAspects.TestAspectPTW"/>

<aspect name="ataspectj.AroundInlineMungerTest.Open"/>
<aspect name="ataspectj.AroundInlineMungerTestAspects.Open"/>
</aspects>
</aspectj>

+ 33
- 9
tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java 파일 보기

@@ -29,15 +29,39 @@ public class AtAjLTWTests extends XMLBasedAjcTestCase {
return new File("../tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml");
}

public void testRunThemAllWithJavacCompiledAndLTW() {
runTest("RunThemAllWithJavacCompiledAndLTW");
}

public void testAjcLTWPerClauseTest_XnoWeave() {
runTest("AjcLTW PerClauseTest -XnoWeave");
}
//FIXME AV - those all 4 depends on #75442...
// public void testRunThemAllWithJavacCompiledAndLTW() {
// runTest("RunThemAllWithJavacCompiledAndLTW");
// }
//
// public void testAjcLTWPerClauseTest_XnoWeave() {
// runTest("AjcLTW PerClauseTest -XnoWeave");
// }
//
// public void testAjcLTWPerClauseTest_Xreweavable() {
// runTest("AjcLTW PerClauseTest -Xreweavable");
// }
//
// public void testJavaCAjcLTWPerClauseTest() {
// runTest("JavaCAjcLTW PerClauseTest");
// }

public void testAjcLTWAroundInlineMungerTest_XnoWeave() {
runTest("AjcLTW AroundInlineMungerTest -XnoWeave");
}

public void testAjcLTWAroundInlineMungerTest_Xreweavable() {
runTest("AjcLTW AroundInlineMungerTest -Xreweavable");
}

public void testAjcLTWAroundInlineMungerTest() {
runTest("AjcLTW AroundInlineMungerTest");
}

public void testAjcLTWAroundInlineMungerTest_XnoInline_Xreweavable() {
runTest("AjcLTW AroundInlineMungerTest -XnoInline -Xreweavable");
}


public void testAjcLTWPerClauseTest_Xreweavable() {
runTest("AjcLTW PerClauseTest -Xreweavable");
}
}

+ 4
- 1
tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjSyntaxTests.java 파일 보기

@@ -32,7 +32,6 @@ public class AtAjSyntaxTests extends XMLBasedAjcTestCase {
return new File("../tests/src/org/aspectj/systemtest/ajc150/ataspectj/syntax.xml");
}


public void testSimpleBefore() {
runTest("SimpleBefore");
}
@@ -77,6 +76,10 @@ public class AtAjSyntaxTests extends XMLBasedAjcTestCase {
runTest("PerClause");
}

public void testAroundInlineMunger_XnoInline() {
runTest("AroundInlineMunger -XnoInline");
}

public void testAroundInlineMunger() {
runTest("AroundInlineMunger");
}

+ 49
- 16
tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml 파일 보기

@@ -19,21 +19,54 @@
<ant file="ajc-ant.xml" target="ltw.PerClauseTest" verbose="true"/>
</ajc-test>

<!-- FIXME AV: todo by Andy-->
<!-- <ajc-test dir="java5/ataspectj" title="JavaCAjcLTW PerClauseTest">-->
<!-- <compile-->
<!-- files="ataspectj/PerClauseTest.java,ataspectj/TestHelper.java"-->
<!-- options="-1.5 -XnoWeave"/>-->
<!-- <comment>-->
<!-- aspectOf methods will be pushed in, ignore warning for adviceDidNotMatch but still do the logic for them-->
<!-- since such just added methods are an interesting case (percflow ajc$perCflowStack advice)-->
<!-- </comment>-->
<!-- <compile-->
<!-- files="ataspectj/PerClauseTestAspects.java"-->
<!-- options="-1.5 -Xdev:NoAtAspectJProcessing">-->
<!-- <message kind="warning"/>-->
<!-- </compile>-->
<!-- <ant file="ajc-ant.xml" target="ltw.PerClauseTest" verbose="true"/>-->
<!-- </ajc-test>-->
<ajc-test dir="java5/ataspectj" title="JavaCAjcLTW PerClauseTest">
<compile
files="ataspectj/PerClauseTest.java,ataspectj/TestHelper.java,ataspectj/PerClauseTestAspects.java"
options="-1.5 -XnoWeave"/>
<comment>
aspectOf methods will be pushed in, ignore warning for adviceDidNotMatch but still do the logic for them
since such just added methods are an interesting case (percflow ajc$perCflowStack advice)
</comment>
<compile
files="ataspectj/PerClauseTestAspects.java"
options="-1.5 -Xdev:NoAtAspectJProcessing">
<message kind="warning"/>
</compile>
<ant file="ajc-ant.xml" target="ltw.PerClauseTest" verbose="true"/>
</ajc-test>

<ajc-test dir="java5/ataspectj" title="AjcLTW AroundInlineMungerTest -XnoWeave">
<compile
files="ataspectj/AroundInlineMungerTest.java,ataspectj/AroundInlineMungerTestAspects.java,ataspectj/TestHelper.java"
options="-1.5 -XnoWeave"/>
<ant file="ajc-ant.xml" target="ltw.AroundInlineMungerTest" verbose="true"/>
</ajc-test>

<ajc-test dir="java5/ataspectj" title="AjcLTW AroundInlineMungerTest -Xreweavable">
<compile
files="ataspectj/AroundInlineMungerTest.java,ataspectj/AroundInlineMungerTestAspects.java,ataspectj/TestHelper.java"
options="-1.5 -Xreweavable"/>
<ant file="ajc-ant.xml" target="ltw.AroundInlineMungerTest" verbose="true"/>
</ajc-test>

<ajc-test dir="java5/ataspectj" title="AjcLTW AroundInlineMungerTest">
<compile
files="ataspectj/AroundInlineMungerTestAspects.java"
options="-1.5 -Xlint:ignore"/>
<compile
files="ataspectj/AroundInlineMungerTest.java,ataspectj/TestHelper.java"
options="-1.5 -Xreweavable"/>
<ant file="ajc-ant.xml" target="ltw.AroundInlineMungerTest" verbose="true"/>
</ajc-test>

<ajc-test dir="java5/ataspectj" title="AjcLTW AroundInlineMungerTest -XnoInline -Xreweavable">
<compile
files="ataspectj/AroundInlineMungerTestAspects.java"
options="-1.5 -Xlint:ignore -XnoInline -Xreweavable"/>
<compile
files="ataspectj/AroundInlineMungerTest.java,ataspectj/TestHelper.java"
options="-1.5 -Xreweavable -XnoInline"/>
<ant file="ajc-ant.xml" target="ltw.AroundInlineMungerTest" verbose="true"/>
</ajc-test>

</suite>

+ 6
- 4
tests/src/org/aspectj/systemtest/ajc150/ataspectj/syntax.xml 파일 보기

@@ -86,11 +86,13 @@
<run class="ataspectj.PerClauseTest"/>
</ajc-test>

<ajc-test dir="java5/ataspectj" title="AroundInlineMunger">
<compile files="ataspectj/AroundInlineMungerTest.java,ataspectj/TestHelper.java" options="-1.5 -XnoInline -Xdev:NoAtAspectJProcessing -Xlint:ignore"/>
<run class="ataspectj.AroundInlineMungerTest"/>
<compile files="ataspectj/AroundInlineMungerTest.java,ataspectj/TestHelper.java" options="-1.5 -Xdev:NoAtAspectJProcessing -Xlint:ignore"/>
<ajc-test dir="java5/ataspectj" title="AroundInlineMunger -XnoInline">
<compile files="ataspectj/AroundInlineMungerTest.java,ataspectj/AroundInlineMungerTestAspects.java,ataspectj/TestHelper.java" options="-1.5 -XnoInline -Xdev:NoAtAspectJProcessing -Xlint:ignore"/>
<run class="ataspectj.AroundInlineMungerTest"/>
</ajc-test>

<ajc-test dir="java5/ataspectj" title="AroundInlineMunger">
<compile files="ataspectj/AroundInlineMungerTest.java,ataspectj/AroundInlineMungerTestAspects.java,ataspectj/TestHelper.java" options="-1.5 -Xdev:NoAtAspectJProcessing -Xlint:ignore"/>
<run class="ataspectj.AroundInlineMungerTest"/>
</ajc-test>
</suite>

+ 10
- 0
weaver/src/org/aspectj/weaver/bcel/BcelAccessForInlineMunger.java 파일 보기

@@ -48,6 +48,9 @@ import java.util.List;
* Specific state and logic is kept in the munger ala ITD so that call/get/set pointcuts can still be matched
* on the wrapped member thanks to the EffectiveSignature attribute.
*
* FIXME AV - this whole one should be skept when -XnoInline is used
* (add breakpoint on lazyMethodGen.setCanInline to see where things happening)
*
* @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
*/
public class BcelAccessForInlineMunger extends BcelTypeMunger {
@@ -219,6 +222,13 @@ public class BcelAccessForInlineMunger extends BcelTypeMunger {

curr = next;
}

// no reason for not inlining this advice
// since it is used for @AJ advice that cannot be inlined by defauilt
// make sure we set inline to true since we have done this analysis
if (!realizedCannotInline) {
aroundAdvice.setCanInline(true);
}
}

/**

+ 8
- 0
weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java 파일 보기

@@ -21,6 +21,7 @@ import java.util.Collections;
import org.aspectj.apache.bcel.generic.InstructionFactory;
import org.aspectj.apache.bcel.generic.InstructionHandle;
import org.aspectj.apache.bcel.generic.InstructionList;
import org.aspectj.apache.bcel.generic.ReferenceType;
import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.Message;
import org.aspectj.weaver.Advice;
@@ -367,6 +368,13 @@ public class BcelAdvice extends Advice {
// ATAJ: for @AJ aspects, handle implicit binding of xxJoinPoint
if (getKind() == AdviceKind.Around) {
il.append(closureInstantiation);
//
// if (canInline(shadow)) {
// //FIXME ALEX? passin a boolean instead of checking there
// il.append(fact.createCheckCast(
// (ReferenceType) BcelWorld.makeBcelType(TypeX.forName("org.aspectj.lang.ProceedingJoinPoint"))
// ));
// }
continue;
} else if ("Lorg/aspectj/lang/JoinPoint$StaticPart;".equals(getSignature().getParameterTypes()[i].getSignature())) {
if ((getExtraParameterFlags() & ThisJoinPointStaticPart) != 0) {

+ 5
- 5
weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java 파일 보기

@@ -327,7 +327,7 @@ class BcelClassWeaver implements IClassWeaver {

Set aspectsAffectingType = null;
if (inReweavableMode) aspectsAffectingType = new HashSet();
if (inReweavableMode || clazz.getType().isAspect()) aspectsAffectingType = new HashSet();
boolean isChanged = false;
@@ -345,7 +345,7 @@ class BcelClassWeaver implements IClassWeaver {
boolean typeMungerAffectedType = munger.munge(this);
if (typeMungerAffectedType) {
isChanged = true;
if (inReweavableMode) aspectsAffectingType.add(munger.getAspectType().getName());
if (inReweavableMode || clazz.getType().isAspect()) aspectsAffectingType.add(munger.getAspectType().getName());
}
}

@@ -378,7 +378,7 @@ class BcelClassWeaver implements IClassWeaver {
boolean shadowMungerMatched = match(mg);
if (shadowMungerMatched) {
// For matching mungers, add their declaring aspects to the list that affected this type
if (inReweavableMode) aspectsAffectingType.addAll(findAspectsForMungers(mg));
if (inReweavableMode || clazz.getType().isAspect()) aspectsAffectingType.addAll(findAspectsForMungers(mg));
isChanged = true;
}
}
@@ -415,7 +415,7 @@ class BcelClassWeaver implements IClassWeaver {
boolean typeMungerAffectedType = munger.munge(this);
if (typeMungerAffectedType) {
isChanged = true;
if (inReweavableMode) aspectsAffectingType.add(munger.getAspectType().getName());
if (inReweavableMode || clazz.getType().isAspect()) aspectsAffectingType.add(munger.getAspectType().getName());
}
}
}
@@ -429,7 +429,7 @@ class BcelClassWeaver implements IClassWeaver {
weaveInAddedMethods(); // FIXME asc are these potentially affected by declare annotation?
}
if (inReweavableMode) {
if (inReweavableMode || clazz.getType().isAspect()) {
WeaverStateInfo wsi = clazz.getOrCreateWeaverStateInfo();
wsi.addAspectsAffectingType(aspectsAffectingType);
wsi.setUnwovenClassFileData(ty.getJavaClass().getBytes());

+ 13
- 6
weaver/src/org/aspectj/weaver/bcel/BcelShadow.java 파일 보기

@@ -52,6 +52,7 @@ import org.aspectj.apache.bcel.generic.SWAP;
import org.aspectj.apache.bcel.generic.StoreInstruction;
import org.aspectj.apache.bcel.generic.TargetLostException;
import org.aspectj.apache.bcel.generic.Type;
import org.aspectj.apache.bcel.generic.ReferenceType;
import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.ISourceLocation;
import org.aspectj.bridge.Message;
@@ -1933,8 +1934,7 @@ public class BcelShadow extends Shadow {
BcelObjectType ot = BcelWorld.getBcelObjectType(declaringType);
LazyMethodGen adviceMethod = ot.getLazyClassGen().getLazyMethodGen(mungerSig);
if (!adviceMethod.getCanInline())
{
if (!adviceMethod.getCanInline()) {
weaveAroundClosure(munger, hasDynamicTest);
return;
}
@@ -2357,6 +2357,14 @@ public class BcelShadow extends Shadow {
ResolvedTypeX stateTypeX = BcelWorld.fromBcel(stateType).resolve(world);
if ("Lorg/aspectj/lang/JoinPoint;".equals(stateType.getSignature())) {
ret.append(new ALOAD(localJp));// from localAdvice signature
// } else if ("Lorg/aspectj/lang/ProceedingJoinPoint;".equals(stateType.getSignature())) {
// //FIXME ALEX?
// ret.append(new ALOAD(localJp));// from localAdvice signature
//// ret.append(fact.createCheckCast(
//// (ReferenceType) BcelWorld.makeBcelType(stateTypeX)
//// ));
// // cast ?
//
} else {
ret.append(InstructionFactory.createLoad(stateType, i));
}
@@ -2452,10 +2460,7 @@ public class BcelShadow extends Shadow {
// return ret;
}

public void weaveAroundClosure(
BcelAdvice munger,
boolean hasDynamicTest)
{
public void weaveAroundClosure(BcelAdvice munger, boolean hasDynamicTest) {
InstructionFactory fact = getFactory();

enclosingMethod.setCanInline(false);
@@ -2938,6 +2943,8 @@ public class BcelShadow extends Shadow {
// join point, it is unnecessary to accept (and pass) tjp.
if (thisJoinPointVar != null) {
parameterTypes = addTypeToEnd(LazyClassGen.tjpType, parameterTypes);
//FIXME ALEX? which one
//parameterTypes = addTypeToEnd(LazyClassGen.proceedingTjpType, parameterTypes);
}
TypeX returnType;

+ 17
- 2
weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java 파일 보기

@@ -162,6 +162,8 @@ public class BcelWeaver implements IWeaver {

//System.out.println("type: " + type + " for " + aspectName);
if (type.isAspect()) {
//TODO AV - happens to reach that a lot of time: for each type flagged reweavable X for each aspect in the weaverstate
//=> mainly for nothing for LTW - pbly for something in incremental build...
xcutSet.addOrReplaceAspect(type);
} else {
// FIXME : Alex: better warning upon no such aspect from aop.xml
@@ -945,7 +947,19 @@ public class BcelWeaver implements IWeaver {
BcelObjectType classType = getClassType(className);
processReweavableStateIfPresent(className, classType);
}

// register all aspect that have been extracted from reweavable state for LTW
// note: when doing AJC, the missing aspect is already catch in the previous state thru Type.MISSING
if (alreadyConfirmedReweavableState != null) {
for (Iterator iterator = alreadyConfirmedReweavableState.iterator(); iterator.hasNext();) {
String aspectClassName = (String) iterator.next();
addLibraryAspect(aspectClassName);
}
// refresh all the stuff... perhaps too much here...
if (!alreadyConfirmedReweavableState.isEmpty())
prepareForWeave();
}

requestor.addingTypeMungers();
// We process type mungers in two groups, first mungers that change the type
@@ -1062,7 +1076,8 @@ public class BcelWeaver implements IWeaver {
world.showMessage(IMessage.INFO,
WeaverMessages.format(WeaverMessages.REWEAVABLE_MODE),
null, null);

//TODO AV - can't we avoid this creation (LTW = happens for each class load!)
alreadyConfirmedReweavableState = new HashSet();
}

+ 4
- 2
weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java 파일 보기

@@ -639,7 +639,7 @@ public final class LazyClassGen {
public boolean isReweavable() {
if (myType.getWeaverState()==null) return false;
return myType.getWeaverState().isReweavable();
return myType.getWeaverState().isReweavable();
}
public Set getAspectsAffectingType() {
@@ -700,7 +700,9 @@ public final class LazyClassGen {
// reflective thisJoinPoint support
Map/*BcelShadow, Field*/ tjpFields = new HashMap();
public static final ObjectType tjpType =
public static final ObjectType proceedingTjpType =
new ObjectType("org.aspectj.lang.ProceedingJoinPoint");
public static final ObjectType tjpType =
new ObjectType("org.aspectj.lang.JoinPoint");
public static final ObjectType staticTjpType =
new ObjectType("org.aspectj.lang.JoinPoint$StaticPart");

+ 25
- 1
weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java 파일 보기

@@ -100,7 +100,7 @@ public final class LazyMethodGen {

private int maxLocals;
private boolean canInline = true;
private boolean canInline = true;//FIXME AV - ALEX? shouldn't that default to false or unknown?
private boolean hasExceptionHandlers;
private boolean isSynthetic = false;
@@ -140,6 +140,18 @@ public final class LazyMethodGen {
this.attributes = new Attribute[0];
this.enclosingClass = enclosingClass;
assertGoodBody();

// @AJ advice are not inlined by default since requires further analysis
// and weaving ordering control
// TODO AV - improve - note: no room for improvement as long as aspects are reweavable
// since the inlined version with wrappers and an to be done annotation to keep
// inline state will be garbaged due to reweavable impl
if (memberView != null && isAdviceMethod()) {
if (enclosingClass.getType().isAnnotationStyleAspect()) {
//TODO we could check for @Around advice as well
this.canInline = false;
}
}
}
private int calculateMaxLocals() {
@@ -167,6 +179,18 @@ public final class LazyMethodGen {
this.accessFlags = m.getAccessFlags();
this.name = m.getName();

// @AJ advice are not inlined by default since requires further analysis
// and weaving ordering control
// TODO AV - improve - note: no room for improvement as long as aspects are reweavable
// since the inlined version with wrappers and an to be done annotation to keep
// inline state will be garbaged due to reweavable impl
if (memberView != null && isAdviceMethod()) {
if (enclosingClass.getType().isAnnotationStyleAspect()) {
//TODO we could check for @Around advice as well
this.canInline = false;
}
}
}
public boolean hasDeclaredLineNumberInfo() {

+ 2
- 2
weaver/src/org/aspectj/weaver/patterns/PerCflow.java 파일 보기

@@ -105,9 +105,9 @@ public class PerCflow extends PerClause {
);
}

//ATAJ inline around advice support
//ATAJ inline around advice support - don't use a late munger to allow around inling for itself
if (Ajc5MemberMaker.isAnnotationStyleAspect(inAspect)) {
inAspect.crosscuttingMembers.addLateTypeMunger(new BcelAccessForInlineMunger(inAspect));
inAspect.crosscuttingMembers.addTypeMunger(new BcelAccessForInlineMunger(inAspect));
}

return ret;

+ 2
- 2
weaver/src/org/aspectj/weaver/patterns/PerObject.java 파일 보기

@@ -118,9 +118,9 @@ public class PerObject extends PerClause {
);
}

//ATAJ inline around advice support
//ATAJ inline around advice support - don't use a late munger to allow around inling for itself
if (Ajc5MemberMaker.isAnnotationStyleAspect(inAspect)) {
inAspect.crosscuttingMembers.addLateTypeMunger(new BcelAccessForInlineMunger(inAspect));
inAspect.crosscuttingMembers.addTypeMunger(new BcelAccessForInlineMunger(inAspect));
}

return ret;

+ 1
- 1
weaver/src/org/aspectj/weaver/patterns/PerSingleton.java 파일 보기

@@ -107,7 +107,7 @@ public class PerSingleton extends PerClause {

//ATAJ inline around advice support
if (Ajc5MemberMaker.isAnnotationStyleAspect(inAspect)) {
inAspect.crosscuttingMembers.addLateTypeMunger(new BcelAccessForInlineMunger(inAspect));
inAspect.crosscuttingMembers.addTypeMunger(new BcelAccessForInlineMunger(inAspect));
}

return ret;

+ 2
- 2
weaver/src/org/aspectj/weaver/patterns/PerTypeWithin.java 파일 보기

@@ -155,9 +155,9 @@ public class PerTypeWithin extends PerClause {
);
}

//ATAJ inline around advice support
//ATAJ inline around advice support - don't use a late munger to allow around inling for itself
if (Ajc5MemberMaker.isAnnotationStyleAspect(inAspect)) {
inAspect.crosscuttingMembers.addLateTypeMunger(new BcelAccessForInlineMunger(inAspect));
inAspect.crosscuttingMembers.addTypeMunger(new BcelAccessForInlineMunger(inAspect));
}

return ret;

Loading…
취소
저장