本文整理汇总了Java中org.jf.dexlib2.iface.Field类的典型用法代码示例。如果您正苦于以下问题:Java Field类的具体用法?Java Field怎么用?Java Field使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Field类属于org.jf.dexlib2.iface包,在下文中一共展示了Field类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reField
import org.jf.dexlib2.iface.Field; //导入依赖的package包/类
@Override
protected Field reField(Field field) {
String name = field.getName();
String newType;
boolean isBasic = false;
boolean isArray = false;
if (field.getType().startsWith("[")) {
isArray = true;
}
if (basicType.containsKey(field.getType())) {
newType = field.getType();
isBasic = true;
} else {
newType = DefineUtils.getDalvikClassName(field.getType());
}
String defineClass = DefineUtils.getDalvikClassName(field.getDefiningClass());
return new ImmutableField(
reType,
classProcessor.filedProcess(defineClass, isBasic ? basicType.get(newType) : newType + (isArray ? "[]" : ""), name).fieldName,
isBasic ? newType :
DefineUtils.getDefineClassName(classProcessor.classProcess(isBasic ? basicType.get(newType) : newType).className, isArray),
field.getAccessFlags(),
field.getInitialValue(),
getAnnotation(field.getAnnotations()));
}
示例2: ImmutableClassDef
import org.jf.dexlib2.iface.Field; //导入依赖的package包/类
public ImmutableClassDef(@Nonnull String type,
int accessFlags,
@Nullable String superclass,
@Nullable Collection<String> interfaces,
@Nullable String sourceFile,
@Nullable Collection<? extends Annotation> annotations,
@Nullable Iterable<? extends Field> fields,
@Nullable Iterable<? extends Method> methods) {
if (fields == null) {
fields = ImmutableList.of();
}
if (methods == null) {
methods = ImmutableList.of();
}
this.type = type;
this.accessFlags = accessFlags;
this.superclass = superclass;
this.interfaces = interfaces==null ? ImmutableSet.<String>of() : ImmutableSet.copyOf(interfaces);
this.sourceFile = sourceFile;
this.annotations = ImmutableAnnotation.immutableSetOf(annotations);
this.staticFields = ImmutableField.immutableSetOf(Iterables.filter(fields, FieldUtil.FIELD_IS_STATIC));
this.instanceFields = ImmutableField.immutableSetOf(Iterables.filter(fields, FieldUtil.FIELD_IS_INSTANCE));
this.directMethods = ImmutableMethod.immutableSetOf(Iterables.filter(methods, MethodUtil.METHOD_IS_DIRECT));
this.virtualMethods = ImmutableMethod.immutableSetOf(Iterables.filter(methods, MethodUtil.METHOD_IS_VIRTUAL));
}
示例3: getFields
import org.jf.dexlib2.iface.Field; //导入依赖的package包/类
@Nonnull @Override public Set<? extends Field> getFields() {
return new AbstractSet<Field>() {
@Nonnull @Override public Iterator<Field> iterator() {
return Iterators.transform(Iterators.forArray(cls.getDeclaredFields()),
new Function<java.lang.reflect.Field, Field>() {
@Nullable @Override public Field apply(@Nullable java.lang.reflect.Field input) {
return new ReflectionField(input);
}
});
}
@Override public int size() {
return cls.getDeclaredFields().length;
}
};
}
示例4: ImmutableClassDef
import org.jf.dexlib2.iface.Field; //导入依赖的package包/类
public ImmutableClassDef( String type,
int accessFlags,
String superclass,
Collection<String> interfaces,
String sourceFile,
Collection<? extends Annotation> annotations,
Iterable<? extends Field> fields,
Iterable<? extends Method> methods) {
if (fields == null) {
fields = ImmutableList.of();
}
if (methods == null) {
methods = ImmutableList.of();
}
this.type = type;
this.accessFlags = accessFlags;
this.superclass = superclass;
this.interfaces = interfaces==null ? ImmutableList.<String>of() : ImmutableList.copyOf(interfaces);
this.sourceFile = sourceFile;
this.annotations = ImmutableAnnotation.immutableSetOf(annotations);
this.staticFields = ImmutableField.immutableSetOf(Iterables.filter(fields, FieldUtil.FIELD_IS_STATIC));
this.instanceFields = ImmutableField.immutableSetOf(Iterables.filter(fields, FieldUtil.FIELD_IS_INSTANCE));
this.directMethods = ImmutableMethod.immutableSetOf(Iterables.filter(methods, MethodUtil.METHOD_IS_DIRECT));
this.virtualMethods = ImmutableMethod.immutableSetOf(Iterables.filter(methods, MethodUtil.METHOD_IS_VIRTUAL));
}
示例5: getFields
import org.jf.dexlib2.iface.Field; //导入依赖的package包/类
@Override public Set<? extends Field> getFields() {
return new AbstractSet<Field>() {
@Override public Iterator<Field> iterator() {
return Iterators.transform(Iterators.forArray(cls.getDeclaredFields()),
new Function<java.lang.reflect.Field, Field>() {
@Override public Field apply( java.lang.reflect.Field input) {
return new ReflectionField(input);
}
});
}
@Override public int size() {
return cls.getDeclaredFields().length;
}
};
}
示例6: ImmutableClassDef
import org.jf.dexlib2.iface.Field; //导入依赖的package包/类
public ImmutableClassDef(@Nonnull String type,
int accessFlags,
@Nullable String superclass,
@Nullable Collection<String> interfaces,
@Nullable String sourceFile,
@Nullable Collection<? extends Annotation> annotations,
@Nullable Iterable<? extends Field> fields,
@Nullable Iterable<? extends Method> methods) {
if (fields == null) {
fields = ImmutableList.of();
}
if (methods == null) {
methods = ImmutableList.of();
}
this.type = type;
this.accessFlags = accessFlags;
this.superclass = superclass;
this.interfaces = interfaces==null ? ImmutableList.<String>of() : ImmutableList.copyOf(interfaces);
this.sourceFile = sourceFile;
this.annotations = ImmutableAnnotation.immutableSetOf(annotations);
this.staticFields = ImmutableField.immutableSetOf(Iterables.filter(fields, FieldUtil.FIELD_IS_STATIC));
this.instanceFields = ImmutableField.immutableSetOf(Iterables.filter(fields, FieldUtil.FIELD_IS_INSTANCE));
this.directMethods = ImmutableMethod.immutableSetOf(Iterables.filter(methods, MethodUtil.METHOD_IS_DIRECT));
this.virtualMethods = ImmutableMethod.immutableSetOf(Iterables.filter(methods, MethodUtil.METHOD_IS_VIRTUAL));
}
示例7: onSimpleEdit
import org.jf.dexlib2.iface.Field; //导入依赖的package包/类
@Override
protected Field onSimpleEdit(Field patch, PatcherAnnotation annotation, Field target, boolean inPlace) {
// Use the static field initializer value in source only
// if not renaming, given that the static constructor in
// source would only initialize it if not renamed.
// This makes behavior predictable across compilers.
EncodedValue value = inPlace ? target.getInitialValue() : null;
value = filterInitialValue(patch, value);
onSimpleRemove(patch, annotation, target);
Field patched = new BasicField(
patch.getDefiningClass(),
patch.getName(),
patch.getType(),
patch.getAccessFlags(),
value,
annotation.getFilteredAnnotations());
return super.onSimpleEdit(patched, annotation, target, inPlace);
}
示例8: BasicClassDef
import org.jf.dexlib2.iface.Field; //导入依赖的package包/类
public BasicClassDef(
String type,
int accessFlags,
String superclass,
List<String> interfaces,
String sourceFile,
Set<? extends Annotation> annotations,
Iterable<? extends Field> fields,
Iterable<? extends Method> methods
) {
this.type = type;
this.accessFlags = accessFlags;
this.superclass = superclass;
this.interfaces = interfaces;
this.sourceFile = sourceFile;
this.annotations = annotations;
this.fields = fields;
this.staticFields = Iterables.filter(fields, FieldUtil.FIELD_IS_STATIC);
this.instanceFields = Iterables.filter(fields, FieldUtil.FIELD_IS_INSTANCE);
this.methods = methods;
this.directMethods = Iterables.filter(methods, MethodUtil.METHOD_IS_DIRECT);
this.virtualMethods = Iterables.filter(methods, MethodUtil.METHOD_IS_VIRTUAL);
}
示例9: ImmutableClassDef
import org.jf.dexlib2.iface.Field; //导入依赖的package包/类
public ImmutableClassDef(@Nonnull String type,
int accessFlags,
@Nullable String superclass,
@Nullable Collection<String> interfaces,
@Nullable String sourceFile,
@Nullable Collection<? extends Annotation> annotations,
@Nullable Iterable<? extends Field> fields,
@Nullable Iterable<? extends Method> methods) {
if (fields == null) {
fields = ImmutableList.of();
}
if (methods == null) {
methods = ImmutableList.of();
}
this.type = type;
this.accessFlags = accessFlags;
this.superclass = superclass;
this.interfaces = interfaces == null ? ImmutableSet.<String>of() : ImmutableSet.copyOf(interfaces);
this.sourceFile = sourceFile;
this.annotations = ImmutableAnnotation.immutableSetOf(annotations);
this.staticFields = ImmutableField.immutableSetOf(Iterables.filter(fields, FieldUtil.FIELD_IS_STATIC));
this.instanceFields = ImmutableField.immutableSetOf(Iterables.filter(fields, FieldUtil.FIELD_IS_INSTANCE));
this.directMethods = ImmutableMethod.immutableSetOf(Iterables.filter(methods, MethodUtil.METHOD_IS_DIRECT));
this.virtualMethods = ImmutableMethod.immutableSetOf(Iterables.filter(methods, MethodUtil.METHOD_IS_VIRTUAL));
}
示例10: getDeclaredFields
import org.jf.dexlib2.iface.Field; //导入依赖的package包/类
@Override
public FieldInfo[] getDeclaredFields() {
List<FieldInfo> result = new ArrayList<>();
Iterable<? extends Field> implFields = classDef.getFields();
for (Field field : implFields) {
FieldInfo fi = new FieldInfo();
fi.typeName = DexlibAdapter.getTypeName(field.getType());
fi.modifiers = field.getAccessFlags();
fi.annotations = convertAnnotations(field.getAnnotations());
fi.name = field.getName();
result.add(fi);
}
FieldInfo[] array = new FieldInfo[result.size()];
return result.toArray(array);
}
示例11: getFields
import org.jf.dexlib2.iface.Field; //导入依赖的package包/类
@Nonnull
@Override
public Set<? extends Field> getFields() {
return new AbstractSet<Field>() {
@Nonnull
@Override
public Iterator<Field> iterator() {
return Iterators.transform(Iterators.forArray(cls.getDeclaredFields()),
new Function<java.lang.reflect.Field, Field>() {
@Nullable
@Override
public Field apply(@Nullable java.lang.reflect.Field input) {
return new ReflectionField(input);
}
});
}
@Override
public int size() {
return cls.getDeclaredFields().length;
}
};
}
示例12: read
import org.jf.dexlib2.iface.Field; //导入依赖的package包/类
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;
}
示例13: writeStaticFields
import org.jf.dexlib2.iface.Field; //导入依赖的package包/类
private Set<String> writeStaticFields(IndentingWriter writer) throws IOException {
if (!fullMethod && !DexDiffInfo.addedClasses.contains(classDef)) {
return null;
}
boolean wroteHeader = false;
Set<String> writtenFields = new HashSet<String>();
Iterable<? extends Field> staticFields;
if (classDef instanceof DexBackedClassDef) {
staticFields = ((DexBackedClassDef) classDef).getStaticFields(false);
} else {
staticFields = classDef.getStaticFields();
}
for (Field field : staticFields) {
if (!wroteHeader) {
writer.write("\n\n");
writer.write("# static fields");
wroteHeader = true;
}
writer.write('\n');
boolean setInStaticConstructor;
IndentingWriter fieldWriter = writer;
String fieldString = ReferenceUtil.getShortFieldDescriptor(field);
if (!writtenFields.add(fieldString)) {
writer.write("# duplicate field ignored\n");
fieldWriter = new CommentingIndentingWriter(writer);
System.err.println(String.format("Ignoring duplicate field: %s->%s", classDef.getType(), fieldString));
setInStaticConstructor = false;
} else {
setInStaticConstructor = fieldsSetInStaticConstructor.contains(fieldString);
}
FieldDefinition.writeTo(options, fieldWriter, field, setInStaticConstructor);
}
return writtenFields;
}
示例14: writeInstanceFields
import org.jf.dexlib2.iface.Field; //导入依赖的package包/类
private void writeInstanceFields(IndentingWriter writer, Set<String> staticFields) throws IOException {
if (!fullMethod&& !DexDiffInfo.addedClasses.contains(classDef)) {
return;
}
boolean wroteHeader = false;
Set<String> writtenFields = new HashSet<String>();
Iterable<? extends Field> instanceFields;
if (classDef instanceof DexBackedClassDef) {
instanceFields = ((DexBackedClassDef) classDef).getInstanceFields(false);
} else {
instanceFields = classDef.getInstanceFields();
}
for (Field field : instanceFields) {
if (!wroteHeader) {
writer.write("\n\n");
writer.write("# instance fields");
wroteHeader = true;
}
writer.write('\n');
IndentingWriter fieldWriter = writer;
String fieldString = ReferenceUtil.getShortFieldDescriptor(field);
if (!writtenFields.add(fieldString)) {
writer.write("# duplicate field ignored\n");
fieldWriter = new CommentingIndentingWriter(writer);
System.err.println(String.format("Ignoring duplicate field: %s->%s", classDef.getType(), fieldString));
} else if (staticFields.contains(fieldString)) {
System.err.println(String.format("Duplicate static+instance field found: %s->%s",
classDef.getType(), fieldString));
System.err.println("You will need to rename one of these fields, including all references.");
writer.write("# There is both a static and instance field with this signature.\n" +
"# You will need to rename one of these fields, including all references.\n");
}
FieldDefinition.writeTo(options, fieldWriter, field, false);
}
}
示例15: of
import org.jf.dexlib2.iface.Field; //导入依赖的package包/类
public static ImmutableField of(Field field) {
if (field instanceof ImmutableField) {
return (ImmutableField)field;
}
return new ImmutableField(
field.getDefiningClass(),
field.getName(),
field.getType(),
field.getAccessFlags(),
field.getInitialValue(),
field.getAnnotations());
}