Given the following line on JRuby 1.6.1, I get a nice Java
NullPointerException for the obvious reason that a string or file object
is required in the constructor…
output_stream = Java::java.io.FileOutputStream.new nil
-> NativeException: java.lang.NullPointerException: null
-> from java.io.FileOutputStream:-1:in `’
If however I do this…
output_stream = Java::java.io.FileOutputStream.new
->ArgumentError: no __jcreate! with arguments matching [] on object
->Java::JavaIo::FileOutputStream
-> from (irb):13:in `evaluate’
…I get something all together more sinister.
I’ve come across this by using attr_accessor within a Rails app and
forgetting to set a value upon it, producing the second stack trace
above.
attr_accessor :file
output_stream = Java::java.io.FileOutputStream.new @file
Is this how I should expect this to behave (and thus I’ll have to rescue
ArgumentError or explicitly initialise @file) or should it really be
throwing a NullPointerException as I originally expected it to.
Cheers