mirror of
https://github.com/FranzHaidnor/haidnorJVM.git
synced 2026-03-13 21:43:42 +08:00
upd JavaMethod
This commit is contained in:
@@ -210,6 +210,11 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
|
||||
staticJavaFieldMap.put(field.getName(), field);
|
||||
}
|
||||
}
|
||||
|
||||
JavaMethod[] javaMethods = getMethods();
|
||||
for (JavaMethod javaMethod : javaMethods) {
|
||||
javaMethod.setJavaClass(this);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -18,6 +18,8 @@ package haidnor.jvm.bcel.classfile;
|
||||
|
||||
import haidnor.jvm.bcel.generic.Type;
|
||||
import haidnor.jvm.bcel.util.BCELComparator;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.IOException;
|
||||
@@ -57,6 +59,10 @@ public class JavaMethod extends FieldOrMethod {
|
||||
// annotations defined on the parameters of a method
|
||||
private ParameterAnnotationEntry[] parameterAnnotationEntries;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private JavaClass javaClass;
|
||||
|
||||
/**
|
||||
* Empty constructor, all attributes have to be defined via 'setXXX' methods. Use at your own risk.
|
||||
*/
|
||||
|
||||
@@ -28,7 +28,7 @@ public class JavaExecutionEngine {
|
||||
*/
|
||||
public static void callMainMethod(JavaClass javaClass) {
|
||||
JavaMethod mainMethod = javaClass.getMainMethod();
|
||||
callMethod(null, javaClass, mainMethod);
|
||||
callMethod(null, mainMethod);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -37,10 +37,10 @@ public class JavaExecutionEngine {
|
||||
* @param lastFrame 方法调用者的栈帧
|
||||
* @param javaMethod 方法元信息
|
||||
*/
|
||||
public static void callMethod(Frame lastFrame, JavaClass javaClass, JavaMethod javaMethod) {
|
||||
public static void callMethod(Frame lastFrame, JavaMethod javaMethod) {
|
||||
JVMThread jvmThread = JVMThreadHolder.get();
|
||||
// 调用方法时会创建新的栈帧
|
||||
Frame newFrame = new Frame(jvmThread, javaClass, javaMethod);
|
||||
Frame newFrame = new Frame(jvmThread, javaMethod);
|
||||
|
||||
// 如果线程栈内存在栈帧, 代表可能需要方法调用传参
|
||||
if (lastFrame != null) {
|
||||
|
||||
@@ -51,9 +51,9 @@ public class Frame {
|
||||
*/
|
||||
private final Slot[] slots;
|
||||
|
||||
public Frame(JVMThread thread, JavaClass javaClass, JavaMethod javaMethod) {
|
||||
public Frame(JVMThread thread, JavaMethod javaMethod) {
|
||||
this.jvmThread = thread;
|
||||
this.javaClass = javaClass;
|
||||
this.javaClass = javaMethod.getJavaClass();
|
||||
this.javaMethod = javaMethod;
|
||||
this.code = javaMethod.getCode();
|
||||
this.codeStream = new CodeStream(javaMethod.getCode());
|
||||
|
||||
Reference in New Issue
Block a user