Skip to content

Commit

Permalink
Add workaround for invalid signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
ThexXTURBOXx committed Sep 4, 2021
1 parent ffa0574 commit f1da047
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions dex-translator/src/main/java/com/googlecode/d2j/dex/Dex2Asm.java
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,16 @@ private static MethodVisitor collectBasicMethodInfo(DexMethodNode methodNode, Cl
final int cleanFlag = ~((DexConstants.ACC_DECLARED_SYNCHRONIZED | DexConstants.ACC_CONSTRUCTOR
| Opcodes.ACC_SYNTHETIC));
access &= cleanFlag;
return cv.visitMethod(access, methodNode.method.getName(), methodNode.method.getDesc(), signature, xthrows);
try {
return cv.visitMethod(access, methodNode.method.getName(), methodNode.method.getDesc(), signature, xthrows);
} catch (StringIndexOutOfBoundsException | IllegalArgumentException e) {
System.err.println("Applying workaround to method "
+ methodNode.method.getOwner() + "#" + methodNode.method.getName()
+ " with original signature " + signature
+ " by changing its types to java.lang.Object.");
return cv.visitMethod(access, methodNode.method.getName(), methodNode.method.getDesc(),
"(Ljava/lang/Object;)Ljava/lang/Object;", xthrows);
}
}

protected static Map<String, Clz> collectClzInfo(DexFileNode fileNode) {
Expand Down Expand Up @@ -568,8 +577,18 @@ public void convertField(DexClassNode classNode, DexFieldNode fieldNode, ClassVi
}
Object value = convertConstantValue(fieldNode.cst);
final int fieldCleanFlag = ~((DexConstants.ACC_DECLARED_SYNCHRONIZED | Opcodes.ACC_SYNTHETIC));
FieldVisitor fv = cv.visitField(fieldNode.access & fieldCleanFlag, fieldNode.field.getName(),
fieldNode.field.getType(), signature == null || !signature.contains(";") ? null : signature, value);
FieldVisitor fv;
try {
fv = cv.visitField(fieldNode.access & fieldCleanFlag, fieldNode.field.getName(),
fieldNode.field.getType(), signature, value);
} catch (StringIndexOutOfBoundsException | IllegalArgumentException e) {
System.err.println("Applying workaround to field "
+ classNode.className + "#" + fieldNode.field.getName()
+ " with original signature " + signature
+ " by changing its type to java.lang.Object.");
fv = cv.visitField(fieldNode.access & fieldCleanFlag, fieldNode.field.getName(),
fieldNode.field.getType(), "Ljava/lang/Object;", value);
}
if (fv == null) {
return;
}
Expand Down

0 comments on commit f1da047

Please sign in to comment.