Package org.apache.harmony.pack200.bytecode

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


        assertFalse(byte2s.encodes(192));
        assertFalse(byte2s.encodes(256));
    }

    public void testRunCodec() throws Exception {
        RunCodec runCodec = new RunCodec(1, Codec.UNSIGNED5, Codec.BYTE1);
        ByteArrayInputStream bais = new ByteArrayInputStream(new byte[] {
                (byte) 192, 0, (byte) 192, 0 });
        assertEquals(192, runCodec.decode(bais));
        assertEquals(192, runCodec.decode(bais));
        assertEquals(0, runCodec.decode(bais));
        assertEquals(0, bais.available());
        runCodec = new RunCodec(1, Codec.BYTE1, Codec.UNSIGNED5);
        bais = new ByteArrayInputStream(new byte[] { (byte) 192, 0, (byte) 192,
                0 });
        assertEquals(192, runCodec.decode(bais));
        assertEquals(0, runCodec.decode(bais));
        assertEquals(192, runCodec.decode(bais));
        assertEquals(0, bais.available());
    }
View Full Code Here


    assertFalse(byte2s.encodes(192));
    assertFalse(byte2s.encodes(256));   
  }

  public void testRunCodec() throws Exception {
    RunCodec runCodec = new RunCodec(1,Codec.UNSIGNED5,Codec.BYTE1);
    ByteArrayInputStream bais = new ByteArrayInputStream(new byte[]{ (byte) 192,0,(byte) 192,0});
    assertEquals(192,runCodec.decode(bais));
    assertEquals(192,runCodec.decode(bais));
    assertEquals(0,runCodec.decode(bais));
    assertEquals(0,bais.available());
    runCodec = new RunCodec(1,Codec.BYTE1,Codec.UNSIGNED5);
    bais = new ByteArrayInputStream(new byte[]{ (byte) 192,0,(byte) 192,0});
    assertEquals(192,runCodec.decode(bais));
    assertEquals(0,runCodec.decode(bais));
    assertEquals(192,runCodec.decode(bais));
    assertEquals(0,bais.available());
  }
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

                           methodByteCodePacked[c][m], segment, operandManager);
                   methodAttributes[c][m].add(attr);
                   // Should I add all the attributes in here?
                 ArrayList currentAttributes = (ArrayList)orderedCodeAttributes.get(i);
                 for(int index=0;index < currentAttributes.size(); index++) {
                     Attribute currentAttribute = (Attribute)currentAttributes.get(index);
                     // TODO: The line below adds the LocalVariableTable
                     // and LineNumber attributes. Currently things are
                     // broken because these tables don't get renumbered
                     // properly. Commenting out the add so the class files
                     // will verify.
                     //attr.attributes.add(currentAttribute);
                     // Fix up the line numbers if needed
                     if(currentAttribute.hasBCIRenumbering()) {
                         ((BCIRenumberedAttribute)currentAttribute).renumber(attr.byteCodeOffsets);
                     }
                 }
                 i++;
               }
View Full Code Here

    public ArrayList getOrderedCodeAttributes() {
        ArrayList orderedAttributeList = new ArrayList();
        for(int classIndex=0; classIndex < codeAttributes.length; classIndex++) {
            ArrayList currentAttributes = new ArrayList();
            for(int attributeIndex = 0; attributeIndex < codeAttributes[classIndex].size(); attributeIndex++) {
                Attribute attribute = (Attribute)codeAttributes[classIndex].get(attributeIndex);
                currentAttributes.add(attribute);
            }
            orderedAttributeList.add(currentAttributes);
        }
        return orderedAttributeList;
View Full Code Here

TOP

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

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.