http://jira.codehaus.org/ is returning a 404 for me, so sending this
here first. Also please advise, is this best as one or two bugs?
Thanks for JRuby 1.5.0.RC1. It gave me pause to figure out:
-
An apparent long standing asymmetry in java class comparison (which I
had previously unwittingly worked around with to_java_object.) -
The JRuby method to_java_object is no longer exposed in JRuby
1.5.0.RC1 (intended?)
Test code with comments below, followed by output:
Foo.java::
public class Foo {
public Class valueType()
{
return Integer.class;
}
}
test_java_class_object.rb::
#!/usr/bin/env jruby
#.hashdot.profile += jruby-shortlived
require ‘java’
require ‘test/unit’
class TestJavaClassObject < Test::Unit::TestCase
import ‘Foo’
Works in Jruby 1.4.0, 1.5.0.RC1!
def test_class_from_java_left
assert_equal( Foo.new.value_type, Java::java.lang.Integer.java_class
)
end
Fails in both Jruby 1.4.0, 1.5.0.RC1!
def test_class_from_java_right
assert_equal( Java::java.lang.Integer.java_class, Foo.new.value_type
)
end
The workaround was to use to_java_object, but this doesn’t exist in
Jruby 1.5.0.RC1:
def test_class_from_java_right_obj
assert_equal( Java::java.lang.Integer.java_class,
Foo.new.value_type.to_java_object )
end
end
% javac Foo.java
% jruby-1.4 ./test_java_class_object_2.rb
Loaded suite ./test_java_class_object_2
Started
.F.
Finished in 0.082 seconds.
- Failure:
test_class_from_java_right(TestJavaClassObject)
[./test_java_class_object_2.rb:17]:
expected but was
.
3 tests, 3 assertions, 1 failures, 0 errors
% jruby-1.5 ./test_java_class_object_2.rb
Loaded suite ./test_java_class_object_2
Started
.FE
Finished in 0.125 seconds.
-
Failure:
test_class_from_java_right(TestJavaClassObject)
[./test_java_class_object_2.rb:17]:
expected but was
. -
Error:
test_class_from_java_right_obj(TestJavaClassObject):
NoMethodError: undefined methodto_java_object' for class java.lang.Integer:Java::JavaLang::Class ./test_java_class_object_2.rb:23:in
test_class_from_java_right_obj’
3 tests, 2 assertions, 1 failures, 1 errors