/** * Closes this context and disposes its resources. A context cannot be closed if it is currently * {@link #enter() entered} by any thread. If a closed context is attempted to be accessed or * entered, then an {@link IllegalStateException} is thrown. If the context is not closed * explicitly, then it is automatically closed together with the parent context. If an attempt * to close a context was successful then consecutive calls to close have no effect. * <p> * Only contexts created by {@link Builder#build()} can be explicitly closed. Other instances * throw {@link UnsupportedOperationException} on close attempts. * * @throws UnsupportedOperationException when not created by {@link Builder#build()}. * @since 0.27 */ @Override @TruffleBoundary public void close() { if (!closeable) { throw new UnsupportedOperationException("It's not possible to close a foreign context."); } AccessAPI.engineAccess().closeInternalContext(impl); }
/** * Closes this context and disposes its resources. A context cannot be closed if it is currently * {@link #enter() entered} by any thread. If a closed context is attempted to be accessed or * entered, then an {@link IllegalStateException} is thrown. If the context is not closed * explicitly, then it is automatically closed together with the parent context. If an attempt * to close a context was successful then consecutive calls to close have no effect. * <p> * Only contexts created by {@link Builder#build()} can be explicitly closed. Other instances * throw {@link UnsupportedOperationException} on close attempts. * * @throws UnsupportedOperationException when not created by {@link Builder#build()}. * @since 0.27 */ @Override @TruffleBoundary public void close() { if (!closeable) { throw new UnsupportedOperationException("It's not possible to close a foreign context."); } AccessAPI.engineAccess().closeInternalContext(impl); }