harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Aleksey Shipilev" <aleksey.shipi...@gmail.com>
Subject Re: [classlib][pack200] Decoupling I/O and processing for unpacking scenario
Date Fri, 18 Jul 2008 14:31:27 GMT
Sian,

On Fri, Jul 18, 2008 at 5:29 PM, Sian January
<sianjanuary@googlemail.com> wrote:
>> Awesome! Am I understanding correctly: this value determines the size
>> of segment? If yes, can you point me how to access this value? Is
>> there API in current implementation?
> Yes - use SegmentHeader.getArchiveSize()

Does spec cover any alignment/padding constraints for segments?
What exactly archive size specify?

I'm doing this one [1]:
 1. Reading the header of segment (moved from readSegment).
 2. Check the field value, then either
  3a. Read the segment into byte array and wrap it with BAIS, then
read from BAIS
  3b. Read the segment from global input stream

I can only read first segment, second fails to read with the "bad
header" exception.

Thanks,
Aleksey.

[1]
    void unpackRead(InputStream in) throws IOException, Pack200Exception {
        if (!in.markSupported())
            in = new BufferedInputStream(in);

        header = new SegmentHeader(this);
        header.read(in);

        int size = (int)header.getArchiveSize();

        if (size != 0) {
            byte[] data = new byte[size];
            in.read(data);
            bin = new ByteArrayInputStream(data);

            readSegment(bin);
        } else {
            readSegment(in);
        }
    }

Mime
View raw message