void init(String nativeHandlerName, int inputBufferCapacity, int outputBufferCapacity) { if (inputBufferCapacity > 0) { this.inputBuffer = ByteBuffer.allocateDirect(inputBufferCapacity); this.inputBuffer.order(ByteOrder.LITTLE_ENDIAN); } if (outputBufferCapacity > 0) { this.outputBuffer = ByteBuffer.allocateDirect(outputBufferCapacity); this.outputBuffer.order(ByteOrder.LITTLE_ENDIAN); } this.nativeHandlerAddr = NativeRuntime.createNativeObject(nativeHandlerName); if (this.nativeHandlerAddr == 0) { throw new RuntimeException("Native object create failed, class: " + nativeHandlerName); } setupHandler(nativeHandlerAddr); }
protected synchronized void releaseNative() { if (nativeHandlerAddr != 0) { NativeRuntime.releaseNativeObject(nativeHandlerAddr); nativeHandlerAddr = 0; } }
static { if (NativeRuntime.isNativeLibraryLoaded()) { InitIDs(); } }