public Object invoke(Object proxy, Method method, Object[] args) throws LuaException
  {
    synchronized(obj.L)
    {
	  	String methodName = method.getName();
	  	LuaObject func    = obj.getField(methodName);
	  	
	  	if ( func.isNil() )
	  	{
	  		return null;
	  	}
	  	
	  	Class retType = method.getReturnType();
	  	Object ret;

	  	// Checks if returned type is void. if it is returns null.
	  	if ( retType.equals( Void.class ) || retType.equals( void.class ) )
	  	{
	  		func.call( args , 0 );
	  		ret = null;
	  	}
	  	else
	  	{
	  		ret = func.call(args, 1)[0];
	  		if( ret != null && ret instanceof Double )
	  		{
	  		  ret = LuaState.convertLuaNumber((Double) ret, retType);
	  		}
	  	}
	  	
	  	return ret;
	  }
  }