本文整理了Java中javassist.bytecode.Bytecode.addAload()
方法的一些代码示例,展示了Bytecode.addAload()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bytecode.addAload()
方法的具体详情如下:
包路径:javassist.bytecode.Bytecode
类名称:Bytecode
方法名:addAload
[英]Appends ALOAD or (WIDE) ALOAD_<n>
[中]附加ALOAD或(宽)ALOAD
代码示例来源:origin: redisson/redisson
protected boolean doit(Bytecode b, int opcode) {
b.addAload(var);
b.addOpcode(MONITOREXIT);
return false;
}
};
代码示例来源:origin: redisson/redisson
protected void insertDefaultSuperCall() throws CompileError {
bytecode.addAload(0);
bytecode.addInvokespecial(MemberResolver.getSuperclass(thisClass),
"<init>", "()V");
}
代码示例来源: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.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.addIconst(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
/**
* @param thisMethod might be null.
*/
private static void callFind2Methods(Bytecode code, String superMethod, String thisMethod,
int index, String desc, int classVar, int arrayVar) {
String findClass = RuntimeSupport.class.getName();
String findDesc
= "(Ljava/lang/Class;Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/reflect/Method;)V";
code.addAload(classVar);
code.addLdc(superMethod);
if (thisMethod == null)
code.addOpcode(Opcode.ACONST_NULL);
else
code.addLdc(thisMethod);
code.addIconst(index);
code.addLdc(desc);
code.addAload(arrayVar);
code.addInvokestatic(findClass, "find2Methods", findDesc);
}
代码示例来源:origin: redisson/redisson
private static int addLoad(Bytecode code, int n, Class type) {
if (type.isPrimitive()) {
if (type == Long.TYPE) {
code.addLload(n);
return 2;
}
else if (type == Float.TYPE)
code.addFload(n);
else if (type == Double.TYPE) {
code.addDload(n);
return 2;
}
else
code.addIload(n);
}
else
code.addAload(n);
return 1;
}
代码示例来源: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
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
private MethodInfo makeDelegator(Method meth, String desc,
ConstPool cp, Class declClass, String delegatorName) {
MethodInfo delegator = new MethodInfo(cp, delegatorName, desc);
delegator.setAccessFlags(Modifier.FINAL | Modifier.PUBLIC
| (meth.getModifiers() & ~(Modifier.PRIVATE
| Modifier.PROTECTED
| Modifier.ABSTRACT
| Modifier.NATIVE
| Modifier.SYNCHRONIZED)));
setThrows(delegator, cp, meth);
Bytecode code = new Bytecode(cp, 0, 0);
code.addAload(0);
int s = addLoadParameters(code, meth.getParameterTypes(), 1);
Class targetClass = invokespecialTarget(declClass);
code.addInvokespecial(targetClass.isInterface(), cp.addClassInfo(targetClass.getName()),
meth.getName(), desc);
addReturn(code, meth.getReturnType());
code.setMaxLocals(++s);
delegator.setCodeAttribute(code.toCodeAttribute());
return delegator;
}
代码示例来源:origin: redisson/redisson
private static void makeParameterList(Bytecode code, Class[] params) {
int regno = 1;
int n = params.length;
code.addIconst(n);
code.addAnewarray("java/lang/Object");
for (int i = 0; i < n; i++) {
code.addOpcode(Opcode.DUP);
code.addIconst(i);
Class type = params[i];
if (type.isPrimitive())
regno = makeWrapper(code, type, regno);
else {
code.addAload(regno);
regno++;
}
code.addOpcode(Opcode.AASTORE);
}
}
代码示例来源: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
protected void makeCode(CtClass[] paramTypes, ConstPool cp) {
Bytecode save = new Bytecode(cp, 0, 0);
Bytecode load = new Bytecode(cp, 0, 0);
int var = maxLocals;
int len = (paramTypes == null) ? 0 : paramTypes.length;
load.addAload(var);
makeCode2(save, load, 0, len, paramTypes, var + 1);
save.addAstore(var);
saveCode = save.get();
loadCode = load.get();
}
代码示例来源:origin: redisson/redisson
private static void addGetter(String classname, ClassFile cf, ConstPool cp)
throws CannotCompileException
{
MethodInfo minfo = new MethodInfo(cp, HANDLER_GETTER,
HANDLER_GETTER_TYPE);
minfo.setAccessFlags(AccessFlag.PUBLIC);
Bytecode code = new Bytecode(cp, 1, 1);
code.addAload(0);
code.addGetfield(classname, HANDLER, HANDLER_TYPE);
code.addOpcode(Bytecode.ARETURN);
minfo.setCodeAttribute(code.toCodeAttribute());
cf.addMethod(minfo);
}
代码示例来源:origin: redisson/redisson
public void doit(JvstCodeGen gen, Bytecode bytecode, ASTList args)
throws CompileError
{
if (args != null && !gen.isParamListName(args))
throw new CompileError(Javac.proceedName
+ "() cannot take a parameter for field reading");
int stack;
if (isStatic(opcode))
stack = 0;
else {
stack = -1;
bytecode.addAload(targetVar);
}
if (fieldType instanceof CtPrimitiveType)
stack += ((CtPrimitiveType)fieldType).getDataSize();
else
++stack;
bytecode.add(opcode);
bytecode.addIndex(index);
bytecode.growStack(stack);
gen.setType(fieldType);
}
代码示例来源:origin: redisson/redisson
private static MethodInfo makeWriteReplace(ConstPool cp) {
MethodInfo minfo = new MethodInfo(cp, "writeReplace", "()Ljava/lang/Object;");
String[] list = new String[1];
list[0] = "java.io.ObjectStreamException";
ExceptionsAttribute ea = new ExceptionsAttribute(cp);
ea.setExceptions(list);
minfo.setExceptionsAttribute(ea);
Bytecode code = new Bytecode(cp, 0, 1);
code.addAload(0);
code.addInvokestatic("javassist.util.proxy.RuntimeSupport",
"makeSerializedProxy",
"(Ljava/lang/Object;)Ljavassist/util/proxy/SerializedProxy;");
code.addOpcode(Opcode.ARETURN);
minfo.setCodeAttribute(code.toCodeAttribute());
return minfo;
}
}
内容来源于网络,如有侵权,请联系作者删除!