本文整理汇总了Java中scouter.javassist.CtField.getName方法的典型用法代码示例。如果您正苦于以下问题:Java CtField.getName方法的具体用法?Java CtField.getName怎么用?Java CtField.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scouter.javassist.CtField
的用法示例。
在下文中一共展示了CtField.getName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isAccessibleField
import scouter.javassist.CtField; //导入方法依赖的package包/类
/**
* Returns null if the field is accessible. Otherwise, it throws
* an exception or it returns AccessorMaker if the field is a private
* one declared in an enclosing class.
*/
private AccessorMaker isAccessibleField(CtField f, FieldInfo finfo)
throws CompileError
{
if (AccessFlag.isPrivate(finfo.getAccessFlags())
&& f.getDeclaringClass() != thisClass) {
CtClass declClass = f.getDeclaringClass();
if (isEnclosing(declClass, thisClass)) {
AccessorMaker maker = declClass.getAccessorMaker();
if (maker != null)
return maker;
else
throw new CompileError("fatal error. bug?");
}
else
throw new CompileError("Field " + f.getName() + " in "
+ declClass.getName() + " is private.");
}
return null; // accessible field
}
示例2: TransformFieldAccess
import scouter.javassist.CtField; //导入方法依赖的package包/类
public TransformFieldAccess(Transformer next, CtField field,
String newClassname, String newFieldname)
{
super(next);
this.fieldClass = field.getDeclaringClass();
this.fieldname = field.getName();
this.isPrivate = Modifier.isPrivate(field.getModifiers());
this.newClassname = newClassname;
this.newFieldname = newFieldname;
this.constPool = null;
}
示例3: TransformReadField
import scouter.javassist.CtField; //导入方法依赖的package包/类
public TransformReadField(Transformer next, CtField field,
String methodClassname, String methodName)
{
super(next);
this.fieldClass = field.getDeclaringClass();
this.fieldname = field.getName();
this.methodClassname = methodClassname;
this.methodName = methodName;
this.isPrivate = Modifier.isPrivate(field.getModifiers());
}
示例4: registerReflectiveClass
import scouter.javassist.CtField; //导入方法依赖的package包/类
/**
* Registers a reflective class. The field accesses to the instances
* of this class are instrumented.
*/
private void registerReflectiveClass(CtClass clazz) {
CtField[] fs = clazz.getDeclaredFields();
for (int i = 0; i < fs.length; ++i) {
CtField f = fs[i];
int mod = f.getModifiers();
if ((mod & Modifier.PUBLIC) != 0 && (mod & Modifier.FINAL) == 0) {
String name = f.getName();
converter.replaceFieldRead(f, clazz, readPrefix + name);
converter.replaceFieldWrite(f, clazz, writePrefix + name);
}
}
}
示例5: processFields
import scouter.javassist.CtField; //导入方法依赖的package包/类
private void processFields(CtClass clazz)
throws CannotCompileException, NotFoundException
{
CtField[] fs = clazz.getDeclaredFields();
for (int i = 0; i < fs.length; ++i) {
CtField f = fs[i];
int mod = f.getModifiers();
if ((mod & Modifier.PUBLIC) != 0 && (mod & Modifier.FINAL) == 0) {
mod |= Modifier.STATIC;
String name = f.getName();
CtClass ftype = f.getType();
CtMethod wmethod
= CtNewMethod.wrapped(ftype, readPrefix + name,
readParam, null, trapRead,
CtMethod.ConstParameter.string(name),
clazz);
wmethod.setModifiers(mod);
clazz.addMethod(wmethod);
CtClass[] writeParam = new CtClass[2];
writeParam[0] = classPool.get("java.lang.Object");
writeParam[1] = ftype;
wmethod = CtNewMethod.wrapped(CtClass.voidType,
writePrefix + name,
writeParam, null, trapWrite,
CtMethod.ConstParameter.string(name), clazz);
wmethod.setModifiers(mod);
clazz.addMethod(wmethod);
}
}
}