Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 4963 invoked from network); 1 Sep 2008 12:09:01 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 1 Sep 2008 12:09:01 -0000 Received: (qmail 27315 invoked by uid 500); 1 Sep 2008 12:08:59 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 27303 invoked by uid 500); 1 Sep 2008 12:08:59 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 27294 invoked by uid 99); 1 Sep 2008 12:08:59 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Sep 2008 05:08:59 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Sep 2008 12:08:09 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 2F972238889D; Mon, 1 Sep 2008 05:08:10 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r690951 - in /harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200: BcBands.java ClassBands.java Date: Mon, 01 Sep 2008 12:08:09 -0000 To: commits@harmony.apache.org From: sjanuary@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080901120810.2F972238889D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: sjanuary Date: Mon Sep 1 05:08:09 2008 New Revision: 690951 URL: http://svn.apache.org/viewvc?rev=690951&view=rev Log: Tentative fix for HARMONY-5960 ([pack200][classlib] IndexOutOfBounds exception in BcBands.unpack()) Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/BcBands.java harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/ClassBands.java Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/BcBands.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/BcBands.java?rev=690951&r1=690950&r2=690951&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/BcBands.java (original) +++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/BcBands.java Mon Sep 1 05:08:09 2008 @@ -20,6 +20,7 @@ import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import org.apache.harmony.pack200.Codec; @@ -396,6 +397,7 @@ int i = 0; ArrayList orderedCodeAttributes = segment.getClassBands() .getOrderedCodeAttributes(); + int codeAttributeIndex = 0; // Exception table fields int[] handlerCount = segment.getClassBands().getCodeHandlerCount(); @@ -407,6 +409,9 @@ int[][] handlerClassTypes = segment.getClassBands() .getCodeHandlerClassRCN(); + boolean allCodeHasFlags = segment.getSegmentHeader().getOptions().hasAllCodeFlags(); + boolean[] codeHasFlags = segment.getClassBands().getCodeHasAttributes(); + for (int c = 0; c < classCount; c++) { int numberOfMethods = methodFlags[c].length; for (int m = 0; m < numberOfMethods; m++) { @@ -459,18 +464,26 @@ } methodAttributesList.add(indexForCodeAttr, codeAttr); codeAttr.renumber(codeAttr.byteCodeOffsets); - if(orderedCodeAttributes.size() > 0) { - ArrayList currentAttributes = (ArrayList) orderedCodeAttributes - .get(i); - for (int index = 0; index < currentAttributes.size(); index++) { - Attribute currentAttribute = (Attribute) currentAttributes - .get(index); - codeAttr.addAttribute(currentAttribute); - // Fix up the line numbers if needed - if (currentAttribute.hasBCIRenumbering()) { - ((BCIRenumberedAttribute) currentAttribute) - .renumber(codeAttr.byteCodeOffsets); - } + List currentAttributes; + if (allCodeHasFlags) { + currentAttributes = (List) orderedCodeAttributes.get(i); + } else { + if (codeHasFlags[i]) { + currentAttributes = (List) orderedCodeAttributes + .get(codeAttributeIndex); + codeAttributeIndex++; + } else { + currentAttributes = Collections.EMPTY_LIST; + } + } + for (int index = 0; index < currentAttributes.size(); index++) { + Attribute currentAttribute = (Attribute) currentAttributes + .get(index); + codeAttr.addAttribute(currentAttribute); + // Fix up the line numbers if needed + if (currentAttribute.hasBCIRenumbering()) { + ((BCIRenumberedAttribute) currentAttribute) + .renumber(codeAttr.byteCodeOffsets); } } i++; Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/ClassBands.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/ClassBands.java?rev=690951&r1=690950&r2=690951&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/ClassBands.java (original) +++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/ClassBands.java Mon Sep 1 05:08:09 2008 @@ -68,7 +68,7 @@ private IcTuple[][] icLocal; - private ArrayList[] codeAttributes; + private List[] codeAttributes; private int[] codeHandlerCount; @@ -114,6 +114,8 @@ private int[][] codeHandlerClassRCN; + private boolean [] codeHasAttributes; + /** * @param segment */ @@ -718,10 +720,19 @@ int codeCount = SegmentUtils.countMatches(methodFlags, layout); int[] codeHeaders = decodeBandInt("code_headers", in, Codec.BYTE1, codeCount); + + boolean allCodeHasFlags = segment.getSegmentHeader().getOptions().hasAllCodeFlags(); + if(!allCodeHasFlags) { + codeHasAttributes = new boolean[codeCount]; + } int codeSpecialHeader = 0; for (int i = 0; i < codeCount; i++) { - if (codeHeaders[i] == 0) + if (codeHeaders[i] == 0) { codeSpecialHeader++; + if(!allCodeHasFlags) { + codeHasAttributes[i] = true; + } + } } int[] codeMaxStackSpecials = decodeBandInt("code_max_stack", in, Codec.UNSIGNED5, codeSpecialHeader); @@ -768,10 +779,9 @@ codeHandlerClassRCN = decodeBandInt( "code_handler_class_RCN", in, Codec.UNSIGNED5, codeHandlerCount); - int codeFlagsCount = segment.getSegmentHeader().getOptions() - .hasAllCodeFlags() ? codeCount : codeSpecialHeader; + int codeFlagsCount = allCodeHasFlags ? codeCount : codeSpecialHeader; - codeAttributes = new ArrayList[codeFlagsCount]; + codeAttributes = new List[codeFlagsCount]; for (int i = 0; i < codeAttributes.length; i++) { codeAttributes[i] = new ArrayList(); } @@ -1389,4 +1399,8 @@ return icLocal; } + public boolean[] getCodeHasAttributes() { + return codeHasAttributes; + } + }