handlestore

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 16, 2026 License: CC0-1.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HandleStore

type HandleStore struct {
	// contains filtered or unexported fields
}

HandleStore maps opaque int64 handles to JNI global references, allowing Java objects to be referenced across gRPC RPC boundaries.

When a server-side RPC returns a JNI object, it stores the object as a global reference in the HandleStore and returns the int64 handle to the client. When the client later passes that handle in another RPC, the server retrieves the global reference from the HandleStore.

HandleStore is safe for concurrent use.

func New

func New() *HandleStore

New creates a new empty HandleStore.

func (*HandleStore) Get

func (s *HandleStore) Get(handle int64) *jni.Object

Get retrieves the JNI global reference for the given handle. Returns nil if the handle is invalid or 0 (the zero handle represents nil).

func (*HandleStore) Len

func (s *HandleStore) Len() int

Len returns the number of active handles.

func (*HandleStore) Put

func (s *HandleStore) Put(env *jni.Env, obj *jni.Object) int64

Put creates a JNI global reference for the given object and returns an opaque int64 handle. The caller must be inside a VM.Do callback (env is required to create the global reference). Returns 0 if obj is nil.

func (*HandleStore) Release

func (s *HandleStore) Release(env *jni.Env, handle int64)

Release deletes the JNI global reference for the given handle and removes it from the store. The caller must be inside a VM.Do callback. Does nothing if the handle is 0 or not found.

type Server

type Server struct {
	pb.UnimplementedHandleStoreServiceServer
	VM      *jni.VM
	Handles *HandleStore
}

Server implements the HandleStoreService gRPC server.

func (*Server) ReleaseHandle

ReleaseHandle releases a previously-stored JNI global reference.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL