public CtConstructor getClassInitializer() { CtMember.Cache memCache = getMembers(); CtMember cons = memCache.consHead(); CtMember consTail = memCache.lastCons(); while (cons != consTail) { cons = cons.next(); CtConstructor cc = (CtConstructor)cons; if (cc.isClassInitializer()) return cc; } return null; }
public URL getURL() throws NotFoundException { URL url = classPool.find(getName()); if (url == null) throw new NotFoundException(getName()); else return url; }
private void nameReplaced() { CtMember.Cache cache = hasMemberCache(); if (cache != null) { CtMember mth = cache.methodHead(); CtMember tail = cache.lastMethod(); while (mth != tail) { mth = mth.next(); mth.nameReplaced(); } } }
public static ClassPool getClassPool(ClassLoader loader) { if (loader == null) { return ClassPool.getDefault(); } ClassPool pool = POOL_MAP.get(loader); if (pool == null) { pool = new ClassPool(true); pool.appendClassPath(new LoaderClassPath(loader)); POOL_MAP.put(loader, pool); } return pool; }
public TransformCall(Transformer next, CtMethod origMethod, CtMethod substMethod) { this(next, origMethod.getName(), substMethod); classname = origMethod.getDeclaringClass().getName(); }
/** * Does the class implement Serializable? */ private static boolean isSerializable(CtClass clazz) throws NotFoundException { ClassPool pool = clazz.getClassPool(); return clazz.subtypeOf(pool.get("java.io.Serializable")); }
/** * 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); }
/** * Returns the uniform resource locator (URL) of the class file. */ public URL getURL() throws NotFoundException { throw new NotFoundException(getName()); }
/** * Lock a class into the cache * * @param c * the class */ public void lockInCache(CtClass c) { super.cacheCtClass(c.getName(), c, false); }
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()); }
static boolean isFieldInSuper(CtClass clazz, CtClass fclass, String fname) { if (!clazz.subclassOf(fclass)) return false; try { CtField f = clazz.getField(fname); return f.getDeclaringClass() == fclass; } catch (NotFoundException e) {} return false; }
public CtMethod[] getMethods() { try { return getSuperclass().getMethods(); } catch (NotFoundException e) { return super.getMethods(); } }
public CtMethod getMethod(String name, String desc) throws NotFoundException { return getSuperclass().getMethod(name, desc); }
public CtConstructor[] getConstructors() { try { return getSuperclass().getConstructors(); } catch (NotFoundException e) { return super.getConstructors(); } } }
public CtMethod getMethod(String name, String desc) throws NotFoundException { CtMethod m = getMethod0(this, name, desc); if (m != null) return m; else throw new NotFoundException(name + "(..) is not found in " + getName()); }
private CtField checkGetField(CtField f, String name, String desc) throws NotFoundException { if (f == null) { String msg = "field: " + name; if (desc != null) msg += " type " + desc; throw new NotFoundException(msg + " in " + getName()); } else return f; }
/** * This method does not change the STATIC bit. The original value is kept. */ public void setModifiers(int mod) { mod = mod & ~Modifier.STATIC; super.setModifiers(mod); updateInnerEntry(mod, getName(), this, true); }
public static ClassPool getClassPool(ClassLoader loader) { if (loader == null) { return ClassPool.getDefault(); } ClassPool pool = POOL_MAP.get(loader); if (pool == null) { pool = new ClassPool(true); pool.appendClassPath(new LoaderClassPath(loader)); POOL_MAP.put(loader, pool); } return pool; }
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; }