Top Description Fields Constructors Methods
org.apache.bcel.verifier.structurals

public Class OperandStack

extends Object
implements Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable
Imports
java.util.ArrayList, org.apache.bcel.generic.ObjectType, .ReferenceType, .Type, org.apache.bcel.verifier.exc.AssertionViolatedException, .StructuralCodeConstraintException

This class implements a stack used for symbolic JVM stack simulation. [It's used as an operand stack substitute.] Elements of this stack are Type objects.

Field Summary

Modifier and TypeField and Description
private final int
maxStack

The maximum number of stack slots this OperandStack instance may hold.

private ArrayList<Type>
stack

We hold the stack information here.

Constructor Summary

AccessConstructor and Description
public
OperandStack(final int maxStack)

Creates an empty stack with a maximum of maxStack slots.

public
OperandStack(final int maxStack, final ObjectType obj)

Creates an otherwise empty stack with a maximum of maxStack slots and the ObjectType 'obj' at the top.

Method Summary

Modifier and TypeMethod and Description
public void
clear()

Clears the stack.

public Object
clone()

Overrides java.lang.Object.clone.

Returns a deep copy of this object; that means, the clone operates on a new stack.
public boolean
equals(final Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Returns true if and only if this OperandStack equals another, meaning equal lengths and equal objects on the stacks.
public OperandStack
getClone()

Returns a (typed!) clone of this.

public int

Returns:

a hash code value for the object.
hashCode
()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
public void
initializeObject(final UninitializedObjectType u)

Deprecated as a consequence of UninitializedObjectType being deprecated.
Replaces all occurrences of u in this OperandStack instance with an "initialized" ObjectType.
public boolean
isEmpty()

Returns true IFF this OperandStack is empty.

public int
maxStack()

Returns the number of stack slots this stack can hold.

public void
merge(final OperandStack s)

Merges another stack state into this instance's stack state.

public Type
peek()

Returns the element on top of the stack.

public Type
peek(final int i)

Returns the element that's i elements below the top element; that means, iff i==0 the top element is returned.

public Type
pop()

Returns the element on top of the stack.

public Type

Returns:

Always returns null.
pop
(final int count)

Pops i elements off the stack.

public void
push(final Type type)

Pushes a Type object onto the stack.

public int
size()

Returns the size of this OperandStack; that means, how many Type objects there are.

public int
slotsUsed()

Returns the number of stack slots used.

public String
toString()

Overrides java.lang.Object.toString.

Returns a String representation of this OperandStack instance.
Inherited from java.lang.Object:
finalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

maxStackback to summary
private final int maxStack

The maximum number of stack slots this OperandStack instance may hold.

stackback to summary
private ArrayList<Type> stack

We hold the stack information here.

Constructor Detail

OperandStackback to summary
public OperandStack(final int maxStack)

Creates an empty stack with a maximum of maxStack slots.

OperandStackback to summary
public OperandStack(final int maxStack, final ObjectType obj)

Creates an otherwise empty stack with a maximum of maxStack slots and the ObjectType 'obj' at the top.

Method Detail

clearback to summary
public void clear()

Clears the stack.

cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

Returns a deep copy of this object; that means, the clone operates on a new stack. However, the Type objects on the stack are shared.

Returns:Object

Doc from java.lang.Object.clone.

a clone of this instance.

Annotations
@Override
equalsback to summary
public boolean equals(final Object o)

Overrides java.lang.Object.equals.

Returns true if and only if this OperandStack equals another, meaning equal lengths and equal objects on the stacks.

Parameters
o:Object

Doc from java.lang.Object.equals.

the reference object with which to compare.

Returns:boolean

Doc from java.lang.Object.equals.

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getCloneback to summary
public OperandStack getClone()

Returns a (typed!) clone of this.

See Also
clone()
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for the object.

Annotations
@Override
initializeObjectback to summary
public void initializeObject(final UninitializedObjectType u)

Deprecated

as a consequence of UninitializedObjectType being deprecated. See corresponding docs for further information.

Replaces all occurrences of u in this OperandStack instance with an "initialized" ObjectType.

isEmptyback to summary
public boolean isEmpty()

Returns true IFF this OperandStack is empty.

maxStackback to summary
public int maxStack()

Returns the number of stack slots this stack can hold.

mergeback to summary
public void merge(final OperandStack s)

Merges another stack state into this instance's stack state. See the Java Virtual Machine Specification, Second Edition, page 146: 4.9.2 for details.

peekback to summary
public Type peek()

Returns the element on top of the stack. The element is not popped off the stack!

peekback to summary
public Type peek(final int i)

Returns the element that's i elements below the top element; that means, iff i==0 the top element is returned. The element is not popped off the stack!

popback to summary
public Type pop()

Returns the element on top of the stack. The element is popped off the stack.

popback to summary
public Type pop(final int count)

Pops i elements off the stack. Always returns null.

Returns:Type

Always returns null.

pushback to summary
public void push(final Type type)

Pushes a Type object onto the stack.

sizeback to summary
public int size()

Returns the size of this OperandStack; that means, how many Type objects there are.

slotsUsedback to summary
public int slotsUsed()

Returns the number of stack slots used.

See Also
maxStack()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a String representation of this OperandStack instance.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object.

Annotations
@Override