Rhino - occurred error when call javascript function with custom class arguments
<p>I made a Bukkit plugin using Java.
And, my plugin is based on Rhino from Mozilla.
I put the argument to "_Player" in function callback "onPlayerJoin".
I executed it, but it was not working ;(</p>

<p><strong>Do you have any idea of this error? or things to modify?</strong></p>

<p>The brief message of the Error is here.</p>

<pre><code>TypeError: Cannot find default value for object. (test.js#1)
</code></pre>

<p>Code(Java):</p>

<pre><code>public static void callMethod(String functionName, Object... args) {
        for(String filename : Main.scripts) {
            Context context = Context.enter();
            Scriptable scope = context.initStandardObjects();

            try {
                ScriptableObject.defineClass(scope, _Bukkit.class);
                ScriptableObject.defineClass(scope, _Player.class, false, true);
                ScriptableObject.putProperty(scope, "ChatColor", constantsToObj(_ChatColor.class));
                context.evaluateReader(scope, new FileReader(FileSystem.LOC_SCRIPT+filename), filename, 0, null);
                Object object = scope.get(functionName, scope);

                if(object != null &amp;&amp; object instanceof Function) {
                    Function function = (Function) object;
                    function.call(context, scope, scope, args);
                }
            } catch(RhinoException e) {
                Debug.danger(e.getMessage()+" ("+e.lineNumber()+", "+e.columnNumber()+")");
            } catch(IOException | IllegalAccessException | InstantiationException | InvocationTargetException e) {
                Debug.danger("An error occured while compiling code.");
            } finally {
                Context.exit();
            }
        }
    }

@EventHandler
public void onPlayerJoin(PlayerJoinEvent e) {
    callMethod("onPlayerJoin", new _Player(e.getPlayer()));
}
</code></pre>

<p>Code-1(Javascript, Not Working):</p>

<pre><code>function onPlayerJoin(player) {
    player.sendMessage("hello!");
}
</code></pre>

<p>Code-2(Javascript, Working):</p>

<pre><code>function onPlayerJoin(player) {
    new Player("playername").sendMessage("hello!");
}
</code></pre>