From 137c47f0bdb7b7276ea3000a8d4d035f02b6eb68 Mon Sep 17 00:00:00 2001 From: ehilsdal Date: Tue, 5 Aug 2003 06:19:38 +0000 Subject: Fix for Bug 39470: Repeating a compilation multiple times produces class files that vary in size Added a filter to make sure we don't add two local variable entries with the same start and slot (BCEL workaround) --- .../src/org/aspectj/weaver/bcel/LazyMethodGen.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java b/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java index 569ac9793..7c4e660db 100644 --- a/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java +++ b/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java @@ -746,6 +746,7 @@ public final class LazyMethodGen { LinkedList exnList = new LinkedList(); + // map from localvariabletag to instruction handle Map localVariableStarts = new HashMap(); Map localVariableEnds = new HashMap(); @@ -849,8 +850,28 @@ public final class LazyMethodGen { } // now add local variables gen.removeLocalVariables(); + + // BCEL sometimes creates extra local variables with the same name. We now + // remove them and add back to the gen. + + Map duplicatedLocalMap = new HashMap(); + for (Iterator iter = localVariableStarts.keySet().iterator(); iter.hasNext(); ) { LocalVariableTag tag = (LocalVariableTag) iter.next(); + // have we already added one with the same slot number and start location? + // if so, just continue. + InstructionHandle start = (InstructionHandle) localVariableStarts.get(tag); + Set slots = (Set) duplicatedLocalMap.get(start); + if (slots == null) { + slots = new HashSet(); + duplicatedLocalMap.put(start, slots); + } + if (slots.contains(new Integer(tag.getSlot()))) { + // we already have a var starting at this tag with this slot + continue; + } + slots.add(new Integer(tag.getSlot())); + gen.addLocalVariable( tag.getName(), BcelWorld.makeBcelType(tag.getType()), -- cgit v1.2.3