本文整理匯總了Java中scouter.javassist.bytecode.MethodInfo.getDescriptor方法的典型用法代碼示例。如果您正苦於以下問題:Java MethodInfo.getDescriptor方法的具體用法?Java MethodInfo.getDescriptor怎麽用?Java MethodInfo.getDescriptor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類scouter.javassist.bytecode.MethodInfo
的用法示例。
在下文中一共展示了MethodInfo.getDescriptor方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: delegator0
import scouter.javassist.bytecode.MethodInfo; //導入方法依賴的package包/類
private static CtMethod delegator0(CtMethod delegate, CtClass declaring)
throws CannotCompileException, NotFoundException
{
MethodInfo deleInfo = delegate.getMethodInfo2();
String methodName = deleInfo.getName();
String desc = deleInfo.getDescriptor();
ConstPool cp = declaring.getClassFile2().getConstPool();
MethodInfo minfo = new MethodInfo(cp, methodName, desc);
minfo.setAccessFlags(deleInfo.getAccessFlags());
ExceptionsAttribute eattr = deleInfo.getExceptionsAttribute();
if (eattr != null)
minfo.setExceptionsAttribute(
(ExceptionsAttribute)eattr.copy(cp, null));
Bytecode code = new Bytecode(cp, 0, 0);
boolean isStatic = Modifier.isStatic(delegate.getModifiers());
CtClass deleClass = delegate.getDeclaringClass();
CtClass[] params = delegate.getParameterTypes();
int s;
if (isStatic) {
s = code.addLoadParameters(params, 0);
code.addInvokestatic(deleClass, methodName, desc);
}
else {
code.addLoad(0, deleClass);
s = code.addLoadParameters(params, 1);
code.addInvokespecial(deleClass, methodName, desc);
}
code.addReturn(delegate.getReturnType());
code.setMaxLocals(++s);
code.setMaxStack(s < 2 ? 2 : s); // for a 2-word return value
minfo.setCodeAttribute(code.toCodeAttribute());
// a stack map is not needed.
return new CtMethod(minfo, declaring);
}
示例2: atMethodCallCore2
import scouter.javassist.bytecode.MethodInfo; //導入方法依賴的package包/類
private void atMethodCallCore2(CtClass targetClass, String mname,
boolean isStatic, boolean isSpecial,
int aload0pos,
MemberResolver.Method found)
throws CompileError
{
CtClass declClass = found.declaring;
MethodInfo minfo = found.info;
String desc = minfo.getDescriptor();
int acc = minfo.getAccessFlags();
if (mname.equals(MethodInfo.nameInit)) {
isSpecial = true;
if (declClass != targetClass)
throw new CompileError("no such constructor: " + targetClass.getName());
if (declClass != thisClass && AccessFlag.isPrivate(acc)) {
desc = getAccessibleConstructor(desc, declClass, minfo);
bytecode.addOpcode(Opcode.ACONST_NULL); // the last parameter
}
}
else if (AccessFlag.isPrivate(acc))
if (declClass == thisClass)
isSpecial = true;
else {
isSpecial = false;
isStatic = true;
String origDesc = desc;
if ((acc & AccessFlag.STATIC) == 0)
desc = Descriptor.insertParameter(declClass.getName(),
origDesc);
acc = AccessFlag.setPackage(acc) | AccessFlag.STATIC;
mname = getAccessiblePrivate(mname, origDesc, desc,
minfo, declClass);
}
boolean popTarget = false;
if ((acc & AccessFlag.STATIC) != 0) {
if (!isStatic) {
/* this method is static but the target object is
on stack. It must be popped out. If aload0pos >= 0,
then the target object was pushed by aload_0. It is
overwritten by NOP.
*/
isStatic = true;
if (aload0pos >= 0)
bytecode.write(aload0pos, NOP);
else
popTarget = true;
}
bytecode.addInvokestatic(declClass, mname, desc);
}
else if (isSpecial) // if (isSpecial && notStatic(acc))
bytecode.addInvokespecial(targetClass, mname, desc);
else {
if (!Modifier.isPublic(declClass.getModifiers())
|| declClass.isInterface() != targetClass.isInterface())
declClass = targetClass;
if (declClass.isInterface()) {
int nargs = Descriptor.paramSize(desc) + 1;
bytecode.addInvokeinterface(declClass, mname, desc, nargs);
}
else
if (isStatic)
throw new CompileError(mname + " is not static");
else
bytecode.addInvokevirtual(declClass, mname, desc);
}
setReturnType(desc, isStatic, popTarget);
}