TypeError: I could use some explanation
Sundararajan Athijegannathan
sundararajan.athijegannathan at oracle.com
Wed Dec 16 14:41:51 UTC 2015
If the script function t4 expects that "t4_context" is a script object
and so calls Object.prototype function or any JS function that expects
"this" to be a script object, you'll get a TypeError (per spec.). We
need bit more information on the code of "t4" to help further.
-Sundar
On 12/16/2015 7:31 PM, Kasmeroglu, Daniel wrote:
> Hi there,
>
> First of all: thanks for the great work with Nashorn.
> Unfortunately I'm currently a little bit stuck as I don't get what I'm
> doing wrong here.
> Here's a simple code snippet that explains what I'm doing:
>
> --<8--
> ScriptEngine engine = ...
> Map<String, Object> context = ...
> engine.put("t4_context", context);
> engine.eval("t4(t4_context);");
> --8>--
>
> The variable 't4' is a compiled template generated through Handlebars
> (so it's a function taking a hash).
> Unfortunately I don't get it running as there's the following complain:
>
> --<8--
> Caused by: <function>:30 TypeError: {assets=dodo} is not an Object
> --8>--
>
> It's clear to me that the issue is caused since the java object
> 'context' isn't an instance of 'ScriptObject'. However it isn't clear to
> me why this happens.
>
> It would be nice to give me a hint of what I'm doing wrong or to point
> me to some helpful documentation.
>
> Thanks in advance.
>
>
More information about the nashorn-dev
mailing list