本文整理了Java中javassist.bytecode.Bytecode.addPutfield()
方法的一些代码示例,展示了Bytecode.addPutfield()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bytecode.addPutfield()
方法的具体详情如下:
包路径:javassist.bytecode.Bytecode
类名称:Bytecode
方法名:addPutfield
[英]Appends PUTFIELD.
[中]附加PUTFIELD。
代码示例来源:origin: redisson/redisson
int compile(CtClass type, String name, Bytecode code,
CtClass[] parameters, Javac drv)
throws CannotCompileException
{
code.addAload(0);
code.addLdc(value);
code.addPutfield(Bytecode.THIS, name, Descriptor.of(type));
return 2; // stack size
}
代码示例来源:origin: redisson/redisson
int compile(CtClass type, String name, Bytecode code,
CtClass[] parameters, Javac drv)
throws CannotCompileException
{
code.addAload(0);
code.addLdc2w(value);
code.addPutfield(Bytecode.THIS, name, Descriptor.of(type));
return 3; // stack size
}
代码示例来源:origin: redisson/redisson
int compile(CtClass type, String name, Bytecode code,
CtClass[] parameters, Javac drv)
throws CannotCompileException
{
code.addAload(0);
addNewarray(code);
code.addPutfield(Bytecode.THIS, name, Descriptor.of(type));
return 2; // stack size
}
代码示例来源:origin: redisson/redisson
int compile(CtClass type, String name, Bytecode code,
CtClass[] parameters, Javac drv)
throws CannotCompileException
{
code.addAload(0);
int s = code.addMultiNewarray(type, dim);
code.addPutfield(Bytecode.THIS, name, Descriptor.of(type));
return s + 1; // stack size
}
代码示例来源:origin: redisson/redisson
int compile(CtClass type, String name, Bytecode code,
CtClass[] parameters, Javac drv)
throws CannotCompileException
{
code.addAload(0);
code.addFconst(value);
code.addPutfield(Bytecode.THIS, name, Descriptor.of(type));
return 3; // stack size
}
代码示例来源:origin: redisson/redisson
int compile(CtClass type, String name, Bytecode code,
CtClass[] parameters, Javac drv)
throws CannotCompileException
{
code.addAload(0);
code.addLdc2w(value);
code.addPutfield(Bytecode.THIS, name, Descriptor.of(type));
return 3; // stack size
}
代码示例来源:origin: redisson/redisson
int compile(CtClass type, String name, Bytecode code,
CtClass[] parameters, Javac drv)
throws CannotCompileException
{
code.addAload(0);
code.addIconst(value);
code.addPutfield(Bytecode.THIS, name, Descriptor.of(type));
return 2; // stack size
}
代码示例来源:origin: org.javassist/javassist
@Override
int compile(CtClass type, String name, Bytecode code,
CtClass[] parameters, Javac drv)
throws CannotCompileException
{
code.addAload(0);
code.addFconst(value);
code.addPutfield(Bytecode.THIS, name, Descriptor.of(type));
return 3; // stack size
}
代码示例来源:origin: org.javassist/javassist
@Override
int compile(CtClass type, String name, Bytecode code,
CtClass[] parameters, Javac drv)
throws CannotCompileException
{
code.addAload(0);
code.addLdc2w(value);
code.addPutfield(Bytecode.THIS, name, Descriptor.of(type));
return 3; // stack size
}
代码示例来源:origin: org.javassist/javassist
@Override
int compile(CtClass type, String name, Bytecode code,
CtClass[] parameters, Javac drv)
throws CannotCompileException
{
code.addAload(0);
int s = code.addMultiNewarray(type, dim);
code.addPutfield(Bytecode.THIS, name, Descriptor.of(type));
return s + 1; // stack size
}
代码示例来源:origin: org.javassist/javassist
@Override
int compile(CtClass type, String name, Bytecode code,
CtClass[] parameters, Javac drv)
throws CannotCompileException
{
code.addAload(0);
code.addIconst(value);
code.addPutfield(Bytecode.THIS, name, Descriptor.of(type));
return 2; // stack size
}
代码示例来源:origin: org.javassist/javassist
@Override
int compile(CtClass type, String name, Bytecode code,
CtClass[] parameters, Javac drv)
throws CannotCompileException
{
code.addAload(0);
code.addLdc(value);
code.addPutfield(Bytecode.THIS, name, Descriptor.of(type));
return 2; // stack size
}
代码示例来源:origin: org.javassist/javassist
@Override
int compile(CtClass type, String name, Bytecode code,
CtClass[] parameters, Javac drv)
throws CannotCompileException
{
code.addAload(0);
addNewarray(code);
code.addPutfield(Bytecode.THIS, name, Descriptor.of(type));
return 2; // stack size
}
代码示例来源:origin: org.javassist/javassist
@Override
int compile(CtClass type, String name, Bytecode code,
CtClass[] parameters, Javac drv)
throws CannotCompileException
{
code.addAload(0);
code.addLdc2w(value);
code.addPutfield(Bytecode.THIS, name, Descriptor.of(type));
return 3; // stack size
}
代码示例来源:origin: redisson/redisson
int compile(CtClass type, String name, Bytecode code,
CtClass[] parameters, Javac drv)
throws CannotCompileException
{
if (parameters != null && nthParam < parameters.length) {
code.addAload(0);
int nth = nthParamToLocal(nthParam, parameters, false);
int s = code.addLoad(nth, type) + 1;
code.addPutfield(Bytecode.THIS, name, Descriptor.of(type));
return s; // stack size
}
else
return 0; // do not initialize
}
代码示例来源:origin: redisson/redisson
int compile(CtClass type, String name, Bytecode code,
CtClass[] parameters, Javac drv)
throws CannotCompileException
{
try {
code.addAload(0);
compileExpr(drv);
code.addPutfield(Bytecode.THIS, name, Descriptor.of(type));
return code.getMaxStack();
}
catch (CompileError e) {
throw new CannotCompileException(e);
}
}
代码示例来源:origin: redisson/redisson
/**
* Produces codes in which a new object is created and assigned to
* the field as the initial value.
*/
int compile(CtClass type, String name, Bytecode code,
CtClass[] parameters, Javac drv)
throws CannotCompileException
{
int stacksize;
code.addAload(0);
code.addAload(0);
if (stringParams == null)
stacksize = 2;
else
stacksize = compileStringParameter(code) + 2;
if (withConstructorParams)
stacksize += CtNewWrappedMethod.compileParameterList(code,
parameters, 1);
String typeDesc = Descriptor.of(type);
String mDesc = getDescriptor() + typeDesc;
code.addInvokestatic(objectType, methodName, mDesc);
code.addPutfield(Bytecode.THIS, name, typeDesc);
return stacksize;
}
代码示例来源:origin: redisson/redisson
private static void addSetter(String classname, ClassFile cf, ConstPool cp)
throws CannotCompileException
{
MethodInfo minfo = new MethodInfo(cp, HANDLER_SETTER,
HANDLER_SETTER_TYPE);
minfo.setAccessFlags(AccessFlag.PUBLIC);
Bytecode code = new Bytecode(cp, 2, 2);
code.addAload(0);
code.addAload(1);
code.addPutfield(classname, HANDLER, HANDLER_TYPE);
code.addOpcode(Bytecode.RETURN);
minfo.setCodeAttribute(code.toCodeAttribute());
cf.addMethod(minfo);
}
代码示例来源:origin: redisson/redisson
/**
* Produces codes in which a new object is created and assigned to
* the field as the initial value.
*/
int compile(CtClass type, String name, Bytecode code,
CtClass[] parameters, Javac drv)
throws CannotCompileException
{
int stacksize;
code.addAload(0);
code.addNew(objectType);
code.add(Bytecode.DUP);
code.addAload(0);
if (stringParams == null)
stacksize = 4;
else
stacksize = compileStringParameter(code) + 4;
if (withConstructorParams)
stacksize += CtNewWrappedMethod.compileParameterList(code,
parameters, 1);
code.addInvokespecial(objectType, "<init>", getDescriptor());
code.addPutfield(Bytecode.THIS, name, Descriptor.of(type));
return stacksize;
}
代码示例来源:origin: org.javassist/javassist
private static void addSetter(String classname, ClassFile cf, ConstPool cp)
throws CannotCompileException
{
MethodInfo minfo = new MethodInfo(cp, HANDLER_SETTER,
HANDLER_SETTER_TYPE);
minfo.setAccessFlags(AccessFlag.PUBLIC);
Bytecode code = new Bytecode(cp, 2, 2);
code.addAload(0);
code.addAload(1);
code.addPutfield(classname, HANDLER, HANDLER_TYPE);
code.addOpcode(Bytecode.RETURN);
minfo.setCodeAttribute(code.toCodeAttribute());
cf.addMethod(minfo);
}
内容来源于网络,如有侵权,请联系作者删除!