From c2ff74fd569ea2ef0c4abdc06e3f36a77b1ddd2c Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Thu, 6 Sep 2012 09:37:31 -0700 Subject: 388971 - fix for double synthetic attributes --- .../src/org/aspectj/weaver/bcel/LazyMethodGen.java | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'weaver') diff --git a/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java b/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java index 84ba6c0b4..b66c6106d 100644 --- a/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java +++ b/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java @@ -967,11 +967,12 @@ public final class LazyMethodGen implements Traceable { if (enclosingClass.getWorld().isInJava5Mode()) { gen.setModifiers(gen.getModifiers() | ACC_SYNTHETIC); } - // belt and braces, do the attribute even on Java 5 in addition to - // the modifier flag - ConstantPool cpg = gen.getConstantPool(); - int index = cpg.addUtf8("Synthetic"); - gen.addAttribute(new Synthetic(index, 0, new byte[0], cpg)); + if (!hasAttribute("Synthetic")) { + // belt and braces, do the attribute even on Java 5 in addition to the modifier flag + ConstantPool cpg = gen.getConstantPool(); + int index = cpg.addUtf8("Synthetic"); + gen.addAttribute(new Synthetic(index, 0, new byte[0], cpg)); + } } if (hasBody()) { @@ -991,6 +992,15 @@ public final class LazyMethodGen implements Traceable { } return gen; } + + private boolean hasAttribute(String attributeName) { + for (Attribute attr: attributes) { + if (attr.getName().equals(attributeName)) { + return true; + } + } + return false; + } private void forceSyntheticForAjcMagicMembers() { if (NameMangler.isSyntheticMethod(getName(), inAspect())) { -- cgit v1.2.3