Skip to content

Commit

Permalink
Fixed: Resolved the issue where Xposed code generation was incorrect …
Browse files Browse the repository at this point in the history
…when dealing with generic parameters and alias fields.
  • Loading branch information
LanBaiCode committed Dec 11, 2023
1 parent ddb5aab commit 6e99268
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions jadx-gui/src/main/java/jadx/gui/ui/codearea/XposedAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,20 @@ private String generateMethodSnippet(JMethod jMth) {
return String.format(xposedFormatStr, xposedMethod, rawClassName, methodName);
}
String params = mthArgs.stream()
.map(type -> (type.isGeneric() ? type.getObject() : type) + ".class, ")
.map(type -> fixTypeContent(type) + ".class, ")
.collect(Collectors.joining());
return String.format(xposedFormatStr, xposedMethod, rawClassName, methodName + params);
}

private String fixTypeContent(ArgType type) {
if (type.isGeneric()) {
return type.getObject();
} else if (type.isGenericType() && type.isObject() && type.isTypeKnown()) {
return "Object";
}
return type.toString();
}

private String generateClassSnippet(JClass jc) {
JavaClass javaClass = jc.getCls();
String rawClassName = javaClass.getRawName();
Expand All @@ -120,6 +129,6 @@ private String generateFieldSnippet(JField jf) {
String isStatic = javaField.getAccessFlags().isStatic() ? "Static" : "";
String type = PRIMITIVE_TYPE_MAPPING.getOrDefault(javaField.getFieldNode().getType().toString(), "Object");
String xposedMethod = "XposedHelpers.get" + isStatic + type + "Field";
return String.format("%s(/*runtimeObject*/, \"%s\");", xposedMethod, javaField.getName());
return String.format("%s(/*runtimeObject*/, \"%s\");", xposedMethod, javaField.getFieldNode().getFieldInfo().getName());
}
}

0 comments on commit 6e99268

Please sign in to comment.