本文整理汇总了Java中scouter.javassist.bytecode.ConstPool.addFieldrefInfo方法的典型用法代码示例。如果您正苦于以下问题:Java ConstPool.addFieldrefInfo方法的具体用法?Java ConstPool.addFieldrefInfo怎么用?Java ConstPool.addFieldrefInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scouter.javassist.bytecode.ConstPool
的用法示例。
在下文中一共展示了ConstPool.addFieldrefInfo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: transform
import scouter.javassist.bytecode.ConstPool; //导入方法依赖的package包/类
/**
* Modify GETFIELD, GETSTATIC, PUTFIELD, and PUTSTATIC so that
* a different field is accessed. The new field must be declared
* in a superclass of the class in which the original field is
* declared.
*/
public int transform(CtClass clazz, int pos,
CodeIterator iterator, ConstPool cp)
{
int c = iterator.byteAt(pos);
if (c == GETFIELD || c == GETSTATIC
|| c == PUTFIELD || c == PUTSTATIC) {
int index = iterator.u16bitAt(pos + 1);
String typedesc
= TransformReadField.isField(clazz.getClassPool(), cp,
fieldClass, fieldname, isPrivate, index);
if (typedesc != null) {
if (newIndex == 0) {
int nt = cp.addNameAndTypeInfo(newFieldname,
typedesc);
newIndex = cp.addFieldrefInfo(
cp.addClassInfo(newClassname), nt);
constPool = cp;
}
iterator.write16bit(newIndex, pos + 1);
}
}
return pos;
}
示例2: addFieldrefInfo
import scouter.javassist.bytecode.ConstPool; //导入方法依赖的package包/类
private int addFieldrefInfo(CtField f, FieldInfo finfo) {
ConstPool cp = bytecode.getConstPool();
String cname = f.getDeclaringClass().getName();
int ci = cp.addClassInfo(cname);
String name = finfo.getName();
String type = finfo.getDescriptor();
return cp.addFieldrefInfo(ci, name, type);
}