Different Mary, although James and Joseph were considered especially close to Jesus. They were called "brothers of Jesus" in the same vein as the word "brother" is used figuratively today: a bond of friendship close to that of family.
On Mary's perpetual virginity, the Catechism of the Catholic Church states (emphasis mine):
499 The deepening of faith in the virginal motherhood led the Church to confess Mary's real and perpetual virginity even in the act of giving birth to the Son of God made man. In fact, Christ's birth "did not diminish his mother's virginal integrity but sanctified it." And so the liturgy of the Church celebrates Mary as Aeiparthenos, the "Ever-virgin".
500 Against this doctrine the objection is sometimes raised that the Bible mentions brothers and sisters of Jesus. The Church has always understood these passages as not referring to other children of the Virgin Mary. In fact James and Joseph, "brothers of Jesus", are the sons of another Mary, a disciple of Christ, whom St. Matthew significantly calls "the other Mary". They are close relations of Jesus, according to an Old Testament expression.
501 Jesus is Mary's only son, but her spiritual motherhood extends to all men whom indeed he came to save: "The Son whom she brought forth is he whom God placed as the first-born among many brethren, that is, the faithful in whose generation and formation she co-operates with a mother's love."