You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by chunrong lai <ch...@gmail.com> on 2008/09/02 08:51:30 UTC

Re: svn commit: r690951 - in /harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200: BcBands.java ClassBands.java

 As reported in the integrity testing, the commit breaks quite a few of the
 org.apache.harmony.unpack200.tests.BcBandsTest in classlib.

http://people.apache.org/~chunrong/harmony-integrity/linux_x86/classlib-test/

  error testSimple org.apache.harmony.unpack200.tests.BcBandsTest error
testMultipleClassesSimple org.apache.harmony.unpack200.tests.BcBandsTest error
testMultipleMethodsSimple org.apache.harmony.unpack200.tests.BcBandsTest error
testBcCaseBands org.apache.harmony.unpack200.tests.BcBandsTest error
testBcByteBand org.apache.harmony.unpack200.tests.BcBandsTest error
testBcShortBand org.apache.harmony.unpack200.tests.BcBandsTest error
testBcLocalBand org.apache.harmony.unpack200.tests.BcBandsTest error
testBcLabelBand org.apache.harmony.unpack200.tests.BcBandsTest error
testWideForms org.apache.harmony.unpack200.tests.BcBandsTest error
testBcIntRefBand org.apache.harmony.unpack200.tests.BcBandsTest error
testBcFloatRefBand org.apache.harmony.unpack200.tests.BcBandsTest error
testBcLongRefBand org.apache.harmony.unpack200.tests.BcBandsTest error
testBcDoubleRefBand org.apache.harmony.unpack200.tests.BcBandsTest error
testBcStringRefBand org.apache.harmony.unpack200.tests.BcBandsTest error
testBcClassRefBand org.apache.harmony.unpack200.tests.BcBandsTest error
testBcFieldRefBand org.apache.harmony.unpack200.tests.BcBandsTest error
testBcMethodRefBand org.apache.harmony.unpack200.tests.BcBandsTest error
testBcIMethodRefBand org.apache.harmony.unpack200.tests.BcBandsTest error
testBcThisFieldBand org.apache.harmony.unpack200.tests.BcBandsTest error
testBcSuperFieldBand org.apache.harmony.unpack200.tests.BcBandsTest error
testBcThisMethodBand org.apache.harmony.unpack200.tests.BcBandsTest

  Test:  testSimple Class:
org.apache.harmony.unpack200.tests.BcBandsTest
java.lang.NullPointerException
 at org.apache.harmony.unpack200.BcBands.unpack(BcBands.java:471)   at
org.apache.harmony.unpack200.BandSet.unpack(BandSet.java:53)   at
org.apache.harmony.unpack200.tests.BcBandsTest.testSimple(BcBandsTest.java:251)
 at java.lang.reflect.VMReflection.invokeMethod(VMReflection.java).......


On 9/1/08, sjanuary@apache.org <sj...@apache.org> wrote:
>
> 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;
> +    }
> +
> }
>
>
>

Re: svn commit: r690951 - in /harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200: BcBands.java ClassBands.java

Posted by Sian January <si...@googlemail.com>.
Thanks Chunrong - I've just fixed it.

On 02/09/2008, chunrong lai <ch...@gmail.com> wrote:
>  As reported in the integrity testing, the commit breaks quite a few of the
>  org.apache.harmony.unpack200.tests.BcBandsTest in classlib.
>
> http://people.apache.org/~chunrong/harmony-integrity/linux_x86/classlib-test/
>
>  error testSimple org.apache.harmony.unpack200.tests.BcBandsTest error
> testMultipleClassesSimple org.apache.harmony.unpack200.tests.BcBandsTest error
> testMultipleMethodsSimple org.apache.harmony.unpack200.tests.BcBandsTest error
> testBcCaseBands org.apache.harmony.unpack200.tests.BcBandsTest error
> testBcByteBand org.apache.harmony.unpack200.tests.BcBandsTest error
> testBcShortBand org.apache.harmony.unpack200.tests.BcBandsTest error
> testBcLocalBand org.apache.harmony.unpack200.tests.BcBandsTest error
> testBcLabelBand org.apache.harmony.unpack200.tests.BcBandsTest error
> testWideForms org.apache.harmony.unpack200.tests.BcBandsTest error
> testBcIntRefBand org.apache.harmony.unpack200.tests.BcBandsTest error
> testBcFloatRefBand org.apache.harmony.unpack200.tests.BcBandsTest error
> testBcLongRefBand org.apache.harmony.unpack200.tests.BcBandsTest error
> testBcDoubleRefBand org.apache.harmony.unpack200.tests.BcBandsTest error
> testBcStringRefBand org.apache.harmony.unpack200.tests.BcBandsTest error
> testBcClassRefBand org.apache.harmony.unpack200.tests.BcBandsTest error
> testBcFieldRefBand org.apache.harmony.unpack200.tests.BcBandsTest error
> testBcMethodRefBand org.apache.harmony.unpack200.tests.BcBandsTest error
> testBcIMethodRefBand org.apache.harmony.unpack200.tests.BcBandsTest error
> testBcThisFieldBand org.apache.harmony.unpack200.tests.BcBandsTest error
> testBcSuperFieldBand org.apache.harmony.unpack200.tests.BcBandsTest error
> testBcThisMethodBand org.apache.harmony.unpack200.tests.BcBandsTest
>
>  Test:  testSimple Class:
> org.apache.harmony.unpack200.tests.BcBandsTest
> java.lang.NullPointerException
>  at org.apache.harmony.unpack200.BcBands.unpack(BcBands.java:471)   at
> org.apache.harmony.unpack200.BandSet.unpack(BandSet.java:53)   at
> org.apache.harmony.unpack200.tests.BcBandsTest.testSimple(BcBandsTest.java:251)
>  at java.lang.reflect.VMReflection.invokeMethod(VMReflection.java).......
>
>
> On 9/1/08, sjanuary@apache.org <sj...@apache.org> wrote:
> >
> > 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;
> > +    }
> > +
> > }
> >
> >
> >
>


-- 
Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU