Java Code Examples for org.jf.dexlib2.iface.Field#getInitialValue()
The following examples show how to use
org.jf.dexlib2.iface.Field#getInitialValue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClassReIClassDef.java From atlas with Apache License 2.0 | 6 votes |
@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())); }
Example 2
Source File: ImmutableField.java From ZjDroid with Apache License 2.0 | 5 votes |
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()); }
Example 3
Source File: FieldDefinition.java From ZjDroid with Apache License 2.0 | 5 votes |
public static void writeTo(IndentingWriter writer, Field field, boolean setInStaticConstructor) throws IOException { EncodedValue initialValue = field.getInitialValue(); int accessFlags = field.getAccessFlags(); if (setInStaticConstructor && AccessFlags.STATIC.isSet(accessFlags) && AccessFlags.FINAL.isSet(accessFlags) && initialValue != null) { if (!EncodedValueUtils.isDefaultValue(initialValue)) { writer.write("# The value of this static final field might be set in the static constructor\n"); } else { // don't write out the default initial value for static final fields that get set in the static // constructor initialValue = null; } } writer.write(".field "); writeAccessFlags(writer, field.getAccessFlags()); writer.write(field.getName()); writer.write(':'); writer.write(field.getType()); if (initialValue != null) { writer.write(" = "); EncodedValueAdaptor.writeTo(writer, initialValue); } writer.write('\n'); Collection<? extends Annotation> annotations = field.getAnnotations(); if (annotations.size() > 0) { writer.indent(4); AnnotationFormatter.writeTo(writer, annotations); writer.deindent(4); writer.write(".end field\n"); } }
Example 4
Source File: ImmutableField.java From zjdroid with Apache License 2.0 | 5 votes |
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()); }
Example 5
Source File: FieldDefinition.java From zjdroid with Apache License 2.0 | 5 votes |
public static void writeTo(IndentingWriter writer, Field field, boolean setInStaticConstructor) throws IOException { EncodedValue initialValue = field.getInitialValue(); int accessFlags = field.getAccessFlags(); if (setInStaticConstructor && AccessFlags.STATIC.isSet(accessFlags) && AccessFlags.FINAL.isSet(accessFlags) && initialValue != null) { if (!EncodedValueUtils.isDefaultValue(initialValue)) { writer.write("# The value of this static final field might be set in the static constructor\n"); } else { // don't write out the default initial value for static final fields that get set in the static // constructor initialValue = null; } } writer.write(".field "); writeAccessFlags(writer, field.getAccessFlags()); writer.write(field.getName()); writer.write(':'); writer.write(field.getType()); if (initialValue != null) { writer.write(" = "); EncodedValueAdaptor.writeTo(writer, initialValue); } writer.write('\n'); Collection<? extends Annotation> annotations = field.getAnnotations(); if (annotations.size() > 0) { writer.indent(4); AnnotationFormatter.writeTo(writer, annotations); writer.deindent(4); writer.write(".end field\n"); } }
Example 6
Source File: DexField.java From JAADAS with GNU General Public License v3.0 | 5 votes |
/** * Add constant tag. Should only be called if field is final. * @param df * @param sf */ private static void addConstantTag(SootField df, Field sf) { Tag tag = null; EncodedValue ev = sf.getInitialValue(); if (ev instanceof BooleanEncodedValue) { tag = new IntegerConstantValueTag(((BooleanEncodedValue) ev).getValue() ==true?1:0); } else if (ev instanceof ByteEncodedValue) { tag = new IntegerConstantValueTag(((ByteEncodedValue) ev).getValue()); } else if (ev instanceof CharEncodedValue) { tag = new IntegerConstantValueTag(((CharEncodedValue) ev).getValue()); } else if (ev instanceof DoubleEncodedValue) { tag = new DoubleConstantValueTag(((DoubleEncodedValue) ev).getValue()); } else if (ev instanceof FloatEncodedValue) { tag = new FloatConstantValueTag(((FloatEncodedValue) ev).getValue()); } else if (ev instanceof IntEncodedValue) { tag = new IntegerConstantValueTag(((IntEncodedValue) ev).getValue()); } else if (ev instanceof LongEncodedValue) { tag = new LongConstantValueTag(((LongEncodedValue) ev).getValue()); } else if (ev instanceof ShortEncodedValue) { tag = new IntegerConstantValueTag(((ShortEncodedValue) ev).getValue()); } else if (ev instanceof StringEncodedValue) { tag = new StringConstantValueTag(((StringEncodedValue) ev).getValue()); } if (tag != null) df.addTag(tag); }
Example 7
Source File: ImmutableField.java From HeyGirl with Apache License 2.0 | 5 votes |
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()); }
Example 8
Source File: FieldDefinition.java From HeyGirl with Apache License 2.0 | 5 votes |
public static void writeTo(IndentingWriter writer, Field field, boolean setInStaticConstructor) throws IOException { EncodedValue initialValue = field.getInitialValue(); int accessFlags = field.getAccessFlags(); if (setInStaticConstructor && AccessFlags.STATIC.isSet(accessFlags) && AccessFlags.FINAL.isSet(accessFlags) && initialValue != null) { if (!EncodedValueUtils.isDefaultValue(initialValue)) { writer.write("# The value of this static final field might be set in the static constructor\n"); } else { // don't write out the default initial value for static final fields that get set in the static // constructor initialValue = null; } } writer.write(".field "); writeAccessFlags(writer, field.getAccessFlags()); writer.write(field.getName()); writer.write(':'); writer.write(field.getType()); if (initialValue != null) { writer.write(" = "); EncodedValueAdaptor.writeTo(writer, initialValue); } writer.write('\n'); Collection<? extends Annotation> annotations = field.getAnnotations(); if (annotations.size() > 0) { writer.indent(4); AnnotationFormatter.writeTo(writer, annotations); writer.deindent(4); writer.write(".end field\n"); } }
Example 9
Source File: ImmutableField.java From ZjDroid with Apache License 2.0 | 5 votes |
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()); }
Example 10
Source File: FieldDefinition.java From ZjDroid with Apache License 2.0 | 5 votes |
public static void writeTo(IndentingWriter writer, Field field, boolean setInStaticConstructor) throws IOException { EncodedValue initialValue = field.getInitialValue(); int accessFlags = field.getAccessFlags(); if (setInStaticConstructor && AccessFlags.STATIC.isSet(accessFlags) && AccessFlags.FINAL.isSet(accessFlags) && initialValue != null) { if (!EncodedValueUtils.isDefaultValue(initialValue)) { writer.write("# The value of this static final field might be set in the static constructor\n"); } else { // don't write out the default initial value for static final fields that get set in the static // constructor initialValue = null; } } writer.write(".field "); writeAccessFlags(writer, field.getAccessFlags()); writer.write(field.getName()); writer.write(':'); writer.write(field.getType()); if (initialValue != null) { writer.write(" = "); EncodedValueAdaptor.writeTo(writer, initialValue); } writer.write('\n'); Collection<? extends Annotation> annotations = field.getAnnotations(); if (annotations.size() > 0) { writer.indent(4); AnnotationFormatter.writeTo(writer, annotations); writer.deindent(4); writer.write(".end field\n"); } }
Example 11
Source File: BuilderClassPool.java From ZjDroid with Apache License 2.0 | 4 votes |
@Override public boolean apply(Field input) { EncodedValue encodedValue = input.getInitialValue(); return encodedValue != null && !EncodedValueUtils.isDefaultValue(encodedValue); }
Example 12
Source File: BuilderClassPool.java From zjdroid with Apache License 2.0 | 4 votes |
@Override public boolean apply(Field input) { EncodedValue encodedValue = input.getInitialValue(); return encodedValue != null && !EncodedValueUtils.isDefaultValue(encodedValue); }
Example 13
Source File: BuilderClassPool.java From HeyGirl with Apache License 2.0 | 4 votes |
@Override public boolean apply(Field input) { EncodedValue encodedValue = input.getInitialValue(); return encodedValue != null && !EncodedValueUtils.isDefaultValue(encodedValue); }
Example 14
Source File: BuilderClassPool.java From ZjDroid with Apache License 2.0 | 4 votes |
@Override public boolean apply(Field input) { EncodedValue encodedValue = input.getInitialValue(); return encodedValue != null && !EncodedValueUtils.isDefaultValue(encodedValue); }