oracle/graal · error · RuntimeException

No instance of Polyglot can be created

Error message

No instance of Polyglot can be created

What it means

Error "No instance of Polyglot can be created" thrown in oracle/graal.

Source

Thrown at espresso/src/com.oracle.truffle.espresso.polyglot/src/com/oracle/truffle/espresso/polyglot/Polyglot.java:68

 * Foreign values, obtained from {@link Polyglot#eval} or {@link Polyglot#importObject}, are
 * returned as {@link Object}. There are two options to make their members accessible from Espresso:
 * <ul>
 * <li>{@link Polyglot#cast Polyglot.cast} the object to a Java interface. In this case, method
 * calls to the interface methods will be forwarded to the foreign object.
 * <li>{@link Polyglot#cast Polyglot.cast} the object to a Java class. In this case, accesses to the
 * class fields will be forwarded to the foreign object, but the Java implementations of the methods
 * will be used.
 * </ul>
 * Casting to abstract classes is not supported.
 * <p>
 * NB: for Java code running in Espresso, these methods will be intrinsified. Otherwise
 * multi-language environment is not available.
 *
 * @since 21.0
 */
public final class Polyglot {
    private Polyglot() {
        throw new RuntimeException("No instance of Polyglot can be created");
    }

    /**
     * Tests if an object is a foreign value, i.e. originates from a different Truffle language.
     *
     * @since 21.0
     */
    @SuppressWarnings("unused")
    public static boolean isForeignObject(Object object) {
        return false;
    }

    /**
     * If a regular {@link Class#cast} of {@code value} to {@code targetClass} succeeds,
     * {@code Polyglot.cast} succeeds too.
     *
     * In addition, if {@code value} is a {@link Polyglot#isForeignObject foreign} object:
     * <ul>

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Fix the condition reported by the error: No instance of Polyglot can be created
  2. Check the throwing call site and ensure its documented preconditions (argument values, types, environment, or configuration) are satisfied before the call.

Example fix

Validate inputs and environment so that the failing condition does not occur: No instance of Polyglot can be created

When it happens

Trigger: Thrown at espresso/src/com.oracle.truffle.espresso.polyglot/src/com/oracle/truffle/espresso/polyglot/Polyglot.java:68 when the library encounters an invalid state.

Common situations: Occurs when a caller violates the contract guarded by this check: No instance of Polyglot can be created


AI-assisted analysis of oracle/graal@a66e9ccd1d (2026-08-14). Data as JSON: /api/errors/1d477d5a7895eefe. Report an issue: GitHub.