jnierr

package
v0.0.3 Latest Latest
Warning

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

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

Documentation

Overview

Package jnierr provides JNI exception-to-Go-error conversion.

This is hand-written because exception extraction requires careful use of raw capi calls to avoid infinite recursion (every generated Env method calls CheckException, so it must not use Env methods).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckException

func CheckException(env *capi.Env) error

CheckException checks for a pending Java exception on the given JNI env pointer and converts it to a Go error. Returns nil if no exception is pending.

Call sequence:

  1. ExceptionCheck — is an exception pending?
  2. ExceptionOccurred — get the jthrowable reference
  3. ExceptionClear — MUST clear before making more JNI calls
  4. Extract class name and message from the throwable
  5. Delete the throwable local ref
  6. Return *JavaException

Types

type JavaException

type JavaException struct {
	ClassName string
	Message   string
}

JavaException represents a Java exception caught by JNI.

func (*JavaException) Error

func (e *JavaException) Error() string

Error returns a human-readable representation of the Java exception.

Jump to

Keyboard shortcuts

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