Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

in Graal 20.x, getMetaObject returns null when called on a polyglot Value representing an ES module #313

Open
ispringer opened this issue Jun 29, 2020 · 0 comments
Assignees

Comments

@ispringer
Copy link

In Graal 19.3, getMetaObject returned a meta object, and we could check if a Value was a module using value.getMetaObject().toString().equals("Module"). In Graal 20.x, getMetaObject returns null, so have to check if a Value is a module using value.toString().equals("[Module]").

This change broke our code in several places. Was the change in behavior intentional?

Here is a failing Groovy test that demonstrates the issue:

@Test
void "Value#getMetaObject returns a non null value for an ES module"() {
    def vfs = new PolyglotInMemoryOnlyFileSystem()

    context = Context.newBuilder("js")
            .allowHostAccess(true)
            .option("js.ecmascript-version", "11") // ES2020 is required for import() call support
            .allowIO(true)
            .fileSystem(vfs)
            .build()

    addModule(vfs, "export function howGreat() { return 'funktastic!'; }", "funky/index")

    Source importSource = Source.newBuilder("js", "import * as Module from 'funky';\n" + "Module;\n", "funky.mjs")
            .build()
    def module = context.eval(importSource)

    // The below assertion fails on Graal 20.x.
    assert module.getMetaObject() != null
}
@woess woess self-assigned this Oct 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants