mirror of
https://github.com/FranzHaidnor/haidnorJVM.git
synced 2026-03-13 21:43:42 +08:00
update INVOKEVIRTUAL
This commit is contained in:
@@ -87,9 +87,10 @@ public class INVOKEVIRTUAL extends Instruction {
|
||||
javaClass = klass.getJavaClass();
|
||||
}
|
||||
|
||||
// 按照继承关系从下往上找实现的方法 (实现多态)
|
||||
org.apache.bcel.classfile.Method method = getMethod(javaClass, methodSignature, methodName);
|
||||
if (method == null) {
|
||||
throw new NoSuchMethodException();
|
||||
throw new AbstractMethodError();
|
||||
}
|
||||
KlassMethod klassMethod = new KlassMethod(klass, method);
|
||||
JavaExecutionEngine.callMethod(frame, klassMethod);
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
package haidnor.jvm.test.clazz;
|
||||
|
||||
public class Baby {
|
||||
public void eat() {
|
||||
System.out.println("婴儿吃奶粉");
|
||||
}
|
||||
}
|
||||
7
src/test/java/haidnor/jvm/test/clazz/Human.java
Normal file
7
src/test/java/haidnor/jvm/test/clazz/Human.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package haidnor.jvm.test.clazz;
|
||||
|
||||
public class Human {
|
||||
public void eat() {
|
||||
System.out.println("人类吃饭");
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package haidnor.jvm.test.clazz;
|
||||
|
||||
public interface Person {
|
||||
|
||||
void eat();
|
||||
|
||||
}
|
||||
@@ -1,15 +1,5 @@
|
||||
package haidnor.jvm.test.clazz;
|
||||
|
||||
public class Student extends Baby{
|
||||
|
||||
private int age;
|
||||
|
||||
public int getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
public void setAge(int age) {
|
||||
this.age = age;
|
||||
}
|
||||
public class Student extends Human {
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user