Package org.apache.harmony.unpack200

Examples of org.apache.harmony.unpack200.MetadataBandGroup


            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


    public void testJustResources() throws Exception {
        in = Segment.class
                .getResourceAsStream("/org/apache/harmony/pack200/tests/JustResources.pack");
        file = File.createTempFile("just", "resources.jar");
        out = new JarOutputStream(new FileOutputStream(file));
        Segment segment = new Segment();
        segment.unpack(in, out);
    }
View Full Code Here

    public void testInterfaceOnly() throws Exception {
        in = Segment.class
                .getResourceAsStream("/org/apache/harmony/pack200/tests/InterfaceOnly.pack");
        file = File.createTempFile("Interface", "Only.jar");
        out = new JarOutputStream(new FileOutputStream(file));
        Segment segment = new Segment();
        segment.unpack(in, out);
    }
View Full Code Here

    public void testHelloWorld() throws Exception {
        in = Segment.class
                .getResourceAsStream("/org/apache/harmony/pack200/tests/HelloWorld.pack");
        file = File.createTempFile("hello", "world.jar");
        out = new JarOutputStream(new FileOutputStream(file));
        Segment segment = new Segment();
        segment.unpack(in, out);
        out.close();
        out = null;
        JarFile jarFile = new JarFile(file);
        file.deleteOnExit();
        JarEntry entry = jarFile
View Full Code Here

    public void testIndex() {
        pool.add(new CPUTF8("OtherThing", 1));
        CPUTF8 u1 = new CPUTF8("thing", 2);
        pool.add(u1);
        pool.resolve(new Segment());
        assertTrue(pool.indexOf(u1) > 0);
    }
View Full Code Here

    }

    public void testLayoutRU() throws Pack200Exception {
        AttributeLayout layout = new AttributeLayout("RU",
                AttributeLayout.CONTEXT_CLASS, "RU", 1);
        Segment segment = new TestSegment();
        assertNull(layout.getValue(-1, segment.getConstantPool()));
        assertEquals("Zero", ((CPUTF8)layout.getValue(0, segment.getConstantPool())).underlyingString());
        assertEquals("One", ((CPUTF8)layout.getValue(1, segment.getConstantPool())).underlyingString());
    }
View Full Code Here

    }

    public void testLayoutRUN() throws Pack200Exception {
        AttributeLayout layout = new AttributeLayout("RUN",
                AttributeLayout.CONTEXT_CLASS, "RUN", 1);
        Segment segment = new TestSegment();
        assertNull(layout.getValue(0, segment.getConstantPool()));
        assertEquals("Zero", ((CPUTF8)layout.getValue(1, segment.getConstantPool())).underlyingString());
        assertEquals("One", ((CPUTF8)layout.getValue(2, segment.getConstantPool())).underlyingString());
    }
View Full Code Here

    }

    public void testLayoutRS() throws Pack200Exception {
        AttributeLayout layout = new AttributeLayout("RS",
                AttributeLayout.CONTEXT_CLASS, "RS", 1);
        Segment segment = new TestSegment();
        assertNull(layout.getValue(-1, segment.getConstantPool()));
        assertEquals("Eins", ((CPUTF8)layout.getValue(0, segment.getConstantPool())).underlyingString());
        assertEquals("Zwei", ((CPUTF8)layout.getValue(1, segment.getConstantPool())).underlyingString());
    }
View Full Code Here

    }

    public void testLayoutRSN() throws Pack200Exception {
        AttributeLayout layout = new AttributeLayout("RSN",
                AttributeLayout.CONTEXT_CLASS, "RSN", 1);
        Segment segment = new TestSegment();
        assertNull(layout.getValue(0, segment.getConstantPool()));
        assertEquals("Eins", ((CPUTF8)layout.getValue(1, segment.getConstantPool())).underlyingString());
        assertEquals("Zwei", ((CPUTF8)layout.getValue(2, segment.getConstantPool())).underlyingString());
    }
View Full Code Here

public class SegmentConstantPoolTest extends TestCase {

    public class MockSegmentConstantPool extends SegmentConstantPool {

        public MockSegmentConstantPool() {
            super(new CpBands(new Segment()));
        };
View Full Code Here

TOP

Related Classes of org.apache.harmony.unpack200.MetadataBandGroup

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.