use of jadx.core.dex.instructions.args.ArgType in project jadx by skylot.
the class DexNode method deepResolveMethod.
@Nullable
private MethodNode deepResolveMethod(@NotNull ClassNode cls, String signature) {
for (MethodNode m : cls.getMethods()) {
if (m.getMethodInfo().getShortId().startsWith(signature)) {
return m;
}
}
MethodNode found;
ArgType superClass = cls.getSuperClass();
if (superClass != null) {
ClassNode superNode = resolveClass(superClass);
if (superNode != null) {
found = deepResolveMethod(superNode, signature);
if (found != null) {
return found;
}
}
}
for (ArgType iFaceType : cls.getInterfaces()) {
ClassNode iFaceNode = resolveClass(iFaceType);
if (iFaceNode != null) {
found = deepResolveMethod(iFaceNode, signature);
if (found != null) {
return found;
}
}
}
return null;
}
use of jadx.core.dex.instructions.args.ArgType in project jadx by skylot.
the class MethodInfo method makeSignature.
public String makeSignature(boolean includeRetType) {
StringBuilder signature = new StringBuilder();
signature.append(name);
signature.append('(');
for (ArgType arg : args) {
signature.append(TypeGen.signature(arg));
}
signature.append(')');
if (includeRetType) {
signature.append(TypeGen.signature(retType));
}
return signature.toString();
}
use of jadx.core.dex.instructions.args.ArgType in project jadx by skylot.
the class AnnotationGen method encodeValue.
// TODO: refactor this boilerplate code
public void encodeValue(CodeWriter code, Object val) {
if (val == null) {
code.add("null");
return;
}
if (val instanceof String) {
code.add(getStringUtils().unescapeString((String) val));
} else if (val instanceof Integer) {
code.add(TypeGen.formatInteger((Integer) val));
} else if (val instanceof Character) {
code.add(getStringUtils().unescapeChar((Character) val));
} else if (val instanceof Boolean) {
code.add(Boolean.TRUE.equals(val) ? "true" : "false");
} else if (val instanceof Float) {
code.add(TypeGen.formatFloat((Float) val));
} else if (val instanceof Double) {
code.add(TypeGen.formatDouble((Double) val));
} else if (val instanceof Long) {
code.add(TypeGen.formatLong((Long) val));
} else if (val instanceof Short) {
code.add(TypeGen.formatShort((Short) val));
} else if (val instanceof Byte) {
code.add(TypeGen.formatByte((Byte) val));
} else if (val instanceof ArgType) {
classGen.useType(code, (ArgType) val);
code.add(".class");
} else if (val instanceof FieldInfo) {
// must be a static field
FieldInfo field = (FieldInfo) val;
InsnGen.makeStaticFieldAccess(code, field, classGen);
} else if (val instanceof Iterable) {
code.add('{');
Iterator<?> it = ((Iterable) val).iterator();
while (it.hasNext()) {
Object obj = it.next();
encodeValue(code, obj);
if (it.hasNext()) {
code.add(", ");
}
}
code.add('}');
} else if (val instanceof Annotation) {
formatAnnotation(code, (Annotation) val);
} else {
// TODO: also can be method values
throw new JadxRuntimeException("Can't decode value: " + val + " (" + val.getClass() + ")");
}
}
use of jadx.core.dex.instructions.args.ArgType in project jadx by skylot.
the class TypeMergeTest method testMerge.
@Test
public void testMerge() throws IOException, DecodeException {
first(INT, INT);
first(BOOLEAN, INT);
reject(INT, LONG);
first(INT, UNKNOWN);
reject(INT, UNKNOWN_OBJECT);
first(INT, NARROW);
first(CHAR, INT);
check(unknown(PrimitiveType.INT, PrimitiveType.BOOLEAN, PrimitiveType.FLOAT), unknown(PrimitiveType.INT, PrimitiveType.BOOLEAN), unknown(PrimitiveType.INT, PrimitiveType.BOOLEAN));
check(unknown(PrimitiveType.INT, PrimitiveType.FLOAT), unknown(PrimitiveType.INT, PrimitiveType.BOOLEAN), INT);
check(unknown(PrimitiveType.INT, PrimitiveType.OBJECT), unknown(PrimitiveType.OBJECT, PrimitiveType.ARRAY), unknown(PrimitiveType.OBJECT));
ArgType objExc = object("java.lang.Exception");
ArgType objThr = object("java.lang.Throwable");
ArgType objIO = object("java.io.IOException");
ArgType objArr = object("java.lang.ArrayIndexOutOfBoundsException");
ArgType objList = object("java.util.List");
first(objExc, objExc);
check(objExc, objList, OBJECT);
first(objExc, OBJECT);
check(objExc, objThr, objThr);
check(objIO, objArr, objExc);
ArgType generic = genericType("T");
first(generic, objExc);
}
use of jadx.core.dex.instructions.args.ArgType in project jadx by skylot.
the class TypeMergeTest method merge.
private void merge(ArgType t1, ArgType t2, ArgType exp) {
ArgType res = ArgType.merge(dex, t1, t2);
String msg = format(t1, t2, exp, res);
if (exp == null) {
assertNull("Incorrect accept: " + msg, res);
} else {
assertNotNull("Incorrect reject: " + msg, res);
assertTrue("Incorrect result: " + msg, exp.equals(res));
}
}
Aggregations