Package org.apache.harmony.unpack200.bytecode

Examples of org.apache.harmony.unpack200.bytecode.ClassFile


            super(segment);
        }

        public AttributeLayoutMap getAttributeDefinitionMap() {
            try {
                return new AttributeLayoutMap();
            } catch (Pack200Exception e) {
                fail(e.getLocalizedMessage());
            }
            return null;
        }
View Full Code Here


import org.apache.harmony.unpack200.IcTuple;

public class ICTupleTest extends TestCase {

    public void testPredictedClassTupleParsing() {
        IcTuple tuple = new IcTuple(
                "orw/SimpleHelloWorld$SimpleHelloWorldInner", 0, null, null,
                -1, -1, -1);
        assertEquals("SimpleHelloWorldInner", tuple.simpleClassName());
        assertEquals("orw/SimpleHelloWorld", tuple.outerClassString());

        tuple = new IcTuple("java/util/AbstractList$2$Local", 0, null, null,
                -1, -1, -1);
        assertEquals("Local", tuple.simpleClassName());
        assertEquals("java/util/AbstractList$2", tuple.outerClassString());

        tuple = new IcTuple("java/util/AbstractList#2#Local", 0, null, null,
                -1, -1, -1);
        assertEquals("Local", tuple.simpleClassName());
        assertEquals("java/util/AbstractList$2", tuple.outerClassString());

        tuple = new IcTuple("java/util/AbstractList$1", 0, null, null, -1, -1,
                -1);
        assertEquals("1", tuple.simpleClassName());
        assertEquals("java/util/AbstractList", tuple.outerClassString());
    }
View Full Code Here

        assertEquals("1", tuple.simpleClassName());
        assertEquals("java/util/AbstractList", tuple.outerClassString());
    }

    public void testExplicitClassTupleParsing() {
        IcTuple tuple = new IcTuple("Foo$$2$Local", IcTuple.NESTED_CLASS_FLAG,
                null, "$2$Local", -1, -1, -1);
        assertEquals("$2$Local", tuple.simpleClassName());
        assertEquals("Foo$$2", tuple.outerClassString());

        tuple = new IcTuple("Red$Herring", IcTuple.NESTED_CLASS_FLAG,
                "Red$Herring", null, -1, -1, -1);
        assertEquals("Herring", tuple.simpleClassName());
        assertEquals("Red$Herring", tuple.outerClassString());

        tuple = new IcTuple("X$1$Q", IcTuple.NESTED_CLASS_FLAG, "X$1", "Q", -1,
                -1, -1);
        assertEquals("Q", tuple.simpleClassName());
        assertEquals("X$1", tuple.outerClassString());
    }
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

import org.apache.harmony.unpack200.SegmentConstantPoolArrayCache;

public class SegmentConstantPoolArrayCacheTest extends TestCase {
   
    public void testSingleSimpleArray() {
        SegmentConstantPoolArrayCache arrayCache = new SegmentConstantPoolArrayCache();
        String array[] = {"Zero", "One", "Two", "Three", "Four"};
        List list = arrayCache.indexesForArrayKey(array, "Three");
        assertEquals(1, list.size());
        assertEquals(3, ((Integer)list.get(0)).intValue());
    }
View Full Code Here

        assertEquals(1, list.size());
        assertEquals(3, ((Integer)list.get(0)).intValue());
    }
   
    public void testSingleMultipleHitArray() {
        SegmentConstantPoolArrayCache arrayCache = new SegmentConstantPoolArrayCache();
        String array[] = {"Zero", "OneThreeFour", "Two", "OneThreeFour", "OneThreeFour"};
        List list = arrayCache.indexesForArrayKey(array, "OneThreeFour");
        assertEquals(3, list.size());
        assertEquals(1, ((Integer)list.get(0)).intValue());
        assertEquals(3, ((Integer)list.get(1)).intValue());
        assertEquals(4, ((Integer)list.get(2)).intValue());
    }
View Full Code Here

        assertEquals(3, ((Integer)list.get(1)).intValue());
        assertEquals(4, ((Integer)list.get(2)).intValue());
    }

    public void testMultipleArrayMultipleHit() {
        SegmentConstantPoolArrayCache arrayCache = new SegmentConstantPoolArrayCache();
        String arrayOne[] = {"Zero", "Shared", "Two", "Shared", "Shared"};
        String arrayTwo[] = {"Shared", "One", "Shared", "Shared", "Shared"};

        List listOne = arrayCache.indexesForArrayKey(arrayOne, "Shared");
        List listTwo = arrayCache.indexesForArrayKey(arrayTwo, "Shared");
        // Make sure we're using the cached values. First trip
        // through builds the cache.
        listOne = arrayCache.indexesForArrayKey(arrayOne, "Two");
        listTwo = arrayCache.indexesForArrayKey(arrayTwo, "Shared");
       
        assertEquals(1, listOne.size());
        assertEquals(2, ((Integer)listOne.get(0)).intValue());

        // Now look for a different element in list one
        listOne = arrayCache.indexesForArrayKey(arrayOne, "Shared");
        assertEquals(3, listOne.size());
        assertEquals(1, ((Integer)listOne.get(0)).intValue());
        assertEquals(3, ((Integer)listOne.get(1)).intValue());
        assertEquals(4, ((Integer)listOne.get(2)).intValue());
       
        assertEquals(4, listTwo.size());
        assertEquals(0, ((Integer)listTwo.get(0)).intValue());
        assertEquals(2, ((Integer)listTwo.get(1)).intValue());
        assertEquals(3, ((Integer)listTwo.get(2)).intValue());
        assertEquals(4, ((Integer)listTwo.get(3)).intValue());
       
        List listThree = arrayCache.indexesForArrayKey(arrayOne, "Not found");
        assertEquals(0, listThree.size());
    }
View Full Code Here

TOP

Related Classes of org.apache.harmony.unpack200.bytecode.ClassFile

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.