org.luaj.vm2.server
Class LuajClassLoader

Class loader that can be used to launch a lua script in a Java VM that has a
unique set of classes for org.luaj classes.

Note: This class is experimental and subject to change in future versions.

By using a custom class loader per script, it allows the script to have
its own set of globals, including static values such as shared metatables
that cannot access lua values from other scripts because their classes are
loaded from different class loaders. Thus normally unsafe libraries such
as luajava can be exposed to scripts in a server environment using these
techniques.

All classes in the package "org.luaj.vm2." are considered user classes, and
loaded into this class loader from their bytes in the class path. Other
classes are considered systemc classes and loaded via the system loader. This
class set can be extended by overriding isUserClass(String).

The Launcher interface is loaded as a system class by exception so
that the caller may use it to launch lua scripts.

The Launcher that is returned will be a pristine luaj vm
whose classes are loaded into this loader including static variables
such as shared metatables, and should not be able to directly access
variables from other Launcher instances.

The Launcher that is returned will be a pristine luaj vm
whose classes are loaded into this loader including static variables
such as shared metatables, and should not be able to directly access
variables from other Launcher instances.

Returns:

instance of type 'launcher_class' that can be used to launch scripts.

Throws:

java.lang.InstantiationException

java.lang.IllegalAccessException

java.lang.ClassNotFoundException

isUserClass

public static boolean isUserClass(java.lang.String classname)

Test if a class name should be considered a user class and loaded
by this loader, or a system class and loaded by the system loader.