当前位置: 首页>>代码示例>>Java>>正文


Java CtField.getName方法代码示例

本文整理汇总了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
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:26,代码来源:MemberCodeGen.java

示例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;
}
 
开发者ID:scouter-project,项目名称:bytescope,代码行数:12,代码来源:TransformFieldAccess.java

示例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());
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:11,代码来源:TransformReadField.java

示例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);
        }
    }
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:17,代码来源:Reflection.java

示例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);
        }
    }
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:31,代码来源:Reflection.java


注:本文中的scouter.javassist.CtField.getName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。