@Override
@SuppressWarnings("PMD.AvoidCatchingGenericException")
public void close() {
if (handle != null && !handle.equals(MemorySegment.NULL)) {
try {
NativeLib.{{ free_handle }}.invoke(handle);
} catch (Throwable e) {
throw new RuntimeException("Failed to free {{ class_name }}: " + e.getMessage(), e);
}
}
}