Package org.plumelib.bcelutil
Class StackVer
java.lang.Object
org.plumelib.bcelutil.StackVer
This is a slightly modified version of Pass3bVerifier from BCEL. It uses NoConstaintsVisitor as
InstConstraintVisitor appears to be quite out of date and incorrectly fails on many valid class
files. Hence, StackVer assumes the method is valid and is only interested in the result of the
symbolic execution in order to capture the state of the local variables and stack at the start of
each byte code instruction.
To see the diffs, you will need a git clone of git@github.com:apache/commons-bcel.git. The
particular version StackVer is based on can be retrieved with
git show e6dcacb9ca1d:src/main/java/org/apache/bcel/verifier/structurals/Pass3bVerifier.java
then run google-java-format on the downloaded file.
The original documentation follows.
This PassVerifier verifies a method of class file according to pass 3, so-called structural verification as described in The Java Virtual Machine Specification, 2nd edition. More detailed information is to be found at the do_verify() method's documentation.
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addMessage
(String message) This method adds a (warning) message to the message pool of this PassVerifier.org.apache.bcel.verifier.VerificationResult
do_stack_ver
(org.apache.bcel.generic.MethodGen mg) Pass 3b implements the data flow analysis as described in the Java Virtual Machine Specification, Second Edition.Return the types on the stack at each byte code offset.void
invalidReturnTypeError
(org.apache.bcel.generic.Type returnedType, org.apache.bcel.generic.MethodGen m) Throws an exception indicating the returned type is not compatible with the return type of the given method.
-
Constructor Details
-
StackVer
public StackVer()This class should only be instantiated by a Verifier.- See Also:
-
-
Method Details
-
get_stackTypes
Return the types on the stack at each byte code offset. Only valid after do_stack_ver() is called.- Returns:
- the StackTypes object for the method being verified
-
invalidReturnTypeError
public void invalidReturnTypeError(org.apache.bcel.generic.Type returnedType, org.apache.bcel.generic.MethodGen m) Throws an exception indicating the returned type is not compatible with the return type of the given method.- Parameters:
returnedType
- the type of the returned expressionm
- the method we are processing- Throws:
org.apache.bcel.verifier.exc.StructuralCodeConstraintException
- always- Since:
- 6.0
-
do_stack_ver
public org.apache.bcel.verifier.VerificationResult do_stack_ver(org.apache.bcel.generic.MethodGen mg) Pass 3b implements the data flow analysis as described in the Java Virtual Machine Specification, Second Edition. Later versions will use LocalVariablesInfo objects to verify if the verifier-inferred types and the class file's debug information (LocalVariables attributes) match [TODO].- Parameters:
mg
- MethodGen for the method to be verified- Returns:
- the VerificationResult
- See Also:
-
addMessage
This method adds a (warning) message to the message pool of this PassVerifier.- Parameters:
message
- the String containing the warning message
-