That's fine, but it can seem to take an object:
Jim: Yesterday I wondered what that mark on the wall was made by
Dave: I wondered the same thing this morning
There you see wonder taking the object the same thing. This can be shown to be an object because it can replace an object for use with a transitive verb:
Jim: Yesterday I took a torch to the caves
Dave: I took the same thing this morning
It is clearly not an adverb there because *"I took quickly this morning" doesn't make sense.
This seems to work similarly with other intransitive verbs:
This plant ages quickly in sunlight and that plant ages the same way.
In the sentence "I walked the same way" is the same way an adverb or a noun phrase? How about "I walked the same route"?
So is "the same X" adverbial in some contexts and an object in others? Does this type of construct have a special name?