Example usage for org.objectweb.asm ClassReader readConst

List of usage examples for org.objectweb.asm ClassReader readConst

Introduction

In this page you can find the example usage for org.objectweb.asm ClassReader readConst.

Prototype

public Object readConst(final int constantPoolEntryIndex, final char[] charBuffer) 

Source Link

Document

Reads a numeric or string constant pool entry in this ClassReader .

Usage

From source file:net.orfjackal.retrolambda.test.TestUtil.java

License:Open Source License

public static void visitConstantPool(ClassReader reader, ConstantPoolVisitor visitor) {
    char[] buf = new char[reader.getMaxStringLength()];
    for (int item = 0; item < reader.getItemCount(); item++) {
        try {/*from  w w w  . j  a  va 2  s  .com*/
            Object constant = reader.readConst(item, buf);
            visitor.visit(item, constant);
        } catch (Exception e) {
            // XXX: constant pool entry which is a Methodref, InvokeDynamic or similar non-plain constant
            // FIXME: readConst throws ArrayIndexOutOfBoundsException nearly all the time; how to use it???
            //e.printStackTrace();
        }
    }
}