public interface Mapper

Mapper interface.

Implement this interface to add support for handling new native types. Adding MappedReturn(MyMapper.class) or Mapped(MyMapper.class) to a native method or one of its argument, respectively, will tell NatJ to use the mapper implementation whenever it has to convert the return or argument value between Java and native side. When converting to Java NatJ will use the implementation’s toJava(long, JavaObjectConstructionInfo) method to convert native value to a Java one. Reasonably, the toNative(Object, NativeObjectConstructionInfo) method will be used for the other direction. and fields are not used by NatJ and free to use for anything.



public Object toJava(long instance, JavaObjectConstructionInfo info)

Has to convert a native value to Java value and return it.

  • instance – The pointer pointing to the native value
  • info – Contains every information needed for conversion

The Java value


public long toNative(Object instance, NativeObjectConstructionInfo info)

Has to convert a Java value to native value and return its pointer.

  • instance – The Java value to convert
  • info – Contains every information needed for conversion

The native value