mirror of
https://github.com/FranzHaidnor/haidnorJVM.git
synced 2026-03-13 21:43:42 +08:00
update Main
This commit is contained in:
@@ -35,12 +35,12 @@ public class Main {
|
||||
// TODO
|
||||
}
|
||||
if (cmd.hasOption("class")) {
|
||||
JvmThreadHolder.set(new JvmThread());
|
||||
String path = cmd.getOptionValue("class");
|
||||
ClassLoader bootClassLoader = new ClassLoader("ApplicationClassLoader");
|
||||
Klass mainMeteKlass = bootClassLoader.loadClassWithAbsolutePath(path);
|
||||
KlassMethod mainKlassMethod = JavaClassUtil.getMainMethod(mainMeteKlass);
|
||||
Metaspace.registerJavaClass(mainMeteKlass);
|
||||
JvmThreadHolder.set(new JvmThread());
|
||||
|
||||
JavaExecutionEngine.callMainStaticMethod(mainKlassMethod);
|
||||
}
|
||||
|
||||
@@ -22,11 +22,11 @@ public class TestJVM {
|
||||
|
||||
@SneakyThrows
|
||||
public static void runMainClass(java.lang.Class<?> mainClass) {
|
||||
JvmThreadHolder.set(new JvmThread());
|
||||
ClassLoader bootClassLoader = new ClassLoader("ApplicationClassLoader");
|
||||
Klass mainMeteKlass = bootClassLoader.loadClass(mainClass.getName().replace('.', '/'));
|
||||
KlassMethod mainKlassMethod = JavaClassUtil.getMainMethod(mainMeteKlass);
|
||||
Metaspace.registerJavaClass(mainMeteKlass);
|
||||
JvmThreadHolder.set(new JvmThread());
|
||||
|
||||
JavaExecutionEngine.callMainStaticMethod(mainKlassMethod);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,10 @@ package haidnor.jvm.test.demo;
|
||||
|
||||
public class Demo5 {
|
||||
|
||||
static {
|
||||
System.out.println("hello,world");
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String str = method1("hello world");
|
||||
method1(str);
|
||||
|
||||
Reference in New Issue
Block a user