Skip to content
This repository was archived by the owner on Feb 4, 2022. It is now read-only.
This repository was archived by the owner on Feb 4, 2022. It is now read-only.

Returned value is set to null when code contains multiple lines #44

@hadim

Description

@hadim

Consider the following code :

package org.scijava.jupyterkernel.sandbox;

import javax.script.ScriptEngine;
import javax.script.ScriptException;
import org.scijava.Context;
import org.scijava.script.ScriptLanguage;
import org.scijava.script.ScriptService;

/**
 *
 * @author Hadrien Mary
 */
public class TestScriptEngine {

    public static void main(String[] args) throws ScriptException {
        // Only for testing purpose

        Context context = new Context();
        ScriptService scriptService = context.getService(ScriptService.class);
        ScriptLanguage scriptLanguage = scriptService.getLanguageByName("python");
        ScriptEngine engine = scriptLanguage.getScriptEngine();

        Object result = engine.eval("p=999\n555");
        System.out.println(result);

        scriptService = context.getService(ScriptService.class);
        scriptLanguage = scriptService.getLanguageByName("python");
        engine = scriptLanguage.getScriptEngine();
        
        result = engine.eval("555");
        System.out.println(result);

        context.dispose();
    }

}

It returns:

null
555

While it should returns :

555
555

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions