Java / GraalVM Interview questions
Describe the polyglot Context API?
org.graalvm.polyglot.Context is the main entry point for embedding and running guest languages from Java host code.
try (Context context = Context.create()) { Value result = context.eval("js", "1 + 2"); System.out.println(result.asInt()); }
A Context represents an isolated execution environment for one or more guest languages - it controls what host classes the guest code can access, whether native access or I/O is permitted, and resource limits like max statements executed.
Values returned from guest code come back wrapped as Value objects, which provide type-safe conversion methods (asInt(), asString(), as(MyInterface.class)) so Java code doesn't need to know the guest language's native representation directly.
More Related questions...