in sdk/host/src/main/java/org/apache/teaclave/javasdk/host/TeeSdkEnclave.java [167:184]
public void destroy() throws EnclaveDestroyingException {
// destroyToken will wait for all ongoing enclave invocations finished.
if (this.getEnclaveContext().getEnclaveToken().destroyToken()) {
try (MetricTraceContext trace = new MetricTraceContext(
this.getEnclaveInfo(),
MetricTraceContext.LogPrefix.METRIC_LOG_ENCLAVE_DESTROYING_PATTERN)) {
// interrupt enclave services' recycler firstly.
this.getEnclaveContext().getEnclaveServicesRecycler().interruptServiceRecycler();
// destroy svm isolate.
nativeSvmDetachIsolate(enclaveHandle, isolateThreadHandle);
// destroy the enclave.
nativeDestroyEnclave(enclaveHandle);
EnclaveInfoManager.getEnclaveInfoManagerInstance().removeEnclave(this);
} catch (MetricTraceLogWriteException e) {
throw new EnclaveDestroyingException(e);
}
}
}