Skip to content

Commit 8496704

Browse files
committed
Finally fix handling of large arrays
1 parent 0e26919 commit 8496704

File tree

1 file changed

+12
-8
lines changed
  • dex-translator/src/main/java/com/googlecode/d2j/dex

1 file changed

+12
-8
lines changed

dex-translator/src/main/java/com/googlecode/d2j/dex/Dex2Asm.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -556,12 +556,14 @@ public void convertClass(int dexVersion, DexClassNode classNode, ClassVisitorFac
556556
cv.visitEnd();
557557
}
558558

559+
private static final String HEX_CLASS_LOCATION = "res/Hex";
560+
559561
private static final Set<String> HEX_DECODE_METHODS =
560562
new HashSet<>(Arrays.asList("decode_J", "decode_I", "decode_S", "decode_B"));
561563

562564
private void addHexDecodeMethod(ClassVisitor outCV, String className, String hexDecodeMethodNameBase) {
563-
// the .data is a class-file compiled from res.Hex
564-
try (InputStream is = Dex2Asm.class.getResourceAsStream("/res/Hex.class")) {
565+
System.err.println(className);
566+
try (InputStream is = Dex2Asm.class.getResourceAsStream("/" + HEX_CLASS_LOCATION + ".class")) {
565567
ClassReader cr = new ClassReader(is);
566568
cr.accept(new ClassVisitor(Constants.ASM_VERSION) {
567569
@Override
@@ -570,14 +572,16 @@ public MethodVisitor visitMethod(int access, String name, String desc, String si
570572
if (HEX_DECODE_METHODS.contains(name)) {
571573
return new MethodVisitor(Constants.ASM_VERSION,
572574
outCV.visitMethod(Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC,
573-
hexDecodeMethodNameBase + "$" + name,
574-
desc, signature, exceptions
575-
)) {
575+
hexDecodeMethodNameBase + "$" + name, desc, signature, exceptions)) {
576576
@Override
577577
public void visitMethodInsn(int opcode, String owner, String name, String descriptor,
578578
boolean isInterface) {
579-
super.visitMethodInsn(opcode, owner.equals("res/Hex") ? className : owner, name,
580-
descriptor, isInterface);
579+
if (owner.equals(HEX_CLASS_LOCATION)) {
580+
super.visitMethodInsn(opcode, className, hexDecodeMethodNameBase + "$" + name,
581+
descriptor, isInterface);
582+
} else {
583+
super.visitMethodInsn(opcode, owner, name, descriptor, isInterface);
584+
}
581585
}
582586
};
583587
} else {
@@ -586,7 +590,7 @@ public void visitMethodInsn(int opcode, String owner, String name, String descri
586590
}
587591
}, ClassReader.EXPAND_FRAMES);
588592
} catch (Throwable t) {
589-
throw new RuntimeException("Failed to add Hex.decode_*", t);
593+
throw new RuntimeException("Failed to add " + HEX_CLASS_LOCATION + ".decode_*", t);
590594
}
591595
}
592596

0 commit comments

Comments
 (0)