本文整理汇总了Java中scouter.javassist.bytecode.Bytecode.addLdc方法的典型用法代码示例。如果您正苦于以下问题:Java Bytecode.addLdc方法的具体用法?Java Bytecode.addLdc怎么用?Java Bytecode.addLdc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scouter.javassist.bytecode.Bytecode
的用法示例。
在下文中一共展示了Bytecode.addLdc方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: callFind2Methods
import scouter.javassist.bytecode.Bytecode; //导入方法依赖的package包/类
/**
* @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);
}
示例2: compileStringParameter
import scouter.javassist.bytecode.Bytecode; //导入方法依赖的package包/类
protected final int compileStringParameter(Bytecode code)
throws CannotCompileException
{
int nparam = stringParams.length;
code.addIconst(nparam);
code.addAnewarray(javaLangString);
for (int j = 0; j < nparam; ++j) {
code.add(Bytecode.DUP); // dup
code.addIconst(j); // iconst_<j>
code.addLdc(stringParams[j]); // ldc ...
code.add(Bytecode.AASTORE); // aastore
}
return 4;
}
示例3: compile
import scouter.javassist.bytecode.Bytecode; //导入方法依赖的package包/类
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
}
示例4: compileIfStatic
import scouter.javassist.bytecode.Bytecode; //导入方法依赖的package包/类
int compileIfStatic(CtClass type, String name, Bytecode code,
Javac drv) throws CannotCompileException
{
code.addLdc(value);
code.addPutstatic(Bytecode.THIS, name, Descriptor.of(type));
return 1; // stack size
}
示例5: compile
import scouter.javassist.bytecode.Bytecode; //导入方法依赖的package包/类
int compile(Bytecode code) throws CannotCompileException {
code.addLdc(param);
return 1;
}
示例6: addClassInitializer
import scouter.javassist.bytecode.Bytecode; //导入方法依赖的package包/类
private static void addClassInitializer(ClassFile cf, ConstPool cp,
String classname, int size, ArrayList forwarders)
throws CannotCompileException
{
FieldInfo finfo = new FieldInfo(cp, HOLDER, HOLDER_TYPE);
finfo.setAccessFlags(AccessFlag.PRIVATE | AccessFlag.STATIC);
cf.addField(finfo);
MethodInfo minfo = new MethodInfo(cp, "<clinit>", "()V");
minfo.setAccessFlags(AccessFlag.STATIC);
setThrows(minfo, cp, new Class[] { ClassNotFoundException.class });
Bytecode code = new Bytecode(cp, 0, 2);
code.addIconst(size * 2);
code.addAnewarray("java.lang.reflect.Method");
final int varArray = 0;
code.addAstore(varArray);
// forName() must be called here. Otherwise, the class might be
// invisible.
code.addLdc(classname);
code.addInvokestatic("java.lang.Class",
"forName", "(Ljava/lang/String;)Ljava/lang/Class;");
final int varClass = 1;
code.addAstore(varClass);
Iterator it = forwarders.iterator();
while (it.hasNext()) {
Find2MethodsArgs args = (Find2MethodsArgs)it.next();
callFind2Methods(code, args.methodName, args.delegatorName,
args.origIndex, args.descriptor, varClass, varArray);
}
code.addAload(varArray);
code.addPutstatic(classname, HOLDER, HOLDER_TYPE);
code.addLconst(SERIAL_VERSION_UID_VALUE);
code.addPutstatic(classname, SERIAL_VERSION_UID_FIELD, SERIAL_VERSION_UID_TYPE);
code.addOpcode(Bytecode.RETURN);
minfo.setCodeAttribute(code.toCodeAttribute());
cf.addMethod(minfo);
}