diff --git a/dex-translator/src/main/java/com/googlecode/d2j/dex/Dex2Asm.java b/dex-translator/src/main/java/com/googlecode/d2j/dex/Dex2Asm.java index cc73b6105..e5b61c427 100644 --- a/dex-translator/src/main/java/com/googlecode/d2j/dex/Dex2Asm.java +++ b/dex-translator/src/main/java/com/googlecode/d2j/dex/Dex2Asm.java @@ -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 collectClzInfo(DexFileNode fileNode) { @@ -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; }