Skip to content

Native access

Zen1th edited this page Mar 17, 2020 · 1 revision

Unlike in most JVMs (OpenJDK's JVM, Oracle HotSpot, etc.), Lukyt native code is in Lua. Any Java program can use Runtime.getRuntime().loadLibrary to load lua files and not C (or any C-compatible language) dynamic libraries. The Lua file is then simply executed with dofile

Native Interface

For Lukyt to know what function to call when a native method is requested, it must of a standard name. Standard lukyt native lua functions name is: package_class_methodName, where package has all / or . replaced by _. Example: org_package_TeaMachine_getTea.

The name doesn't include descriptors as the function can check the method argument (see below) to check for the descriptor.

Functions arguments

A native function 4 arguments, respectively: the Class of the method, the Method itself, the current Thread and the arguments to the method.

The 4th argument (arguments to the method) is an indexed table containing the arguments as Java Objects.

Clone this wiki locally