Method and device for implementing push and pop
The invention discloses a method and a device for implementing push and pop. The method comprises: when a push Reference is received, calculating a first check value according to a first object reference in the push Reference, combining the first check value with the first object reference, and writing the combined data into a stack in sequence; when a pop Reference is received, reading data from the stack according to the principle of first in last out, acquiring a second check value and a second object reference from the read data, calculating a third check value according to the acquired second object reference, judging that the calculated third check value and the acquired second check value are the same, and returning the acquired second object reference. According to the scheme, when the pop Reference is received, the second check value is compared with the third check value, and the second object reference is returned when the second check value and the third check value are the same, so that attackers cannot operate the contents of the objects corresponding to the object references by using push short or push int, and the security is improved.