下面列出了怎么用org.objectweb.asm.ByteVector的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
protected ByteVector write(
final ClassWriter classWriter,
final byte[] code,
final int codeLength,
final int maxStack,
final int maxLocals) {
ByteVector byteVector = new ByteVector();
byteVector.putShort(classWriter.newUTF8(algorithm));
if (modules == null) {
byteVector.putShort(0);
} else {
int numModules = modules.size();
byteVector.putShort(numModules);
for (int i = 0; i < numModules; ++i) {
String module = modules.get(i);
byte[] hash = hashes.get(i);
byteVector
.putShort(classWriter.newModule(module))
.putShort(hash.length)
.putByteArray(hash, 0, hash.length);
}
}
return byteVector;
}
@Override
protected ByteVector write(
final ClassWriter classWriter,
final byte[] code,
final int codeLength,
final int maxStack,
final int maxLocals) {
ByteVector byteVector = new ByteVector();
byteVector.putShort(classWriter.newUTF8(algorithm));
if (modules == null) {
byteVector.putShort(0);
} else {
int numModules = modules.size();
byteVector.putShort(numModules);
for (int i = 0; i < numModules; ++i) {
String module = modules.get(i);
byte[] hash = hashes.get(i);
byteVector
.putShort(classWriter.newModule(module))
.putShort(hash.length)
.putByteArray(hash, 0, hash.length);
}
}
return byteVector;
}
/**
* 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;
}
};
}
@Override
protected ByteVector write(
final ClassWriter classWriter,
final byte[] code,
final int codeLength,
final int maxStack,
final int maxLocals) {
ByteVector byteVector = new ByteVector();
byteVector.putShort(classWriter.newUTF8(algorithm));
if (modules == null) {
byteVector.putShort(0);
} else {
int numModules = modules.size();
byteVector.putShort(numModules);
for (int i = 0; i < numModules; ++i) {
String module = modules.get(i);
byte[] hash = hashes.get(i);
byteVector
.putShort(classWriter.newModule(module))
.putShort(hash.length)
.putByteArray(hash, 0, hash.length);
}
}
return byteVector;
}
@Override
protected ByteVector write(
final ClassWriter classWriter,
final byte[] code,
final int codeLength,
final int maxStack,
final int maxLocals) {
ByteVector byteVector = new ByteVector();
byteVector.putShort(classWriter.newUTF8(algorithm));
if (modules == null) {
byteVector.putShort(0);
} else {
int numModules = modules.size();
byteVector.putShort(numModules);
for (int i = 0; i < numModules; ++i) {
String module = modules.get(i);
byte[] hash = hashes.get(i);
byteVector
.putShort(classWriter.newModule(module))
.putShort(hash.length)
.putByteArray(hash, 0, hash.length);
}
}
return byteVector;
}
@Override
protected ByteVector write(
final ClassWriter classWriter,
final byte[] code,
final int codeLength,
final int maxStack,
final int maxLocals) {
ByteVector byteVector = new ByteVector();
byteVector.putShort(resolution);
return byteVector;
}
@Override
protected ByteVector write(
final ClassWriter classWriter,
final byte[] code,
final int codeLength,
final int maxStack,
final int maxLocals) {
ByteVector byteVector = new ByteVector();
byteVector.putShort(platform == null ? 0 : classWriter.newUTF8(platform));
return byteVector;
}
@Override
protected ByteVector write(
final ClassWriter classWriter,
final byte[] code,
final int codeLength,
final int maxStack,
final int maxLocals) {
ByteVector byteVector = new ByteVector();
byteVector.putShort(resolution);
return byteVector;
}
@Override
protected ByteVector write(
final ClassWriter classWriter,
final byte[] code,
final int codeLength,
final int maxStack,
final int maxLocals) {
ByteVector byteVector = new ByteVector();
byteVector.putShort(platform == null ? 0 : classWriter.newUTF8(platform));
return byteVector;
}
@Override
protected ByteVector write(
final ClassWriter classWriter,
final byte[] code,
final int codeLength,
final int maxStack,
final int maxLocals) {
ByteVector byteVector = new ByteVector();
byteVector.putShort(resolution);
return byteVector;
}
@Override
protected ByteVector write(
final ClassWriter classWriter,
final byte[] code,
final int codeLength,
final int maxStack,
final int maxLocals) {
ByteVector byteVector = new ByteVector();
byteVector.putShort(platform == null ? 0 : classWriter.newUTF8(platform));
return byteVector;
}
@Override
protected ByteVector write(
final ClassWriter classWriter,
final byte[] code,
final int codeLength,
final int maxStack,
final int maxLocals) {
ByteVector byteVector = new ByteVector();
byteVector.putShort(resolution);
return byteVector;
}
@Override
protected ByteVector write(
final ClassWriter classWriter,
final byte[] code,
final int codeLength,
final int maxStack,
final int maxLocals) {
ByteVector byteVector = new ByteVector();
byteVector.putShort(platform == null ? 0 : classWriter.newUTF8(platform));
return byteVector;
}
protected ByteVector write(
final ClassWriter cw,
final byte[] code,
final int len,
final int maxStack,
final int maxLocals)
{
ByteVector bv = new ByteVector();
bv.putInt(retroweaverBuildNumber);
bv.putInt(originalClassVersion);
bv.putLong(timestamp);
return bv;
}
@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;
}
@Override
protected ByteVector write(ClassWriter writer, byte[] code, int len,
int maxStack, int maxLocals) {
return new ByteVector().putByte(value);
}