Skip to content

Commit

Permalink
try fix compute_frame
Browse files Browse the repository at this point in the history
  • Loading branch information
eebssk1 committed Apr 30, 2023
1 parent 53e4d33 commit d24b835
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion dex-translator/src/main/java/com/googlecode/d2j/dex/Dex2jar.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;

public final class Dex2jar {

Expand Down Expand Up @@ -56,11 +57,47 @@ private void doTranslate(final Path dist) {
exceptionHandler.handleFileException(ex);
}
ClassVisitorFactory cvf = new ClassVisitorFactory() {
public String curSupnam = null;
public boolean isInterf = false;
@Override
public ClassVisitor create(final String name) {
final ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
final ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES) {
@Override
protected String getCommonSuperClass(String type1, String type2) {
if(type1.equals("java/lang/Object") || type2.equals("java/lang/Object") || isInterf)
return "java/lang/Object";
String name;
String name2 = "none";
try {
return super.getCommonSuperClass(type1, type2);
} catch (TypeNotPresentException e) {
name = e.typeName();
};
if (name.equals(type1)) {
name2 = type2;
} else if (name.equals(type2)) {
name2 = type1;
}
if(name2.equals(curSupnam))
return curSupnam;
System.err.printf("Another associated class is %s for %s\n", name2, name);
// FIXME This may be a safer choice for now but we really need to find the real one.
System.err.printf("Assuming java/lang/Object !\n");
return "java/lang/Object";
}
};
final LambadaNameSafeClassAdapter rca = new LambadaNameSafeClassAdapter(cw);
return new ClassVisitor(Constants.ASM_VERSION, rca) {
@Override
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
super.visit(version, access, name, signature, superName, interfaces);
curSupnam = superName;
if((access & Opcodes.ACC_INTERFACE) != 0){
isInterf = true;
} else {
isInterf = false;
}
}
@Override
public void visitEnd() {
super.visitEnd();
Expand Down

0 comments on commit d24b835

Please sign in to comment.