### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/codegen/Label.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/Label.java,v retrieving revision 1.34 diff -u -r1.34 Label.java --- compiler/org/eclipse/jdt/internal/compiler/codegen/Label.java 14 Oct 2005 22:43:00 -0000 1.34 +++ compiler/org/eclipse/jdt/internal/compiler/codegen/Label.java 3 Nov 2005 09:11:36 -0000 @@ -43,11 +43,15 @@ /** * Add a forward refrence for the array. */ -void addForwardReference(int iPos) { +void addForwardReference(int pos) { + int[] refs = this.forwardReferences; + for (int i = 0, count = this.forwardReferenceCount; i < count; i++) { + if (refs[i] == pos) return; // already recorded + } int length; - if (forwardReferenceCount >= (length = forwardReferences.length)) - System.arraycopy(forwardReferences, 0, (forwardReferences = new int[2*length]), 0, length); - forwardReferences[forwardReferenceCount++] = iPos; + if (forwardReferenceCount >= (length = refs.length)) + System.arraycopy(refs, 0, (this.forwardReferences = new int[2*length]), 0, length); + this.forwardReferences[this.forwardReferenceCount++] = pos; } /** @@ -56,14 +60,22 @@ public void appendForwardReferencesFrom(Label otherLabel) { int otherCount = otherLabel.forwardReferenceCount; if (otherCount == 0) return; - int length = forwardReferences.length; - int neededSpace = otherCount + forwardReferenceCount; - if (neededSpace >= length){ - System.arraycopy(forwardReferences, 0, (forwardReferences = new int[neededSpace]), 0, forwardReferenceCount); + int count = this.forwardReferenceCount; + int[] refs = this.forwardReferences; + int neededSpace = count + otherCount; + if (neededSpace >= refs.length){ + System.arraycopy(refs, 0, (this.forwardReferences = refs = new int[neededSpace]), 0, count); } // append other forward references at the end, so they will get updated as well - System.arraycopy(otherLabel.forwardReferences, 0, forwardReferences, forwardReferenceCount, otherCount); - forwardReferenceCount = neededSpace; + int[] otherRefs = otherLabel.forwardReferences; + otherLoop: for (int i = 0; i < otherCount; i++) { + int otherRef = otherRefs[i]; + for (int j = 0; j < count; j++) { + if (refs[j] == otherRef) continue otherLoop; // already recorded + } + refs[count++] = otherRef; + } + this.forwardReferenceCount = count; } /* @@ -94,7 +106,7 @@ if (position == POS_NOT_SET) { addForwardReference(codeStream.position); // Leave 4 bytes free to generate the jump offset afterwards - this.tagBits |= WIDE; + this.tagBits |= WIDE; codeStream.position += 4; codeStream.classFileOffset += 4; } else { //Position is set. Write it!