public CtClass getSuperclass() throws NotFoundException { return pool.get(javaLangObject); }
private static Type lookupType(String name) { try { return new Type(ClassPool.getDefault().get(name)); } catch (NotFoundException e) { throw new RuntimeException(e); } }
private CtClass getCtClass(Class<?> c) throws NotFoundException { return mPool.get(c.getName()); }
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); } }
private CtClass getCtClass(Class<?> c) throws NotFoundException { return mPool.get(c.getName()); }
public CtClass[] getInterfaces() throws NotFoundException { if (interfaces == null) { Class[] intfs = Object[].class.getInterfaces(); // java.lang.Cloneable and java.io.Serializable. // If the JVM is CLDC, intfs is empty. interfaces = new CtClass[intfs.length]; for (int i = 0; i < intfs.length; i++) interfaces[i] = pool.get(intfs[i].getName()); } return interfaces; }
/** * 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); }
@Override public CtClass get(String classname) throws NotFoundException { if ( rawByteClassDefs.containsKey(classname)) { try { return makeClass(new ByteArrayInputStream(rawByteClassDefs.get(classname))); } catch (IOException e) { e.printStackTrace(); } } return super.get(classname); } };
/** * Returns the class of the created object. */ private CtClass getCtClass() throws NotFoundException { return thisClass.getClassPool().get(newTypeName); }
public CtClass getComponentType() throws NotFoundException { String name = getName(); return pool.get(name.substring(0, name.length() - 2)); }
/** * Reads a class file and obtains a compile-time method. * * @param classname the class name * @param methodname the method name * @see CtClass#getDeclaredMethod(String) */ public CtMethod getMethod(String classname, String methodname) throws NotFoundException { CtClass c = get(classname); return c.getDeclaredMethod(methodname); }
/** * Returns the class in which the field is declared. */ private CtClass getCtClass() throws NotFoundException { return thisClass.getClassPool().get(getClassName()); }
private Type getType(String name) throws BadBytecode { try { return Type.get(classPool.get(name)); } catch (NotFoundException e) { throw new BadBytecode("Could not find class [pos = " + lastPos + "]: " + name); } }
public CtClass[] getInterfaces() throws NotFoundException { String[] ifs = getClassFile2().getInterfaces(); int num = ifs.length; CtClass[] ifc = new CtClass[num]; for (int i = 0; i < num; ++i) ifc[i] = classPool.get(ifs[i]); return ifc; }
/** * 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")); }
public CtClass getSuperclass() throws NotFoundException { String supername = getClassFile2().getSuperclass(); if (supername == null) return null; else return classPool.get(supername); }
/** * Returns the class of the target object, * which the method is called on. */ protected CtClass getCtClass() throws NotFoundException { return thisClass.getClassPool().get(getClassName()); }
private Type createArray(Type rootComponent, int dims) { if (rootComponent instanceof MultiType) return new MultiArrayType((MultiType) rootComponent, dims); String name = arrayName(rootComponent.clazz.getName(), dims); Type type; try { type = Type.get(getClassPool(rootComponent).get(name)); } catch (NotFoundException e) { throw new RuntimeException(e); } return type; }
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; }
/** * Obtains exceptions that this method/constructor may throw. * * @return a zero-length array if there is no throws clause. */ public CtClass[] getExceptionTypes() throws NotFoundException { String[] exceptions; ExceptionsAttribute ea = methodInfo.getExceptionsAttribute(); if (ea == null) exceptions = null; else exceptions = ea.getExceptions(); return declaringClass.getClassPool().get(exceptions); }