From 32a02ec2a3e15651249d5d7cc5f63fa409468b2a Mon Sep 17 00:00:00 2001 From: aclement Date: Tue, 4 Oct 2005 13:37:01 +0000 Subject: [PATCH] test and fix for pr110906: vararg ITDs --- .../ast/InterTypeMethodDeclaration.java | 6 +++-- .../compiler/lookup/EclipseFactory.java | 5 +++- .../compiler/lookup/EclipseTypeMunger.java | 2 +- .../testdata/OutjarTest/aspects.jar | Bin 1417 -> 1385 bytes .../testdata/OutjarTest/child.jar | Bin 724 -> 724 bytes .../testdata/OutjarTest/parent.jar | Bin 630 -> 630 bytes tests/bugs150/pr110906.aj | 25 ++++++++++++++++++ .../systemtest/ajc150/Ajc150Tests.java | 2 ++ .../org/aspectj/systemtest/ajc150/ajc150.xml | 9 ++++++- .../aspectj/weaver/ResolvedMemberImpl.java | 17 +++++++++--- 10 files changed, 58 insertions(+), 8 deletions(-) create mode 100644 tests/bugs150/pr110906.aj diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java index 859704441..2ef5cc7e1 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java @@ -35,6 +35,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.parser.Parser; import org.aspectj.org.eclipse.jdt.internal.compiler.problem.AbortCompilationUnit; import org.aspectj.weaver.AjAttribute; import org.aspectj.weaver.AjcMemberMaker; +import org.aspectj.weaver.Constants; import org.aspectj.weaver.NameMangler; import org.aspectj.weaver.NewMethodTypeMunger; import org.aspectj.weaver.ResolvedMember; @@ -188,8 +189,9 @@ public class InterTypeMethodDeclaration extends InterTypeDeclaration { // referred to in the parameters/returntype ResolvedMember sig = world.makeResolvedMember(binding,onTypeBinding); sig.resetName(new String(declaredSelector)); - sig.resetModifiers(declaredModifiers); - + int resetModifiers = declaredModifiers; + if (binding.isVarargs()) resetModifiers = resetModifiers | Constants.ACC_VARARGS; + sig.resetModifiers(resetModifiers); NewMethodTypeMunger myMunger = new NewMethodTypeMunger(sig, null); setMunger(myMunger); ResolvedType aspectType = world.fromEclipse(classScope.referenceContext.binding); diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java index 68858e92e..4eb290647 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java @@ -449,7 +449,7 @@ public class EclipseFactory { // AMC these next two lines shouldn't be needed once we sort out generic types properly in the world map ResolvedType realDeclaringType = world.resolve(fromBinding(declaringType)); if (realDeclaringType.isRawType()) realDeclaringType = realDeclaringType.getGenericType(); - ResolvedMember ret = new ResolvedMemberImpl( + ResolvedMemberImpl ret = new ResolvedMemberImpl( binding.isConstructor() ? Member.CONSTRUCTOR : Member.METHOD, realDeclaringType, binding.modifiers, @@ -458,6 +458,9 @@ public class EclipseFactory { fromBindings(binding.parameters), fromBindings(binding.thrownExceptions) ); + if (binding.isVarargs()) { + ret.setVarargsMethod(); + } if (typeVariablesForThisMember.size()!=0) { UnresolvedType[] tvars = new UnresolvedType[typeVariablesForThisMember.size()]; int i =0; diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseTypeMunger.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseTypeMunger.java index e499f2df5..8f7b1544f 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseTypeMunger.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseTypeMunger.java @@ -131,7 +131,7 @@ public class EclipseTypeMunger extends ConcreteTypeMunger { binding.modifiers = (binding.modifiers & (IConstants.AccPublic | IConstants.AccProtected | IConstants.AccPrivate)); if (isAbstract) binding.modifiers |= IConstants.AccAbstract; } - + if (munger.getSignature().isVarargsMethod()) binding.modifiers |= IConstants.AccVarargs; findOrCreateInterTypeMemberFinder(sourceType).addInterTypeMethod(binding); return true; } diff --git a/org.aspectj.ajdt.core/testdata/OutjarTest/aspects.jar b/org.aspectj.ajdt.core/testdata/OutjarTest/aspects.jar index a0245667af6ab1e4c84b60ee3837c138591db186..8a252d19b993708d1675a0adfa43267b729d7ce2 100644 GIT binary patch delta 1128 zcmV-u1eg1X3+W0CP)h>@6aWYS2mmr|M3D`A12Szyk&G*UcN?coou+NLq$!xzcFQ`w zKtmH6+LTJDAqjF66lAHItS9kW&Th0jj#D8aBzWVA2Yv%Dc_67o5S6G<)q?VqcmU4K zZsJQ9!3$E6V(IhFoH^%wXU?3Nv;W6WKLarEKEq25?p`h5@-~DilVA*k4Zg|CO>VE1 z=T{n98f7?t$s1?Zvw5wE0R?OfsBN>KnqXSoT^|NXP!r z_9VAWG8vfdVkFhnl-X2{Z!$y+#U+N=j8h}MW7>t|$r-(zMHZP1A{fXbjzpS9#~Fq~ z=#x0XaD3LX#awHBMYxMf$dH?LOx|4LuBGOIFfpZnsk0bX&SN-5^s;Vw3}cF(uS((O zRlN88c=MO@E2|R|6XVx8!-(Uq8C=U7MqBVr;TpGUo0i(85wiA?kaeeaN0?3Sa%nks zC&r$%R~~p$tS9j*WyER8!z^1)dBL@8S&^>b>yufG;%pkPVT`srJ>~~!taHmQ6jONp zAUVB%R!QU;k{e3Uw8?X!>i|iEj%%{Gl*M^m$ly&B=y?21%&!tjq1bnJqhT3nR36x} zE~I5rSrPz|;sr4Bul1qVew3QfL;s`S8KG0}HWt+YU`cIRT(nzyQ z^kwwT{)l7WA$70x5Q95f5+%(XjfS+1k_^!Q@S$Znu#A`XaC%2mom7r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index 000000000..b7f7446e0 --- /dev/null +++ b/tests/bugs150/pr110906.aj @@ -0,0 +1,25 @@ +public class pr110906 { + + public static void main(String []argv) { + new pr110906().printNames(new Object[]{"a","b","c"}); + new pr110906().printNames("a","b","c"); // should be allowed!! + new pr110906().printNames2("a","b","c"); // should be allowed!! + } + +} + +aspect A { + + private interface HasName {} + + declare parents: (pr110906) implements HasName; + + public void HasName.printNames(Object... names) { + System.out.println(names[0]); + } + + public void HasName.printNames2(String... names) { + System.out.println(names[0]); + } + +} diff --git a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java index e41053fe0..daa404fab 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java @@ -53,6 +53,8 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase { public void testBadDecp_pr110788_2() { runTest("bad generic decp - 2");} public void testBadDecp_pr110788_3() { runTest("bad generic decp - 3");} public void testBadDecp_pr110788_4() { runTest("bad generic decp - 4");} + + public void testVarargsITD_pr110906() { runTest("ITD varargs problem");} public void testBadGenericSigAttribute_pr110927() { runTest("cant create signature attribute"); diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml index c06e718ac..ef3f9fcd4 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml @@ -4900,7 +4900,14 @@ - + + + + + + + + diff --git a/weaver/src/org/aspectj/weaver/ResolvedMemberImpl.java b/weaver/src/org/aspectj/weaver/ResolvedMemberImpl.java index cf1732ebd..c54ca4fd2 100644 --- a/weaver/src/org/aspectj/weaver/ResolvedMemberImpl.java +++ b/weaver/src/org/aspectj/weaver/ResolvedMemberImpl.java @@ -321,10 +321,14 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno return (modifiers & Constants.ACC_VARARGS)!=0; } + public void setVarargsMethod() { + modifiers = modifiers | Constants.ACC_VARARGS; + } + public boolean isSynthetic() { return false; } - + public void write(DataOutputStream s) throws IOException { getKind().write(s); getDeclaringType().write(s); @@ -335,6 +339,7 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno s.writeInt(getStart()); s.writeInt(getEnd()); + s.writeBoolean(isVarargsMethod()); // Write out any type variables... if (typeVariables==null) { @@ -356,15 +361,21 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno public static ResolvedMemberImpl readResolvedMember(VersionedDataInputStream s, ISourceContext sourceContext) throws IOException { - ResolvedMemberImpl m = new ResolvedMemberImpl(Kind.read(s), UnresolvedType.read(s), s.readInt(), s.readUTF(), s.readUTF()); + + ResolvedMemberImpl m = new ResolvedMemberImpl(Kind.read(s), UnresolvedType.read(s), s.readInt(), + s.readUTF(), s.readUTF()); m.checkedExceptions = UnresolvedType.readArray(s); m.start = s.readInt(); m.end = s.readInt(); m.sourceContext = sourceContext; - // Read in the type variables... + if (s.getMajorVersion()>=AjAttribute.WeaverVersionInfo.WEAVER_VERSION_MAJOR_AJ150) { + + boolean isvarargs = s.readBoolean(); + if (isvarargs) m.setVarargsMethod(); + int tvcount = s.readInt(); if (tvcount!=0) { m.typeVariables = new UnresolvedType[tvcount]; -- 2.39.5