Browse Source

due fix and test for @AJ ITD reweavable, serialization of the method delegate munger

tags/V1_5_0RC1
avasseur 18 years ago
parent
commit
51a117846c

+ 39
- 0
tests/java5/ataspectj/ajc-ant.xml View File

@@ -122,4 +122,43 @@
<jvmarg value="-Daj5.def=ataspectj/aop-unweavabletest.xml"/>
</java>
</target>

<target name="ltw.Decp">
<java fork="yes" classname="ataspectj.DeclareParentsInterfaceTest" failonerror="yes">
<classpath>
<path refid="aj.path"/>
</classpath>
<jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
<jvmarg value="-Daj5.def=ataspectj/aop-decptest.xml"/>
</java>
<java fork="yes" classname="ataspectj.DeclareParentsImplementsTest" failonerror="yes">
<classpath>
<path refid="aj.path"/>
</classpath>
<jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
<jvmarg value="-Daj5.def=ataspectj/aop-decptest.xml"/>
</java>
</target>

<target name="ltw.Decp2">
<!-- javac compile the 2nd aspect -->
<javac destdir="${aj.sandbox}"
srcdir="${basedir}"
includes="ataspectj/DeclareParentsImplementsReweavableTestAspect.java"
debug="true">
<classpath>
<path refid="aj.path"/>
<pathelement path="${aj.sandbox}"/>
</classpath>
</javac>

<java fork="yes" classname="ataspectj.DeclareParentsImplementsReweavableTest" failonerror="yes">
<classpath>
<path refid="aj.path"/>
</classpath>
<jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
<jvmarg value="-Daj5.def=ataspectj/aop-decptest2.xml"/>
<jvmarg line="${jdwp}"/>
</java>
</target>
</project>

+ 65
- 0
tests/java5/ataspectj/ataspectj/DeclareParentsImplementsReweavableTest.java View File

@@ -0,0 +1,65 @@
/*******************************************************************************
* 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 junit.framework.TestCase;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.DeclareParents;

import java.util.Arrays;

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

static class Target {}

static interface I1 { int do1(); }

static class Imp1 implements I1 {
public int do1() {return 1;}
}

public static interface I2 { int do2(); }

public static class Imp2 implements I2 {
public int do2() {return 2;}
}

@Aspect
static class TestAspect {

@DeclareParents("ataspectj.DeclareParentsImplementsReweavableTest.Target")
public static I1 i1 = new Imp1();
}

public void testDecPInt() {
Class[] intfs = Target.class.getInterfaces();
assertTrue("I1 was not introduced", Arrays.asList(intfs).contains(I1.class));
assertEquals(1, ((I1)new Target()).do1());

// test stuff weaved in by DeclareParentsImplementsReweavableAspect
// thru reweable mode
assertTrue("I2 was not introduced", Arrays.asList(intfs).contains(I2.class));
assertEquals(2, ((I2)new Target()).do2());
}

public static void main(String[] args) {
TestHelper.runAndThrowOnFailure(suite());
}

public static junit.framework.Test suite() {
return new junit.framework.TestSuite(DeclareParentsImplementsReweavableTest.class);
}

}

+ 26
- 0
tests/java5/ataspectj/ataspectj/DeclareParentsImplementsReweavableTestAspect.java View File

@@ -0,0 +1,26 @@
/*******************************************************************************
* 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.DeclareParents;

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

@DeclareParents("ataspectj.DeclareParentsImplementsReweavableTest.Target")
public static DeclareParentsImplementsReweavableTest.I2 i2 = new DeclareParentsImplementsReweavableTest.Imp2();

}

+ 8
- 0
tests/java5/ataspectj/ataspectj/aop-decptest.xml View File

@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<aspectj>
<weaver options="-XmessageHandlerClass:ataspectj.TestHelper"/>
<aspects>
<aspect name="ataspectj.DeclareParentsImplementsTest.TestAspect"/>
<aspect name="ataspectj.DeclareParentsInterfaceTest.TestAspect"/>
</aspects>
</aspectj>

+ 8
- 0
tests/java5/ataspectj/ataspectj/aop-decptest2.xml View File

@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<aspectj>
<weaver options="-XmessageHandlerClass:ataspectj.TestHelper"/>
<aspects>
<aspect name="ataspectj.DeclareParentsImplementsReweavableTest.TestAspect"/>
<aspect name="ataspectj.DeclareParentsImplementsReweavableTestAspect"/>
</aspects>
</aspectj>

+ 7
- 0
tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java View File

@@ -82,4 +82,11 @@ public class AtAjLTWTests extends XMLBasedAjcTestCase {
runTest("LTW Unweavable");
}

public void testLTWDecp() {
runTest("LTW Decp");
}

public void testLTWDecp2() {
runTest("LTW Decp2");
}
}

+ 18
- 0
tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml View File

@@ -102,4 +102,22 @@
<ant file="ajc-ant.xml" target="ltw.Unweavable" verbose="true"/>
</ajc-test>

<ajc-test dir="java5/ataspectj" title="LTW Decp">
<!-- ajc compile them to test reweable as well -->
<compile
files="ataspectj/DeclareParentsInterfaceTest.java,ataspectj/DeclareParentsImplementsTest.java,ataspectj/TestHelper.java"
options="-1.5"
/>
<ant file="ajc-ant.xml" target="ltw.Decp" verbose="true"/>
</ajc-test>

<ajc-test dir="java5/ataspectj" title="LTW Decp2">
<!-- ajc compile them but with only one aspect -->
<compile
files="ataspectj/DeclareParentsImplementsReweavableTest.java,ataspectj/TestHelper.java"
options="-1.5"
/>
<!-- compile the other aspect alone (won't be applied) -->
<ant file="ajc-ant.xml" target="ltw.Decp2" verbose="true"/>
</ajc-test>
</suite>

+ 18
- 9
weaver/src/org/aspectj/weaver/MethodDelegateTypeMunger.java View File

@@ -65,22 +65,31 @@ public class MethodDelegateTypeMunger extends ResolvedTypeMunger {
}
}

private MethodDelegateTypeMunger(ResolvedMember signature, ResolvedMember fieldDelegate, TypePattern typePattern) {
super(MethodDelegate, signature);
this.aspectFieldDelegate = fieldDelegate;
this.typePattern = typePattern;
}

public ResolvedMember getDelegate() {
return aspectFieldDelegate;
}

public void write(DataOutputStream s) throws IOException {
;//FIXME AVITD needed as changes public signature throw new RuntimeException("unimplemented");
kind.write(s);
signature.write(s);
aspectFieldDelegate.write(s);
typePattern.write(s);
}

// public static ResolvedTypeMunger readMethod(VersionedDataInputStream s, ISourceContext context) throws IOException {
// ResolvedMemberImpl rmi = ResolvedMemberImpl.readResolvedMember(s, context);
// Set superMethodsCalled = readSuperMethodsCalled(s);
// ISourceLocation sLoc = readSourceLocation(s);
// ResolvedTypeMunger munger = new MethodDelegateTypeMunger(rmi, superMethodsCalled);
// if (sLoc != null) munger.setSourceLocation(sLoc);
// return munger;
// }
public static ResolvedTypeMunger readMethod(VersionedDataInputStream s, ISourceContext context) throws IOException {
ResolvedMemberImpl signature = ResolvedMemberImpl.readResolvedMember(s, context);
ResolvedMemberImpl field = ResolvedMemberImpl.readResolvedMember(s, context);
TypePattern tp = TypePattern.read(s, context);
return new MethodDelegateTypeMunger(signature, field, tp);
}

/**
* Match based on given type pattern, only classes can be matched

+ 1
- 2
weaver/src/org/aspectj/weaver/NewMethodTypeMunger.java View File

@@ -47,8 +47,7 @@ public class NewMethodTypeMunger extends ResolvedTypeMunger {
}
public static ResolvedTypeMunger readMethod(VersionedDataInputStream s, ISourceContext context) throws IOException {
ISourceLocation sloc = null;
ISourceLocation sloc = null;
ResolvedMemberImpl rmImpl = ResolvedMemberImpl.readResolvedMember(s, context);
Set superMethodsCalled = readSuperMethodsCalled(s);
sloc = readSourceLocation(s);

+ 6
- 4
weaver/src/org/aspectj/weaver/ResolvedTypeMunger.java View File

@@ -123,10 +123,11 @@ public abstract class ResolvedTypeMunger {
return NewFieldTypeMunger.readField(s, context);
} else if (kind == Method) {
return NewMethodTypeMunger.readMethod(s, context);

} else if (kind == Constructor) {
return NewConstructorTypeMunger.readConstructor(s, context);
} else {
} else if (kind == MethodDelegate) {
return MethodDelegateTypeMunger.readMethod(s, context);
} else {
throw new RuntimeException("unimplemented");
}
}
@@ -227,7 +228,8 @@ public abstract class ResolvedTypeMunger {
case 1: return Field;
case 2: return Method;
case 5: return Constructor;
}
case 9: return MethodDelegate;
}
throw new BCException("bad kind: " + key);
}
}
@@ -247,7 +249,7 @@ public abstract class ResolvedTypeMunger {
public static final Kind AnnotationOnType = new Kind("AnnotationOnType",8); // not serialized

public static final Kind MethodDelegate = new Kind("MethodDelegate", 9);// not serialized, @AJ ITDs
public static final Kind MethodDelegate = new Kind("MethodDelegate", 9);// serialized, @AJ ITDs

public static final String SUPER_DISPATCH_NAME = "superDispatch";


Loading…
Cancel
Save