mirror of
https://github.com/FranzHaidnor/haidnorJVM.git
synced 2026-03-13 13:33:42 +08:00
support finally
This commit is contained in:
@@ -3,7 +3,7 @@ package haidnor.jvm.core;
|
||||
|
||||
import haidnor.jvm.instruction.Instruction;
|
||||
import haidnor.jvm.instruction.InstructionFactory;
|
||||
import haidnor.jvm.instruction.control.RETURN;
|
||||
import haidnor.jvm.instruction.control.*;
|
||||
import haidnor.jvm.rtda.KlassMethod;
|
||||
import haidnor.jvm.runtime.Frame;
|
||||
import haidnor.jvm.runtime.JVMThread;
|
||||
@@ -95,7 +95,7 @@ public class JavaExecutionEngine {
|
||||
Instruction instruction = instructionMap.get(i);
|
||||
log.debug("{}│ {}", blank, instruction);
|
||||
instruction.execute(frame);
|
||||
if (instruction instanceof RETURN) {
|
||||
if (instruction instanceof RETURN || instruction instanceof ARETURN || instruction instanceof DRETURN || instruction instanceof FRETURN || instruction instanceof IRETURN) {
|
||||
break;
|
||||
}
|
||||
i += instruction.offSet();
|
||||
|
||||
@@ -595,7 +595,7 @@ public abstract class InstructionFactory {
|
||||
return new ARRAYLENGTH(codeStream);
|
||||
}
|
||||
case Const.ATHROW -> {
|
||||
throw new Error("Not support JavaVM opcode ATHROW");
|
||||
return new ATHROW(codeStream);
|
||||
}
|
||||
case Const.CHECKCAST -> {
|
||||
return new CHECKCAST(codeStream);
|
||||
|
||||
20
src/main/java/haidnor/jvm/instruction/references/ATHROW.java
Normal file
20
src/main/java/haidnor/jvm/instruction/references/ATHROW.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package haidnor.jvm.instruction.references;
|
||||
|
||||
import haidnor.jvm.instruction.Instruction;
|
||||
import haidnor.jvm.runtime.Frame;
|
||||
import haidnor.jvm.util.CodeStream;
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
public class ATHROW extends Instruction {
|
||||
|
||||
public ATHROW(CodeStream codeStream) {
|
||||
super(codeStream);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public void execute(Frame frame) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -70,6 +70,11 @@ public class TestJVM {
|
||||
runMainClass(Demo6.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_7() throws Exception {
|
||||
runMainClass(Demo7.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_NEW() throws Exception {
|
||||
runMainClass(NEW.class);
|
||||
|
||||
20
src/test/java/haidnor/jvm/test/demo/Demo7.java
Normal file
20
src/test/java/haidnor/jvm/test/demo/Demo7.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package haidnor.jvm.test.demo;
|
||||
|
||||
|
||||
public class Demo7 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
String fun = fun();
|
||||
System.out.println(fun);
|
||||
}
|
||||
|
||||
public static String fun() {
|
||||
String str = "hello";
|
||||
try {
|
||||
return str;
|
||||
} finally {
|
||||
System.out.println("zhangsan");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user