com.sun.org.apache.bcel.internal.classfile.ConstantNameAndType Java Examples

The following examples show how to use com.sun.org.apache.bcel.internal.classfile.ConstantNameAndType. 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 File: ConstantPoolGen.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Add a new NameAndType constant to the ConstantPool if it is not already
 * in there.
 *
 * @param name Name string to add
 * @param signature signature string to add
 * @return index of entry
 */
public int addNameAndType( final String name, final String signature ) {
    int ret;
    int name_index;
    int signature_index;
    if ((ret = lookupNameAndType(name, signature)) != -1) {
        return ret; // Already in CP
    }
    adjustSize();
    name_index = addUtf8(name);
    signature_index = addUtf8(signature);
    ret = index;
    constants[index++] = new ConstantNameAndType(name_index, signature_index);
    final String key = name + NAT_DELIM + signature;
    if (!n_a_t_table.containsKey(key)) {
        n_a_t_table.put(key, new Index(ret));
    }
    return ret;
}
 
Example #2
Source File: FieldOrMethod.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/** @return signature of referenced method/field.
 */
public String getSignature( final ConstantPoolGen cpg ) {
    final ConstantPool cp = cpg.getConstantPool();
    final ConstantCP cmr = (ConstantCP) cp.getConstant(super.getIndex());
    final ConstantNameAndType cnat = (ConstantNameAndType) cp.getConstant(cmr.getNameAndTypeIndex());
    return ((ConstantUtf8) cp.getConstant(cnat.getSignatureIndex())).getBytes();
}
 
Example #3
Source File: FieldOrMethod.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/** @return name of referenced method/field.
 */
public String getName( final ConstantPoolGen cpg ) {
    final ConstantPool cp = cpg.getConstantPool();
    final ConstantCP cmr = (ConstantCP) cp.getConstant(super.getIndex());
    final ConstantNameAndType cnat = (ConstantNameAndType) cp.getConstant(cmr.getNameAndTypeIndex());
    return ((ConstantUtf8) cp.getConstant(cnat.getNameIndex())).getBytes();
}
 
Example #4
Source File: NameSignatureInstruction.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
public ConstantNameAndType getNameAndType(final ConstantPoolGen cpg) {
    final ConstantPool cp = cpg.getConstantPool();
    final ConstantCP cmr = (ConstantCP) cp.getConstant(super.getIndex());
    return  (ConstantNameAndType) cp.getConstant(cmr.getNameAndTypeIndex());
}
 
Example #5
Source File: NameSignatureInstruction.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/** @return signature of referenced method/field.
 */
public String getSignature(final ConstantPoolGen cpg) {
    final ConstantPool cp = cpg.getConstantPool();
    final ConstantNameAndType cnat = getNameAndType(cpg);
    return ((ConstantUtf8) cp.getConstant(cnat.getSignatureIndex())).getBytes();
}
 
Example #6
Source File: NameSignatureInstruction.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/** @return name of referenced method/field.
 */
public String getName(final ConstantPoolGen cpg) {
    final ConstantPool cp = cpg.getConstantPool();
    final ConstantNameAndType cnat = getNameAndType(cpg);
    return ((ConstantUtf8) cp.getConstant(cnat.getNameIndex())).getBytes();
}
 
Example #7
Source File: INVOKEDYNAMIC.java    From Bytecoder with Apache License 2.0 3 votes vote down vote up
/**
 * Override the parent method because our classname is held elsewhere.
 *
 * @param cpg the ConstantPool generator
 * @deprecated in FieldOrMethod
 *
 * @return name of the referenced class/interface
 */
@Override
@Deprecated
public String getClassName( final ConstantPoolGen cpg ) {
    final ConstantPool cp = cpg.getConstantPool();
    final ConstantInvokeDynamic cid = (ConstantInvokeDynamic) cp.getConstant(super.getIndex(), Const.CONSTANT_InvokeDynamic);
    return ((ConstantNameAndType) cp.getConstant(cid.getNameAndTypeIndex())).getName(cp);
}