Forum: JRuby JRuby 1.1.6 - Fixnum to class java.lang.Number error

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
1b859a9a7fbd1a98246086695906cfa4?d=identicon&s=25 kain (Guest)
on 2008-12-27 15:17
(Received via mailing list)
I'm using JFreeChart and with code tha creates dataset:

def createDataset

        result = Chart::DefaultPieDataset.new

        $p.each do |x|
              result.setValue(x.name, x.length)
        end

        return result

end

I'm getting the following message:

C:\Documents and Settings\Marcin\Pulpit\Algosymulink\data>jruby main.rb
Exception in thread "AWT-EventQueue-0" p_piechart.rb:20:in
`createDataset':
coul
d not coerce Fixnum to class java.lang.Number (TypeError)
        from p_piechart.rb:19:in `each'
        from p_piechart.rb:19:in `createDataset'
        from p_piechart.rb:30:in `updateChart'
        from p_dane.rb:493:in `accept_data'
        from p_dane.rb:493:in `each'
        from p_dane.rb:493:in `accept_data'
        from p_dane.rb:395:in `test_data'
        from p_dane.rb:89:in `create_buttons'
        from :1
        ...internal jruby stack elided...
        from JPieChart3D.createDataset(p_piechart.rb:19)
        from Array.each(p_piechart.rb:19)
        from JPieChart3D.createDataset(p_piechart.rb:30)
        from JPieChart3D.updateChart(p_dane.rb:493)
        from DanePanel.accept_data(p_dane.rb:493)
        from Array.each(p_dane.rb:493)
        from DanePanel.accept_data(p_dane.rb:395)
        from DanePanel.test_data(p_dane.rb:89)
        from DanePanel.create_buttons(:1)
        from (unknown).(unknown)(:1)

When I use jruby-complete-1.1.6 that error doesn't show. With previous
1.1.5
release both "jruby main.rb" and "java -jar jruby-complete-1.1.5
main.rb"
worked fine.

Is it a JRuby 1.1.6 bug ?

Marcin.
--
View this message in context:
http://www.nabble.com/JRuby-1.1.6---Fixnum-to-clas...
Sent from the JRuby - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Ede2aa10c6462f1d825143879be59e38?d=identicon&s=25 Charles Oliver Nutter (Guest)
on 2008-12-28 22:45
(Received via mailing list)
kain wrote:
>
> Is it a JRuby 1.1.6 bug ?

It sure sounds like it. Can you report it and hopefully reduce it to a
simple case that doesn't require jfreechart?

- Charlie

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
2a79a6ae4b858079dbf6587b50779e8f?d=identicon&s=25 huan yang (Guest)
on 2008-12-29 02:16
(Received via mailing list)
try:
$p.each do |x|
     result.setValue(x.name, new JavaLang::Integer(x.length))
     #or result.setValue(x.name, new java.lang.Integer(x.length))
     #or result.setValue(x.name, new java.lang.Double(x.length)) and so
on
end


kain wrote:
>
>         from p_piechart.rb:19:in `each'
>         from Array.each(p_piechart.rb:19)
> 1.1.5 release both "jruby main.rb" and "java -jar jruby-complete-1.1.5
> main.rb" worked fine.
>
> Is it a JRuby 1.1.6 bug ?
>
> Marcin.
>

--
View this message in context:
http://www.nabble.com/JRuby-1.1.6---Fixnum-to-clas...
Sent from the JRuby - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
1b859a9a7fbd1a98246086695906cfa4?d=identicon&s=25 kain (Guest)
on 2008-12-29 13:08
(Received via mailing list)
Charles Oliver Nutter-2 wrote:
>> When I use jruby-complete-1.1.6 that error doesn't show. With previous
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>
>
>

java.lang.Integer.new(x.length) solves the problem so there is no point
in
bothering with that. I haven't noticed that argument must be
java.lang.Number type - sorry my mistake.

Thanks
Marcin
--
View this message in context:
http://www.nabble.com/JRuby-1.1.6---Fixnum-to-clas...
Sent from the JRuby - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Ede2aa10c6462f1d825143879be59e38?d=identicon&s=25 Charles Oliver Nutter (Guest)
on 2008-12-29 22:24
(Received via mailing list)
kain wrote:
> java.lang.Integer.new(x.length) solves the problem so there is no point in
> bothering with that. I haven't noticed that argument must be
> java.lang.Number type - sorry my mistake.

I think you could file a bug anyway; seems like we could automatically
coerce numeric types to their nearest equivalent Number type. Good idea?

- Charlie

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
This topic is locked and can not be replied to.