Package org.apache.harmony.unpack200.bytecode

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


        assertEquals("Zero", ((CPUTF8)layout.getValue(1, segment.getConstantPool())).underlyingString());
        assertEquals("One", ((CPUTF8)layout.getValue(2, segment.getConstantPool())).underlyingString());
    }

    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


        assertEquals("Eins", ((CPUTF8)layout.getValue(0, segment.getConstantPool())).underlyingString());
        assertEquals("Zwei", ((CPUTF8)layout.getValue(1, segment.getConstantPool())).underlyingString());
    }

    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

        assertEquals("Eins", ((CPUTF8)layout.getValue(1, segment.getConstantPool())).underlyingString());
        assertEquals("Zwei", ((CPUTF8)layout.getValue(2, segment.getConstantPool())).underlyingString());
    }

    public void testGetCodec() throws Pack200Exception {
        AttributeLayout layout = new AttributeLayout("O",
                AttributeLayout.CONTEXT_CLASS, "HOBS", 1);
        assertEquals(Codec.BRANCH5, layout.getCodec());
        layout = new AttributeLayout("P", AttributeLayout.CONTEXT_METHOD,
                "PIN", 1);
        assertEquals(Codec.BCI5, layout.getCodec());
        layout = new AttributeLayout("S", AttributeLayout.CONTEXT_FIELD, "HS",
                1);
        assertEquals(Codec.SIGNED5, layout.getCodec());
        layout = new AttributeLayout("RS", AttributeLayout.CONTEXT_CODE,
                "RRRS", 1);
        assertEquals(Codec.UNSIGNED5, layout.getCodec());
        layout = new AttributeLayout("KS", AttributeLayout.CONTEXT_CLASS,
                "RKS", 1);
        assertEquals(Codec.UNSIGNED5, layout.getCodec());
        layout = new AttributeLayout("B", AttributeLayout.CONTEXT_CLASS,
                "TRKSB", 1);
        assertEquals(Codec.BYTE1, layout.getCodec());
    }
View Full Code Here

        assertEquals(Codec.BYTE1, layout.getCodec());
    }

    public boolean throwsException(String name, int context, String layout) {
        try {
            new AttributeLayout(name, context, layout, -1);
            return false;
        } catch (Pack200Exception e) {
            return true;
        }
    }
View Full Code Here

public class AttributeLayoutMapTest extends TestCase {

    public void testRepeatable() throws Pack200Exception {
        // Check we can retrieve a default layout
        AttributeLayoutMap a = new AttributeLayoutMap();
        AttributeLayout layout = a.getAttributeLayout("SourceFile",
                AttributeLayout.CONTEXT_CLASS);
        assertNotNull(layout);
        assertEquals("RUNH", layout.getLayout());
        // and that we can change it
        a.add(new AttributeLayout("SourceFile", AttributeLayout.CONTEXT_CLASS,
                "FROG", 15));
        layout = a.getAttributeLayout("SourceFile",
                AttributeLayout.CONTEXT_CLASS);
        assertNotNull(layout);
        assertEquals("FROG", layout.getLayout());
        assertTrue(layout.matches(1 << 15));
        assertFalse(layout.matches(1 << 16));
        assertTrue(layout.matches(-1));
        assertFalse(layout.matches(0));
        // and that changes don't affect subsequent defaults
        AttributeLayoutMap b = new AttributeLayoutMap();
        layout = b.getAttributeLayout("SourceFile",
                AttributeLayout.CONTEXT_CLASS);
        assertNotNull(layout);
        assertEquals("RUNH", layout.getLayout());

    }
View Full Code Here

            super(segment);
        }

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

public class AttributeLayoutMapTest extends TestCase {

    public void testRepeatable() throws Pack200Exception {
        // Check we can retrieve a default layout
        AttributeLayoutMap a = new AttributeLayoutMap();
        AttributeLayout layout = a.getAttributeLayout("SourceFile",
                AttributeLayout.CONTEXT_CLASS);
        assertNotNull(layout);
        assertEquals("RUNH", layout.getLayout());
        // and that we can change it
        a.add(new AttributeLayout("SourceFile", AttributeLayout.CONTEXT_CLASS,
                "FROG", 15));
        layout = a.getAttributeLayout("SourceFile",
                AttributeLayout.CONTEXT_CLASS);
        assertNotNull(layout);
        assertEquals("FROG", layout.getLayout());
        assertTrue(layout.matches(1 << 15));
        assertFalse(layout.matches(1 << 16));
        assertTrue(layout.matches(-1));
        assertFalse(layout.matches(0));
        // and that changes don't affect subsequent defaults
        AttributeLayoutMap b = new AttributeLayoutMap();
        layout = b.getAttributeLayout("SourceFile",
                AttributeLayout.CONTEXT_CLASS);
        assertNotNull(layout);
        assertEquals("RUNH", layout.getLayout());

    }
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

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

TOP

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

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.