some nashorn testing

Marcus Lagergren marcus.lagergren at oracle.com
Wed Jan 9 07:50:26 PST 2013


My bad. This actually reproduces through the JSR223 bridge. Must be an eval related problem. I am on it! 

/M


On Jan 9, 2013, at 4:26 PM, Marcus Lagergren <marcus.lagergren at oracle.com> wrote:

> Where did you get/build your nashorn.jar? We'll get proper versioning in there as soon as we've integrated fully with the OpenJDK build system. I still get nothing when I manually build the latest nashorn.jar from the openjdk and run the JS snippet from the command line with java -jar nashorn.jar <program.js>  (Haven't gone through the script engine bridge, but as it seems to be a JavaScript problem it should be sufficient to run it as a standalone script). This very much looks like a bug that I fixed before christmas and pushed into the closed repo - I've verified that it made it into the openjdk source.
> /M
> 
> On Jan 9, 2013, at 3:51 PM, Andreas Rieber <rieberandreas at gmail.com> wrote:
> 
>> Hi Marcus and Remi,
>> 
>> please find attached a better test to reproduce.
>> 
>> Rhino output:
>> -------------
>> data 0 : 1.0
>> data 1 : 2.0
>> data 2 : 3.0
>> 
>> Nashorn output:
>> ---------------
>> Exception in thread "main" java.lang.ClassCastException: Cannot cast jdk.nashorn.internal.objects.NativeArray to [Ljava.lang.Object;
>>   at sun.invoke.util.ValueConversions.newClassCastException(ValueConversions.java:461)
>>   at sun.invoke.util.ValueConversions.castReference(ValueConversions.java:456)
>>   at jdk.nashorn.internal.scripts.Script$\^eval\_.varargFunc(<eval>:10)
>>   at jdk.nashorn.internal.scripts.Script$\^eval\_.runScript(<eval>:13)
>>   at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:359)
>>   at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:310)
>>   at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:438)
>>   at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:423)
>>   at jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:150)
>>   at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
>>   at ObjectArray.main(ObjectArray.java:16)
>> 
>> 
>> 
>> On 09.01.13 08:45, Marcus Lagergren wrote:
>>> Remi, Andreas
>>> 
>>> I can't reproduce your problem running
>>> 
>>> java -jar nashorn.jar script.js
>>> 
>>> where script.js is
>>> 
>>> --
>>> var array;
>>> try {
>>>   array = new (Java.type("java.lang.Object[]"))(len);
>>> } catch (x) {
>>>   array = [];
>>> }
>>> --
>>> 
>>> Do you have a reproducer you can send me ? I know there was a bug regarding array literal types just before Christmas, but it's in the openjdk as far as I can tell.
>>> 
>>> Regards
>>> Marcus
>>> 
>>> 
>>> On Jan 8, 2013, at 10:56 PM, Remi Forax <forax at univ-mlv.fr> wrote:
>>> 
>>>> On 01/08/2013 10:49 PM, Attila Szegedi wrote:
>>>>> Hey Marcus and Jim, this is similar to that bug we saw before with array literals in the ternary operator. Something related to codegen's inference of types…
>>>> a simple workaround is to change the last line
>>>> 
>>>> var array;
>>>> try {
>>>>   array = new (Java.type("java.lang.Object[]"))(len);  // array is Object[]
>>>> } catch (x) {
>>>>   //array = [];                                        // array is NativeArray
>>>>   array = new (Java.type("java.lang.Object[]"))(0);    // array is Object[]
>>>> }
>>>> 
>>>> Rémi
>>>> 
>>>>> On Jan 8, 2013, at 9:30 PM, Andreas Rieber <rieberandreas at gmail.com> wrote:
>>>>> 
>>>>>> I tried some cases and will go for (Nashorn and Rhino):
>>>>>> 
>>>>>>  var array;
>>>>>>  try {
>>>>>>    array = new (Java.type("java.lang.Object[]"))(len);
>>>>>>  } catch (x) {
>>>>>>    array = [];
>>>>>>  }
>>>>>> 
>>>>>> The catch block works with Rhino but gives with Nashorn:
>>>>>> 
>>>>>> Exception in thread "main" java.lang.ClassCastException: Cannot cast jdk.nashorn.internal.objects.NativeArray to [Ljava.lang.Object;
>>>>>>    at sun.invoke.util.ValueConversions.newClassCastException(ValueConversions.java:461)
>>>>>>    at sun.invoke.util.ValueConversions.castReference(ValueConversions.java:456)
>>>>>>    at jdk.nashorn.internal.scripts.Script$main.sprintf(main.js:114)
>>>>>>    at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:350)
>>>>>>    at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:310)
>>>>>>    at jdk.nashorn.internal.objects.NativeFunction.apply(NativeFunction.java:133)
>>>>>> 
>>>>>> 
>>>>>> cheers
>>>>>> Andreas
>>>>>> 
>> <ObjectArray.java>
> 



More information about the nashorn-dev mailing list