Package org.apache.harmony.pack200.bytecode

Examples of org.apache.harmony.pack200.bytecode.CPUTF8


        // native signatures end up in DOMAINNORMALASCIIZ
        // while nonnatives end up in DOMAINSIGNATUREASCIIZ.
        // TODO: is this the right thing to do?
        for(int x=0; x < localVariableTableTypeRS.length; x++) {
            for(int y=0; y < localVariableTableTypeRS[x].length; y++) {
                CPUTF8 element = localVariableTableTypeRS[x][y];
                // TODO: come up with a better test for native vs nonnative signatures?
                if(element.underlyingString().length() > 2) {
                    element.setDomain(ClassConstantPool.DOMAIN_SIGNATUREASCIIZ);
                } else {
                    element.setDomain(ClassConstantPool.DOMAIN_NORMALASCIIZ);
                }
            }
        }

        int lengthLocalVariableTypeTableNBand = SegmentUtils.countMatches(
View Full Code Here


    private CPUTF8[][] stringsToCPUTF8(String[][] strings) {
        CPUTF8[][] cpUTF8s = new CPUTF8[strings.length][];
        for (int i = 0; i < strings.length; i++) {
            cpUTF8s[i] = new CPUTF8[strings[i].length];
            for (int j = 0; j < strings[i].length; j++) {
                cpUTF8s[i][j] = new CPUTF8(strings[i][j], ClassConstantPool.DOMAIN_NORMALASCIIZ);
            }
        }
        return cpUTF8s;
    }
View Full Code Here


    private CPUTF8[] stringsToCPUTF8(String[] strings) {
        CPUTF8[] cpUTF8s = new CPUTF8[strings.length];
        for (int i = 0; i < strings.length; i++) {
            cpUTF8s[i] = new CPUTF8(strings[i], ClassConstantPool.DOMAIN_UNDEFINED);
        }
        return cpUTF8s;
    }
View Full Code Here

  public void setUp() {
    pool = new ClassConstantPool();
  }
  public void testDuplicateUTF8() {
    CPUTF8 u1 = new CPUTF8("thing");
    CPUTF8 u2 = new CPUTF8("thing");
    pool.add(u1);
    pool.add(u2);
    assertEquals(1,pool.size());
  }
View Full Code Here

    CPMember cp2 = new CPMember("name:I",0,null);
    pool.add(cp2);
    assertEquals(2,pool.size());
  }
  public void testIndex() {
    pool.add(new CPUTF8("OtherThing"));
    CPUTF8 u1 = new CPUTF8("thing");
    pool.add(u1);
    pool.resolve();
    assertTrue(pool.indexOf(u1) > 0);
  }
View Full Code Here

import org.apache.harmony.pack200.bytecode.CPUTF8;
import org.apache.harmony.pack200.bytecode.SourceFileAttribute;

public class ClassFileEntryTest extends TestCase {
  public void testUTF8() {
    CPUTF8 u1 = new CPUTF8(new String("thing")); //$NON-NLS-1$
    CPUTF8 u2 = new CPUTF8(new String("thing")); //$NON-NLS-1$
    CPUTF8 u3 = new CPUTF8(new String("otherthing")); //$NON-NLS-1$
    checkEquality(u1, u2, "thing", u3);
  }
View Full Code Here

        // fieldDescr and fieldFlags used to create this
        for (i = 0; i < cfFields.length; i++) {
            int descriptorIndex = classBands.getFieldDescrInts()[classNum][i];
            int nameIndex = cpBands.getCpDescriptorNameInts()[descriptorIndex];
            int typeIndex = cpBands.getCpDescriptorTypeInts()[descriptorIndex];
            CPUTF8 name = cpBands.cpUTF8Value(nameIndex);
            CPUTF8 descriptor = cpBands.cpSignatureValue(typeIndex);
            cfFields[i] = cp.add(new CPField(name, descriptor, classBands
                    .getFieldFlags()[classNum][i], classBands
                    .getFieldAttributes()[classNum][i]));
        }
        // add methods
        ClassFileEntry cfMethods[] = new ClassFileEntry[classBands
                .getClassMethodCount()[classNum]];
        // methodDescr and methodFlags used to create this
        for (i = 0; i < cfMethods.length; i++) {
            int descriptorIndex = classBands.getMethodDescrInts()[classNum][i];
//            int colon = descriptorStr.indexOf(':');
            int nameIndex = cpBands.getCpDescriptorNameInts()[descriptorIndex];
            int typeIndex = cpBands.getCpDescriptorTypeInts()[descriptorIndex];
            CPUTF8 name = cpBands.cpUTF8Value(nameIndex);
            CPUTF8 descriptor = cpBands.cpSignatureValue(typeIndex);
            cfMethods[i] = cp.add(new CPMethod(name, descriptor, classBands
                    .getMethodFlags()[classNum][i], classBands
                    .getMethodAttributes()[classNum][i]));
        }
        cp.addNestedEntries();

        // add inner class attribute (if required)
        boolean addInnerClassesAttr = false;
        IcTuple[] ic_local = getClassBands().getIcLocal()[classNum];
        boolean ic_local_sent = ic_local != null;
        InnerClassesAttribute innerClassesAttribute = new InnerClassesAttribute(
                "InnerClasses");
        IcTuple[] ic_relevant = getIcBands().getRelevantIcTuples(fullName, cp);
        List ic_stored = computeIcStored(ic_local, ic_relevant);
        for (int index = 0; index < ic_stored.size(); index++) {
          IcTuple icStored = (IcTuple)ic_stored.get(index);
            int innerClassIndex = icStored.thisClassIndex();
            int outerClassIndex = icStored.outerClassIndex();
            int simpleClassNameIndex = icStored.simpleClassNameIndex();

            String innerClassString = icStored.thisClassString();
            String outerClassString = icStored.outerClassString();
            String simpleClassName = icStored.simpleClassName();

            CPClass innerClass = null;
            CPUTF8 innerName = null;
            CPClass outerClass = null;

            innerClass = innerClassIndex != -1 ? cpBands
                    .cpClassValue(innerClassIndex) : cpBands
                    .cpClassValue(innerClassString);
View Full Code Here

    public void setUp() {
        pool = new ClassConstantPool();
    }

    public void testDuplicateUTF8() {
        CPUTF8 u1 = new CPUTF8("thing", 1);
        CPUTF8 u2 = new CPUTF8("thing", 1);
        pool.add(u1);
        pool.add(u2);
        assertEquals(1, pool.size());
    }
View Full Code Here

        pool.add(u2);
        assertEquals(1, pool.size());
    }

    public void testDuplicateField() {
        CPMember cp1 = new CPMember(new CPUTF8("name", 1), new CPUTF8("I", 2),
                0, null);
        pool.add(cp1);
        pool.addNestedEntries();
        assertEquals(2, pool.size());
        CPMember cp2 = new CPMember(new CPUTF8("name", 1), new CPUTF8("I", 2),
                0, null);
        pool.add(cp2);
        pool.addNestedEntries();
        assertEquals(2, pool.size());
    }
View Full Code Here

        pool.addNestedEntries();
        assertEquals(2, pool.size());
    }

    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

TOP

Related Classes of org.apache.harmony.pack200.bytecode.CPUTF8

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.