Class VerifierFactory
java.lang.Object
org.apache.bcel.verifier.VerifierFactory
This class produces instances of the Verifier class. Its purpose is to make sure that they are singleton instances with respect to the class name they
operate on. That means, for every class (represented by a unique fully qualified class name) there is at most one cached Verifier. The cache is bounded (see
MAX_CACHE_SIZE_PROPERTY); after eviction, a new Verifier is transparently created on the next request for that class name.
The system property org.apache.bcel.verifier.VerifierFactory.maxCacheSize controls how many Verifier instances this factory caches;
least-recently-used entries are evicted first. Verifier names are taken from the constant pools of the (possibly untrusted) classes being verified, so an
unbounded cache would let a single hostile class file referencing many distinct bogus type names grow the heap without limit in a long-running process. Set
the property to 0 or a negative value to opt out and restore the historical unbounded behavior.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidAdds the VerifierFactoryObserver o to the list of observers.static voidclear()Clears the factory.static voidRemoves the VerifierFactoryObserver o from the list of observers.static VerifiergetVerifier(String fullyQualifiedClassName) Returns the verifier responsible for the class with the given name.static Verifier[]Returns all Verifier instances created so far.
-
Method Details
-
attach
Adds the VerifierFactoryObserver o to the list of observers.- Parameters:
o- The observer to add.
-
clear
-
detach
Removes the VerifierFactoryObserver o from the list of observers.- Parameters:
o- The observer to remove.
-
getVerifier
Returns the verifier responsible for the class with the given name. Possibly a new Verifier object is transparently created; if the cache bound (MAX_CACHE_SIZE_PROPERTY) has been reached, the least-recently-used cached Verifier is evicted first.- Parameters:
fullyQualifiedClassName- The fully qualified class name.- Returns:
- The verifier responsible for the class with the given name.
-
getVerifiers
Returns all Verifier instances created so far. This is useful when a Verifier recursively lets the VerifierFactory create other Verifier instances and if you want to verify the transitive hull of referenced class files.- Returns:
- array of all Verifier instances.
-