To_java no longer working? ERROR IN TESTING wrong element type class java.lang.String(array contains

Hi I am working on expanding someone else’s code and have been working
with
it for almost a year now. Recently, it just randomly stopped working. I
have
re installed an older version of java to see if it was that, I never
updated
jruby or anything, all I did was install git (version control). I didn’t
really do anything, however it said it will replace LF lines with CRLF
or
something like that. Anyway the code has been running fine for ages, I
haven’t made any modifications and I go to run a test yesterday and I
get
this:

This error message is on my ubuntu machine, however I get a similar
error on
my windows machine (on which the code has been running fine on for
ages):

jruby run.rb test

=================Processing FREDERICKSBURG_1.1=======================
ERROR IN TESTING wrong element type class java.lang.String(array
contains
char)
/home/daryl/Desktop/work/Code/geografikos/lib/sentence_splitter/splitter.rb:21:in
to_java' /home/daryl/Desktop/work/Code/geografikos/lib/sentence_splitter/splitter.rb:21:in split’
/home/daryl/Desktop/work/Code/geografikos/lib/models/page.rb:103:in
sentences' /home/daryl/Desktop/work/Code/geografikos/lib/extractor/lingpipe_svm.rb:34:in extract’
/home/daryl/Desktop/work/Code/geografikos/lib/extractor/geo_controller.rb:9:in
process' /home/daryl/Desktop/work/Code/geografikos/lib/extractor/geo_controller.rb:8:in each’
/home/daryl/Desktop/work/Code/geografikos/lib/extractor/geo_controller.rb:8:in
process' /home/daryl/Desktop/work/Code/geografikos/lib/extractor/geo_controller.rb:6:in each’
/home/daryl/Desktop/work/Code/geografikos/lib/extractor/geo_controller.rb:6:in
process' /home/daryl/Desktop/work/Code/geografikos/lib/statistics.rb:111:in generate_all’
/home/daryl/Desktop/work/Code/geografikos/lib/statistics.rb:105:in
each' /home/daryl/Desktop/work/Code/geografikos/lib/statistics.rb:105:in generate_all’
run.rb:56

The line of code causing the error is:

tokenizer =
IndoEuropeanTokenizerFactory.new.tokenizer(text.split(‘’).to_java(:char),
0,
text.length)

What I need to do is convert individual ruby strings (thus the .split to
split it into characters), and use them as an argument into a java class
(which should be java chars). I have tested the to_java function and I
cannot do something like:

irb(main):002:0> [‘1’,‘2’,‘3’].to_java :char
ArgumentError: wrong element type class java.lang.String(array contains
char)
from (irb):3:in `to_java’
from (irb):3

I have never had this problem before, and the code has been functional
for a
very long time. No changes have been made regarding this class in
general so
I have no idea why it would suddenly stop working. Any help would be
greatly
appreciated.

java version “1.6.0_18”
OpenJDK Runtime Environment (IcedTea6 1.8) (6b18-1.8-0ubuntu1)
OpenJDK 64-Bit Server VM (build 14.0-b16, mixed mode)

View this message in context:
http://old.nabble.com/to_java-no-longer-working--ERROR-IN-TESTING-wrong-element-type-class-java.lang.String(array-contains-char)-tp28893527p28893527.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

On Tue, Jun 15, 2010 at 11:36 AM, peanutcracker1
[email protected] wrote:

irb(main):002:0> [‘1’,‘2’,‘3’].to_java :char
ArgumentError: wrong element type class java.lang.String(array contains
char)
    from (irb):3:in `to_java’
    from (irb):3

You’re sure the JRuby version didn’t change? It looks like something
that regressed, but regressed sometime during the JRuby 1.4 release
and was never caught or reported until now. Here’s JRuby 1.3.1 through
JRuby 1.5.0:

~/projects/jruby âž” …/jruby-1.5.0/bin/jruby -rjava -e “p [‘1’,
‘2’].to_java :char”
-e:1:in `to_java’: cannot convert instance of class
org.jruby.RubyString to char (TypeError)
from -e:1

~/projects/jruby âž” …/jruby-1.4.0/bin/jruby -rjava -e “p [‘1’,
‘2’].to_java :char”
-e:1:in `to_java’: wrong element type class java.lang.String(array
contains char) (ArgumentError)
from -e:1

~/projects/jruby âž” …/jruby-1.3.1/bin/jruby -rjava -e “p [‘1’,
‘2’].to_java :char”
#<#Class:01x122c9df:0xf3552f>

~/projects/jruby âž” …/jruby-1.3.1/bin/jruby -rjava -e “p [‘1’,
‘2’].to_java(:char)[0]”
49

It seems like you must have updated JRuby in order for this to break.
This probably should also be a bug, though you can also just get the
individual bytes and coerce them to char (which will unfortunately
only work for ascii-ranged values).

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Okay so based on what you’re saying, it looks like this should work in
the
1.3.1 version of jruby but not the newer releases?

Charles Oliver N.-4 wrote:

that regressed, but regressed sometime during the JRuby 1.4 release
‘2’].to_java :char"
49

http://xircles.codehaus.org/manage_email


View this message in context:
http://old.nabble.com/to_java-no-longer-working--ERROR-IN-TESTING-wrong-element-type-class-java.lang.String(array-contains-char)-tp28893527p28895588.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

And thus arises the problem that I also need YAML, but apparently that
only
works versions 1.4 and higher on jruby

Charles Oliver N.-4 wrote:

Charles Oliver N.-4 wrote:

that regressed, but regressed sometime during the JRuby 1.4 release
‘2’].to_java :char"
49

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


View this message in context:
http://old.nabble.com/to_java-no-longer-working--ERROR-IN-TESTING-wrong-element-type-class-java.lang.String(array-contains-char)-tp28893527p28896156.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

Yeah, that seems to be the case.

On Tue, Jun 15, 2010 at 2:51 PM, peanutcracker1
[email protected] wrote:

char)
-e:1:in `to_java’: cannot convert instance of class
‘2’].to_java :char"


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

peanutcracker1 wrote:

And thus arises the problem that I also need YAML, but apparently that
only
works versions 1.4 and higher on jruby

If you can convert your types to ruby marshal’ed data (or java
serialized) that would work with older versions of jruby.

-rp