diff --git a/TotalCrossSDK/src/main/java/tc/tools/converter/Bytecode2TCCode.java b/TotalCrossSDK/src/main/java/tc/tools/converter/Bytecode2TCCode.java index 8a7a0a47c1..e0959f9a66 100644 --- a/TotalCrossSDK/src/main/java/tc/tools/converter/Bytecode2TCCode.java +++ b/TotalCrossSDK/src/main/java/tc/tools/converter/Bytecode2TCCode.java @@ -1517,6 +1517,7 @@ public static Instruction convert(ByteCode[] bcs, ByteCode i, OperandStack stack case INVOKESPECIAL: //183 case INVOKESTATIC: //184 case INVOKEINTERFACE: //185 + case INVOKEDYNAMIC: //186 { MethodCall ji = (MethodCall) i; ji.className = replaceTotalCrossLangToJavaLang(ji.className); @@ -1575,7 +1576,7 @@ public static Instruction convert(ByteCode[] bcs, ByteCode i, OperandStack stack } OperandReg _this; - if (op == INVOKESTATIC) { + if (op == INVOKESTATIC || op == INVOKEDYNAMIC) { _this = new OperandReg(TCConstants.opr_regO); _this.index = 0; } else { @@ -1604,7 +1605,7 @@ public static Instruction convert(ByteCode[] bcs, ByteCode i, OperandStack stack } break; } - case NEW: //187 (186 is not used) + case NEW: //187 { BC187_new ji = (BC187_new) i; ji.className = replaceTotalCrossLangToJavaLang(ji.className); diff --git a/TotalCrossSDK/src/main/java/tc/tools/converter/JConstants.java b/TotalCrossSDK/src/main/java/tc/tools/converter/JConstants.java index ba489d3cb4..00f22b5d38 100644 --- a/TotalCrossSDK/src/main/java/tc/tools/converter/JConstants.java +++ b/TotalCrossSDK/src/main/java/tc/tools/converter/JConstants.java @@ -224,6 +224,7 @@ public interface JConstants { public static final int INVOKESPECIAL = 183; public static final int INVOKESTATIC = 184; public static final int INVOKEINTERFACE = 185; + public static final int INVOKEDYNAMIC = 186; public static final int NEW = 187; public static final int NEWARRAY = 188; public static final int ANEWARRAY = 189; diff --git a/TotalCrossSDK/src/main/java/tc/tools/converter/bytecode/BC186_invokedynamic.java b/TotalCrossSDK/src/main/java/tc/tools/converter/bytecode/BC186_invokedynamic.java new file mode 100644 index 0000000000..94b5a7a377 --- /dev/null +++ b/TotalCrossSDK/src/main/java/tc/tools/converter/bytecode/BC186_invokedynamic.java @@ -0,0 +1,12 @@ +package tc.tools.converter.bytecode; + +public class BC186_invokedynamic extends MethodCall { + public BC186_invokedynamic() { + super(readUInt16(pc + 1)); + pcInc = 5; + } + + @Override + public void exec() { + } + } diff --git a/TotalCrossSDK/src/main/java/tc/tools/converter/bytecode/ByteCode.java b/TotalCrossSDK/src/main/java/tc/tools/converter/bytecode/ByteCode.java index 1a1c1dd6ac..c5a747559b 100644 --- a/TotalCrossSDK/src/main/java/tc/tools/converter/bytecode/ByteCode.java +++ b/TotalCrossSDK/src/main/java/tc/tools/converter/bytecode/ByteCode.java @@ -246,6 +246,7 @@ public static void initClasses() throws ClassNotFoundException { bcClasses[183] = tc.tools.converter.bytecode.BC183_invokespecial.class; bcClasses[184] = tc.tools.converter.bytecode.BC184_invokestatic.class; bcClasses[185] = tc.tools.converter.bytecode.BC185_invokeinterface.class; + bcClasses[186] = tc.tools.converter.bytecode.BC186_invokedynamic.class; bcClasses[187] = tc.tools.converter.bytecode.BC187_new.class; bcClasses[188] = tc.tools.converter.bytecode.BC188_newarray.class; bcClasses[189] = tc.tools.converter.bytecode.BC189_anewarray.class; diff --git a/TotalCrossSDK/src/main/java/tc/tools/converter/bytecode/MethodCall.java b/TotalCrossSDK/src/main/java/tc/tools/converter/bytecode/MethodCall.java index a960635a1c..2b2e3c0f0c 100644 --- a/TotalCrossSDK/src/main/java/tc/tools/converter/bytecode/MethodCall.java +++ b/TotalCrossSDK/src/main/java/tc/tools/converter/bytecode/MethodCall.java @@ -20,7 +20,7 @@ public MethodCall(int idx) { JavaConstantInfo jci = (JavaConstantInfo) cp.constants[idx]; int classIndex = jci.index1; int nameAndTypeIndex = jci.index2; - className = cp.getString1(classIndex); + className = cp.getClassName(jci); name = cp.getString1(nameAndTypeIndex); parameters = cp.getString2(nameAndTypeIndex); pcInc = 3; diff --git a/TotalCrossSDK/src/main/java/tc/tools/converter/java/JavaConstantPool.java b/TotalCrossSDK/src/main/java/tc/tools/converter/java/JavaConstantPool.java index 1d8b4ed9d4..a3e78d7126 100644 --- a/TotalCrossSDK/src/main/java/tc/tools/converter/java/JavaConstantPool.java +++ b/TotalCrossSDK/src/main/java/tc/tools/converter/java/JavaConstantPool.java @@ -39,14 +39,19 @@ public JavaConstantPool(DataStream ds) throws totalcross.io.IOException { break; case 7: // Class case 8: // String - constants[i] = new JavaConstantInfo(b, ds.readUnsignedShort()); - break; + case 16: // method type + constants[i] = new JavaConstantInfo(b, ds.readUnsignedShort()); + break; case 9: // field case 10: // method case 11: // interface method case 12: // name and type - constants[i] = new JavaConstantInfo(b, ds.readUnsignedShort(), ds.readUnsignedShort()); - break; + case 18: // invoke dynamic + constants[i] = new JavaConstantInfo(b, ds.readUnsignedShort(), ds.readUnsignedShort()); + break; + case 15: // method handle + constants[i] = new JavaConstantInfo(b, ds.readByte(), ds.readUnsignedShort()); + break; } } } @@ -71,4 +76,11 @@ public String getString2(int idx) { JavaConstantInfo ci = (JavaConstantInfo) constants[idx]; return (String) constants[ci.index2]; } + + public String getClassName(JavaConstantInfo jci) { + if (jci.type == 18) { + return String.valueOf(jci.index1); + } + return getString1(jci.index1); + } }