CxxRuntime

public class CxxRuntime

CxxRuntime.

NativeRuntime implementation used for supporting C++ features.

Fields

ILLEGAL_MEMORY_ADDRESS

public static final long ILLEGAL_MEMORY_ADDRESS

Placeholder value for illegal memory address.

primitivePtrTypeMap

public static final Map<Class<?>, Class<?>> primitivePtrTypeMap

Primitive pointer type map.

Methods

castToPtr

public static <T extends CxxObject> VoidPtr castToPtr(T object)

Casts the specified object to a VoidPtr.

Parameters:
  • object – Object to cast
  • <T> – Object type
Returns:

VoidPtr instance or null

construct

public static <T extends CxxObject> T construct(long peer, Class<T> implClass)

Constructs a Java object with the specified impl Class.

Parameters:
  • peer – Native peer
  • implClass – Impl class
  • <T> – Object type
Returns:

Constructed object

constructPtrForPeer

public static ConstVoidPtr constructPtrForPeer(long peer, int depth, Class<?> elementClass)

Creates a pointer for the specified peer, depth and element Class.

Parameters:
  • peer – Native peer
  • depth – Indirection depth
  • elementClass – Element class
Throws:
Returns:

Constructed pointer

delete

public static void delete(CxxObject obj)

Invokes the ‘delete’ operator on the given object.

Parameters:
  • obj – Object to delete

deleteWith

public static <T extends CxxObject> void deleteWith(T object, Releaser<T> releaser)

Releases the specified object with the specified releaser.

Parameters:
  • object – Object to release
  • releaser – Releaser instance
  • <T> – Type to release

detachOnly

public static <T extends CxxObject> void detachOnly(T object)

Detaches the specified object from the runtime cache.

Parameters:
  • object – Object to detach
  • <T> – Type of object

get

public static CxxObject get(long peer)

Returns the cached object for the specified peer.

Parameters:
  • peer – Native peer
Returns:

Cached object or null

getClassImplForName

public static Class<?> getClassImplForName(String className, String implSuffix)

Returns the impl class for the specified class.

Parameters:
  • className – Base class
  • implSuffix – Impl class suffix
Returns:

Impl class

getImplClass

public static <T extends CxxObject> Class<T> getImplClass(Class<T> cls)

Returns the impl class for the specified class.

Parameters:
  • cls – Base class
  • <T> – Class type
Returns:

Impl class

getObjectForUID

public static Object getObjectForUID(long uid)

Returns the object associated with the UID.

Parameters:
  • uid – UID
Returns:

Associated object

getPtrDeleteMethod

public static final <T extends CxxObject> Method getPtrDeleteMethod(Class<T> cls)

Returns the ‘ptrdeletej’ method for the specified class.

Parameters:
  • cls – Owner Class
  • <T> – Class type
Returns:

Method instance or null on failure

getPtrGetMethod

public static final <T extends CxxObject> Method getPtrGetMethod(Class<T> cls)

Returns the ‘ptrgetji’ method for the specified class.

Parameters:
  • cls – Owner Class
  • <T> – Class type
Returns:

Method instance or null on failure

getPtrNewMethod

public static final <T extends CxxObject> Method getPtrNewMethod(Class<T> cls)

Returns the ‘ptrnewi’ method for the specified class.

Parameters:
  • cls – Owner Class
  • <T> – Class type
Returns:

Method instance or null on failure

getPtrSetMethod

public static final <T extends CxxObject> Method getPtrSetMethod(Class<T> cls)

Returns the ‘ptrsetjij’ method for the specified class.

Parameters:
  • cls – Owner Class
  • <T> – Class type
Returns:

Method instance or null on failure

getUIDForObject

public static long getUIDForObject(Object object)

Returns a new UID for the specified object.

Parameters:
  • object – Object to associate with the UID
Returns:

UID

initialize

public static void initialize()

Initializes the C++ runtime.

register

public static void register(CxxObject object)

Registers the object in the Object cache.

Parameters:
  • object – Object to register

sizeof

public static final long sizeof(CxxObject object)

Returns the native ‘sizeof’ value for the C++ class/struct represented by the specified object.

Parameters:
  • object – Binding object
Returns:

‘sizeof’ value or -1 if the required field does not exist

sizeof

public static final <T extends CxxObject> long sizeof(Class<T> cls)

Returns the native ‘sizeof’ value for the C++ class/struct represented by the specified Class.

Parameters:
  • cls – Binding class
  • <T> – Class type
Returns:

‘sizeof’ value or -1 if the required field does not exist