Package org.apache.harmony.pack200.Archive

Examples of org.apache.harmony.pack200.Archive.File


        in = new JarInputStream(
                Archive.class
                        .getResourceAsStream("/org/apache/harmony/pack200/tests/hw.jar"));
        file = File.createTempFile("helloworld", ".pack.gz");
        out = new FileOutputStream(file);
        new Archive(in, out, true).pack();
        in.close();
        out.close();

        // now unpack
        InputStream in2 = new FileInputStream(file);
View Full Code Here


            ClassReader reader = (ClassReader) iterator.next();
            classNames.add(reader.getClassName());
        }
        CPUTF8 emptyString = cpBands.getCPUtf8("");
        for (int i = 0; i < files.size(); i++) {
             File file = (File)files.get(i);
             String name = file.getName();
             if(name.endsWith(".class")) {
                 file_options[i] |= (1 << 1);
                 if(classNames.contains(name.substring(0, name.length() - 6))) {
                     fileName[i] = emptyString;
                 } else {
                     fileName[i] = cpBands.getCPUtf8(name);
                 }
             } else {
                 fileName[i] = cpBands.getCPUtf8(name);
             }
             byte[] bytes = file.getContents();
             file_size[i] = bytes.length;
             totalSize += file_size[i];
             file_modtime[i] = (int)(file.getModtime() - archiveModtime);
             file_bits[i] = file.getContents();
         }
    }
View Full Code Here

        file_options = new int[size];
        CPUTF8 emptyString = cpBands.getCPUtf8("");
        int totalSize = 0;
        file_bits = new byte[files.size()][];
         for (int i = 0; i < files.size(); i++) {
             File file = (File)files.get(i);
             String name = file.getName();
             fileName[i] = cpBands.getCPUtf8(name); // TODO: sometimes this can be the empty string
             if(name.endsWith(".class")) {
//                 fileName[i] = emptyString;
                 file_options[i] |= (1 << 1);
//             } else {
//                 fileName[i] = cpBands.getCPUtf8(name);
             }
             byte[] bytes = file.getContents();
             file_size[i] = bytes.length;
             totalSize += file_size[i];
             file_modtime[i] = file.getModtime();
             file_bits[i] = file.getContents();
         }
    }
View Full Code Here

    assertTrue(!throwsException("name",AttributeLayout.CONTEXT_CODE,""));
    assertTrue(throwsException("name",-1,""));
    assertTrue(throwsException("name",1234,""));
  }
  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",layout.getValue(0, segment.getConstantPool()));
    assertEquals("One",layout.getValue(1, segment.getConstantPool()));
  }
View Full Code Here

    assertNull(layout.getValue(-1, segment.getConstantPool()));
    assertEquals("Zero",layout.getValue(0, segment.getConstantPool()));
    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

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

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

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

import org.apache.harmony.pack200.Pack200Exception;

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

TOP

Related Classes of org.apache.harmony.pack200.Archive.File

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.