本文整理汇总了Java中org.apache.bcel.classfile.ConstantPool.getConstantString方法的典型用法代码示例。如果您正苦于以下问题:Java ConstantPool.getConstantString方法的具体用法?Java ConstantPool.getConstantString怎么用?Java ConstantPool.getConstantString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.bcel.classfile.ConstantPool
的用法示例。
在下文中一共展示了ConstantPool.getConstantString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getClassName
import org.apache.bcel.classfile.ConstantPool; //导入方法依赖的package包/类
/** @return name of the referenced class/interface
* @deprecated If the instruction references an array class,
* this method will return "java.lang.Object".
* For code generated by Java 1.5, this answer is
* sometimes wrong (e.g., if the "clone()" method is
* called on an array). A better idea is to use
* the getReferenceType() method, which correctly distinguishes
* between class types and array types.
*/
public String getClassName( ConstantPoolGen cpg ) {
ConstantPool cp = cpg.getConstantPool();
ConstantCP cmr = (ConstantCP) cp.getConstant(index);
String className = cp.getConstantString(cmr.getClassIndex(),
org.apache.bcel.Constants.CONSTANT_Class);
if (className.startsWith("[")) {
// Turn array classes into java.lang.Object.
return "java.lang.Object";
}
return className.replace('/', '.');
}
示例2: getReferenceType
import org.apache.bcel.classfile.ConstantPool; //导入方法依赖的package包/类
/**
* Return the reference type representing the class, interface,
* or array class referenced by the instruction.
* @param cpg the ConstantPoolGen used to create the instruction
* @return an ObjectType (if the referenced class type is a class
* or interface), or an ArrayType (if the referenced class
* type is an array class)
*/
public ReferenceType getReferenceType( ConstantPoolGen cpg ) {
ConstantPool cp = cpg.getConstantPool();
ConstantCP cmr = (ConstantCP) cp.getConstant(index);
String className = cp.getConstantString(cmr.getClassIndex(),
org.apache.bcel.Constants.CONSTANT_Class);
if (className.startsWith("[")) {
return (ArrayType) Type.getType(className);
} else {
className = className.replace('/', '.');
return new ObjectType(className);
}
}
示例3: getType
import org.apache.bcel.classfile.ConstantPool; //导入方法依赖的package包/类
/** @return type related with this instruction.
*/
public Type getType( ConstantPoolGen cpg ) {
ConstantPool cp = cpg.getConstantPool();
String name = cp.getConstantString(index, org.apache.bcel.Constants.CONSTANT_Class);
if (!name.startsWith("[")) {
name = "L" + name + ";";
}
return Type.getType(name);
}
示例4: getType
import org.apache.bcel.classfile.ConstantPool; //导入方法依赖的package包/类
/**
* @return type related with this instruction.
*/
public Type getType(ConstantPoolGen cpg) {
ConstantPool cp = cpg.getConstantPool();
String name = cp.getConstantString(index, org.apache.bcel.Constants.CONSTANT_Class);
if (!name.startsWith("["))
name = "L" + name + ";";
return Type.getType(name);
}