Package org.apache.harmony.pack200

Examples of org.apache.harmony.pack200.Pack200Exception


        .getAttributeLayout(AttributeLayout.ATTRIBUTE_SOURCE_FILE,
            AttributeLayout.CONTEXT_CLASS);
    if (SOURCE_FILE.matches(classBands.getClassFlags()[classNum])) {
      String fileName = fullName.substring(i) + ".java";
      classFile.attributes = new Attribute[] { (Attribute) cp
          .add(new SourceFileAttribute(fileName)) };
    } else {
      classFile.attributes = new Attribute[] {};
    }
    // this/superclass
    ClassFileEntry cfThis = cp.add(new CPClass(fullName));
View Full Code Here


            boolean adef = (offset >> 3 & 1) == 1;
            boolean bdef = (offset >> 4 & 1) == 1;
            // If both A and B use the default encoding, what's the point of
            // having a run of default values followed by default values
            if (adef && bdef)
                throw new Pack200Exception(
                        "ADef and BDef should never both be true");
            int kb = (kbflag ? in.read() : 3);
            int k = (kb + 1) * (int) Math.pow(16, kx);
            Codec aCodec, bCodec;
            if (adef) {
                aCodec = defaultCodec;
            } else {
                aCodec = getCodec(in.read(), in, defaultCodec);
            }
            if (bdef) {
                bCodec = defaultCodec;
            } else {
                bCodec = getCodec(in.read(), in, defaultCodec);
            }
            return new RunCodec(k, aCodec, bCodec);
        } else if (value >= 141 && value <= 188) { // Population Codec
            int offset = value - 141;
            boolean fdef = (offset & 1) == 1;
            boolean udef = (offset >> 1 & 1) == 1;
            int tdefl = offset >> 2;
            boolean tdef = tdefl != 0;
            // From section 6.7.3 of spec
            final int[] tdefToL = { 0, 4, 8, 16, 32, 64, 128, 192, 224, 240,
                    248, 252 };
            int l = tdefToL[tdefl];
            // NOTE: Do not re-factor this to bring out uCodec; the order in
            // which
            // they are read from the stream is important
            if (tdef) {
                Codec fCodec = (fdef ? defaultCodec : getCodec(in.read(), in,
                        defaultCodec));
                Codec uCodec = (udef ? defaultCodec : getCodec(in.read(), in,
                        defaultCodec));
                // Unfortunately, if tdef, then tCodec depends both on l and
                // also on k, the
                // number of items read from the fCodec. So we don't know in
                // advance what
                // the codec will be.
                return new PopulationCodec(fCodec, l, uCodec);
            } else {
                Codec fCodec = (fdef ? defaultCodec : getCodec(in.read(), in,
                        defaultCodec));
                Codec tCodec = getCodec(in.read(), in, defaultCodec);
                Codec uCodec = (udef ? defaultCodec : getCodec(in.read(), in,
                        defaultCodec));
                return new PopulationCodec(fCodec, tCodec, uCodec);
            }
        } else {
            throw new Pack200Exception("Invalid codec encoding byte (" + value
                    + ") found");
        }
    }
View Full Code Here

            int indexOfStartPC = unrenumbered_start_pcs[index];
            // Given the index of the start_pc, we can now add
            // the encodedLength to it to get the stop index.
            int stopIndex = indexOfStartPC + encodedLength;
            if (stopIndex < 0) {
                throw new Pack200Exception("Error renumbering bytecode indexes");
            }
            // Length can either be an index into the byte code offsets, or one
            // beyond the
            // end of the byte code offsets. Need to determine which this is.
            if (stopIndex == byteCodeOffsets.size()) {
View Full Code Here

            int indexOfStartPC = unrenumbered_start_pcs[index];
            // Given the index of the start_pc, we can now add
            // the encodedLength to it to get the stop index.
            int stopIndex = indexOfStartPC + encodedLength;
            if (stopIndex < 0) {
                throw new Pack200Exception("Error renumbering bytecode indexes");
            }
            // Length can either be an index into the byte code offsets, or one
            // beyond the
            // end of the byte code offsets. Need to determine which this is.
            if (stopIndex == byteCodeOffsets.size()) {
View Full Code Here

        return cardinality;
    }

    public long decode(InputStream in) throws IOException, Pack200Exception {
        if (d != 0)
            throw new Pack200Exception(
                    "Delta encoding used without passing in last value; this is a coding error");
        return decode(in, 0);
    }
View Full Code Here

    public byte[] encode(long value, long last) throws Pack200Exception {
        if (isDelta()) {
            value -= last;
        }
        if (!encodes(value)) {
            throw new Pack200Exception("The codec " + toString()
                    + " does not encode the value " + value);
        }
        long z = value;
        if (isSigned()) {
            if (z < 0) {
View Full Code Here

    private final Codec bCodec;
    private long last;

    public RunCodec(int k, Codec aCodec, Codec bCodec) throws Pack200Exception {
        if (k <= 0)
            throw new Pack200Exception(
                    "Cannot have a RunCodec for a negative number of numbers");
        if (aCodec == null || bCodec == null)
            throw new Pack200Exception("Must supply both codecs for a RunCodec");
        this.k = k;
        this.aCodec = aCodec;
        this.bCodec = bCodec;
    }
View Full Code Here

        this.l = l;
        this.unvafouredCodec = unvafouredCodec;
    }

    public long decode(InputStream in) throws IOException, Pack200Exception {
        throw new Pack200Exception(
                "Population encoding does not work unless the number of elements are known");
    }
View Full Code Here

                "Population encoding does not work unless the number of elements are known");
    }

    public long decode(InputStream in, long last) throws IOException,
            Pack200Exception {
        throw new Pack200Exception(
                "Population encoding does not work unless the number of elements are known");
    }
View Full Code Here

                    BHSDCodec codec = new BHSDCodec(b, 256 - l, 0);
                    if (codec.encodes(k))
                        tokenCodec = codec;
                }
                if (tokenCodec == null)
                    throw new Pack200Exception(
                            "Cannot calculate token codec from " + k + " and "
                                    + l);
            }
        }
        // read favorites
View Full Code Here

TOP

Related Classes of org.apache.harmony.pack200.Pack200Exception

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.