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

Using ScriptEngineManager to eval a class script file returns null #22

Open
jpicklyk opened this issue Apr 25, 2023 · 0 comments
Open

Comments

@jpicklyk
Copy link

jpicklyk commented Apr 25, 2023

Kotlin version 1.8.20

Simple class defined in a file called simple.kts
class Test {
val x = 5
}

Testing the Script Engine Manager using the following:
@test
fun testClassCompile() {
val scriptReader = this::class.java.classLoader.getResource("simple.kts").openStream().reader()
val engine = ScriptEngineManager().getEngineByExtension("kts")
try {
val result = engine.eval(scriptReader)
assertNotNull(result)
}catch (se: ScriptException) {
fail()
}
}

If I am not mistaken this test should be returning an Object of type Class and not null. Please correct me if I am incorrect or have misunderstood how to get the Class object back.

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

1 participant