Neither, He was upholding the Law:
5 “Now Moses, in the law, commanded us that such should be stoned. But what do You say?”
6 This they said, testing Him, that they might have something of which to accuse Him. But Jesus stooped down and wrote on the ground with His finger, as though He did not hear.
7 So when they continued asking Him, He raised Himself up and said to them, "He who is without sin among you, let him throw a stone at her first."
8 And again He stooped down and wrote on the ground.
9 Then those who heard it, being convicted by their conscience, went out one by one, beginning with the oldest even to the last. And Jesus was left alone, and the woman standing in the midst.
10 When Jesus had raised Himself up and saw no one but the woman, He said to her, “Woman, where are those accusers of yours? Has no one condemned you?”
11 She said, “No one, Lord.” And Jesus said to her, “Neither do I condemn you; go and sin no more.”
(Jn. 8:5-11 NKJ)
The Law required stoning of the guilty, by the innocent:
"The hands of the witnesses shall be the first against him to put him to death, and afterward the hands of all the people. So you shall put away the evil from among you. (Deut. 17:7 NKJ) (also Deut. 13:9)
Those who brought her to Jesus were guilty of lawbreaking, they failed to bring the man also to be stoned (Lev. 20:10) or do the stoning themselves. They are lawbreakers, sinners.
As Jesus wrote scriptures on the ground they broke, they realized she wasn’t the only one worthy of being stoned.
As the Messiah, Jesus could forgive sins (Deut. 18:15; Mat. 9:6) and so He was acting lawfully when He forgave her sins.