Skip to content

Commit

Permalink
First GraalSDK init may result in ServiceConfigurationError, should b…
Browse files Browse the repository at this point in the history
…e caught
  • Loading branch information
sdedic committed Apr 16, 2024
1 parent e7545a9 commit 0389c34
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.ServiceConfigurationError;
import java.util.function.BiFunction;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.script.Bindings;
import javax.script.ScriptEngineFactory;
import javax.script.ScriptEngineManager;
Expand All @@ -43,6 +46,8 @@
// libraries.
@ServiceProvider(service = EngineProvider.class, position = 100000)
public final class GraalEnginesProvider implements EngineProvider {
private static final Logger LOG = Logger.getLogger(GraalEnginesProvider.class.getName());

private Throwable disable;

public GraalEnginesProvider() {
Expand All @@ -60,7 +65,11 @@ public List<ScriptEngineFactory> factories(ScriptEngineManager m) {
if (disable == null) {
enumerateLanguages(arr, m == null ? null : m.getBindings());
}
} catch (IllegalStateException | LinkageError err) {
} catch (IllegalStateException | LinkageError | ServiceConfigurationError err) {
// See NETBEANS #7245: First-time initialization with broken implementation may produce ServiceConfigurationError, As this
// happens in class-initializer, subsequent attempts will throw LinkageErrors.
LOG.log(Level.WARNING, "Not enabling bundled GraalVM/polyglot infrastructure, unable to initialize languages: {0}", err.getMessage());
LOG.log(Level.WARNING, "Stacktrace: ", err);
disable = err;
}
return arr;
Expand Down

0 comments on commit 0389c34

Please sign in to comment.