本文整理汇总了Java中scouter.javassist.bytecode.ConstPool.addClassInfo方法的典型用法代码示例。如果您正苦于以下问题:Java ConstPool.addClassInfo方法的具体用法?Java ConstPool.addClassInfo怎么用?Java ConstPool.addClassInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scouter.javassist.bytecode.ConstPool
的用法示例。
在下文中一共展示了ConstPool.addClassInfo方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例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) {
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);
}
示例3: transform
import scouter.javassist.bytecode.ConstPool; //导入方法依赖的package包/类
/**
* Modifies a sequence of
* NEW classname
* DUP
* ...
* INVOKESPECIAL classname:method
*/
public int transform(CtClass clazz, int pos, CodeIterator iterator,
ConstPool cp) throws CannotCompileException
{
int index;
int c = iterator.byteAt(pos);
if (c == NEW) {
index = iterator.u16bitAt(pos + 1);
if (cp.getClassInfo(index).equals(classname)) {
if (iterator.byteAt(pos + 3) != DUP)
throw new CannotCompileException(
"NEW followed by no DUP was found");
if (newClassIndex == 0)
newClassIndex = cp.addClassInfo(newClassName);
iterator.write16bit(newClassIndex, pos + 1);
++nested;
}
}
else if (c == INVOKESPECIAL) {
index = iterator.u16bitAt(pos + 1);
int typedesc = cp.isConstructor(classname, index);
if (typedesc != 0 && nested > 0) {
int nt = cp.getMethodrefNameAndType(index);
if (newMethodNTIndex != nt) {
newMethodNTIndex = nt;
newMethodIndex = cp.addMethodrefInfo(newClassIndex, nt);
}
iterator.write16bit(newMethodIndex, pos + 1);
--nested;
}
}
return pos;
}
示例4: transform
import scouter.javassist.bytecode.ConstPool; //导入方法依赖的package包/类
public int transform(CtClass tclazz, int pos, CodeIterator iterator,
ConstPool cp) throws BadBytecode
{
int c = iterator.byteAt(pos);
if (c == GETFIELD || c == GETSTATIC) {
int index = iterator.u16bitAt(pos + 1);
String typedesc = isField(tclazz.getClassPool(), cp,
fieldClass, fieldname, isPrivate, index);
if (typedesc != null) {
if (c == GETSTATIC) {
iterator.move(pos);
pos = iterator.insertGap(1); // insertGap() may insert 4 bytes.
iterator.writeByte(ACONST_NULL, pos);
pos = iterator.next();
}
String type = "(Ljava/lang/Object;)" + typedesc;
int mi = cp.addClassInfo(methodClassname);
int methodref = cp.addMethodrefInfo(mi, methodName, type);
iterator.writeByte(INVOKESTATIC, pos);
iterator.write16bit(methodref, pos + 1);
return pos;
}
}
return pos;
}
示例5: replace
import scouter.javassist.bytecode.ConstPool; //导入方法依赖的package包/类
private int replace(ConstPool cp, CodeIterator iterator, int pos,
int opcode, String signature) throws BadBytecode {
String castType = null;
String methodName = getMethodName(opcode);
if (methodName != null) {
// See if the object must be cast
if (opcode == AALOAD) {
castType = getTopType(iterator.lookAhead());
// Do not replace an AALOAD instruction that we do not have a type for
// This happens when the state is guaranteed to be null (Type.UNINIT)
// So we don't really care about this case.
if (castType == null)
return pos;
if ("java/lang/Object".equals(castType))
castType = null;
}
// The gap may include extra padding
// Write a nop in case the padding pushes the instruction forward
iterator.writeByte(NOP, pos);
CodeIterator.Gap gap
= iterator.insertGapAt(pos, castType != null ? 5 : 2, false);
pos = gap.position;
int mi = cp.addClassInfo(methodClassname);
int methodref = cp.addMethodrefInfo(mi, methodName, signature);
iterator.writeByte(INVOKESTATIC, pos);
iterator.write16bit(methodref, pos + 1);
if (castType != null) {
int index = cp.addClassInfo(castType);
iterator.writeByte(CHECKCAST, pos + 3);
iterator.write16bit(index, pos + 4);
}
pos = updatePos(pos, gap.length);
}
return pos;
}
示例6: computeMethodref
import scouter.javassist.bytecode.ConstPool; //导入方法依赖的package包/类
private int computeMethodref(int typedesc, ConstPool cp) {
int classIndex = cp.addClassInfo(trapClass);
int mnameIndex = cp.addUtf8Info(trapMethod);
typedesc = cp.addUtf8Info(
Descriptor.changeReturnType(classname,
cp.getUtf8Info(typedesc)));
return cp.addMethodrefInfo(classIndex,
cp.addNameAndTypeInfo(mnameIndex, typedesc));
}
示例7: 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);
}
示例8: transform
import scouter.javassist.bytecode.ConstPool; //导入方法依赖的package包/类
public int transform(CtClass tclazz, int pos, CodeIterator iterator,
ConstPool cp) throws BadBytecode
{
int c = iterator.byteAt(pos);
if (c == PUTFIELD || c == PUTSTATIC) {
int index = iterator.u16bitAt(pos + 1);
String typedesc = isField(tclazz.getClassPool(), cp,
fieldClass, fieldname, isPrivate, index);
if (typedesc != null) {
if (c == PUTSTATIC) {
CodeAttribute ca = iterator.get();
iterator.move(pos);
char c0 = typedesc.charAt(0);
if (c0 == 'J' || c0 == 'D') { // long or double
// insertGap() may insert 4 bytes.
pos = iterator.insertGap(3);
iterator.writeByte(ACONST_NULL, pos);
iterator.writeByte(DUP_X2, pos + 1);
iterator.writeByte(POP, pos + 2);
ca.setMaxStack(ca.getMaxStack() + 2);
}
else {
// insertGap() may insert 4 bytes.
pos = iterator.insertGap(2);
iterator.writeByte(ACONST_NULL, pos);
iterator.writeByte(SWAP, pos + 1);
ca.setMaxStack(ca.getMaxStack() + 1);
}
pos = iterator.next();
}
int mi = cp.addClassInfo(methodClassname);
String type = "(Ljava/lang/Object;" + typedesc + ")V";
int methodref = cp.addMethodrefInfo(mi, methodName, type);
iterator.writeByte(INVOKESTATIC, pos);
iterator.write16bit(methodref, pos + 1);
}
}
return pos;
}
示例9: getTypeData
import scouter.javassist.bytecode.ConstPool; //导入方法依赖的package包/类
public int getTypeData(ConstPool cp) {
return cp.addClassInfo(getName());
}