diff options
author | Andy Clement <aclement@gopivotal.com> | 2013-07-22 14:47:02 -0700 |
---|---|---|
committer | Andy Clement <andrew.clement@gmail.com> | 2013-07-22 14:50:14 -0700 |
commit | 302c14ee680d5782cba619d8cc748e60afd09561 (patch) | |
tree | 9c023bcb46b7165866dc8a81e23c15df58249dcd | |
parent | e6cb5086ad825e8df5f182aa0c5586b0b4af9d21 (diff) | |
download | aspectj-302c14ee680d5782cba619d8cc748e60afd09561.tar.gz aspectj-302c14ee680d5782cba619d8cc748e60afd09561.zip |
Bug413378: ctor itd super call: test and fixAS_BETA_JAVA8_CREATED
-rw-r--r-- | tests/bugs174/pr413378/Code.java | 38 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/AllTests17.java | 2 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc174/Ajc174Tests.java | 39 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc174/AllTestsAspectJ174.java | 25 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc174/ajc174.xml | 17 | ||||
-rw-r--r-- | weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java | 10 |
6 files changed, 125 insertions, 6 deletions
diff --git a/tests/bugs174/pr413378/Code.java b/tests/bugs174/pr413378/Code.java new file mode 100644 index 000000000..f591dac45 --- /dev/null +++ b/tests/bugs174/pr413378/Code.java @@ -0,0 +1,38 @@ +class Child extends Parent{ + + public String mParent = "John"; + + public Child(String parent) { + this.mParent = parent; + } + + public String getParent() + { + return this.mParent; + } +} + +class Parent { + private String mName = "John"; + private int mAge = 50; + + public int getAge(){ + return mAge; + } +} + +aspect MyTest { + + public Child.new(String parent, int age) { + this(parent); + + System.out.println("Get Age:" + super.getAge()); + System.out.println("Child Name:" + this.mParent); + } +} + +public class Code { + public static void main(String []argv) { + new Child("Andy",5); + } +} diff --git a/tests/src/org/aspectj/systemtest/AllTests17.java b/tests/src/org/aspectj/systemtest/AllTests17.java index 4bde943ce..5e46eba73 100644 --- a/tests/src/org/aspectj/systemtest/AllTests17.java +++ b/tests/src/org/aspectj/systemtest/AllTests17.java @@ -10,12 +10,14 @@ import org.aspectj.systemtest.ajc170.AllTestsAspectJ170; import org.aspectj.systemtest.ajc171.AllTestsAspectJ171; import org.aspectj.systemtest.ajc172.AllTestsAspectJ172; import org.aspectj.systemtest.ajc173.AllTestsAspectJ173; +import org.aspectj.systemtest.ajc174.AllTestsAspectJ174; public class AllTests17 { public static Test suite() { TestSuite suite = new TestSuite("AspectJ System Test Suite - 1.7"); // $JUnit-BEGIN$ + suite.addTest(AllTestsAspectJ174.suite()); suite.addTest(AllTestsAspectJ173.suite()); suite.addTest(AllTestsAspectJ172.suite()); suite.addTest(AllTestsAspectJ171.suite()); diff --git a/tests/src/org/aspectj/systemtest/ajc174/Ajc174Tests.java b/tests/src/org/aspectj/systemtest/ajc174/Ajc174Tests.java new file mode 100644 index 000000000..464c948e5 --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc174/Ajc174Tests.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2013 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://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc174; + +import java.io.File; + +import junit.framework.Test; + +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * @author Andy Clement + */ +public class Ajc174Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + + public void testSuperItdCtor_413378() throws Exception { + runTest("super itd ctor"); + } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc174Tests.class); + } + + @Override + protected File getSpecFile() { + return new File("../tests/src/org/aspectj/systemtest/ajc174/ajc174.xml"); + } + +} diff --git a/tests/src/org/aspectj/systemtest/ajc174/AllTestsAspectJ174.java b/tests/src/org/aspectj/systemtest/ajc174/AllTestsAspectJ174.java new file mode 100644 index 000000000..01a9525ec --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc174/AllTestsAspectJ174.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2013 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://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc174; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ174 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.7.4 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc174Tests.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/org/aspectj/systemtest/ajc174/ajc174.xml b/tests/src/org/aspectj/systemtest/ajc174/ajc174.xml new file mode 100644 index 000000000..0a64273e5 --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc174/ajc174.xml @@ -0,0 +1,17 @@ +<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]> + +<suite> + + <ajc-test dir="bugs174/pr413378" title="super itd ctor"> + <compile files="Code.java" options="-1.5 -showWeaveInfo"> + <message kind="weave" text="Type 'Child' (Code.java) has intertyped constructor from 'MyTest' (Code.java:'void Child.<init>(java.lang.String, int)')"/> + </compile> + <run class="Code"> + <stdout> + <line text="Get Age:50"/> + <line text="Child Name:Andy"/> + </stdout> + </run> + </ajc-test> + +</suite> diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java index 1a1b81f54..9e5b6a210 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java @@ -1594,12 +1594,9 @@ public class BcelTypeMunger extends ConcreteTypeMunger { private void addNeededSuperCallMethods(BcelClassWeaver weaver, ResolvedType onType, Set<ResolvedMember> neededSuperCalls) { LazyClassGen gen = weaver.getLazyClassGen(); - - for (Iterator<ResolvedMember> iter = neededSuperCalls.iterator(); iter.hasNext();) { - ResolvedMember superMethod = iter.next(); + for (ResolvedMember superMethod: neededSuperCalls) { if (weaver.addDispatchTarget(superMethod)) { - // System.err.println("super type: " + - // superMethod.getDeclaringType() + ", " + gen.getType()); + // System.err.println("super type: " + superMethod.getDeclaringType() + ", " + gen.getType()); boolean isSuper = !superMethod.getDeclaringType().equals(gen.getType()); String dispatchName; if (isSuper) { @@ -1609,7 +1606,6 @@ public class BcelTypeMunger extends ConcreteTypeMunger { } superMethod = superMethod.resolve(weaver.getWorld()); LazyMethodGen dispatcher = makeDispatcher(gen, dispatchName, superMethod, weaver.getWorld(), isSuper); - weaver.addLazyMethodGen(dispatcher); } } @@ -1773,6 +1769,8 @@ public class BcelTypeMunger extends ConcreteTypeMunger { // don't forget to return!! body.append(InstructionConstants.RETURN); + addNeededSuperCallMethods(weaver, onType, munger.getSuperMethodsCalled()); + return true; } |