-
The Call of ChrismathuluR.J. LorimerFri, Nov 7 2008 @ 2:38 pm
-
Getting True Java Classes in JRubyR.J. LorimerThu, Sep 25 2008 @ 6:41 pm
-
JRuby 1.1.4 ReleasedR.J. LorimerFri, Aug 29 2008 @ 5:41 am
-
My XBoxR.J. LorimerMon, Aug 25 2008 @ 3:22 am
-
Why So Serious?R.J. LorimerSat, Aug 23 2008 @ 5:25 am
JFace + JRuby + TableViewer = Confused Jenius
Ok, so I’m working with SWT/JFace and JRuby, and I have so far implemented a fairly straightforward UI. Unfortunately, no matter what I do, when I run my little GUI program outside of debug mode, my lone TableViewer renders empty. If, however, I run in debug mode, it renders just fine.
Glossing over any minor technical details, it’s a run of the mill JFace TableViewer, backed by a ContentProvider (IStructuredContentProvider, actually) that calls into a Ruby model to get the list of items.
Working with just an SWT table, I was able to implement this very quickly, and everything worked like a charm. I then moved to JFace for the Model/View separation, and now I’m thoroughly stuck. What’s very strange is if I start the JVM in debug mode everything works perfectly. If I just run, however (using the default client VM) everything works fine except the TableViewer never renders my items. If I put debug statements in the ContentProvider I can see it hit getElements(parent), and then I can see it hit the LabelProvider getColumnText(item, idx) method for each item with an index of 0. That’s all it does, however, and then it stops. In debug mode, it will call getColumnText for all items, and it will hit it with each index as well (0 through 5).
So then I think, that’s ok - I’ll just debug the JFace code and figure out why it’s not finishing the rendering loop. Oh wait! If I run in debug it works!
It seemed like it may be a race condition, so I’ve dumped thread name outputs everywhere in the code, and it’s definitely not jumping off into some magic multi-threaded universe - everything is synchronous.
Likewise, I thought maybe it had something to do with JRuby’s JIT code, so I disabled that using the system property jruby.jit.enabled and turned on logging with jruby.jit.logging just to make sure nothing was going - still no good!
I’m officially stumped. I can keep moving forward, but at some point I’d like to stop having to run this in debug mode. Thoughts?

Comments
Classloader?
Sounds like a classloader problem to me. JRuby does some weird stuff with classloaders, even with JITing disabled. Normally it doesn't cause a problem, but if you combine JRuby's classloader tricks with classloader tricks of your own, bad things happen. I honestly don't know if JFace is doing anything weird with classloaders, but that's what I'd look at.
In my experience, the only two things that cause different behavior debug mode vs run mode are race conditions and classloaders. You've already ruled out one. Maybe try the other?