I’m in the process of trying to add native JRuby support to the
ruby-yui-compressor gem, but I’m stumped. I thought this would be a
great chance to both get familiar with JRuby and do something really
useful at the same time, and I’ve gotten most of the way there.
There’s just one last snag (I think).
I’ve reduced the problem to a simple test case you can find at http://github.com/mjijackson/jruby-yuicompressor. If you run the
test.rb file with the latest JRuby, you’ll see what I mean. There’s an
exception being thrown from within the Java code. I think it’s being
caused by some error on the input stream, though I’ve checked the
input stream with a normal read loop (from Ruby land) and it works
just fine.
If someone with a bit more JRuby/Java experience would kindly take a
look at this, I’d appreciate it very much. BTW, here’s my `ruby -v’.
jruby 1.5.1 (ruby 1.8.7 patchlevel 249) (2010-06-06 f3a3480) (Java
HotSpot™ 64-Bit Server VM 1.6.0_20) [x86_64-java]
Sorry. I should have included it in the first email. Here’s what I get.
$ ruby -v test.rb
jruby 1.5.1 (ruby 1.8.7 patchlevel 249) (2010-06-06 f3a3480) (Java
HotSpot™ 64-Bit Server VM 1.6.0_20) [x86_64-java]
com/yahoo/platform/yui/compressor/JavaScriptCompressor.java:299:in printSourceNumber': java.lang.RuntimeException: null (NativeException) from com/yahoo/platform/yui/compressor/JavaScriptCompressor.java:336:in parse’
from
com/yahoo/platform/yui/compressor/JavaScriptCompressor.java:533:in <init>' from sun/reflect/NativeConstructorAccessorImpl.java:-2:in newInstance0’
from sun/reflect/NativeConstructorAccessorImpl.java:39:in newInstance' from sun/reflect/DelegatingConstructorAccessorImpl.java:27:in newInstance’
from java/lang/reflect/Constructor.java:513:in newInstance' from org/jruby/javasupport/JavaConstructor.java:291:in newInstanceDirect’
from test.rb:12:in `new_proxy’
from test.rb:28
I also tried your repo and could not get it to fail. I even changed
some of the source around like adding a couple of var statements
including assignments. Are you getting this error with source other
than what you provided because the stacktrace you reported seems to be
choking on a Token.Number in the Java side of things and although I
don’t know what this token represents there does not appear to be a
number in test.js.
Brainstorming:
There is an interesting environmental difference (ENV or -D you are
always running)
There is a bug in the parser code itself in yuicompressor and you
are using some source which hits it and not test.js
You are using a charset we are (JRuby) doing something bad to?
-Tom
On Sun, Jul 18, 2010 at 7:53 AM, Michael J. [email protected]
wrote:
`printSourceNumber’: java.lang.RuntimeException: null
from test.rb:28
On Sun, Jul 18, 2010 at 6:50 AM, Michael J. [email protected]
wrote:
from com/yahoo/platform/yui/compressor/JavaScriptCompressor.java:336:in `parse'
–
put it works fine here. Perhaps something is wrong in your classpath.
jruby 1.5.1 (ruby 1.8.7 patchlevel 249) (2010-06-06 f3a3480) (Java
ruby-yui-compressor gem, but I’m stumped. I thought this would be a
just fine.
Michael J.
Thanks for giving it a try. I’m using the code exactly as provided in
the repo, without any modifications. I can understand how you thought
it was a strange error because there aren’t any numbers. I thought the
same thing.
The only thing that I can think of about my environment that isn’t
exactly standard is that I’m using JRuby as installed by RVM instead
of installing it myself. However, I have tried downloading and
installing JRuby from jruby.org with the same result.
As far as character sets go, Vim tells me that both files (test.rb and
test.js) are encoded using utf-8.
I know that’s not a lot to go on. Any other ideas?