public synchronized Object toJavaObject( int idx ) throws LuaException
	{
		Object obj = null;

		if (isBoolean(idx))
		{
			obj = new Boolean(toBoolean(idx));
		}
		else if (type(idx) == LuaState.LUA_TSTRING.intValue())
		{
			obj = toString(idx);
		}
		else if (isFunction(idx))
		{
			obj = getLuaObject(idx);
		}
		else if (isTable(idx))
		{
			obj = getLuaObject(idx);
		}
		else if (type(idx) == LuaState.LUA_TNUMBER.intValue())
		{
				obj = new Double(toNumber(idx));
		}
		else if (isUserdata(idx))
		{
			if (isObject(idx))
			{
				obj = getObjectFromUserdata(idx);
			}
			else
			{
				obj = getLuaObject(idx);
			}
		}
		else if (isNil(idx))
		{
			obj = null;
		}

		return obj;
	}