Package org.apache.harmony.pack200

Examples of org.apache.harmony.pack200.AttributeLayout$Key


    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


      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

  public void testUnused() {
    int[] unused = new int[] { 3, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
        23, 24, 25, 26, 27, 28, 29, 30, 31 };
    for (int i = 0; i < unused.length; i++) {
      try {
        new SegmentOptions(1 << unused[i]);
        fail("Bit " + unused[i] + " should be unused, but it's not caught during construction");
      } catch (Pack200Exception e) {
        assertTrue(true);
      }
    }
View Full Code Here

                if (n > 0) {
                   CPClass[] exceptions = new CPClass[n];
                   if (layout.matches(flag)) {
                       for (int k = 0; k < n; k++) {
                           long result = codec.decode(in);
                           exceptions[k] = new CPClass(cpBands.getCpClass()[(int) result]);
                       }
                   }
                   methodExceptions[i][j] = new ExceptionsAttribute(exceptions);
                   methodAttributes[i][j].add(methodExceptions[i][j]);
               }
View Full Code Here

          .add(new SourceFileAttribute(fileName)) };
    } else {
      classFile.attributes = new Attribute[] {};
    }
    // this/superclass
    ClassFileEntry cfThis = cp.add(new CPClass(fullName));
    ClassFileEntry cfSuper = cp.add(new CPClass(classBands.getClassSuper()[classNum]));
    // add interfaces
    ClassFileEntry cfInterfaces[] = new ClassFileEntry[classBands.getClassInterfaces()[classNum].length];
    for (i = 0; i < cfInterfaces.length; i++) {
      cfInterfaces[i] = cp.add(new CPClass(classBands.getClassInterfaces()[classNum][i]));
    }
    // add fields
    ClassFileEntry cfFields[] = new ClassFileEntry[classBands.getClassFieldCount()[classNum]];
    // fieldDescr and fieldFlags used to create this
    for (i = 0; i < cfFields.length; i++) {
View Full Code Here

    }
    // add fields
    ClassFileEntry cfFields[] = new ClassFileEntry[classBands.getClassFieldCount()[classNum]];
    // fieldDescr and fieldFlags used to create this
    for (i = 0; i < cfFields.length; i++) {
      cfFields[i] = cp.add(new CPField(classBands.getFieldDescr()[classNum][i],
                    classBands.getFieldFlags()[classNum][i], classBands.getFieldAttributes()[classNum][i]));
    }
    // add methods
    ClassFileEntry cfMethods[] = new ClassFileEntry[classBands.getClassMethodCount()[classNum]];
    // fieldDescr and fieldFlags used to create this
View Full Code Here

    }
    // add methods
    ClassFileEntry cfMethods[] = new ClassFileEntry[classBands.getClassMethodCount()[classNum]];
    // fieldDescr and fieldFlags used to create this
    for (i = 0; i < cfMethods.length; i++) {
      cfMethods[i] = cp.add(new CPMethod(classBands.getMethodDescr()[classNum][i],
                    classBands.getMethodFlags()[classNum][i], classBands.getMethodAttributes()[classNum][i]));
    }
    // sort CP according to cp_All
    cp.resolve();
    // print out entries
View Full Code Here

    // that instead
    classFile.minor = header.getDefaultClassMinorVersion(); // TODO if
    // classVersionMinor[] use
    // that instead
    // build constant pool
    ClassConstantPool cp = classFile.pool;
    String fullName = classBands.getClassThis()[classNum];
    // SourceFile attribute
    int i = fullName.lastIndexOf("/") + 1; // if lastIndexOf==-1, then
    // -1+1=0, so str.substring(0)
    // == str
    AttributeLayout SOURCE_FILE = attrDefinitionBands.getAttributeDefinitionMap()
        .getAttributeLayout(AttributeLayout.ATTRIBUTE_SOURCE_FILE,
            AttributeLayout.CONTEXT_CLASS);
    if (SOURCE_FILE.matches(classBands.getClassFlags()[classNum])) {
      String fileName = fullName.substring(i) + ".java";
      classFile.attributes = new Attribute[] { (Attribute) cp
          .add(new SourceFileAttribute(fileName)) };
    } else {
      classFile.attributes = new Attribute[] {};
    }
    // this/superclass
    ClassFileEntry cfThis = cp.add(new CPClass(fullName));
    ClassFileEntry cfSuper = cp.add(new CPClass(classBands.getClassSuper()[classNum]));
    // add interfaces
    ClassFileEntry cfInterfaces[] = new ClassFileEntry[classBands.getClassInterfaces()[classNum].length];
    for (i = 0; i < cfInterfaces.length; i++) {
      cfInterfaces[i] = cp.add(new CPClass(classBands.getClassInterfaces()[classNum][i]));
    }
    // add fields
    ClassFileEntry cfFields[] = new ClassFileEntry[classBands.getClassFieldCount()[classNum]];
    // fieldDescr and fieldFlags used to create this
    for (i = 0; i < cfFields.length; i++) {
      cfFields[i] = cp.add(new CPField(classBands.getFieldDescr()[classNum][i],
                    classBands.getFieldFlags()[classNum][i], classBands.getFieldAttributes()[classNum][i]));
    }
    // add methods
    ClassFileEntry cfMethods[] = new ClassFileEntry[classBands.getClassMethodCount()[classNum]];
    // fieldDescr and fieldFlags used to create this
    for (i = 0; i < cfMethods.length; i++) {
      cfMethods[i] = cp.add(new CPMethod(classBands.getMethodDescr()[classNum][i],
                    classBands.getMethodFlags()[classNum][i], classBands.getMethodAttributes()[classNum][i]));
    }
    // sort CP according to cp_All
    cp.resolve();
    // print out entries
    debug("Constant pool looks like:");
    for (i = 1; i <= cp.size(); i++) {
      debug(String.valueOf(i) + ":" + String.valueOf(cp.get(i)));
    }
    // NOTE the indexOf is only valid after the cp.resolve()
    // build up remainder of file
    classFile.accessFlags = (int) classBands.getClassFlags()[classNum];
    classFile.thisClass = cp.indexOf(cfThis);
    classFile.superClass = cp.indexOf(cfSuper);
    // TODO placate format of file for writing purposes
    classFile.interfaces = new int[cfInterfaces.length];
    for (i = 0; i < cfInterfaces.length; i++) {
      classFile.interfaces[i] = cp.indexOf(cfInterfaces[i]);
    }
    classFile.fields = cfFields;
    classFile.methods = cfMethods;
    return classFile;
  }
View Full Code Here

    private BcBands bcBands;

    private FileBands fileBands;

  private ClassFile buildClassFile(int classNum) throws Pack200Exception {
    ClassFile classFile = new ClassFile();
    classFile.major = header.getDefaultClassMajorVersion(); // TODO If
    // classVersionMajor[] use
    // that instead
    classFile.minor = header.getDefaultClassMinorVersion(); // TODO if
    // classVersionMinor[] use
View Full Code Here

      entry.setTime(modtime);
      out.putNextEntry(entry);

      if (isClass) {
        // write to dos
        ClassFile classFile = buildClassFile(classNum);
        classFile.write(dos);
        dos.flush();
        classNum++;
      } else {
        long size = fileSize[i];
        entry.setSize(size);
View Full Code Here

TOP

Related Classes of org.apache.harmony.pack200.AttributeLayout$Key

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.