Weird ClassCastException

A. Sundararajan sundararajan.athijegannathan at oracle.com
Tue Nov 5 02:41:09 PST 2013


Thanks. Filed https://bugs.openjdk.java.net/browse/JDK-8027828 to track 
this issue.

-Sundar

On Tuesday 05 November 2013 02:47 PM, Tal Liron wrote:
> OK, after some work I've managed to isolate the bug. This short 
> program will cause the exception:
>
> var x = new java.util.HashMap()
> x.put('test', new java.io.File('test'))
> if (x.get('test')) {
>   print('Found!')
> }
>
> The issue seems to be with *casting return values of Java methods* 
> (which should cast to boolean; I don't know why it tries to cast to a 
> java.langNumber). Simple casting a Java object won't cause the exception.
>
> I'll remind you that this bug appeared only in a recent commit (last 
> few days).
>
> On 11/05/2013 03:39 PM, A. Sundararajan wrote:
>> No, it is hard to debug with cast issue without access to code.
>



More information about the nashorn-dev mailing list