destroy method

void destroy()

Shuts the VM down.

Terminal for the whole process: HotSpot cannot start a second VM afterwards, so a test suite or long-running app should simply let the VM live until exit. Provided for completeness and for the single-shot CLI case.

Implementation

void destroy() {
  final fn = _vmSlot(
    JniVmFn.destroyJavaVm,
  ).cast<NativeFunction<VmIntC>>().asFunction<VmIntDart>();

  final rc = fn(vm);
  if (rc != JniResult.ok) {
    throw JniError('DestroyJavaVM failed: ${JniResult.describe(rc)}');
  }
  if (identical(_instance, this)) _instance = null;
}