本文整理汇总了Java中scouter.javassist.bytecode.Bytecode.setMaxStack方法的典型用法代码示例。如果您正苦于以下问题:Java Bytecode.setMaxStack方法的具体用法?Java Bytecode.setMaxStack怎么用?Java Bytecode.setMaxStack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scouter.javassist.bytecode.Bytecode
的用法示例。
在下文中一共展示了Bytecode.setMaxStack方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeBody
import scouter.javassist.bytecode.Bytecode; //导入方法依赖的package包/类
static Bytecode makeBody(CtClass clazz, ClassFile classfile,
CtMethod wrappedBody,
CtClass[] parameters,
CtClass returnType,
ConstParameter cparam)
throws CannotCompileException
{
boolean isStatic = Modifier.isStatic(wrappedBody.getModifiers());
Bytecode code = new Bytecode(classfile.getConstPool(), 0, 0);
int stacksize = makeBody0(clazz, classfile, wrappedBody, isStatic,
parameters, returnType, cparam, code);
code.setMaxStack(stacksize);
code.setMaxLocals(isStatic, parameters, 0);
return code;
}
示例2: delegator0
import scouter.javassist.bytecode.Bytecode; //导入方法依赖的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);
}
示例3: makeBody
import scouter.javassist.bytecode.Bytecode; //导入方法依赖的package包/类
protected static Bytecode makeBody(CtClass declaring, ClassFile classfile,
int howToCallSuper,
CtMethod wrappedBody,
CtClass[] parameters,
ConstParameter cparam)
throws CannotCompileException
{
int stacksize, stacksize2;
int superclazz = classfile.getSuperclassId();
Bytecode code = new Bytecode(classfile.getConstPool(), 0, 0);
code.setMaxLocals(false, parameters, 0);
code.addAload(0);
if (howToCallSuper == PASS_NONE) {
stacksize = 1;
code.addInvokespecial(superclazz, "<init>", "()V");
}
else if (howToCallSuper == PASS_PARAMS) {
stacksize = code.addLoadParameters(parameters, 1) + 1;
code.addInvokespecial(superclazz, "<init>",
Descriptor.ofConstructor(parameters));
}
else {
stacksize = compileParameterList(code, parameters, 1);
String desc;
if (cparam == null) {
stacksize2 = 2;
desc = ConstParameter.defaultConstDescriptor();
}
else {
stacksize2 = cparam.compile(code) + 2;
desc = cparam.constDescriptor();
}
if (stacksize < stacksize2)
stacksize = stacksize2;
code.addInvokespecial(superclazz, "<init>", desc);
}
if (wrappedBody == null)
code.add(Bytecode.RETURN);
else {
stacksize2 = makeBody0(declaring, classfile, wrappedBody,
false, parameters, CtClass.voidType,
cparam, code);
if (stacksize < stacksize2)
stacksize = stacksize2;
}
code.setMaxStack(stacksize);
return code;
}
示例4: makeBody
import scouter.javassist.bytecode.Bytecode; //导入方法依赖的package包/类
protected static Bytecode makeBody(CtClass declaring, ClassFile classfile,
int howToCallSuper,
CtMethod wrappedBody,
CtClass[] parameters,
CtMethod.ConstParameter cparam)
throws CannotCompileException
{
int stacksize, stacksize2;
int superclazz = classfile.getSuperclassId();
Bytecode code = new Bytecode(classfile.getConstPool(), 0, 0);
code.setMaxLocals(false, parameters, 0);
code.addAload(0);
if (howToCallSuper == PASS_NONE) {
stacksize = 1;
code.addInvokespecial(superclazz, "<init>", "()V");
}
else if (howToCallSuper == PASS_PARAMS) {
stacksize = code.addLoadParameters(parameters, 1) + 1;
code.addInvokespecial(superclazz, "<init>",
Descriptor.ofConstructor(parameters));
}
else {
stacksize = compileParameterList(code, parameters, 1);
String desc;
if (cparam == null) {
stacksize2 = 2;
desc = CtMethod.ConstParameter.defaultConstDescriptor();
}
else {
stacksize2 = cparam.compile(code) + 2;
desc = cparam.constDescriptor();
}
if (stacksize < stacksize2)
stacksize = stacksize2;
code.addInvokespecial(superclazz, "<init>", desc);
}
if (wrappedBody == null)
code.add(Bytecode.RETURN);
else {
stacksize2 = makeBody0(declaring, classfile, wrappedBody,
false, parameters, CtClass.voidType,
cparam, code);
if (stacksize < stacksize2)
stacksize = stacksize2;
}
code.setMaxStack(stacksize);
return code;
}