I have a great-great-grandfather John Leary, whose existence I know of through his children's baptism records, the earlier of whom was born in 1837, wife Catherine Ryan.
Nothing turned up for a marriage under this name (only 2 likely matches both in Cork); However, I did find a James Leary & Catherine Ryan, married in 1837 in the same parish.
Doing a search for children, I could none associated with a James Leary & Catherine Ryan.
For now does the balance of probability suggest James is John?
Possibly - priest could have made a mistake in the first name, also, depends on how clear the handwriting is. Sometimes James is recorded as Jas, John as Jno.... it can be hard to read the scrawl.
I've just looked at an English baptism record where the child and father are recorded with the mother's surname, so mistakes happen.
In this particular case it's definitely a legible "James" but maybe still possibly a mixup.