本文整理了Java中org.jf.dexlib2.iface.Field
类的一些代码示例,展示了Field
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Field
类的具体详情如下:
包路径:org.jf.dexlib2.iface.Field
类名称:Field
[英]This class represents a specific field definition in a class. It also acts as a FieldReference to itself. Any equality/comparison is based on its identity as a FieldReference, and shouldn't take into account any non-FieldReference specifics of this field.
[中]此类表示类中的特定字段定义。它还充当对自身的字段引用。任何相等/比较都基于其作为字段引用的身份,不应考虑该字段的任何非字段引用细节。
代码示例来源:origin: Tencent/tinker
for (Field field : classDef.getFields()) {
final BuilderField builderField = dexBuilder.internField(
field.getDefiningClass(),
field.getName(),
field.getType(),
field.getAccessFlags(),
field.getInitialValue(),
field.getAnnotations()
);
builderFields.add(builderField);
代码示例来源:origin: CalebFenton/simplify
private void visitFields(Iterable<? extends Field> fields, ClassWriter classWriter,
int classAccessFlags) {
for (Field field : fields) {
/*
* It's possible to declare a Smali interface with private fields. Android doesn't seem to mind, but
* the Java class loader will complain. To get around this, just set them public, which is what they
* should be anyway.
*/
int fieldAccessFlags = field.getAccessFlags();
if ((classAccessFlags & Opcodes.ACC_INTERFACE) != 0) {
if ((fieldAccessFlags & Opcodes.ACC_PRIVATE) != 0) {
fieldAccessFlags &= ~Opcodes.ACC_PRIVATE;
fieldAccessFlags |= Opcodes.ACC_PUBLIC;
}
}
String name = field.getName();
String desc = field.getType();
String signature = null;
Object value = null;
classWriter.visitField(fieldAccessFlags, name, desc, signature, value);
}
}
代码示例来源:origin: Sable/soot
/**
* Loads a single field from a dex file
*
* @param declaringClass
* The class that declares the method to load
* @param annotations
* The worker object for handling annotations
* @param field
* The field to load
*/
protected void loadField(SootClass declaringClass, DexAnnotation annotations, Field sf) {
if (declaringClass.declaresField(sf.getName(), DexType.toSoot(sf.getType()))) {
return;
}
SootField sootField = DexField.makeSootField(sf);
sootField = declaringClass.getOrAddField(sootField);
annotations.handleFieldAnnotation(sootField, sf);
}
代码示例来源:origin: JesusFreke/smali
@Override public int getFieldAccessFlags(@Nonnull Field field) {
return field.getAccessFlags();
}
代码示例来源:origin: JesusFreke/smali
EncodedValue initialValue = field.getInitialValue();
if (initialValue != null) {
dexPool.internEncodedValue(initialValue);
dexPool.annotationSetSection.intern(field.getAnnotations());
代码示例来源:origin: JesusFreke/smali
@Nullable @Override public Set<? extends Annotation> getFieldAnnotations(@Nonnull Field field) {
Set<? extends Annotation> annotations = field.getAnnotations();
if (annotations.size() == 0) {
return null;
}
return annotations;
}
代码示例来源:origin: testwhat/SmaliEx
fields.put(field.getName(), field);
Assert.assertNotNull(field.getInitialValue());
Assert.assertEquals(ValueType.METHOD, field.getInitialValue().getValueType());
MethodEncodedValue methodEncodedValue = (MethodEncodedValue)field.getInitialValue();
Assert.assertEquals(classDef.getType(), methodEncodedValue.getValue().getDefiningClass());
Assert.assertEquals("toString", methodEncodedValue.getValue().getName());
Assert.assertNotNull(field.getInitialValue());
Assert.assertEquals(ValueType.METHOD, field.getInitialValue().getValueType());
methodEncodedValue = (MethodEncodedValue)field.getInitialValue();
Assert.assertEquals(classDef.getType(), methodEncodedValue.getValue().getDefiningClass());
Assert.assertEquals("V", methodEncodedValue.getValue().getName());
Assert.assertNotNull(field.getInitialValue());
Assert.assertEquals(ValueType.METHOD, field.getInitialValue().getValueType());
methodEncodedValue = (MethodEncodedValue)field.getInitialValue();
Assert.assertEquals(classDef.getType(), methodEncodedValue.getValue().getDefiningClass());
Assert.assertEquals("I", methodEncodedValue.getValue().getName());
Assert.assertNotNull(field.getInitialValue());
Assert.assertEquals(ValueType.TYPE, field.getInitialValue().getValueType());
TypeEncodedValue typeEncodedValue = (TypeEncodedValue)field.getInitialValue();
Assert.assertEquals("I", typeEncodedValue.getValue());
代码示例来源:origin: Sable/soot
Tag tag = null;
EncodedValue ev = sf.getInitialValue();
代码示例来源:origin: testwhat/SmaliEx
@Override
public EncodedValue apply(Field input) {
EncodedValue initialValue = input.getInitialValue();
if (initialValue == null) {
return ImmutableEncodedValueFactory.defaultValueForType(input.getType());
}
return initialValue;
}
};
代码示例来源:origin: testwhat/SmaliEx
@Override
public int compare(Field f1, Field f2) {
int type1 = getTypeAsPrimitiveType(f1);
int type2 = getTypeAsPrimitiveType(f2);
if (type1 != type2) {
boolean isPrimitive1 = type1 != kPrimNot;
boolean isPrimitive2 = type2 != kPrimNot;
boolean is64bit1 = isPrimitive1 &&
(type1 == kPrimLong || type1 == kPrimDouble);
boolean is64bit2 = isPrimitive2 &&
(type2 == kPrimLong || type2 == kPrimDouble);
int order1 = !isPrimitive1 ? 0 : (is64bit1 ? 1 : 2);
int order2 = !isPrimitive2 ? 0 : (is64bit2 ? 1 : 2);
return order1 - order2;
}
return f1.getName().compareTo(f2.getName());
}
}
代码示例来源:origin: testwhat/SmaliEx
static int getTypeAsPrimitiveType(Field field) {
return getPrimitiveType(field.getType().charAt(0));
}
代码示例来源:origin: Sable/soot
/**
*
* @return the Soot equivalent of a field
*/
public static SootField makeSootField(Field f) {
String name = f.getName();
Type type = DexType.toSoot(f.getType());
int flags = f.getAccessFlags();
SootField sf = Scene.v().makeSootField(name, type, flags);
DexField.addConstantTag(sf, f);
return sf;
}
}
代码示例来源:origin: testwhat/SmaliEx
public int getAccessFlags() {
return field.getAccessFlags();
}
代码示例来源:origin: wala/WALA
public DexIField(Field encodedField, DexIClass klass) {
//public DexIField(EncodedField encodedField) {
eField = encodedField;
myClass = klass;
String fieldName = eField.getName();
name = Atom.findOrCreateUnicodeAtom(fieldName);
String fieldType = eField.getType();
TypeName T = DexUtil.getTypeName(fieldType);
TypeReference type = TypeReference.findOrCreate(myClass.getClassLoader().getReference(), T);
myFieldRef = FieldReference.findOrCreate(myClass.getReference(), name, type);
}
代码示例来源:origin: KB5201314/ZjDroid
EncodedValue initialValue = field.getInitialValue();
if (initialValue != null) {
DexPool.internEncodedValue(initialValue, stringPool, typePool, fieldPool, methodPool);
annotationSetPool.intern(field.getAnnotations());
代码示例来源:origin: Sable/soot
/**
* Converts field annotations from Dexlib to Jimple
*
* @param h
* @param f
*/
public void handleFieldAnnotation(Host h, Field f) {
Set<? extends Annotation> aSet = f.getAnnotations();
if (aSet != null && !aSet.isEmpty()) {
List<Tag> tags = handleAnnotation(aSet, null);
if (tags != null) {
for (Tag t : tags) {
if (t != null) {
h.addTag(t);
}
}
}
}
}
代码示例来源:origin: testwhat/SmaliEx
fields.put(field.getName(), field);
Assert.assertNotNull(field.getInitialValue());
Assert.assertEquals(ValueType.FIELD, field.getInitialValue().getValueType());
FieldEncodedValue fieldEncodedValue = (FieldEncodedValue)field.getInitialValue();
Assert.assertEquals(classDef.getType(), fieldEncodedValue.getValue().getDefiningClass());
Assert.assertEquals("someField", fieldEncodedValue.getValue().getName());
Assert.assertNotNull(field.getInitialValue());
Assert.assertEquals(ValueType.FIELD, field.getInitialValue().getValueType());
fieldEncodedValue = (FieldEncodedValue)field.getInitialValue();
Assert.assertEquals(classDef.getType(), fieldEncodedValue.getValue().getDefiningClass());
Assert.assertEquals("V", fieldEncodedValue.getValue().getName());
Assert.assertNotNull(field.getInitialValue());
Assert.assertEquals(ValueType.FIELD, field.getInitialValue().getValueType());
fieldEncodedValue = (FieldEncodedValue)field.getInitialValue();
Assert.assertEquals(classDef.getType(), fieldEncodedValue.getValue().getDefiningClass());
Assert.assertEquals("I", fieldEncodedValue.getValue().getName());
代码示例来源:origin: testwhat/SmaliEx
@Override
public BuilderEncodedValue apply(BuilderField input) {
BuilderEncodedValue initialValue = input.getInitialValue();
if (initialValue == null) {
return BuilderEncodedValues.defaultValueForType(input.getType());
}
return initialValue;
}
};
代码示例来源:origin: org.smali/dexlib2
@Override
public EncodedValue apply(Field input) {
EncodedValue initialValue = input.getInitialValue();
if (initialValue == null) {
return ImmutableEncodedValueFactory.defaultValueForType(input.getType());
}
return initialValue;
}
};
代码示例来源:origin: com.taobao.android/dex_patch
public Field read(String className,String member) throws Exception {
if (reader == null){
return null;
}
classDef = (ClassDef) reader.read(className,null);
Iterable<? extends Field> fields = classDef.getFields();
for (Field field:fields){
if (field.getName().equals(member)){
return field;
}
}
return null;
}
内容来源于网络,如有侵权,请联系作者删除!