org.objectweb.asm.Attribute Java Examples

The following examples show how to use org.objectweb.asm.Attribute. 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: Textifier.java    From Concurnas with MIT License 6 votes vote down vote up
/**
 * Prints a disassembled view of the given attribute.
 *
 * @param attribute an attribute.
 */
public void visitAttribute(final Attribute attribute) {
  stringBuilder.setLength(0);
  stringBuilder.append(tab).append("ATTRIBUTE ");
  appendDescriptor(-1, attribute.type);

  if (attribute instanceof TextifierSupport) {
    if (labelNames == null) {
      labelNames = new HashMap<>();
    }
    ((TextifierSupport) attribute).textify(stringBuilder, labelNames);
  } else {
    stringBuilder.append(" : unknown\n");
  }

  text.add(stringBuilder.toString());
}
 
Example #2
Source File: CheckClassAdapter.java    From JByteMod-Beta with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void visitAttribute(final Attribute attr) {
  checkState();
  if (attr == null) {
    throw new IllegalArgumentException("Invalid attribute (must not be null)");
  }
  super.visitAttribute(attr);
}
 
Example #3
Source File: FieldNode.java    From Cafebabe with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void visitAttribute(final Attribute attribute) {
	if (attrs == null) {
		attrs = new ArrayList<>(1);
	}
	attrs.add(attribute);
}
 
Example #4
Source File: ClassNode.java    From Cafebabe with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void visitAttribute(final Attribute attribute) {
	if (attrs == null) {
		attrs = new ArrayList<>(1);
	}
	attrs.add(attribute);
}
 
Example #5
Source File: MethodNode.java    From Cafebabe with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void visitAttribute(final Attribute attribute) {
	if (attrs == null) {
		attrs = new ArrayList<>(1);
	}
	attrs.add(attribute);
}
 
Example #6
Source File: ClassRemapper.java    From JByteMod-Beta with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void visitAttribute(final Attribute attribute) {
  if (attribute instanceof ModuleHashesAttribute) {
    ModuleHashesAttribute moduleHashesAttribute = (ModuleHashesAttribute) attribute;
    List<String> modules = moduleHashesAttribute.modules;
    for (int i = 0; i < modules.size(); ++i) {
      modules.set(i, remapper.mapModuleName(modules.get(i)));
    }
  }
  super.visitAttribute(attribute);
}
 
Example #7
Source File: ModuleResolutionAttribute.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 codeOffset,
    final Label[] labels) {
  return new ModuleResolutionAttribute(classReader.readUnsignedShort(offset));
}
 
Example #8
Source File: ClassNode.java    From JByteMod-Beta with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void visitAttribute(final Attribute attr) {
  if (attrs == null) {
    attrs = new ArrayList<Attribute>(1);
  }
  attrs.add(attr);
}
 
Example #9
Source File: ModuleResolutionAttribute.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 codeOffset,
    final Label[] labels) {
  return new ModuleResolutionAttribute(classReader.readUnsignedShort(offset));
}
 
Example #10
Source File: ModuleTargetAttribute.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 codeOffset,
    final Label[] labels) {
  return new ModuleTargetAttribute(classReader.readUTF8(offset, charBuffer));
}
 
Example #11
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 #12
Source File: ModuleTargetAttribute.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 codeOffset,
    final Label[] labels) {
  return new ModuleTargetAttribute(classReader.readUTF8(offset, charBuffer));
}
 
Example #13
Source File: ClassRemapper.java    From Concurnas with MIT License 5 votes vote down vote up
@Override
public void visitAttribute(final Attribute attribute) {
  if (attribute instanceof ModuleHashesAttribute) {
    ModuleHashesAttribute moduleHashesAttribute = (ModuleHashesAttribute) attribute;
    List<String> modules = moduleHashesAttribute.modules;
    for (int i = 0; i < modules.size(); ++i) {
      modules.set(i, remapper.mapModuleName(modules.get(i)));
    }
  }
  super.visitAttribute(attribute);
}
 
Example #14
Source File: FieldNode.java    From JByteMod-Beta with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void visitAttribute(final Attribute attr) {
  if (attrs == null) {
    attrs = new ArrayList<Attribute>(1);
  }
  attrs.add(attr);
}
 
Example #15
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 #16
Source File: CodeScanClassVisitor.java    From MRouter with Apache License 2.0 5 votes vote down vote up
@Override
public void visitAttribute(Attribute attribute) {
    for (IHandler handler : handlers) {
        handler.visitAttribute(attribute);
    }
    super.visitAttribute(attribute);
}
 
Example #17
Source File: MethodNode.java    From JByteMod-Beta with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void visitAttribute(final Attribute attr) {
  if (attrs == null) {
    attrs = new ArrayList<Attribute>(1);
  }
  attrs.add(attr);
}
 
Example #18
Source File: CheckFieldAdapter.java    From JByteMod-Beta with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void visitAttribute(final Attribute attr) {
  checkEnd();
  if (attr == null) {
    throw new IllegalArgumentException("Invalid attribute (must not be null)");
  }
  super.visitAttribute(attr);
}
 
Example #19
Source File: ASMifier.java    From Concurnas with MIT License 5 votes vote down vote up
/**
 * Visit a class, field or method attribute.
 *
 * @param attribute an attribute.
 */
public void visitAttribute(final Attribute attribute) {
  stringBuilder.setLength(0);
  stringBuilder.append("// ATTRIBUTE ").append(attribute.type).append('\n');
  if (attribute instanceof ASMifierSupport) {
    if (labelNames == null) {
      labelNames = new HashMap<>();
    }
    stringBuilder.append("{\n");
    ((ASMifierSupport) attribute).asmify(stringBuilder, "attribute", labelNames);
    stringBuilder.append(name).append(".visitAttribute(attribute);\n");
    stringBuilder.append("}\n");
  }
  text.add(stringBuilder.toString());
}
 
Example #20
Source File: CheckClassAdapter.java    From Concurnas with MIT License 5 votes vote down vote up
@Override
public void visitAttribute(final Attribute attribute) {
  checkState();
  if (attribute == null) {
    throw new IllegalArgumentException("Invalid attribute (must not be null)");
  }
  super.visitAttribute(attribute);
}
 
Example #21
Source File: ASMifier.java    From JByteMod-Beta with GNU General Public License v2.0 5 votes vote down vote up
public void visitAttribute(final Attribute attr) {
  buf.setLength(0);
  buf.append("// ATTRIBUTE ").append(attr.type).append('\n');
  if (attr instanceof ASMifiable) {
    if (labelNames == null) {
      labelNames = new HashMap<Label, String>();
    }
    buf.append("{\n");
    ((ASMifiable) attr).asmify(buf, "attr", labelNames);
    buf.append(name).append(".visitAttribute(attr);\n");
    buf.append("}\n");
  }
  text.add(buf.toString());
}
 
Example #22
Source File: CheckMethodAdapter.java    From Concurnas with MIT License 5 votes vote down vote up
@Override
public void visitAttribute(final Attribute attribute) {
  checkVisitEndNotCalled();
  if (attribute == null) {
    throw new IllegalArgumentException("Invalid attribute (must not be null)");
  }
  super.visitAttribute(attribute);
}
 
Example #23
Source File: ASMPrinter.java    From maple-ir with GNU General Public License v3.0 5 votes vote down vote up
public void emitNodeAttributes(List<Attribute> attrs) {
    for (int i = 0; i < attrs.size(); i++) {
        Attribute attr = attrs.get(i);

        if (i < (attrs.size() - 1)) {
            Attribute next = attrs.get(i + 1);
        }
    }

    this.emitDirective("attrs", attrs);
}
 
Example #24
Source File: CheckMethodAdapter.java    From JByteMod-Beta with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void visitAttribute(final Attribute attr) {
  checkEndMethod();
  if (attr == null) {
    throw new IllegalArgumentException("Invalid attribute (must not be null)");
  }
  super.visitAttribute(attr);
}
 
Example #25
Source File: Textifier.java    From JByteMod-Beta with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Prints a disassembled view of the given attribute.
 *
 * @param attr
 *          an attribute.
 */
public void visitAttribute(final Attribute attr) {
  buf.setLength(0);
  buf.append(tab).append("ATTRIBUTE ");
  appendDescriptor(-1, attr.type);

  if (attr instanceof Textifiable) {
    ((Textifiable) attr).textify(buf, null);
  } else {
    buf.append(" : unknown\n");
  }

  text.add(buf.toString());
}
 
Example #26
Source File: Textifier.java    From JByteMod-Beta with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void visitMethodAttribute(final Attribute attr) {
  buf.setLength(0);
  buf.append(tab).append("ATTRIBUTE ");
  appendDescriptor(-1, attr.type);

  if (attr instanceof Textifiable) {
    ((Textifiable) attr).textify(buf, labelNames);
  } else {
    buf.append(" : unknown\n");
  }

  text.add(buf.toString());
}
 
Example #27
Source File: CheckFieldAdapter.java    From Concurnas with MIT License 5 votes vote down vote up
@Override
public void visitAttribute(final Attribute attribute) {
  checkVisitEndNotCalled();
  if (attribute == null) {
    throw new IllegalArgumentException("Invalid attribute (must not be null)");
  }
  super.visitAttribute(attribute);
}
 
Example #28
Source File: ASMifier.java    From JByteMod-Beta with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void visitMethodAttribute(final Attribute attr) {
  visitAttribute(attr);
}
 
Example #29
Source File: ASMifier.java    From JByteMod-Beta with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void visitFieldAttribute(final Attribute attr) {
  visitAttribute(attr);
}
 
Example #30
Source File: ASMifier.java    From JByteMod-Beta with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void visitClassAttribute(final Attribute attr) {
  visitAttribute(attr);
}