本文整理汇总了Java中scouter.javassist.bytecode.FieldInfo.setAccessFlags方法的典型用法代码示例。如果您正苦于以下问题:Java FieldInfo.setAccessFlags方法的具体用法?Java FieldInfo.setAccessFlags怎么用?Java FieldInfo.setAccessFlags使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scouter.javassist.bytecode.FieldInfo
的用法示例。
在下文中一共展示了FieldInfo.setAccessFlags方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: CtField
import scouter.javassist.bytecode.FieldInfo; //导入方法依赖的package包/类
/**
* Creates a copy of the given field.
* The created field must be added to a class
* with <code>CtClass.addField()</code>.
* An initial value of the field is specified
* by a <code>CtField.Initializer</code> object.
*
* <p>If getter and setter methods are needed,
* call <code>CtNewMethod.getter()</code> and
* <code>CtNewMethod.setter()</code>.
*
* @param src the original field
* @param declaring the class to which the field will be added.
* @see CtNewMethod#getter(String,CtField)
* @see CtNewMethod#setter(String,CtField)
* @see CtField.Initializer
*/
public CtField(CtField src, CtClass declaring)
throws CannotCompileException
{
this(src.fieldInfo.getDescriptor(), src.fieldInfo.getName(),
declaring);
java.util.ListIterator iterator
= src.fieldInfo.getAttributes().listIterator();
FieldInfo fi = fieldInfo;
fi.setAccessFlags(src.fieldInfo.getAccessFlags());
ConstPool cp = fi.getConstPool();
while (iterator.hasNext()) {
AttributeInfo ainfo = (AttributeInfo)iterator.next();
fi.addAttribute(ainfo.copy(cp, null));
}
}
示例2: make
import scouter.javassist.bytecode.FieldInfo; //导入方法依赖的package包/类
private ClassFile make() throws CannotCompileException {
ClassFile cf = new ClassFile(false, classname, superName);
cf.setAccessFlags(AccessFlag.PUBLIC);
setInterfaces(cf, interfaces, hasGetHandler ? Proxy.class : ProxyObject.class);
ConstPool pool = cf.getConstPool();
// legacy: we only add the static field for the default interceptor if caching is disabled
if (!factoryUseCache) {
FieldInfo finfo = new FieldInfo(pool, DEFAULT_INTERCEPTOR, HANDLER_TYPE);
finfo.setAccessFlags(AccessFlag.PUBLIC | AccessFlag.STATIC);
cf.addField(finfo);
}
// handler is per instance
FieldInfo finfo2 = new FieldInfo(pool, HANDLER, HANDLER_TYPE);
finfo2.setAccessFlags(AccessFlag.PRIVATE);
cf.addField(finfo2);
// filter signature is per class
FieldInfo finfo3 = new FieldInfo(pool, FILTER_SIGNATURE_FIELD, FILTER_SIGNATURE_TYPE);
finfo3.setAccessFlags(AccessFlag.PUBLIC | AccessFlag.STATIC);
cf.addField(finfo3);
// the proxy class serial uid must always be a fixed value
FieldInfo finfo4 = new FieldInfo(pool, SERIAL_VERSION_UID_FIELD, SERIAL_VERSION_UID_TYPE);
finfo4.setAccessFlags(AccessFlag.PUBLIC | AccessFlag.STATIC| AccessFlag.FINAL);
cf.addField(finfo4);
// HashMap allMethods = getMethods(superClass, interfaces);
// int size = allMethods.size();
makeConstructors(classname, cf, pool, classname);
ArrayList forwarders = new ArrayList();
int s = overrideMethods(cf, pool, classname, forwarders);
addClassInitializer(cf, pool, classname, s, forwarders);
addSetter(classname, cf, pool);
if (!hasGetHandler)
addGetter(classname, cf, pool);
if (factoryWriteReplace) {
try {
cf.addMethod(makeWriteReplace(pool));
}
catch (DuplicateMemberException e) {
// writeReplace() is already declared in the super class/interfaces.
}
}
thisClass = null;
return cf;
}
示例3: addClassInitializer
import scouter.javassist.bytecode.FieldInfo; //导入方法依赖的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);
}