|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjasm.util.dfa.ForwardFlowAnalysis<TypeAnalysis.Store>
jasm.verifier.TypeAnalysis
public class TypeAnalysis
A forward flow analysis which determines the type of each variable and stack
location in a given ClassFile.Method
. In the case of a method
which is not well-typed, a verification error is reported. For valid methods,
a StackMapTable
attribute is added to the Code
attribute (and any existing one replaced).
NOTE: this analysis currently has some problems dealing with wide types (i.e. long or double). This is because it does not correctly model the stack (which in their case requires two slots per item).
Nested Class Summary | |
---|---|
protected static class |
TypeAnalysis.Store
An abstract representation of the typing environment used in the JVM bytecode verifier. |
static class |
TypeAnalysis.VerificationException
Indicates that the bytecode being analysis is malformed in some manner. |
Constructor Summary | |
---|---|
TypeAnalysis()
|
Method Summary | |
---|---|
protected void |
addStackMapTable(ClassFile.Method method,
TypeAnalysis.Store[] stores)
|
TypeAnalysis.Store[] |
apply(ClassFile.Method method)
Apply the analysis to a given method in a classfile. |
void |
apply(ClassFile cf)
Apply the analysis to every method in a classfile, creating the necessary StackMapTable attributes. |
protected void |
checkIsSubtype(JvmType t1,
JvmType t2,
int index,
TypeAnalysis.Store store)
Check t1 is a supertype of t2 (i.e. |
protected void |
checkMaxStack(int max,
int index,
TypeAnalysis.Store store)
Check that there are at least max free spaces on the stack. |
protected void |
checkMinStack(int min,
int index,
TypeAnalysis.Store store)
Check that there are at least min items on the stack. |
TypeAnalysis.Store[] |
initialise(Code attr,
ClassFile.Method method)
Generate an array of stores, one for each bytecode in the given method. |
protected boolean |
isSubtype(JvmType t1,
JvmType t2)
Determine whether t1 is a supertype of t2 (i.e. |
protected JvmType |
join(JvmType t1,
JvmType t2)
|
boolean |
merge(int index,
TypeAnalysis.Store original,
TypeAnalysis.Store update)
Merge one abstract store into another to form a store at a join point in the control-flow graph. |
TypeAnalysis.Store |
transfer(int index,
boolean branch,
Bytecode.IfCmp code,
TypeAnalysis.Store store)
Generate an updated a abstract store by apply the abstract effect(s) of a given bytecode to an incoming store. |
TypeAnalysis.Store |
transfer(int index,
boolean branch,
Bytecode.If code,
TypeAnalysis.Store store)
Generate an updated a abstract store by apply the abstract effect(s) of a given bytecode to an incoming store. |
TypeAnalysis.Store |
transfer(int index,
Bytecode.ArrayLength code,
TypeAnalysis.Store store)
Generate an updated a abstract store by apply the abstract effect(s) of a arraystore bytecode to an incoming store. |
TypeAnalysis.Store |
transfer(int index,
Bytecode.ArrayLoad code,
TypeAnalysis.Store store)
Generate an updated a abstract store by apply the abstract effect(s) of a arrayload bytecode to an incoming store. |
TypeAnalysis.Store |
transfer(int index,
Bytecode.ArrayStore code,
TypeAnalysis.Store store)
Generate an updated a abstract store by apply the abstract effect(s) of a arraystore bytecode to an incoming store. |
TypeAnalysis.Store |
transfer(int index,
Bytecode.BinOp code,
TypeAnalysis.Store store)
Generate an updated a abstract store by apply the abstract effect(s) of a binop bytecode to an incoming store. |
TypeAnalysis.Store |
transfer(int index,
Bytecode.CheckCast code,
TypeAnalysis.Store store)
Generate an updated a abstract store by apply the abstract effect(s) of a checkcast bytecode to an incoming store. |
TypeAnalysis.Store |
transfer(int index,
Bytecode.Cmp code,
TypeAnalysis.Store store)
Generate an updated a abstract store by apply the abstract effect(s) of a cmp bytecode to an incoming store. |
TypeAnalysis.Store |
transfer(int index,
Bytecode.Conversion code,
TypeAnalysis.Store store)
Generate an updated a abstract store by apply the abstract effect(s) of a convert bytecode to an incoming store. |
TypeAnalysis.Store |
transfer(int index,
Bytecode.Dup code,
TypeAnalysis.Store store)
Generate an updated a abstract store by apply the abstract effect(s) of a dup bytecode to an incoming store. |
TypeAnalysis.Store |
transfer(int index,
Bytecode.DupX1 code,
TypeAnalysis.Store store)
Generate an updated a abstract store by apply the abstract effect(s) of a dup_x1 bytecode to an incoming store. |
TypeAnalysis.Store |
transfer(int index,
Bytecode.DupX2 code,
TypeAnalysis.Store store)
Generate an updated a abstract store by apply the abstract effect(s) of a dup_x2 bytecode to an incoming store. |
TypeAnalysis.Store |
transfer(int index,
Bytecode.GetField code,
TypeAnalysis.Store store)
Generate an updated a abstract store by apply the abstract effect(s) of a getfield bytecode to an incoming store. |
TypeAnalysis.Store |
transfer(int index,
Bytecode.Iinc code,
TypeAnalysis.Store store)
Generate an updated a abstract store by apply the abstract effect(s) of an iinc bytecode to an incoming store. |
TypeAnalysis.Store |
transfer(int index,
Bytecode.InstanceOf code,
TypeAnalysis.Store store)
Generate an updated a abstract store by apply the abstract effect(s) of a instanceof bytecode to an incoming store. |
TypeAnalysis.Store |
transfer(int index,
Bytecode.Invoke code,
TypeAnalysis.Store store)
Generate an updated a abstract store by apply the abstract effect(s) of a invoke bytecode to an incoming store. |
TypeAnalysis.Store |
transfer(int index,
Bytecode.LoadConst code,
TypeAnalysis.Store store)
Generate an updated a abstract store by apply the abstract effect(s) of a loadconst bytecode to an incoming store. |
TypeAnalysis.Store |
transfer(int index,
Bytecode.Load code,
TypeAnalysis.Store store)
Generate an updated a abstract store by apply the abstract effect(s) of a load bytecode to an incoming store. |
TypeAnalysis.Store |
transfer(int index,
Bytecode.MonitorEnter code,
TypeAnalysis.Store store)
Generate an updated a abstract store by apply the abstract effect(s) of a monitorenter bytecode to an incoming store. |
TypeAnalysis.Store |
transfer(int index,
Bytecode.MonitorExit code,
TypeAnalysis.Store store)
Generate an updated a abstract store by apply the abstract effect(s) of a monitorexit bytecode to an incoming store. |
TypeAnalysis.Store |
transfer(int index,
Bytecode.Neg code,
TypeAnalysis.Store store)
Generate an updated a abstract store by apply the abstract effect(s) of a neg bytecode to an incoming store. |
TypeAnalysis.Store |
transfer(int index,
Bytecode.New code,
TypeAnalysis.Store store)
Generate an updated a abstract store by apply the abstract effect(s) of a new bytecode to an incoming store. |
TypeAnalysis.Store |
transfer(int index,
Bytecode.Nop code,
TypeAnalysis.Store store)
Generate an updated a abstract store by apply the abstract effect(s) of a nop bytecode to an incoming store. |
TypeAnalysis.Store |
transfer(int index,
Bytecode.Pop code,
TypeAnalysis.Store store)
Generate an updated a abstract store by apply the abstract effect(s) of a pop bytecode to an incoming store. |
TypeAnalysis.Store |
transfer(int index,
Bytecode.PutField code,
TypeAnalysis.Store store)
Generate an updated a abstract store by apply the abstract effect(s) of a arraystore bytecode to an incoming store. |
void |
transfer(int index,
Bytecode.Return code,
TypeAnalysis.Store store)
Generate an updated a abstract store by apply the abstract effect(s) of a return bytecode to an incoming store. |
TypeAnalysis.Store |
transfer(int index,
Bytecode.Store code,
TypeAnalysis.Store store)
Generate an updated a abstract store by apply the abstract effect(s) of a store bytecode to an incoming store. |
TypeAnalysis.Store |
transfer(int index,
Bytecode.Swap code,
TypeAnalysis.Store store)
Generate an updated a abstract store by apply the abstract effect(s) of a swap bytecode to an incoming store. |
void |
transfer(int index,
Bytecode.Throw code,
TypeAnalysis.Store store)
Generate an updated a abstract store by apply the abstract effect(s) of a throw bytecode to an incoming store. |
Methods inherited from class jasm.util.dfa.ForwardFlowAnalysis |
---|
merge, select |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TypeAnalysis()
Method Detail |
---|
public void apply(ClassFile cf)
StackMapTable
attributes.
cf
- public TypeAnalysis.Store[] apply(ClassFile.Method method)
apply
in class ForwardFlowAnalysis<TypeAnalysis.Store>
cf
- protected void addStackMapTable(ClassFile.Method method, TypeAnalysis.Store[] stores)
public TypeAnalysis.Store[] initialise(Code attr, ClassFile.Method method)
ForwardFlowAnalysis
initialise
in class ForwardFlowAnalysis<TypeAnalysis.Store>
attr
- --- code attribute being analysed.method
- --- enclosing method.
public TypeAnalysis.Store transfer(int index, Bytecode.Store code, TypeAnalysis.Store store)
ForwardFlowAnalysis
transfer
in class ForwardFlowAnalysis<TypeAnalysis.Store>
index
- --- index in bytecode array of bytecode being analysed.store
- --- incoming abstract store.
public TypeAnalysis.Store transfer(int index, Bytecode.Load code, TypeAnalysis.Store store)
ForwardFlowAnalysis
transfer
in class ForwardFlowAnalysis<TypeAnalysis.Store>
index
- --- index in bytecode array of bytecode being analysed.store
- --- incoming abstract store.
public TypeAnalysis.Store transfer(int index, Bytecode.LoadConst code, TypeAnalysis.Store store)
ForwardFlowAnalysis
transfer
in class ForwardFlowAnalysis<TypeAnalysis.Store>
index
- --- index in bytecode array of bytecode being analysed.store
- --- incoming abstract store.
public TypeAnalysis.Store transfer(int index, Bytecode.ArrayLoad code, TypeAnalysis.Store store)
ForwardFlowAnalysis
transfer
in class ForwardFlowAnalysis<TypeAnalysis.Store>
index
- --- index in bytecode array of bytecode being analysed.store
- --- incoming abstract store.
public TypeAnalysis.Store transfer(int index, Bytecode.ArrayStore code, TypeAnalysis.Store store)
ForwardFlowAnalysis
transfer
in class ForwardFlowAnalysis<TypeAnalysis.Store>
index
- --- index in bytecode array of bytecode being analysed.store
- --- incoming abstract store.
public void transfer(int index, Bytecode.Throw code, TypeAnalysis.Store store)
ForwardFlowAnalysis
transfer
in class ForwardFlowAnalysis<TypeAnalysis.Store>
index
- --- index in bytecode array of bytecode being analysed.store
- --- incoming abstract store.public void transfer(int index, Bytecode.Return code, TypeAnalysis.Store store)
ForwardFlowAnalysis
transfer
in class ForwardFlowAnalysis<TypeAnalysis.Store>
index
- --- index in bytecode array of bytecode being analysed.store
- --- incoming abstract store.public TypeAnalysis.Store transfer(int index, Bytecode.Iinc code, TypeAnalysis.Store store)
ForwardFlowAnalysis
transfer
in class ForwardFlowAnalysis<TypeAnalysis.Store>
index
- --- index in bytecode array of bytecode being analysed.store
- --- incoming abstract store.
public TypeAnalysis.Store transfer(int index, Bytecode.BinOp code, TypeAnalysis.Store store)
ForwardFlowAnalysis
transfer
in class ForwardFlowAnalysis<TypeAnalysis.Store>
index
- --- index in bytecode array of bytecode being analysed.store
- --- incoming abstract store.
public TypeAnalysis.Store transfer(int index, Bytecode.Neg code, TypeAnalysis.Store store)
ForwardFlowAnalysis
transfer
in class ForwardFlowAnalysis<TypeAnalysis.Store>
index
- --- index in bytecode array of bytecode being analysed.store
- --- incoming abstract store.
public TypeAnalysis.Store transfer(int index, Bytecode.New code, TypeAnalysis.Store store)
ForwardFlowAnalysis
transfer
in class ForwardFlowAnalysis<TypeAnalysis.Store>
index
- --- index in bytecode array of bytecode being analysed.store
- --- incoming abstract store.
public TypeAnalysis.Store transfer(int index, boolean branch, Bytecode.If code, TypeAnalysis.Store store)
ForwardFlowAnalysis
transfer
in class ForwardFlowAnalysis<TypeAnalysis.Store>
index
- --- index in bytecode array of bytecode being analysed.branch
- --- indicates the true or false branch is to be considered.store
- --- incoming abstract store.
public TypeAnalysis.Store transfer(int index, boolean branch, Bytecode.IfCmp code, TypeAnalysis.Store store)
ForwardFlowAnalysis
transfer
in class ForwardFlowAnalysis<TypeAnalysis.Store>
index
- --- index in bytecode array of bytecode being analysed.branch
- --- indicates the true or false branch is to be considered.store
- --- incoming abstract store.
public TypeAnalysis.Store transfer(int index, Bytecode.GetField code, TypeAnalysis.Store store)
ForwardFlowAnalysis
transfer
in class ForwardFlowAnalysis<TypeAnalysis.Store>
index
- --- index in bytecode array of bytecode being analysed.store
- --- incoming abstract store.
public TypeAnalysis.Store transfer(int index, Bytecode.PutField code, TypeAnalysis.Store store)
ForwardFlowAnalysis
transfer
in class ForwardFlowAnalysis<TypeAnalysis.Store>
index
- --- index in bytecode array of bytecode being analysed.store
- --- incoming abstract store.
public TypeAnalysis.Store transfer(int index, Bytecode.ArrayLength code, TypeAnalysis.Store store)
ForwardFlowAnalysis
transfer
in class ForwardFlowAnalysis<TypeAnalysis.Store>
index
- --- index in bytecode array of bytecode being analysed.store
- --- incoming abstract store.
public TypeAnalysis.Store transfer(int index, Bytecode.Invoke code, TypeAnalysis.Store store)
ForwardFlowAnalysis
transfer
in class ForwardFlowAnalysis<TypeAnalysis.Store>
index
- --- index in bytecode array of bytecode being analysed.store
- --- incoming abstract store.
public TypeAnalysis.Store transfer(int index, Bytecode.CheckCast code, TypeAnalysis.Store store)
ForwardFlowAnalysis
transfer
in class ForwardFlowAnalysis<TypeAnalysis.Store>
index
- --- index in bytecode array of bytecode being analysed.store
- --- incoming abstract store.
public TypeAnalysis.Store transfer(int index, Bytecode.Conversion code, TypeAnalysis.Store store)
ForwardFlowAnalysis
transfer
in class ForwardFlowAnalysis<TypeAnalysis.Store>
index
- --- index in bytecode array of bytecode being analysed.store
- --- incoming abstract store.
public TypeAnalysis.Store transfer(int index, Bytecode.InstanceOf code, TypeAnalysis.Store store)
ForwardFlowAnalysis
transfer
in class ForwardFlowAnalysis<TypeAnalysis.Store>
index
- --- index in bytecode array of bytecode being analysed.store
- --- incoming abstract store.
public TypeAnalysis.Store transfer(int index, Bytecode.Pop code, TypeAnalysis.Store store)
ForwardFlowAnalysis
transfer
in class ForwardFlowAnalysis<TypeAnalysis.Store>
index
- --- index in bytecode array of bytecode being analysed.store
- --- incoming abstract store.
public TypeAnalysis.Store transfer(int index, Bytecode.Dup code, TypeAnalysis.Store store)
ForwardFlowAnalysis
transfer
in class ForwardFlowAnalysis<TypeAnalysis.Store>
index
- --- index in bytecode array of bytecode being analysed.store
- --- incoming abstract store.
public TypeAnalysis.Store transfer(int index, Bytecode.DupX1 code, TypeAnalysis.Store store)
ForwardFlowAnalysis
transfer
in class ForwardFlowAnalysis<TypeAnalysis.Store>
index
- --- index in bytecode array of bytecode being analysed.store
- --- incoming abstract store.
public TypeAnalysis.Store transfer(int index, Bytecode.DupX2 code, TypeAnalysis.Store store)
ForwardFlowAnalysis
transfer
in class ForwardFlowAnalysis<TypeAnalysis.Store>
index
- --- index in bytecode array of bytecode being analysed.store
- --- incoming abstract store.
public TypeAnalysis.Store transfer(int index, Bytecode.Swap code, TypeAnalysis.Store store)
ForwardFlowAnalysis
transfer
in class ForwardFlowAnalysis<TypeAnalysis.Store>
index
- --- index in bytecode array of bytecode being analysed.store
- --- incoming abstract store.
public TypeAnalysis.Store transfer(int index, Bytecode.Cmp code, TypeAnalysis.Store store)
ForwardFlowAnalysis
transfer
in class ForwardFlowAnalysis<TypeAnalysis.Store>
index
- --- index in bytecode array of bytecode being analysed.store
- --- incoming abstract store.
public TypeAnalysis.Store transfer(int index, Bytecode.Nop code, TypeAnalysis.Store store)
ForwardFlowAnalysis
transfer
in class ForwardFlowAnalysis<TypeAnalysis.Store>
index
- --- index in bytecode array of bytecode being analysed.store
- --- incoming abstract store.
public TypeAnalysis.Store transfer(int index, Bytecode.MonitorEnter code, TypeAnalysis.Store store)
ForwardFlowAnalysis
transfer
in class ForwardFlowAnalysis<TypeAnalysis.Store>
index
- --- index in bytecode array of bytecode being analysed.store
- --- incoming abstract store.
public TypeAnalysis.Store transfer(int index, Bytecode.MonitorExit code, TypeAnalysis.Store store)
ForwardFlowAnalysis
transfer
in class ForwardFlowAnalysis<TypeAnalysis.Store>
index
- --- index in bytecode array of bytecode being analysed.store
- --- incoming abstract store.
public boolean merge(int index, TypeAnalysis.Store original, TypeAnalysis.Store update)
ForwardFlowAnalysis
merge
in class ForwardFlowAnalysis<TypeAnalysis.Store>
original
- --- original store to join "into". In the case of no change,
this should be returned.
protected JvmType join(JvmType t1, JvmType t2)
protected void checkMinStack(int min, int index, TypeAnalysis.Store store)
min
- protected void checkMaxStack(int max, int index, TypeAnalysis.Store store)
min
- protected void checkIsSubtype(JvmType t1, JvmType t2, int index, TypeAnalysis.Store store)
protected boolean isSubtype(JvmType t1, JvmType t2)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |