Is there any official reference for their action?
Of course there is! It is the JVM specification - specifically section 6.5.
I won't copy it here. Follow the link and read it all yourself. But the basic idea is that the dup_x1
and dup_x2
variants are inserting the duplicate value/values lower down the stack.
I'm confused, because there's no reason for defining two opcodes for same action.
Look carefully (in the spec). They are not doing the same thing.