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.

Andrew Davey
added a comment - 08/Sep/09 8:29 AM Dammit. Forgot to hit preview.
The example was supposed to look like:
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

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.

Charles Oliver Nutter
added a comment - 07/Mar/10 4:53 PM 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.