本文整理汇总了Java中scouter.javassist.bytecode.ConstPool.addNameAndTypeInfo方法的典型用法代码示例。如果您正苦于以下问题:Java ConstPool.addNameAndTypeInfo方法的具体用法?Java ConstPool.addNameAndTypeInfo怎么用?Java ConstPool.addNameAndTypeInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scouter.javassist.bytecode.ConstPool
的用法示例。
在下文中一共展示了ConstPool.addNameAndTypeInfo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: match
import scouter.javassist.bytecode.ConstPool; //导入方法依赖的package包/类
protected int match(int c, int pos, CodeIterator iterator,
int typedesc, ConstPool cp) throws BadBytecode
{
if (newIndex == 0) {
int nt = cp.addNameAndTypeInfo(cp.addUtf8Info(newMethodname),
typedesc);
int ci = cp.addClassInfo(newClassname);
if (c == INVOKEINTERFACE)
newIndex = cp.addInterfaceMethodrefInfo(ci, nt);
else {
if (newMethodIsPrivate && c == INVOKEVIRTUAL)
iterator.writeByte(INVOKESPECIAL, pos);
newIndex = cp.addMethodrefInfo(ci, nt);
}
constPool = cp;
}
iterator.write16bit(newIndex, pos + 1);
return pos;
}
示例3: match
import scouter.javassist.bytecode.ConstPool; //导入方法依赖的package包/类
protected int match(int c, int pos, CodeIterator iterator,
int typedesc, ConstPool cp) throws BadBytecode
{
if (newIndex == 0) {
String desc = Descriptor.ofParameters(parameterTypes) + 'V';
desc = Descriptor.insertParameter(classname, desc);
int nt = cp.addNameAndTypeInfo(newMethodname, desc);
int ci = cp.addClassInfo(newClassname);
newIndex = cp.addMethodrefInfo(ci, nt);
constPool = cp;
}
if (saveCode == null)
makeCode(parameterTypes, cp);
return match2(pos, iterator);
}