use of jadx.api.plugins.input.data.IMethodHandle in project jadx by skylot.
the class CustomStringConcat method isStringConcat.
public static boolean isStringConcat(List<EncodedValue> values) {
if (values.size() < 4) {
return false;
}
IMethodHandle methodHandle = (IMethodHandle) values.get(0).getValue();
if (methodHandle.getType() != MethodHandleType.INVOKE_STATIC) {
return false;
}
IMethodRef methodRef = methodHandle.getMethodRef();
if (!methodRef.getName().equals("makeConcatWithConstants")) {
return false;
}
if (!methodRef.getParentClassType().equals("Ljava/lang/invoke/StringConcatFactory;")) {
return false;
}
if (!Objects.equals(values.get(1).getValue(), "makeConcatWithConstants")) {
return false;
}
if (values.get(3).getType() != EncodedType.ENCODED_STRING) {
return false;
}
return true;
}
use of jadx.api.plugins.input.data.IMethodHandle in project jadx by skylot.
the class CustomLambdaCall method isLambdaInvoke.
/**
* Expect LambdaMetafactory.metafactory method
*/
public static boolean isLambdaInvoke(List<EncodedValue> values) {
if (values.size() < 6) {
return false;
}
IMethodHandle methodHandle = (IMethodHandle) values.get(0).getValue();
if (methodHandle.getType() != MethodHandleType.INVOKE_STATIC) {
return false;
}
IMethodRef methodRef = methodHandle.getMethodRef();
if (!methodRef.getName().equals("metafactory")) {
return false;
}
if (!methodRef.getParentClassType().equals("Ljava/lang/invoke/LambdaMetafactory;")) {
return false;
}
return true;
}
use of jadx.api.plugins.input.data.IMethodHandle in project jadx by skylot.
the class UsageInfoVisitor method processInsn.
private static void processInsn(RootNode root, MethodNode mth, InsnData insnData, UsageInfo usageInfo) {
if (insnData.getOpcode() == Opcode.UNKNOWN) {
return;
}
switch(insnData.getIndexType()) {
case TYPE_REF:
insnData.decode();
ArgType usedType = ArgType.parse(insnData.getIndexAsType());
usageInfo.clsUse(mth, usedType);
break;
case FIELD_REF:
insnData.decode();
FieldNode fieldNode = root.resolveField(FieldInfo.fromRef(root, insnData.getIndexAsField()));
if (fieldNode != null) {
usageInfo.fieldUse(mth, fieldNode);
}
break;
case METHOD_REF:
{
insnData.decode();
IMethodRef mthRef;
ICustomPayload payload = insnData.getPayload();
if (payload != null) {
mthRef = ((IMethodRef) payload);
} else {
mthRef = insnData.getIndexAsMethod();
}
MethodNode methodNode = root.resolveMethod(MethodInfo.fromRef(root, mthRef));
if (methodNode != null) {
usageInfo.methodUse(mth, methodNode);
}
break;
}
case CALL_SITE:
{
insnData.decode();
ICallSite callSite = InsnDataUtils.getCallSite(insnData);
IMethodHandle methodHandle = InsnDataUtils.getMethodHandleAt(callSite, 4);
if (methodHandle != null) {
IMethodRef mthRef = methodHandle.getMethodRef();
MethodNode mthNode = root.resolveMethod(MethodInfo.fromRef(root, mthRef));
if (mthNode != null) {
usageInfo.methodUse(mth, mthNode);
}
}
break;
}
}
}
use of jadx.api.plugins.input.data.IMethodHandle in project jadx by skylot.
the class CustomLambdaCall method buildLambdaMethodCall.
public static InvokeCustomNode buildLambdaMethodCall(MethodNode mth, InsnData insn, boolean isRange, List<EncodedValue> values) {
IMethodHandle callMthHandle = (IMethodHandle) values.get(4).getValue();
if (callMthHandle.getType().isField()) {
throw new JadxRuntimeException("Not yet supported");
}
InvokeCustomNode resNode = buildMethodCall(mth, insn, isRange, values, callMthHandle);
int resReg = insn.getResultReg();
if (resReg != -1) {
resNode.setResult(InsnArg.reg(resReg, mth.getReturnType()));
}
return resNode;
}
Aggregations