@@ -556,12 +556,14 @@ public void convertClass(int dexVersion, DexClassNode classNode, ClassVisitorFac
556
556
cv .visitEnd ();
557
557
}
558
558
559
+ private static final String HEX_CLASS_LOCATION = "res/Hex" ;
560
+
559
561
private static final Set <String > HEX_DECODE_METHODS =
560
562
new HashSet <>(Arrays .asList ("decode_J" , "decode_I" , "decode_S" , "decode_B" ));
561
563
562
564
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" )) {
565
567
ClassReader cr = new ClassReader (is );
566
568
cr .accept (new ClassVisitor (Constants .ASM_VERSION ) {
567
569
@ Override
@@ -570,14 +572,16 @@ public MethodVisitor visitMethod(int access, String name, String desc, String si
570
572
if (HEX_DECODE_METHODS .contains (name )) {
571
573
return new MethodVisitor (Constants .ASM_VERSION ,
572
574
outCV .visitMethod (Opcodes .ACC_PRIVATE | Opcodes .ACC_STATIC ,
573
- hexDecodeMethodNameBase + "$" + name ,
574
- desc , signature , exceptions
575
- )) {
575
+ hexDecodeMethodNameBase + "$" + name , desc , signature , exceptions )) {
576
576
@ Override
577
577
public void visitMethodInsn (int opcode , String owner , String name , String descriptor ,
578
578
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
+ }
581
585
}
582
586
};
583
587
} else {
@@ -586,7 +590,7 @@ public void visitMethodInsn(int opcode, String owner, String name, String descri
586
590
}
587
591
}, ClassReader .EXPAND_FRAMES );
588
592
} 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 );
590
594
}
591
595
}
592
596
0 commit comments