chore:优化 Native Image 相关代码
- 移除 module-info.java 中对 org.graalvm.nativeimage 的直接引用 - 修改 VMUtils 中的 isNativeImage 方法,使用反射调用 ImageInfo
This commit is contained in:
parent
f777841937
commit
b826fc43aa
@ -4,7 +4,6 @@ module org.jcnc.snow.compiler {
|
|||||||
uses CLICommand;
|
uses CLICommand;
|
||||||
requires java.desktop;
|
requires java.desktop;
|
||||||
requires java.logging;
|
requires java.logging;
|
||||||
requires org.graalvm.nativeimage;
|
|
||||||
exports org.jcnc.snow.compiler.ir.core;
|
exports org.jcnc.snow.compiler.ir.core;
|
||||||
exports org.jcnc.snow.compiler.ir.instruction;
|
exports org.jcnc.snow.compiler.ir.instruction;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
package org.jcnc.snow.vm.utils;
|
package org.jcnc.snow.vm.utils;
|
||||||
|
|
||||||
import org.graalvm.nativeimage.ImageInfo;
|
|
||||||
import org.jcnc.snow.vm.engine.VirtualMachineEngine;
|
import org.jcnc.snow.vm.engine.VirtualMachineEngine;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -52,9 +51,11 @@ public class VMUtils {
|
|||||||
*/
|
*/
|
||||||
public static boolean isNativeImage() {
|
public static boolean isNativeImage() {
|
||||||
try {
|
try {
|
||||||
return ImageInfo.inImageCode();
|
Class<?> imageInfo = Class.forName("org.graalvm.nativeimage.ImageInfo");
|
||||||
|
return (Boolean) imageInfo.getMethod("inImageCode").invoke(null);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user