本文整理了Java中com.googlecode.d2j.Field
类的一些代码示例,展示了Field
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Field
类的具体详情如下:
包路径:com.googlecode.d2j.Field
类名称:Field
[英]represent a field_id_item in dex file format
[中]以dex文件格式表示字段\ id \项
代码示例来源:origin: pxb1988/dex2jar
@Override
public void visitEnum(String name, String desc, String value) {
objs.add(new Field(null, value, desc));
}
}
代码示例来源:origin: pxb1988/dex2jar
@Override
public String toString() {
return this.getOwner() + "." + this.getName() + " " + this.getType();
}
}
代码示例来源:origin: pxb1988/dex2jar
if ((fn.access & ACC_STATIC_FINAL) == ACC_STATIC_FINAL) {
if (fn.cst == null) {
char t = fn.field.getType().charAt(0);
if (t == 'L' || t == '[') {
fs.put(fn.field.getName() + ":" + fn.field.getType(), fn);
} else if (isPrimitiveZero(fn.field.getType(), fn.cst)) {
shouldNotBeAssigned.put(fn.field.getName() + ":" + fn.field.getType(), fn);
fn.cst = getDefaultValueOfType(fn.field.getType().charAt(0));
代码示例来源:origin: pxb1988/dex2jar
public static void doAccept(DexAnnotationVisitor dexAnnotationVisitor, String k, Object value) {
if (value instanceof ArrayList) {
DexAnnotationVisitor a = dexAnnotationVisitor.visitArray(k);
for (Object o : (ArrayList) value) {
doAccept(a, null, o);
}
a.visitEnd();
} else if (value instanceof Ann) {
Ann ann = (Ann) value;
DexAnnotationVisitor a = dexAnnotationVisitor.visitAnnotation(k, ann.name);
for (Map.Entry<String, Object> e : ann.elements) {
doAccept(a, e.getKey(), e.getValue());
}
a.visitEnd();
} else if (value instanceof Field) {
Field f = (Field) value;
dexAnnotationVisitor.visitEnum(k, f.getOwner(), f.getName());
} else {
dexAnnotationVisitor.visit(k, value);
}
}
代码示例来源:origin: pxb1988/dex2jar
@Override
public DexFieldVisitor visitField(int accessFlags, Field field, Object value) {
String fieldName = String.format("f%03d_%s", fCount++, field.getName());
out.s("%s(cv);", fieldName);
final ArrayOut f = new ArrayOut();
fieldOuts.add(f);
f.s("public static void %s(DexClassVisitor cv) {", fieldName);
f.push();
f.s("DexFieldVisitor fv=cv.visitField(%s, %s, %s);", Escape.fieldAcc(accessFlags), Escape.v(field),
Escape.v(value));
f.s("if(fv != null) {");
f.push();
return new DexFieldVisitor() {
@Override
public DexAnnotationVisitor visitAnnotation(String name, Visibility visibility) {
return new ASMifierAnnotationV("fv", f, name, visibility);
}
@Override
public void visitEnd() {
f.s("fv.visitEnd();");
f.pop();
f.s("}");
f.pop();
f.s("}");
}
};
}
代码示例来源:origin: pxb1988/dex2jar
private int acceptField(ByteBuffer in, int lastIndex, DexClassVisitor dcv,
Map<Integer, Integer> fieldAnnotationPositions, Object value, int config) {
int diff = (int) readULeb128i(in);
int field_access_flags = (int) readULeb128i(in);
int field_id = lastIndex + diff;
Field field = getField(field_id);
// //////////////////////////////////////////////////////////////
DexFieldVisitor dfv = dcv.visitField(field_access_flags, field, value);
if (dfv != null) {
if ((config & SKIP_ANNOTATION) == 0) {
Integer annotation_offset = fieldAnnotationPositions.get(field_id);
if (annotation_offset != null) {
try {
read_annotation_set_item(annotation_offset, dfv);
} catch (Exception e) {
throw new DexException(e, "while accept annotation in field:%s.", field.toString());
}
}
}
dfv.visitEnd();
}
// //////////////////////////////////////////////////////////////
return field_id;
}
代码示例来源:origin: pxb1988/dex2jar
FieldVisitor fv = cv.visitField(fieldNode.access & FieldCleanFlag, fieldNode.field.getName(),
fieldNode.field.getType(), signature, value);
if (fv == null) {
return;
代码示例来源:origin: SparkInLee/dexdiff
private void writeAnnotationArrayValue(DexAnnotationVisitor aw, EncodedArray array) {
for (EncodedValue value : array.values) {
String name = null;
Object decodeValue = decodeValue(value);
if (value.valueType == VALUE_ENUM) {
Field field = (Field) decodeValue;
aw.visitEnum(name, field.getOwner(), field.getName());
} else if (decodeValue instanceof EncodedAnnotation) {
EncodedAnnotation aannotation = (EncodedAnnotation) decodeValue;
DexAnnotationVisitor aaw = aw.visitAnnotation(name, aannotation.type.descriptor.stringData.string);
writeAnnotation(aaw, aannotation);
aaw.visitEnd();
} else if (decodeValue instanceof EncodedArray) {
DexAnnotationVisitor aaw = aw.visitArray(name);
writeAnnotationArrayValue(aaw, (EncodedArray) decodeValue);
aaw.visitEnd();
} else if (decodeValue instanceof Object[]) {
Object[] values = (Object[]) decodeValue;
EncodedArray aarray = new EncodedArray();
for (Object avalue : values) {
aarray.values.add(EncodedValue.wrap(mFw.cp.wrapEncodedItem(avalue)));
}
DexAnnotationVisitor aaw = aw.visitArray(name);
writeAnnotationArrayValue(aaw, aarray);
aaw.visitEnd();
} else {
aw.visit(name, decodeValue);
}
}
}
代码示例来源:origin: SparkInLee/dexdiff
@Override
public DexFieldVisitor visitField(int accessFlags, Field field, Object value) {
String fieldName = String.format("f%03d_%s", fCount++, field.getName());
out.s("%s(cv);", fieldName);
final ArrayOut f = new ArrayOut();
fieldOuts.add(f);
f.s("public static void %s(DexClassVisitor cv) {", fieldName);
f.push();
f.s("DexFieldVisitor fv=cv.visitField(%s, %s, %s);", Escape.fieldAcc(accessFlags), Escape.v(field),
Escape.v(value));
f.s("if(fv != null) {");
f.push();
return new DexFieldVisitor() {
@Override
public DexAnnotationVisitor visitAnnotation(String name, Visibility visibility) {
return new ASMifierAnnotationV("fv", f, name, visibility);
}
@Override
public void visitEnd() {
f.s("fv.visitEnd();");
f.pop();
f.s("}");
f.pop();
f.s("}");
}
};
}
代码示例来源:origin: SparkInLee/dexdiff
private int acceptField(ByteBuffer in, int lastIndex, DexClassVisitor dcv,
Map<Integer, Integer> fieldAnnotationPositions, Object value, int config) {
int diff = (int) readULeb128i(in);
int field_access_flags = (int) readULeb128i(in);
int field_id = lastIndex + diff;
Field field = getField(field_id);
// //////////////////////////////////////////////////////////////
DexFieldVisitor dfv = dcv.visitField(field_access_flags, field, value);
if (dfv != null) {
if ((config & SKIP_ANNOTATION) == 0) {
Integer annotation_offset = fieldAnnotationPositions.get(field_id);
if (annotation_offset != null) {
try {
read_annotation_set_item(annotation_offset, dfv);
} catch (Exception e) {
throw new DexException(e, "while accept annotation in field:%s.", field.toString());
}
}
}
dfv.visitEnd();
}
// //////////////////////////////////////////////////////////////
return field_id;
}
代码示例来源:origin: pxb1988/dex2jar
public FieldIdItem uniqField(Field field) {
return uniqField(field.getOwner(), field.getName(), field.getType());
}
代码示例来源:origin: pxb1988/dex2jar
@Override
public void visitEnum(String name, String desc, String value) {
items.add(new Item(name, new Field(desc, value, desc)));
}
}
代码示例来源:origin: pxb1988/dex2jar
@Override
public Object visitFlocal(SmaliParser.FlocalContext ctx) {
if (dexDebugVisitor != null) {
DexLabel dexLabel = new DexLabel();
scv.visitLabel(dexLabel);
int reg = m.pareReg(ctx.r.getText());
String name;
String type;
if (ctx.v1 != null) {
Field fld = parseFieldAndUnescape("Lt;", ctx.v1.getText());
name = fld.getName();
type = fld.getType();
} else if (ctx.v2 != null) {
String txt = ctx.v2.getText();
int i = findString(txt, 1, txt.length(), '\"');
name = unescapeStr(txt.substring(0, i + 1));
type = unEscapeId(txt.substring(i + 2));
} else {
if (ctx.name2 != null) {
name = unescapeStr(ctx.name2.getText());
} else {
name = unEscapeId(ctx.name1.getText());
}
type = unEscapeId(ctx.type.getText());
}
String sig = ctx.sig == null ? null : unescapeStr(ctx.sig.getText());
dexDebugVisitor.visitStartLocal(reg, dexLabel, name, type, sig);
}
return null;
}
代码示例来源:origin: SparkInLee/dexdiff
if (element.value.valueType == VALUE_ENUM) {
Field field = (Field) decodeValue;
aw.visitEnum(name, field.getOwner(), field.getName());
} else if (decodeValue instanceof EncodedAnnotation) {
EncodedAnnotation aannotation = (EncodedAnnotation) decodeValue;
代码示例来源:origin: pxb1988/dex2jar
public static String escapeField(Field f) {
String owner = f.getOwner();
if (owner == null) {
owner = f.getType();
}
return escapeType(owner) + "->" + f.getName() + ":" + escapeType(f.getType());
}
代码示例来源:origin: pxb1988/dex2jar
public static Field parseFieldAndUnescape(String owner, String part) throws RuntimeException {
int x = part.indexOf(':');
if (x < 0) {
throw new RuntimeException();
}
return new Field(owner, unEscapeId(part.substring(0, x)), unEscapeId(part.substring(x + 1)));
}
代码示例来源:origin: pxb1988/dex2jar
dav.visitEnum(name, f.getType(), f.getName());
} else if (o instanceof DexType) {
dav.visit(name, Type.getType(((DexType) o).desc));
代码示例来源:origin: pxb1988/dex2jar
@Override
public void visitFieldStmt(Op op, int a, int b, Field field) {
switch (op) {
case SPUT:
case SPUT_BOOLEAN:
case SPUT_BYTE:
case SPUT_CHAR:
case SPUT_OBJECT:
case SPUT_SHORT:
case SPUT_WIDE:
if (field.getOwner().equals(classNode.className)) {
String key = field.getName() + ":" + field.getType();
fs.remove(key);
DexFieldNode dn = shouldNotBeAssigned.get(key);
if (dn != null) {
//System.out.println(field.getName() + ":" + field.getType());
dn.cst = null;
}
}
break;
default:
// ignored
break;
}
}
});
代码示例来源:origin: pxb1988/dex2jar
private Field getField(int id) {
fieldIdIn.position(id * 8);
int owner_idx = 0xFFFF & fieldIdIn.getShort();
int type_idx = 0xFFFF & fieldIdIn.getShort();
int name_idx = fieldIdIn.getInt();
return new Field(getType(owner_idx), getString(name_idx), getType(type_idx));
}
代码示例来源:origin: pxb1988/dex2jar
public static void acceptAnnotationItem(DexAnnotationVisitor dav, String name, Object o) {
if (o instanceof Object[]) {
DexAnnotationVisitor arrayVisitor = dav.visitArray(name);
if (arrayVisitor != null) {
Object[] array = (Object[]) o;
for (Object e : array) {
acceptAnnotationItem(arrayVisitor, null, e);
}
arrayVisitor.visitEnd();
}
} else if (o instanceof DexAnnotationNode) {
DexAnnotationNode ann = (DexAnnotationNode) o;
DexAnnotationVisitor av = dav.visitAnnotation(name, ann.type);
if (av != null) {
for (DexAnnotationNode.Item item : ann.items) {
acceptAnnotationItem(av, item.name, item.value);
}
av.visitEnd();
}
} else if (o instanceof Field) {
Field f = (Field) o;
dav.visitEnum(name, f.getType(), f.getName());
} else {
dav.visit(name, o);
}
}
内容来源于网络,如有侵权,请联系作者删除!