Package org.apache.harmony.pack200

Examples of org.apache.harmony.pack200.RunCodec


            assertEquals(band[i], bandDecoded[i]);
        }
    }

    public void testToString() throws Pack200Exception {
        RunCodec runCodec = new RunCodec(3, Codec.UNSIGNED5, Codec.BYTE1);
        assertEquals(
                "RunCodec[k=" + 3 + ";aCodec=" + Codec.UNSIGNED5.toString()
                        + "bCodec=" + Codec.BYTE1.toString() + "]",
                runCodec.toString());
    }
View Full Code Here


                runCodec.toString());
    }

    public void testEncodeSingleValue() {
        try {
            new RunCodec(10, BHSDCodec.SIGNED5, BHSDCodec.UDELTA5).encode(5);
            fail("Should not allow a single value to be encoded as we don't know which codec to use");
        } catch (Pack200Exception e) {
            // pass
        }
        try {
            new RunCodec(10, BHSDCodec.SIGNED5, BHSDCodec.UDELTA5).encode(5, 8);
            fail("Should not allow a single value to be encoded as we don't know which codec to use");
        } catch (Pack200Exception e) {
            // pass
        }
    }
View Full Code Here

    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

    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

    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

    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

TOP

Related Classes of org.apache.harmony.pack200.RunCodec

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.