Java Code Examples for org.objectweb.asm.ClassReader#readModule()

The following examples show how to use org.objectweb.asm.ClassReader#readModule() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ModuleHashesAttribute.java    From Concurnas with MIT License 5 votes vote down vote up
@Override
protected Attribute read(
    final ClassReader classReader,
    final int offset,
    final int length,
    final char[] charBuffer,
    final int codeAttributeOffset,
    final Label[] labels) {
  int currentOffset = offset;

  String hashAlgorithm = classReader.readUTF8(currentOffset, charBuffer);
  currentOffset += 2;

  int numModules = classReader.readUnsignedShort(currentOffset);
  currentOffset += 2;

  ArrayList<String> moduleList = new ArrayList<>(numModules);
  ArrayList<byte[]> hashList = new ArrayList<>(numModules);

  for (int i = 0; i < numModules; ++i) {
    String module = classReader.readModule(currentOffset, charBuffer);
    currentOffset += 2;
    moduleList.add(module);

    int hashLength = classReader.readUnsignedShort(currentOffset);
    currentOffset += 2;
    byte[] hash = new byte[hashLength];
    for (int j = 0; j < hashLength; ++j) {
      hash[j] = (byte) (classReader.readByte(currentOffset) & 0xFF);
      currentOffset += 1;
    }
    hashList.add(hash);
  }
  return new ModuleHashesAttribute(hashAlgorithm, moduleList, hashList);
}
 
Example 2
Source File: ModuleHashesAttribute.java    From JByteMod-Beta with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected Attribute read(
    final ClassReader classReader,
    final int offset,
    final int length,
    final char[] charBuffer,
    final int codeAttributeOffset,
    final Label[] labels) {
  int currentOffset = offset;

  String hashAlgorithm = classReader.readUTF8(currentOffset, charBuffer);
  currentOffset += 2;

  int numModules = classReader.readUnsignedShort(currentOffset);
  currentOffset += 2;

  ArrayList<String> moduleList = new ArrayList<String>(numModules);
  ArrayList<byte[]> hashList = new ArrayList<byte[]>(numModules);

  for (int i = 0; i < numModules; ++i) {
    String module = classReader.readModule(currentOffset, charBuffer);
    currentOffset += 2;
    moduleList.add(module);

    int hashLength = classReader.readUnsignedShort(currentOffset);
    currentOffset += 2;
    byte[] hash = new byte[hashLength];
    for (int j = 0; j < hashLength; ++j) {
      hash[j] = (byte) (classReader.readByte(currentOffset) & 0xFF);
      currentOffset += 1;
    }
    hashList.add(hash);
  }
  return new ModuleHashesAttribute(hashAlgorithm, moduleList, hashList);
}
 
Example 3
Source File: ModuleHashesAttribute.java    From JReFrameworker with MIT License 5 votes vote down vote up
@Override
protected Attribute read(
    final ClassReader classReader,
    final int offset,
    final int length,
    final char[] charBuffer,
    final int codeAttributeOffset,
    final Label[] labels) {
  int currentOffset = offset;

  String hashAlgorithm = classReader.readUTF8(currentOffset, charBuffer);
  currentOffset += 2;

  int numModules = classReader.readUnsignedShort(currentOffset);
  currentOffset += 2;

  ArrayList<String> moduleList = new ArrayList<String>(numModules);
  ArrayList<byte[]> hashList = new ArrayList<byte[]>(numModules);

  for (int i = 0; i < numModules; ++i) {
    String module = classReader.readModule(currentOffset, charBuffer);
    currentOffset += 2;
    moduleList.add(module);

    int hashLength = classReader.readUnsignedShort(currentOffset);
    currentOffset += 2;
    byte[] hash = new byte[hashLength];
    for (int j = 0; j < hashLength; ++j) {
      hash[j] = (byte) (classReader.readByte(currentOffset) & 0xFF);
      currentOffset += 1;
    }
    hashList.add(hash);
  }
  return new ModuleHashesAttribute(hashAlgorithm, moduleList, hashList);
}
 
Example 4
Source File: ModuleHashesAttribute.java    From JReFrameworker with MIT License 5 votes vote down vote up
@Override
protected Attribute read(
    final ClassReader classReader,
    final int offset,
    final int length,
    final char[] charBuffer,
    final int codeAttributeOffset,
    final Label[] labels) {
  int currentOffset = offset;

  String hashAlgorithm = classReader.readUTF8(currentOffset, charBuffer);
  currentOffset += 2;

  int numModules = classReader.readUnsignedShort(currentOffset);
  currentOffset += 2;

  ArrayList<String> moduleList = new ArrayList<String>(numModules);
  ArrayList<byte[]> hashList = new ArrayList<byte[]>(numModules);

  for (int i = 0; i < numModules; ++i) {
    String module = classReader.readModule(currentOffset, charBuffer);
    currentOffset += 2;
    moduleList.add(module);

    int hashLength = classReader.readUnsignedShort(currentOffset);
    currentOffset += 2;
    byte[] hash = new byte[hashLength];
    for (int j = 0; j < hashLength; ++j) {
      hash[j] = (byte) (classReader.readByte(currentOffset) & 0xFF);
      currentOffset += 1;
    }
    hashList.add(hash);
  }
  return new ModuleHashesAttribute(hashAlgorithm, moduleList, hashList);
}