From: Andy Clement Date: Mon, 22 Jul 2013 21:47:02 +0000 (-0700) Subject: Bug413378: ctor itd super call: test and fix X-Git-Tag: AS_BETA_JAVA8_CREATED X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=302c14ee680d5782cba619d8cc748e60afd09561;p=aspectj.git Bug413378: ctor itd super call: test and fix --- 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 @@ + + + + + + + + + + + + + + + + + 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 neededSuperCalls) { LazyClassGen gen = weaver.getLazyClassGen(); - - for (Iterator 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; }