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

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-class-java.lang.Number-error-tp21184430p21184430.html
Sent from the JRuby - User mailing list archive at Nabble.com.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

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

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-class-java.lang.Number-error-tp21184430p21197901.html
Sent from the JRuby - User mailing list archive at Nabble.com.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

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

Charles Oliver N.-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-class-java.lang.Number-error-tp21184430p21202350.html
Sent from the JRuby - User mailing list archive at Nabble.com.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email