text: Details
  - Type:
  Bug
  - Status:
  Resolved
  - Priority:
  Major
  - Resolution: Fixed
  - Affects Version/s: JRuby 1.4
  - Fix Version/s: JRuby 1.7.0.pre1
  - Component/s: None
  - Labels:None
  - Environment:java 1.6.0_10, ubuntu 8.10
  - Testcase included:
  - Number of attachments :
  Description
  If you try to assign a java String to a java static field of type Integer an IllegalArgumentException is raised. However if you wrap that code in begin/rescue, the rescue block is never executed and basically your program crashes.
  Example:
  If you have the following java class:
  package com.mycompany public class SomeClass { public static Integer staticIntegerField = null; }
  and then try and run the ruby code below, the rescue block will not get called.
  def this_will_crash Java::com.mycompany.SomeClass.staticIntegerField = Java::java.lang.String.new("blah") rescue Exception => ex # this will not get executed puts "Phew. I caught the error" end
  Additional Notes
  I've attached a test case patch.
  Activity
  Needs a spec, but it's working in 1.4.
  On second this, this should probably be raising a normal Ruby error like TypeError, rather than just failing over to the Java error. I've made this fix in 007b8e9, but this still needs a spec. Since a missing spec will not block 1.5, I'm punting off that release.
  For JRuby 1.7, we now propagate the actual error, and for JRuby 1.6 we made rescue of Object or Exception also rescue Java errors.
  Dammit. Forgot to hit preview.
  The example was supposed to look like:
  Example:
  If you have the following java class:
  and then try and run the ruby code below, the rescue block will not get called.