diff --git a/dex-ir/src/main/java/com/googlecode/dex2jar/ir/expr/Exprs.java b/dex-ir/src/main/java/com/googlecode/dex2jar/ir/expr/Exprs.java index 2db7ee4ef..5c16e4d54 100644 --- a/dex-ir/src/main/java/com/googlecode/dex2jar/ir/expr/Exprs.java +++ b/dex-ir/src/main/java/com/googlecode/dex2jar/ir/expr/Exprs.java @@ -75,7 +75,12 @@ public static Constant nShort(short i) { public static Constant nString(String i) { return new Constant(i); } - + public static Constant nMethodHandle(MethodHandle i) { + return new Constant(i); + } + public static Constant nProto(Proto i) { + return new Constant(i); + } public static BinopExpr nAdd(Value a, Value b, String type) { return new BinopExpr(VT.ADD, a, b, type); } diff --git a/dex-reader-api/src/main/java/com/googlecode/d2j/node/analysis/DvmFrame.java b/dex-reader-api/src/main/java/com/googlecode/d2j/node/analysis/DvmFrame.java index 3312194cb..56971b963 100644 --- a/dex-reader-api/src/main/java/com/googlecode/d2j/node/analysis/DvmFrame.java +++ b/dex-reader-api/src/main/java/com/googlecode/d2j/node/analysis/DvmFrame.java @@ -46,6 +46,8 @@ public void execute(DexStmtNode insn, DvmInterpreter interpreter) { case CONST_STRING: case CONST_STRING_JUMBO: case CONST_CLASS: + case CONST_METHOD_HANDLE: + case CONST_METHOD_TYPE: setReg(((ConstStmtNode) insn).a, interpreter.newOperation(insn)); setTmp(null); break; @@ -378,7 +380,7 @@ public void execute(DexStmtNode insn, DvmInterpreter interpreter) { setTmp(null); break; default: - throw new RuntimeException(); + throw new RuntimeException("not support " + insn.op); } } diff --git a/dex-reader/src/test/resources/dex039.dex b/dex-reader/src/test/resources/dex039.dex new file mode 100644 index 000000000..7902f0199 Binary files /dev/null and b/dex-reader/src/test/resources/dex039.dex differ diff --git a/dex-translator/libs/dx-27.0.3.jar b/dex-translator/libs/dx-27.0.3.jar deleted file mode 100644 index 023b8da38..000000000 Binary files a/dex-translator/libs/dx-27.0.3.jar and /dev/null differ diff --git a/dex-translator/libs/dx-30.0.2.jar b/dex-translator/libs/dx-30.0.2.jar new file mode 100644 index 000000000..ef90a14d8 Binary files /dev/null and b/dex-translator/libs/dx-30.0.2.jar differ diff --git a/dex-translator/src/main/java/com/googlecode/d2j/converter/Dex2IRConverter.java b/dex-translator/src/main/java/com/googlecode/d2j/converter/Dex2IRConverter.java index 3fb02b031..d70c8200a 100644 --- a/dex-translator/src/main/java/com/googlecode/d2j/converter/Dex2IRConverter.java +++ b/dex-translator/src/main/java/com/googlecode/d2j/converter/Dex2IRConverter.java @@ -4,6 +4,8 @@ import com.googlecode.d2j.DexType; import com.googlecode.d2j.Field; import com.googlecode.d2j.Method; +import com.googlecode.d2j.MethodHandle; +import com.googlecode.d2j.Proto; import com.googlecode.d2j.node.DexCodeNode; import com.googlecode.d2j.node.TryCatchNode; import com.googlecode.d2j.node.analysis.DvmFrame; @@ -560,6 +562,10 @@ public DvmValue newOperation(DexStmtNode insn) { case CONST_STRING: case CONST_STRING_JUMBO: return b(nString((String) ((ConstStmtNode) insn).value)); + case CONST_METHOD_HANDLE: + return b(nMethodHandle((MethodHandle) ((ConstStmtNode) insn).value)); + case CONST_METHOD_TYPE: + return b(nProto((Proto) ((ConstStmtNode) insn).value)); case SGET: case SGET_BOOLEAN: case SGET_BYTE: diff --git a/dex-translator/src/main/java/com/googlecode/d2j/converter/IR2JConverter.java b/dex-translator/src/main/java/com/googlecode/d2j/converter/IR2JConverter.java index 9bf8f2496..68c7c6a54 100755 --- a/dex-translator/src/main/java/com/googlecode/d2j/converter/IR2JConverter.java +++ b/dex-translator/src/main/java/com/googlecode/d2j/converter/IR2JConverter.java @@ -18,6 +18,7 @@ import com.googlecode.d2j.DexType; import com.googlecode.d2j.Method; +import com.googlecode.d2j.MethodHandle; import com.googlecode.d2j.Proto; import com.googlecode.d2j.asm.LdcOptimizeAdapter; import com.googlecode.d2j.dex.Dex2Asm; @@ -679,8 +680,8 @@ private void accept(Value value, MethodVisitor asm) { Constant cst = (Constant) value; if (cst.value.equals(Constant.Null)) { asm.visitInsn(ACONST_NULL); - } else if (cst.value instanceof DexType) { - asm.visitLdcInsn(Type.getType(((DexType) cst.value).desc)); + } else if (cst.value instanceof DexType || cst.value instanceof MethodHandle || cst.value instanceof Proto) { + asm.visitLdcInsn(Dex2Asm.convertConstantValue(cst.value)); } else { asm.visitLdcInsn(cst.value); } diff --git a/dex-translator/src/test/java/com/googlecode/dex2jar/test/TestUtils.java b/dex-translator/src/test/java/com/googlecode/dex2jar/test/TestUtils.java index 03f114369..30c4f1fb6 100644 --- a/dex-translator/src/test/java/com/googlecode/dex2jar/test/TestUtils.java +++ b/dex-translator/src/test/java/com/googlecode/dex2jar/test/TestUtils.java @@ -328,8 +328,12 @@ public ClassVisitor create(String classInternalName) { CfOptions cfOptions = new CfOptions(); cfOptions.strictNameCheck = false; DexOptions dexOptions = new DexOptions(); - if (fileNode != null && fileNode.dexVersion >= DexConstants.DEX_037) { - dexOptions.minSdkVersion = 26; + if (fileNode != null) { + if (fileNode.dexVersion >= DexConstants.DEX_039) { + dexOptions.minSdkVersion = 28; + } else if (fileNode.dexVersion >= DexConstants.DEX_037) { + dexOptions.minSdkVersion = 26; + } } DirectClassFile dcf = new DirectClassFile(data, rca.getClassName() + ".class", true); diff --git a/dex-writer/src/main/java/com/googlecode/d2j/dex/writer/CodeWriter.java b/dex-writer/src/main/java/com/googlecode/d2j/dex/writer/CodeWriter.java index 11b14354d..941c9ea04 100644 --- a/dex-writer/src/main/java/com/googlecode/d2j/dex/writer/CodeWriter.java +++ b/dex-writer/src/main/java/com/googlecode/d2j/dex/writer/CodeWriter.java @@ -391,7 +391,7 @@ public void visitFillArrayDataStmt(Op op, int ra, Object value) { @Override public void visitConstStmt(Op op, int ra, Object value) { switch (op.format) { - case kFmt21c:// value is field,type,string + case kFmt21c:// value is field,type,string,method_handle,proto case kFmt31c:// value is string, value = cp.wrapEncodedItem(value); ops.add(new CodeWriter.IndexedInsn(op, ra, 0, (BaseItem) value));