diff options
author | jhugunin <jhugunin> | 2003-08-08 00:26:22 +0000 |
---|---|---|
committer | jhugunin <jhugunin> | 2003-08-08 00:26:22 +0000 |
commit | efc1cc47398443b33fe90da11c4cf1d14dc9c108 (patch) | |
tree | 9c967c62b6b4b51003b282976f2558ee7914cb91 /org.aspectj.ajdt.core | |
parent | bdfba603c4aee6d32a4873ddca43657e6eee92a8 (diff) | |
download | aspectj-efc1cc47398443b33fe90da11c4cf1d14dc9c108.tar.gz aspectj-efc1cc47398443b33fe90da11c4cf1d14dc9c108.zip |
fix for Bugzilla Bug 41175
binary aspect-declared methods conflict, lost their exception clauses
larger fix to address more issues with aspect-declared methods in bytecode form
also addressed declared exception issue more generally
this fix should be more stable than a smaller hack that just fixed this specific bug
report would have been. added a few tests to match increased scope.
Diffstat (limited to 'org.aspectj.ajdt.core')
6 files changed, 57 insertions, 17 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeConstructorDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeConstructorDeclaration.java index 9ddf959d8..a1c8c8e02 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeConstructorDeclaration.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeConstructorDeclaration.java @@ -212,8 +212,8 @@ public class InterTypeConstructorDeclaration extends InterTypeDeclaration { ResolvedMember signature = new ResolvedMember(Member.CONSTRUCTOR, declaringTypeX, declaredModifiers, - ResolvedTypeX.VOID, "<init>", bindingAsMember.getParameterTypes()); - signature.setCheckedExceptions(world.fromEclipse(binding.thrownExceptions)); + ResolvedTypeX.VOID, "<init>", bindingAsMember.getParameterTypes(), + world.fromEclipse(binding.thrownExceptions)); ResolvedMember syntheticInterMember = AjcMemberMaker.interConstructor(declaringTypeX, signature, aspectType); 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 662a5bc3f..2039fd54c 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 @@ -86,8 +86,8 @@ public class InterTypeMethodDeclaration extends InterTypeDeclaration { binding = classScope.referenceContext.binding.resolveTypesFor(binding); ResolvedMember sig = new ResolvedMember(Member.METHOD, EclipseFactory.fromBinding(onTypeBinding), declaredModifiers, EclipseFactory.fromBinding(binding.returnType), new String(declaredSelector), - EclipseFactory.fromBindings(binding.parameters)); - sig.setCheckedExceptions(world.fromEclipse(binding.thrownExceptions)); + EclipseFactory.fromBindings(binding.parameters), + world.fromEclipse(binding.thrownExceptions)); NewMethodTypeMunger myMunger = new NewMethodTypeMunger(sig, null); setMunger(myMunger); diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java index 868499adc..daacbc4e5 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java @@ -43,6 +43,7 @@ public class AjLookupEnvironment extends LookupEnvironment { // private boolean builtInterTypesAndPerClauses = false; private List pendingTypesToWeave = new ArrayList(); + private Map dangerousInterfaces = new HashMap(); public AjLookupEnvironment( ITypeRequestor typeRequestor, @@ -151,16 +152,49 @@ public class AjLookupEnvironment extends LookupEnvironment { } } - - private void weaveInterTypeDeclarations(SourceTypeBinding sourceType, Collection typeMungers, Collection declareParents, boolean skipInners) { -// if (new String(sourceType.sourceName()).equals("Target")) { -// Thread.currentThread().dumpStack(); -// } -// -// System.out.println("weaving types: " + new String(sourceType.sourceName())); -// System.out.println(" mungers: " + typeMungers); ResolvedTypeX onType = factory.fromEclipse(sourceType); + WeaverStateInfo info = onType.getWeaverState(); + + if (info != null && !info.isOldStyle()) { + Collection mungers = + onType.getWeaverState().getTypeMungers(onType); + + //System.out.println("mungers: " + mungers); + for (Iterator i = mungers.iterator(); i.hasNext(); ) { + ConcreteTypeMunger m = (ConcreteTypeMunger)i.next(); + EclipseTypeMunger munger = factory.makeEclipseTypeMunger(m); + if (munger.munge(sourceType)) { + if (onType.isInterface() && + munger.getMunger().needsAccessToTopmostImplementor()) + { + if (!onType.getWorld().getCrosscuttingMembersSet().containsAspect(munger.getAspectType())) { + dangerousInterfaces.put(onType, + "implementors of " + onType + " must be woven by " + + munger.getAspectType()); + } + } + } + + } + + return; + } + + //System.out.println("dangerousInterfaces: " + dangerousInterfaces); + + for (Iterator i = dangerousInterfaces.entrySet().iterator(); i.hasNext();) { + Map.Entry entry = (Map.Entry) i.next(); + ResolvedTypeX interfaceType = (ResolvedTypeX)entry.getKey(); + if (onType.isTopmostImplementor(interfaceType)) { + factory.showMessage(IMessage.ERROR, + onType + ": " + entry.getValue(), + onType.getSourceLocation(), null); + } + } + + boolean needOldStyleWarning = (info != null && info.isOldStyle()); + onType.clearInterTypeMungers(); for (Iterator i = declareParents.iterator(); i.hasNext();) { @@ -170,6 +204,12 @@ public class AjLookupEnvironment extends LookupEnvironment { for (Iterator i = typeMungers.iterator(); i.hasNext();) { EclipseTypeMunger munger = (EclipseTypeMunger) i.next(); if (munger.matches(onType)) { + if (needOldStyleWarning) { + factory.showMessage(IMessage.WARNING, + "The class for " + onType + " should be recompiled with ajc-1.1.1 for best results", + onType.getSourceLocation(), null); + needOldStyleWarning = false; + } onType.addInterTypeMunger(munger); } } 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 76de36409..e9f9f0402 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 @@ -192,8 +192,8 @@ public class EclipseFactory { binding.modifiers, fromBinding(binding.returnType), new String(binding.selector), - fromBindings(binding.parameters)); - ret.setCheckedExceptions(fromBindings(binding.thrownExceptions)); + fromBindings(binding.parameters), + fromBindings(binding.thrownExceptions)); return ret; } diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java index e965ea031..60f317f1f 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java @@ -66,8 +66,8 @@ public class EclipseSourceType extends ResolvedTypeX.ConcreteName { return declaration instanceof AspectDeclaration; } - public boolean isWovenBy(ResolvedTypeX aspectType) { - return false; + public WeaverStateInfo getWeaverState() { + return null; } public ResolvedTypeX getSuperclass() { diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BinaryFormsTestCase.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BinaryFormsTestCase.java index c98a12a11..0382c9a1f 100644 --- a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BinaryFormsTestCase.java +++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BinaryFormsTestCase.java @@ -101,7 +101,7 @@ public class BinaryFormsTestCase extends CommandTestCase { args.add("testdata/src1/binary/client/Client1.java"); - CommandTestCase.runCompiler(args, new int[] {9, 11, 15, 17}); + CommandTestCase.runCompiler(args, new int[] {15, 17, 22}); args = new ArrayList(); args.add("-classpath"); |