allocObject

context(env: JniEnv)
fun JClass.allocObject(): JObject?(source)

Allocates a new Java object without invoking any of the constructors for the object.

Note: The Java Language Specification, "Implementing Finalization" (JLS §12.6.1) states: "An object o is not finalizable until its constructor has invoked the constructor for Object on o and that invocation has completed successfully". Since allocObject does not invoke a constructor, objects created with this function are not eligible for finalization.

This class argument must not refer to an array class.

Return

a Java object, or null if the object cannot be constructed.

Throws

InstantiationException

if the class is an interface or an abstract class.

if the system runs out of memory.