use of jadx.api.plugins.input.data.annotations.EncodedValue in project jadx by skylot.
the class PrepareForCodeGen method checkEncodedValue.
@SuppressWarnings("unchecked")
private void checkEncodedValue(MethodNode mth, EncodedValue encodedValue) {
switch(encodedValue.getType()) {
case ENCODED_FIELD:
Object fieldData = encodedValue.getValue();
FieldInfo fieldInfo;
if (fieldData instanceof IFieldRef) {
fieldInfo = FieldInfo.fromRef(mth.root(), (IFieldRef) fieldData);
} else {
fieldInfo = (FieldInfo) fieldData;
}
FieldNode fieldNode = mth.root().resolveField(fieldInfo);
if (fieldNode != null) {
fieldNode.addUseIn(mth);
}
break;
case ENCODED_ANNOTATION:
IAnnotation annotation = (IAnnotation) encodedValue.getValue();
annotation.getValues().forEach((k, v) -> checkEncodedValue(mth, v));
break;
case ENCODED_ARRAY:
List<EncodedValue> valueList = (List<EncodedValue>) encodedValue.getValue();
valueList.forEach(v -> checkEncodedValue(mth, v));
break;
}
}
use of jadx.api.plugins.input.data.annotations.EncodedValue in project jadx by skylot.
the class EncodedValueReader method read.
public static EncodedValue read(JavaClassData clsData, DataReader reader) {
ConstPoolReader constPool = clsData.getConstPoolReader();
char tag = (char) reader.readU1();
switch(tag) {
case 'B':
return new EncodedValue(EncodedType.ENCODED_BYTE, (byte) constPool.getInt(reader.readU2()));
case 'C':
return new EncodedValue(EncodedType.ENCODED_CHAR, (char) constPool.getInt(reader.readU2()));
case 'D':
return new EncodedValue(EncodedType.ENCODED_DOUBLE, constPool.getDouble(reader.readU2()));
case 'F':
return new EncodedValue(EncodedType.ENCODED_FLOAT, constPool.getFloat(reader.readU2()));
case 'I':
return new EncodedValue(EncodedType.ENCODED_INT, constPool.getInt(reader.readU2()));
case 'J':
return new EncodedValue(EncodedType.ENCODED_LONG, constPool.getLong(reader.readU2()));
case 'S':
return new EncodedValue(EncodedType.ENCODED_SHORT, (short) constPool.getInt(reader.readU2()));
case 'Z':
return new EncodedValue(EncodedType.ENCODED_BOOLEAN, 1 == constPool.getInt(reader.readU2()));
case 's':
return new EncodedValue(EncodedType.ENCODED_STRING, constPool.getUtf8(reader.readU2()));
case 'e':
String cls = constPool.getUtf8(reader.readU2());
String name = constPool.getUtf8(reader.readU2());
return new EncodedValue(EncodedType.ENCODED_ENUM, new JadxFieldRef(cls, name, cls));
case 'c':
return new EncodedValue(EncodedType.ENCODED_TYPE, constPool.getUtf8(reader.readU2()));
case '@':
return new EncodedValue(EncodedType.ENCODED_ANNOTATION, JavaAnnotationsAttr.readAnnotation(AnnotationVisibility.RUNTIME, clsData, reader));
case '[':
int len = reader.readU2();
List<EncodedValue> values = new ArrayList<>(len);
for (int i = 0; i < len; i++) {
values.add(read(clsData, reader));
}
return new EncodedValue(EncodedType.ENCODED_ARRAY, values);
default:
throw new JavaClassParseException("Unknown element value tag: " + tag);
}
}
Aggregations