From 32a02ec2a3e15651249d5d7cc5f63fa409468b2a Mon Sep 17 00:00:00 2001 From: aclement Date: Tue, 4 Oct 2005 13:37:01 +0000 Subject: test and fix for pr110906: vararg ITDs --- .../compiler/ast/InterTypeMethodDeclaration.java | 6 +++-- .../internal/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 +++++++++++++++++++++ .../org/aspectj/systemtest/ajc150/Ajc150Tests.java | 2 ++ tests/src/org/aspectj/systemtest/ajc150/ajc150.xml | 9 +++++++- .../src/org/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 a0245667a..8a252d19b 100644 Binary files a/org.aspectj.ajdt.core/testdata/OutjarTest/aspects.jar and b/org.aspectj.ajdt.core/testdata/OutjarTest/aspects.jar differ diff --git a/org.aspectj.ajdt.core/testdata/OutjarTest/child.jar b/org.aspectj.ajdt.core/testdata/OutjarTest/child.jar index 9b798abda..634616fd8 100644 Binary files a/org.aspectj.ajdt.core/testdata/OutjarTest/child.jar and b/org.aspectj.ajdt.core/testdata/OutjarTest/child.jar differ diff --git a/org.aspectj.ajdt.core/testdata/OutjarTest/parent.jar b/org.aspectj.ajdt.core/testdata/OutjarTest/parent.jar index f2078004f..5c9aa4239 100644 Binary files a/org.aspectj.ajdt.core/testdata/OutjarTest/parent.jar and b/org.aspectj.ajdt.core/testdata/OutjarTest/parent.jar differ diff --git a/tests/bugs150/pr110906.aj b/tests/bugs150/pr110906.aj new file mode 100644 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]; -- cgit v1.2.3