Java Code Examples for org.objectweb.asm.ByteVector#putByteArray()

The following examples show how to use org.objectweb.asm.ByteVector#putByteArray() . 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: ASMBackendUtils.java    From JAADAS with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Create an ASM attribute from an Soot attribute
 * @param attr Soot attribute
 * @return ASM attribute
 */
public static org.objectweb.asm.Attribute createASMAttribute(Attribute attr) {
    final Attribute a = attr;
    return new org.objectweb.asm.Attribute(
            attr.getName()) {
        @Override
        protected ByteVector write(final ClassWriter cw,
                                   final byte[] code, final int len,
                                   final int maxStack, final int maxLocals) {
            ByteVector result = new ByteVector();
            result.putByteArray(a.getValue(), 0,
                    a.getValue().length);
            return result;
        }
    };
}
 
Example 2
Source File: DesugarMethodAttribute.java    From bazel with Apache License 2.0 5 votes vote down vote up
@Override
protected ByteVector write(
    ClassWriter classWriter, byte[] code, int codeLength, int maxStack, int maxLocals) {
  ByteVector byteVector = new ByteVector();
  byte[] payloadBytes = payload.toByteArray();
  byteVector.putByteArray(payloadBytes, 0, payloadBytes.length);
  return byteVector;
}