-
Notifications
You must be signed in to change notification settings - Fork 2
/
jvml
28 lines (23 loc) · 857 Bytes
/
jvml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
local jcd = fs.combine("", shell.getRunningProgram():sub(1, -1 - #(fs.getName(shell.getRunningProgram()))))
local env = setmetatable({
jcd = jcd,
jcp = "/" .. fs.combine(jcd, "CCLib/build/classes")..":."
}, {__index=getfenv()})
local function dofile(path, ...)
local f = assert(loadfile(path))
setfenv(f, env)
return f(...)
end
dofile(fs.combine(env.jcd, "jvml_data/vm/classpath.lua"))
dofile(fs.combine(env.jcd, "jvml_data/vm/classloader.lua"))
env.jcp = env.jcp .. ":/" .. env.jcd -- So that loadJavaClass isn't needed here and so Yo and Test get loaded right
local ok, err = pcall(function()
local ok, exc = env.findMethod(env.classByName("MyFirstProgram"),"main([Ljava/lang/String;)V")[1]()
if not ok then
env.findMethod(exc.data, "printStackTrace()V")[1](exc)
end
end)
if not ok then
printError(err)
printError(env.getStackTrace())
end