Package org.apache.harmony.pack200

Examples of org.apache.harmony.pack200.Segment$SegmentConstantPool


    assertEquals("One",layout.getValue(1, segment.getConstantPool()));
  }

  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",layout.getValue(1, segment.getConstantPool()));
    assertEquals("One",layout.getValue(2, segment.getConstantPool()));
  }
View Full Code Here


    assertEquals("One",layout.getValue(2, segment.getConstantPool()));
  }

  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",layout.getValue(0, segment.getConstantPool()));
    assertEquals("Zwei",layout.getValue(1, segment.getConstantPool()));
  }
View Full Code Here

    assertEquals("Zwei",layout.getValue(1, segment.getConstantPool()));
  }

    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",layout.getValue(1, segment.getConstantPool()));
    assertEquals("Zwei",layout.getValue(2, segment.getConstantPool()));
  }
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

  boolean handlingInnerClasses = false;

  public void testHelloWorld() throws Exception {
        InputStream in = Segment.class
            .getResourceAsStream("/org/apache/harmony/pack200/tests/HelloWorld.pack");
        Segment segment = Segment.parse(in);
        assertNotNull(segment);
        segment.writeJar(new JarOutputStream(new FileOutputStream(File.createTempFile("Hello", "World.jar"))), in);
  }
View Full Code Here

  }

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

      throw new IllegalArgumentException(
          "Must specify both input and output streams");
    completed(0);
    try {
      while (in.available() > 0) {
        Segment s = Segment.parse(in);
        s.writeJar(out, in);
        out.flush();
      }
    } catch (Pack200Exception e) {
      throw new IOException("Failed to unpack Jar:" + String.valueOf(e));
    }
View Full Code Here

      final Object[][] data = new Object[][] {
          { }, // ALL
          { "Zero", "One" }, // UTF-8
          { "Ein", "Zwei" }, // Signature
      };
      return new SegmentConstantPool(null) {
        public Object getValue(int cp, long index) {
          if (index == -1)
            return null;
          return data[cp][(int)index];
        }
View Full Code Here

            OperandManager operandManager) {
        ClassFileEntry[] nested = null;
        int offset = getOffset(operandManager);
        if(offset == 0) {
            // Use current class
            SegmentConstantPool globalPool = operandManager.globalConstantPool();
            nested = new ClassFileEntry[] {
                        globalPool.getClassPoolEntry(operandManager.getCurrentClass())
            };
            byteCode.setNested(nested);
            byteCode.setNestedPositions(new int[][] {{0,2}});
        } else {
            // Look up the class in the classpool
View Full Code Here

    protected abstract int getOffset(OperandManager operandManager);
    protected abstract int getPoolID();
    protected abstract String context(OperandManager operandManager);
   
    protected void setNestedEntries(ByteCode byteCode, OperandManager operandManager, int offset) throws Pack200Exception {
        SegmentConstantPool globalPool = operandManager.globalConstantPool();
        ClassFileEntry[] nested = null;
        nested = new ClassFileEntry[] {
                globalPool.getClassSpecificPoolEntry(getPoolID(), offset, context(operandManager))
                };
        byteCode.setNested(nested);
        byteCode.setNestedPositions(new int[][] {{0, 2}});
    }
View Full Code Here

TOP

Related Classes of org.apache.harmony.pack200.Segment$SegmentConstantPool

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.