Java Code Examples for org.apache.bcel.classfile.DescendingVisitor

The following examples show how to use org.apache.bcel.classfile.DescendingVisitor. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: commons-bcel   Source File: Pass2Verifier.java    License: Apache License 2.0 6 votes vote down vote up
private CPESSC_Visitor(final JavaClass _jc) {
    jc = _jc;
    cp = _jc.getConstantPool();
    cplen = cp.getLength();

    CONST_Class = ConstantClass.class;
    /*
    CONST_Fieldref = ConstantFieldref.class;
    CONST_Methodref = ConstantMethodref.class;
    CONST_InterfaceMethodref = ConstantInterfaceMethodref.class;
    */
    CONST_String = ConstantString.class;
    CONST_Integer = ConstantInteger.class;
    CONST_Float = ConstantFloat.class;
    CONST_Long = ConstantLong.class;
    CONST_Double = ConstantDouble.class;
    CONST_NameAndType = ConstantNameAndType.class;
    CONST_Utf8 = ConstantUtf8.class;

    carrier = new DescendingVisitor(_jc, this);
    carrier.visit();
}
 
Example 2
/**
 * Traverses a JavaClass parse tree and accepts all registered
 * visitors.
 * @param aJavaClass the root of the tree.
 */
public void walk(JavaClass aJavaClass)
{
    DescendingVisitor visitor =
        new DescendingVisitor(aJavaClass, mVisitor);
    aJavaClass.accept(visitor);
}
 
Example 3
/**
 * Traverses a JavaClass parse tree and accepts all registered
 * visitors.
 * @param aJavaClass the root of the tree.
 */
public void walk(JavaClass aJavaClass)
{
    DescendingVisitor visitor =
        new DescendingVisitor(aJavaClass, mVisitor);
    aJavaClass.accept(visitor);
}
 
Example 4
Source Project: commons-bcel   Source File: Pass2Verifier.java    License: Apache License 2.0 4 votes vote down vote up
/** Constructs an InnerClassDetector working on the JavaClass _jc. */
public InnerClassDetector(final JavaClass javaClass) {
    this.jc = javaClass;
    this.cp = jc.getConstantPool();
    (new DescendingVisitor(jc, this)).visit();
}
 
Example 5
@Override
public void setUp() throws ClassNotFoundException
{
    visitor = new CounterVisitor();
    new DescendingVisitor(getTestClass(), getVisitor()).visit();
}
 
Example 6
Source Project: commons-bcel   Source File: Pass2Verifier.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * 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.
 * <B>Precondition: index-style cross referencing in the constant
 * pool must be valid. Simply invoke constant_pool_entries_satisfy_static_constraints()
 * before.</B>
 *
 * @throws ClassConstraintException otherwise.
 * @see #constant_pool_entries_satisfy_static_constraints()
 */
private void field_and_method_refs_are_valid() {
    try {
    final JavaClass jc = Repository.lookupClass(myOwner.getClassName());
    final DescendingVisitor v = new DescendingVisitor(jc, new FAMRAV_Visitor(jc));
    v.visit();

    } catch (final ClassNotFoundException e) {
    // FIXME: this might not be the best way to handle missing classes.
    throw new AssertionViolatedException("Missing class: " + e, e);
    }
}