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


Java ClassPool.get方法代码示例

本文整理汇总了Java中scouter.javassist.ClassPool.get方法的典型用法代码示例。如果您正苦于以下问题:Java ClassPool.get方法的具体用法?Java ClassPool.get怎么用?Java ClassPool.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scouter.javassist.ClassPool的用法示例。


在下文中一共展示了ClassPool.get方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCtClass

import scouter.javassist.ClassPool; //导入方法依赖的package包/类
public CtClass getCtClass() {
    CtClass clazz = component.getCtClass();
    if (clazz == null)
        return null;

    ClassPool pool = clazz.getClassPool();
    if (pool == null)
        pool = ClassPool.getDefault();

    String name = arrayName(clazz.getName(), dims);

    try {
        return pool.get(name);
    } catch (NotFoundException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:scouter-project,项目名称:bytescope,代码行数:18,代码来源:MultiArrayType.java

示例2: fixTypes2

import scouter.javassist.ClassPool; //导入方法依赖的package包/类
private String fixTypes2(ArrayList scc, HashSet lowersSet, ClassPool cp) throws NotFoundException {
    Iterator it = lowersSet.iterator();
    if (lowersSet.size() == 0)
        return null;      // only NullType
    else if (lowersSet.size() == 1)
        return (String)it.next(); 
    else {
    	CtClass cc = cp.get((String)it.next());
    	while (it.hasNext())
    		cc = commonSuperClassEx(cc, cp.get((String)it.next()));

    	if (cc.getSuperclass() == null || isObjectArray(cc))
    	    cc = fixByUppers(scc, cp, new HashSet(), cc);

    	if (cc.isArray())
    	    return Descriptor.toJvmName(cc);
    	else
    	    return cc.getName();
    }
}
 
开发者ID:scouter-project,项目名称:bytescope,代码行数:21,代码来源:TypeData.java

示例3: fixByUppers

import scouter.javassist.ClassPool; //导入方法依赖的package包/类
private CtClass fixByUppers(ArrayList users, ClassPool cp, HashSet visited, CtClass type)
    throws NotFoundException
{
    if (users == null)
        return type;

    int size = users.size();
    for (int i = 0; i < size; i++) {
        TypeVar t = (TypeVar)users.get(i);
        if (!visited.add(t))
            return type;

        if (t.uppers != null) {
            int s = t.uppers.size();
            for (int k = 0; k < s; k++) {
                CtClass cc = cp.get((String)t.uppers.get(k));
                if (cc.subtypeOf(type))
                    type = cc;
            }
        }

        type = fixByUppers(t.usedBy, cp, visited, type);
    }

    return type;
}
 
开发者ID:scouter-project,项目名称:bytescope,代码行数:27,代码来源:TypeData.java

示例4: fixTypes2

import scouter.javassist.ClassPool; //导入方法依赖的package包/类
private String fixTypes2(ArrayList scc, HashSet lowersSet, ClassPool cp) throws NotFoundException {
    Iterator it = lowersSet.iterator();
    if (lowersSet.size() == 0)
        return null;      // only NullType
    else if (lowersSet.size() == 1)
        return (String)it.next(); 
    else {
        CtClass cc = cp.get((String)it.next());
        while (it.hasNext())
            cc = commonSuperClassEx(cc, cp.get((String)it.next()));

        if (cc.getSuperclass() == null || isObjectArray(cc))
            cc = fixByUppers(scc, cp, new HashSet(), cc);

        if (cc.isArray())
            return Descriptor.toJvmName(cc);
        else
            return cc.getName();
    }
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:21,代码来源:TypeData.java

示例5: start

import scouter.javassist.ClassPool; //导入方法依赖的package包/类
/**
 * Initializes the object.
 * This is a method declared in Translator.
 *
 * @see Translator#start(ClassPool)
 */
public void start(ClassPool pool) throws NotFoundException {
    classPool = pool;
    CtClass c = pool.get(sampleClass);
    forwardMethod = c.getDeclaredMethod("forward");
    forwardStaticMethod = c.getDeclaredMethod("forwardStatic");

    proxyConstructorParamTypes
        = pool.get(new String[] { "ObjectImporter",
                                     "int" });
    interfacesForProxy
        = pool.get(new String[] { "java.io.Serializable",
                                     "Proxy" });
    exceptionForProxy
        = new CtClass[] { pool.get("RemoteException") };
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:22,代码来源:StubGenerator.java

示例6: toCtClass

import scouter.javassist.ClassPool; //导入方法依赖的package包/类
/**
 * Returns a <code>CtClass</code> object representing the type
 * specified by the given descriptor.
 *
 * <p>This method works even if the package-class separator is
 * not <code>/</code> but <code>.</code> (period).  For example,
 * it accepts <code>Ljava.lang.Object;</code>
 * as well as <code>Ljava/lang/Object;</code>.
 *
 * @param desc descriptor.
 * @param cp   the class pool used for obtaining
 *             a <code>CtClass</code> object.
 */
public static CtClass toCtClass(String desc, ClassPool cp)
    throws NotFoundException
{
    CtClass[] clazz = new CtClass[1];
    int res = toCtClass(cp, desc, 0, clazz, 0);
    if (res >= 0)
        return clazz[0];
    else {
        // maybe, you forgot to surround the class name with
        // L and ;.  It violates the protocol, but I'm tolerant...
        return cp.get(desc.replace('/', '.'));
    }
}
 
开发者ID:scouter-project,项目名称:bytescope,代码行数:27,代码来源:Descriptor.java

示例7: main

import scouter.javassist.ClassPool; //导入方法依赖的package包/类
/**
 * Main method.
 *
 * @param args <code>args[0]</code> is the class file name.
 */
public static void main(String[] args) throws Exception {
    if (args.length != 1) {
        System.err.println("Usage: java javassist.tools.framedump <fully-qualified class name>");
        return;
    }
    
    ClassPool pool = ClassPool.getDefault();
    CtClass clazz = pool.get(args[0]);
    System.out.println("Frame Dump of " + clazz.getName() + ":");
    FramePrinter.print(clazz, System.out);
}
 
开发者ID:scouter-project,项目名称:bytescope,代码行数:17,代码来源:framedump.java

示例8: processClasses

import scouter.javassist.ClassPool; //导入方法依赖的package包/类
private static void processClasses(CompiledClass[] entries, int n)
    throws Exception
{
    Reflection implementor = new Reflection();
    ClassPool pool = ClassPool.getDefault();
    implementor.start(pool);

    for (int i = 0; i < n; ++i) {
        CtClass c = pool.get(entries[i].classname);
        if (entries[i].metaobject != null
                                    || entries[i].classobject != null) {
            String metaobj, classobj;

            if (entries[i].metaobject == null)
                metaobj = "javassist.tools.reflect.Metaobject";
            else
                metaobj = entries[i].metaobject;

            if (entries[i].classobject == null)
                classobj = "javassist.tools.reflect.ClassMetaobject";
            else
                classobj = entries[i].classobject;

            if (!implementor.makeReflective(c, pool.get(metaobj),
                                          pool.get(classobj)))
                System.err.println("Warning: " + c.getName()
                            + " is reflective.  It was not changed.");

            System.err.println(c.getName() + ": " + metaobj + ", "
                               + classobj);
        }
        else
            System.err.println(c.getName() + ": not reflective");
    }

    for (int i = 0; i < n; ++i) {
        implementor.onLoad(pool, entries[i].classname);
        pool.get(entries[i].classname).writeFile();
    }
}
 
开发者ID:scouter-project,项目名称:bytescope,代码行数:41,代码来源:Compiler.java

示例9: isField

import scouter.javassist.ClassPool; //导入方法依赖的package包/类
static String isField(ClassPool pool, ConstPool cp, CtClass fclass,
                      String fname, boolean is_private, int index) {
    if (!cp.getFieldrefName(index).equals(fname))
        return null;

    try {
        CtClass c = pool.get(cp.getFieldrefClassName(index));
        if (c == fclass || (!is_private && isFieldInSuper(c, fclass, fname)))
            return cp.getFieldrefType(index);
    }
    catch (NotFoundException e) {}
    return null;
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:14,代码来源:TransformReadField.java

示例10: main

import scouter.javassist.ClassPool; //导入方法依赖的package包/类
/**
 * Main method.
 *
 * @param args <code>args[0]</code> is the class file name.
 */
public static void main(String[] args) throws Exception {
    if (args.length != 1) {
        System.err.println("Usage: java framedump <fully-qualified class name>");
        return;
    }
    
    ClassPool pool = ClassPool.getDefault();
    CtClass clazz = pool.get(args[0]);
    System.out.println("Frame Dump of " + clazz.getName() + ":");
    FramePrinter.print(clazz, System.out);
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:17,代码来源:framedump.java

示例11: onLoad

import scouter.javassist.ClassPool; //导入方法依赖的package包/类
/**
 * Inserts hooks for intercepting accesses to the fields declared
 * in reflective classes.
 */
public void onLoad(ClassPool pool, String classname)
    throws CannotCompileException, NotFoundException
{
    CtClass clazz = pool.get(classname);
    clazz.instrument(converter);
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:11,代码来源:Reflection.java

示例12: processClasses

import scouter.javassist.ClassPool; //导入方法依赖的package包/类
private static void processClasses(CompiledClass[] entries, int n)
    throws Exception
{
    Reflection implementor = new Reflection();
    ClassPool pool = ClassPool.getDefault();
    implementor.start(pool);

    for (int i = 0; i < n; ++i) {
        CtClass c = pool.get(entries[i].classname);
        if (entries[i].metaobject != null
                                    || entries[i].classobject != null) {
            String metaobj, classobj;

            if (entries[i].metaobject == null)
                metaobj = "Metaobject";
            else
                metaobj = entries[i].metaobject;

            if (entries[i].classobject == null)
                classobj = "ClassMetaobject";
            else
                classobj = entries[i].classobject;

            if (!implementor.makeReflective(c, pool.get(metaobj),
                                          pool.get(classobj)))
                System.err.println("Warning: " + c.getName()
                            + " is reflective.  It was not changed.");

            System.err.println(c.getName() + ": " + metaobj + ", "
                               + classobj);
        }
        else
            System.err.println(c.getName() + ": not reflective");
    }

    for (int i = 0; i < n; ++i) {
        implementor.onLoad(pool, entries[i].classname);
        pool.get(entries[i].classname).writeFile();
    }
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:41,代码来源:Compiler.java


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