You may have stumbled over this problem already or have seen that question here in the forum. I recently came across it myself in Alon's article. I wanted to change the "Occurrence" of a failure mode. So I started with a simple thing like:
var fm = selection[0];
fm.rawOccurrence = 2;
However, that fails miserably with "java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Integer". Reason is that Java Script only knows Double as the only Number type, while "Occurrence" is defined as an Integer value.

Next thing I tried was using parseInt but that fails with the same error. background is that the Rhino engine converts any Number (and Integer *is* a Number too) into a Double when crossing the border between script and Java realm.
Next I tried to make usage of the java.lang.Integer wrapper class which is left untouched by Rhino, and voila, it works well:
var fm = selection[0];
fm.rawOccurrence = new java.lang.Integer(4);
Its not ideal and we may introduce some means to force Rhino to keep Integer values as they are but for time being its a valid solution.
Happy Scripting
Jan