private static void enqueueScriptTask(Realm realm, Init init) { realm.enqueueScriptTask( () -> { try { init.apply(); } catch (IOException e) { throw new UncheckedIOException(e); } catch (URISyntaxException e) { throw new UncheckedIOException(new IOException(e)); } catch (MalformedNameException | ResolutionException e) { throw e.toScriptException(realm.defaultContext()); } }); }