Different overloaded Java methods called when JVM runs in client or server mode 
on Solaris
------------------------------------------------------------------------------------------

                 Key: JRUBY-4905
                 URL: http://jira.codehaus.org/browse/JRUBY-4905
             Project: JRuby
          Issue Type: Bug
          Components: Java Integration
    Affects Versions: JRuby 1.5.1
         Environment: Solaris 5.10
JDK 1.5.0_15-b04 and 1.5.0_12-b04
JFreeChart 1.0.12
            Reporter: Brent Snook
            Priority: Minor
         Attachments: jcommon-1.0.15.jar, jfreechart-1.0.12.jar

Calling the overloaded addValue() method in a JFreeChart DefaultCategoryDataset 
(http://www.jfree.org/jfreechart/api/javadoc/org/jfree/data/category/DefaultCategoryDataset.html)
 running the JVM in client and server mode seems to result in different 
results. The method has two versions that take a java.lang.Number and double 
primitive.

Running in server mode results in a TypeError:

{code}
export CLASSPATH=.:jfreechart-1.0.12.jar:jcommon-1.0.15.jar:$CLASSPATH
jruby --server $JRUBY_HOME/bin/jirb

irb(main):001:0> require 'java'
=> true
irb(main):002:0> import 'org.jfree.data.category.DefaultCategoryDataset'
=> ["org.jfree.data.category.DefaultCategoryDataset"]
irb(main):003:0> DefaultCategoryDataset.new.add_value 5, :thing, "key"
TypeError: could not coerce Fixnum to class java.lang.Number
        from (irb):3
{code}

This leads me to believe that it is attempting to call the Number version of 
addValue(). Doing the same running in client mode results in no problems, which 
in turn makes me think that in this case it is calling the double version.

The problem has surfaced since an upgrade from JRuby 1.3 to 1.5.1.

I can't reproduce this with a simplified Java class example which leads me to 
believe that the JFreeChart library may also have something to do with it.

I've also tried to reproduce this on Ubuntu 10.4 with JDK 1.5.0_16-b02 but it 
only seems to affect Solaris.

We have this problem in combination with [JRUBY-3279]. Our work-around is to 
force a call of the Number signature of the method along with an explicit cast 
to Integer:
{code}
  class CategoryDataset < org.jfree.data.category.DefaultCategoryDataset
    def add_integer_value(value, row_key, column_key)
      signature = [java.lang.Number.java_class, 
java.lang.Comparable.java_class, java.lang.Comparable.java_class]
      java_send(:addValue, signature, value.to_java(java.lang.Integer), 
row_key, column_key)
    end
  end
{code}

JFreeChart jars are attached; drop them into a directory and run example above 
under Solaris 5.10 to reproduce.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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

    http://xircles.codehaus.org/manage_email


Reply via email to