333 * @param args Call arguments. |
333 * @param args Call arguments. |
334 * @return Call result. |
334 * @return Call result. |
335 */ |
335 */ |
336 public static Object checkAndApply(final ScriptFunction target, final Object self, final Object... args) { |
336 public static Object checkAndApply(final ScriptFunction target, final Object self, final Object... args) { |
337 final ScriptObject global = Context.getGlobalTrusted(); |
337 final ScriptObject global = Context.getGlobalTrusted(); |
338 if (! (global instanceof GlobalObject)) { |
338 assert (global instanceof GlobalObject): "No current global set"; |
339 throw new IllegalStateException("No current global set"); |
|
340 } |
|
341 |
339 |
342 if (target.getContext() != global.getContext()) { |
340 if (target.getContext() != global.getContext()) { |
343 throw new IllegalArgumentException("'target' function is not from current Context"); |
341 throw new IllegalArgumentException("'target' function is not from current Context"); |
344 } |
342 } |
345 |
343 |