org.apache.bcel.verifier.statics
Class Pass2Verifier
public final
class
Pass2Verifier
extends PassVerifier
implements Constants
This PassVerifier verifies a class file according to
pass 2 as described in The Java Virtual Machine
Specification, 2nd edition.
More detailed information is to be found at the do_verify()
method's documentation.
Version: $Id: Pass2Verifier.java 386056 2006-03-15 11:31:56Z tcurdt $
Author: Enver Haase
See Also: do_verify
Method Summary |
void | constant_pool_entries_satisfy_static_constraints()
Ensures that the constant pool entries satisfy the static constraints
as described in The Java Virtual Machine Specification, 2nd Edition.
|
VerificationResult | do_verify()
Pass 2 is the pass where static properties of the
class file are checked without looking into "Code"
arrays of methods.
|
void | every_class_has_an_accessible_superclass()
Ensures that every class has a super class and that
final classes are not subclassed.
|
void | field_and_method_refs_are_valid()
Ensures that the ConstantCP-subclassed entries of the constant
pool are valid. |
void | final_methods_are_not_overridden()
Ensures that final methods are not overridden.
|
LocalVariablesInfo | getLocalVariablesInfo(int method_nr)
Returns a LocalVariablesInfo object containing information
about the usage of the local variables in the Code attribute
of the said method or null if the class file this
Pass2Verifier operates on could not be pass-2-verified correctly.
|
static String | tostring(Node n)
This method is here to save typing work and improve code readability. |
static boolean | validClassMethodName(String name)
This method returns true if and only if the supplied String
represents a valid method name that may be referenced by
ConstantMethodref objects. |
static boolean | validClassName(String name)
This method returns true if and only if the supplied String
represents a valid Java class name. |
static boolean | validFieldName(String name)
This method returns true if and only if the supplied String
represents a valid Java field name. |
static boolean | validInterfaceMethodName(String name)
This method returns true if and only if the supplied String
represents a valid Java interface method name that may be
referenced by ConstantInterfaceMethodref objects. |
static boolean | validJavaIdentifier(String name)
This method returns true if and only if the supplied String
represents a valid Java identifier (so-called simple name). |
static boolean | validJavaLangMethodName(String name)
This method returns true if and only if the supplied String
represents a valid Java programming language method name stored as a simple
(non-qualified) name.
|
static boolean | validMethodName(String name, boolean allowStaticInit)
This method returns true if and only if the supplied String
represents a valid method name.
|
The LocalVariableInfo instances used by Pass3bVerifier.
localVariablesInfos[i] denotes the information for the
local variables of method number i in the
JavaClass this verifier operates on.
The Verifier that created this.
Should only be instantiated by a Verifier.
See Also: Verifier
private void constant_pool_entries_satisfy_static_constraints()
Ensures that the constant pool entries satisfy the static constraints
as described in The Java Virtual Machine Specification, 2nd Edition.
Throws: ClassConstraintException otherwise.
Pass 2 is the pass where static properties of the
class file are checked without looking into "Code"
arrays of methods.
This verification pass is usually invoked when
a class is resolved; and it may be possible that
this verification pass has to load in other classes
such as superclasses or implemented interfaces.
Therefore, Pass 1 is run on them.
Note that most referenced classes are
not loaded
in for verification or for an existance check by this
pass; only the syntactical correctness of their names
and descriptors (a.k.a. signatures) is checked.
Very few checks that conceptually belong here
are delayed until pass 3a in JustIce. JustIce does
not only check for syntactical correctness but also
for semantical sanity - therefore it needs access to
the "Code" array of methods in a few cases. Please
see the pass 3a documentation, too.
See Also: Pass3aVerifier
private void every_class_has_an_accessible_superclass()
Ensures that every class has a super class and that
final classes are not subclassed.
This means, the class this Pass2Verifier operates
on has proper super classes (transitively) up to
java.lang.Object.
The reason for really loading (and Pass1-verifying)
all of those classes here is that we need them in
Pass2 anyway to verify no final methods are overridden
(that could be declared anywhere in the ancestor hierarchy).
Throws: ClassConstraintException otherwise.
private void field_and_method_refs_are_valid()
Ensures that the ConstantCP-subclassed entries of the constant
pool are valid. According to "Yellin: Low Level Security in Java",
this method does not verify the existence of referenced entities
(such as classes) but only the formal correctness (such as well-formed
signatures).
The visitXXX() methods throw ClassConstraintException instances otherwise.
Precondition: index-style cross referencing in the constant
pool must be valid. Simply invoke constant_pool_entries_satisfy_static_constraints()
before.
Throws: ClassConstraintException otherwise.
See Also: constant_pool_entries_satisfy_static_constraints
private void final_methods_are_not_overridden()
Returns a LocalVariablesInfo object containing information
about the usage of the local variables in the Code attribute
of the said method or null if the class file this
Pass2Verifier operates on could not be pass-2-verified correctly.
The method number method_nr is the method you get using
Repository.lookupClass(myOwner.getClassname()).getMethods()[method_nr];.
You should not add own information. Leave that to JustIce.
private static String tostring(
Node n)
This method is here to save typing work and improve code readability.
private static boolean validClassMethodName(String name)
This method returns true if and only if the supplied String
represents a valid method name that may be referenced by
ConstantMethodref objects.
private static final boolean validClassName(String name)
This method returns true if and only if the supplied String
represents a valid Java class name.
private static boolean validFieldName(String name)
This method returns true if and only if the supplied String
represents a valid Java field name.
private static boolean validInterfaceMethodName(String name)
This method returns true if and only if the supplied String
represents a valid Java interface method name that may be
referenced by ConstantInterfaceMethodref objects.
private static boolean validJavaIdentifier(String name)
This method returns true if and only if the supplied String
represents a valid Java identifier (so-called simple name).
private static boolean validJavaLangMethodName(String name)
This method returns true if and only if the supplied String
represents a valid Java programming language method name stored as a simple
(non-qualified) name.
Conforming to: The Java Virtual Machine Specification, Second Edition, §2.7, §2.7.1, §2.2.
private static boolean validMethodName(String name, boolean allowStaticInit)
This method returns true if and only if the supplied String
represents a valid method name.
This is basically the same as a valid identifier name in the
Java programming language, but the special name for
the instance initialization method is allowed and the special name
for the class/interface initialization method may be allowed.