本文整理汇总了Java中com.android.dx.util.ByteArray类的典型用法代码示例。如果您正苦于以下问题:Java ByteArray类的具体用法?Java ByteArray怎么用?Java ByteArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ByteArray类属于com.android.dx.util包,在下文中一共展示了ByteArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeTo0
import com.android.dx.util.ByteArray; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void writeTo0(DexFile file, AnnotatedOutput out) {
ByteArray bytes = value.getBytes();
int utf16Size = value.getUtf16Size();
if (out.annotates()) {
out.annotate(Leb128.unsignedLeb128Size(utf16Size),
"utf16_size: " + Hex.u4(utf16Size));
out.annotate(bytes.size() + 1, value.toQuoted());
}
out.writeUleb128(utf16Size);
out.write(bytes);
out.writeByte(0);
}
示例2: dump
import com.android.dx.util.ByteArray; //导入依赖的package包/类
/**
* Does the dumping.
*/
public void dump() {
byte[] bytes = getBytes();
ByteArray ba = new ByteArray(bytes);
DirectClassFile cf =
new DirectClassFile(ba, getFilePath(), getStrictParse());
cf.setAttributeFactory(StdAttributeFactory.THE_ONE);
cf.setObserver(this);
cf.getMagic(); // Force parsing to happen.
int at = getAt();
if (at != bytes.length) {
parsed(ba, at, bytes.length - at, "<extra data at end of file>");
}
}
示例3: DirectClassFile
import com.android.dx.util.ByteArray; //导入依赖的package包/类
/**
* Constructs an instance.
*
* @param bytes {@code non-null;} the bytes of the file
* @param filePath {@code non-null;} the file path for the class,
* excluding any base directory specification
* @param strictParse whether to be strict about parsing; if
* {@code false}, this avoids doing checks that only exist
* for purposes of verification (such as magic number matching and
* path-package consistency checking)
*/
public DirectClassFile(ByteArray bytes, String filePath,
boolean strictParse) {
if (bytes == null) {
throw new NullPointerException("bytes == null");
}
if (filePath == null) {
throw new NullPointerException("filePath == null");
}
this.filePath = filePath;
this.bytes = bytes;
this.strictParse = strictParse;
this.accessFlags = -1;
}
示例4: exceptions
import com.android.dx.util.ByteArray; //导入依赖的package包/类
/**
* Parses an {@code Exceptions} attribute.
*/
private Attribute exceptions(DirectClassFile cf, int offset, int length,
ParseObserver observer) {
if (length < 2) {
return throwSeverelyTruncated();
}
ByteArray bytes = cf.getBytes();
int count = bytes.getUnsignedShort(offset); // number_of_exceptions
if (observer != null) {
observer.parsed(bytes, offset, 2,
"number_of_exceptions: " + Hex.u2(count));
}
offset += 2;
length -= 2;
if (length != (count * 2)) {
throwBadLength((count * 2) + 2);
}
TypeList list = cf.makeTypeList(offset, count);
return new AttExceptions(list);
}
示例5: constantValue
import com.android.dx.util.ByteArray; //导入依赖的package包/类
/**
* Parses a {@code ConstantValue} attribute.
*/
private Attribute constantValue(DirectClassFile cf, int offset, int length,
ParseObserver observer) {
if (length != 2) {
return throwBadLength(2);
}
ByteArray bytes = cf.getBytes();
ConstantPool pool = cf.getConstantPool();
int idx = bytes.getUnsignedShort(offset);
TypedConstant cst = (TypedConstant) pool.get(idx);
Attribute result = new AttConstantValue(cst);
if (observer != null) {
observer.parsed(bytes, offset, 2, "value: " + cst);
}
return result;
}
示例6: enclosingMethod
import com.android.dx.util.ByteArray; //导入依赖的package包/类
/**
* Parses an {@code EnclosingMethod} attribute.
*/
private Attribute enclosingMethod(DirectClassFile cf, int offset,
int length, ParseObserver observer) {
if (length != 4) {
throwBadLength(4);
}
ByteArray bytes = cf.getBytes();
ConstantPool pool = cf.getConstantPool();
int idx = bytes.getUnsignedShort(offset);
CstType type = (CstType) pool.get(idx);
idx = bytes.getUnsignedShort(offset + 2);
CstNat method = (CstNat) pool.get0Ok(idx);
Attribute result = new AttEnclosingMethod(type, method);
if (observer != null) {
observer.parsed(bytes, offset, 2, "class: " + type);
observer.parsed(bytes, offset + 2, 2, "method: " +
DirectClassFile.stringOrNone(method));
}
return result;
}
示例7: sourceFile
import com.android.dx.util.ByteArray; //导入依赖的package包/类
/**
* Parses a {@code SourceFile} attribute.
*/
private Attribute sourceFile(DirectClassFile cf, int offset, int length,
ParseObserver observer) {
if (length != 2) {
throwBadLength(2);
}
ByteArray bytes = cf.getBytes();
ConstantPool pool = cf.getConstantPool();
int idx = bytes.getUnsignedShort(offset);
CstString cst = (CstString) pool.get(idx);
Attribute result = new AttSourceFile(cst);
if (observer != null) {
observer.parsed(bytes, offset, 2, "source: " + cst);
}
return result;
}
示例8: localVariableTable
import com.android.dx.util.ByteArray; //导入依赖的package包/类
/**
* Parses a {@code LocalVariableTable} attribute.
*/
private Attribute localVariableTable(DirectClassFile cf, int offset,
int length, ParseObserver observer) {
if (length < 2) {
return throwSeverelyTruncated();
}
ByteArray bytes = cf.getBytes();
int count = bytes.getUnsignedShort(offset);
if (observer != null) {
observer.parsed(bytes, offset, 2,
"local_variable_table_length: " + Hex.u2(count));
}
LocalVariableList list = parseLocalVariables(
bytes.slice(offset + 2, offset + length), cf.getConstantPool(),
observer, count, false);
return new AttLocalVariableTable(list);
}
示例9: localVariableTypeTable
import com.android.dx.util.ByteArray; //导入依赖的package包/类
/**
* Parses a {@code LocalVariableTypeTable} attribute.
*/
private Attribute localVariableTypeTable(DirectClassFile cf, int offset,
int length, ParseObserver observer) {
if (length < 2) {
return throwSeverelyTruncated();
}
ByteArray bytes = cf.getBytes();
int count = bytes.getUnsignedShort(offset);
if (observer != null) {
observer.parsed(bytes, offset, 2,
"local_variable_type_table_length: " + Hex.u2(count));
}
LocalVariableList list = parseLocalVariables(
bytes.slice(offset + 2, offset + length), cf.getConstantPool(),
observer, count, true);
return new AttLocalVariableTypeTable(list);
}
示例10: signature
import com.android.dx.util.ByteArray; //导入依赖的package包/类
/**
* Parses a {@code Signature} attribute.
*/
private Attribute signature(DirectClassFile cf, int offset, int length,
ParseObserver observer) {
if (length != 2) {
throwBadLength(2);
}
ByteArray bytes = cf.getBytes();
ConstantPool pool = cf.getConstantPool();
int idx = bytes.getUnsignedShort(offset);
CstString cst = (CstString) pool.get(idx);
Attribute result = new AttSignature(cst);
if (observer != null) {
observer.parsed(bytes, offset, 2, "signature: " + cst);
}
return result;
}
示例11: dump
import com.android.dx.util.ByteArray; //导入依赖的package包/类
/**
* Does the dumping.
*/
public void dump() {
byte[] bytes = getBytes();
ByteArray ba = new ByteArray(bytes);
/*
* First, parse the file completely, so we can safely refer to
* attributes, etc.
*/
classFile = new DirectClassFile(ba, getFilePath(), getStrictParse());
classFile.setAttributeFactory(StdAttributeFactory.THE_ONE);
classFile.getMagic(); // Force parsing to happen.
// Next, reparse it and observe the process.
DirectClassFile liveCf =
new DirectClassFile(ba, getFilePath(), getStrictParse());
liveCf.setAttributeFactory(StdAttributeFactory.THE_ONE);
liveCf.setObserver(this);
liveCf.getMagic(); // Force parsing to happen.
}
示例12: endParsingMember
import com.android.dx.util.ByteArray; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void endParsingMember(ByteArray bytes, int offset, String name,
String descriptor, Member member) {
if (!(member instanceof Method)) {
return;
}
if (!shouldDumpMethod(name)) {
return;
}
if ((member.getAccessFlags() & (AccessFlags.ACC_ABSTRACT |
AccessFlags.ACC_NATIVE)) != 0) {
return;
}
ConcreteMethod meth =
new ConcreteMethod((Method) member, classFile, true, true);
if (rop) {
ropDump(meth);
} else {
regularDump(meth);
}
}
示例13: run
import com.android.dx.util.ByteArray; //导入依赖的package包/类
private void run() {
ByteArray ba = new ByteArray(bytes);
/*
* First, parse the file completely, so we can safely refer to
* attributes, etc.
*/
classFile = new DirectClassFile(ba, filePath, strictParse);
classFile.setAttributeFactory(StdAttributeFactory.THE_ONE);
classFile.getMagic(); // Force parsing to happen.
// Next, reparse it and observe the process.
DirectClassFile liveCf =
new DirectClassFile(ba, filePath, strictParse);
liveCf.setAttributeFactory(StdAttributeFactory.THE_ONE);
liveCf.setObserver(this);
liveCf.getMagic(); // Force parsing to happen.
}
示例14: writeTo0
import com.android.dx.util.ByteArray; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void writeTo0(DexFile file, AnnotatedOutput out) {
ByteArray bytes = value.getBytes();
int utf16Size = value.getUtf16Size();
if (out.annotates()) {
out.annotate(Leb128Utils.unsignedLeb128Size(utf16Size),
"utf16_size: " + Hex.u4(utf16Size));
out.annotate(bytes.size() + 1, value.toQuoted());
}
out.writeUleb128(utf16Size);
out.write(bytes);
out.writeByte(0);
}
示例15: CodeObserver
import com.android.dx.util.ByteArray; //导入依赖的package包/类
/**
* Constructs an instance.
*
* @param bytes {@code non-null;} actual array of bytecode
* @param observer {@code non-null;} observer to inform of parsing
*/
public CodeObserver(ByteArray bytes, ParseObserver observer) {
if (bytes == null) {
throw new NullPointerException("bytes == null");
}
if (observer == null) {
throw new NullPointerException("observer == null");
}
this.bytes = bytes;
this.observer = observer;
}