/** * Retrieves the field with the specified name among the fields * declared in the class. * * <p>Note: this method does not search the super classes. */ public CtField getDeclaredField(String name) throws NotFoundException { throw new NotFoundException(name); }
/** * Always throws a <code>NotFoundException</code>. * * @see #getConstructor() */ public CtMethod getMethod() throws NotFoundException { throw new NotFoundException("this is a constructor call. Call getConstructor()."); }
/** * Retrieves the method with the specified name among the methods * declared in the class. If there are multiple methods with * the specified name, then this method returns one of them. * * <p>Note: this method does not search the superclasses. * * @see javassist.CtMethod */ public CtMethod getDeclaredMethod(String name) throws NotFoundException { throw new NotFoundException(name); }
/** * Retrieves methods with the specified name among the methods * declared in the class. Multiple methods with different parameters * may be returned. * * <p>Note: this method does not search the superclasses.</p> * * @param name method name. * @since 3.19 */ public CtMethod[] getDeclaredMethods(String name) throws NotFoundException { throw new NotFoundException(name); }
/** * Returns the field with the specified name and type. The returned field * may be a private field declared in a super class or interface. * Unlike Java, the JVM allows a class to have * multiple fields with the same name but different types. * * @param name the field name. * @param desc the type descriptor of the field. It is available by * {@link CtField#getSignature()}. * @see CtField#getSignature() */ public CtField getField(String name, String desc) throws NotFoundException { throw new NotFoundException(name); }
/** * Retrieves the method with the specified name and parameter types * among the methods declared in the class. * * <p>Note: this method does not search the superclasses. * * @param name method name * @param params parameter types * @see javassist.CtMethod */ public CtMethod getDeclaredMethod(String name, CtClass[] params) throws NotFoundException { throw new NotFoundException(name); }
/** * Retrieves the field with the specified name and type among the fields * declared in the class. Unlike Java, the JVM allows a class to have * multiple fields with the same name but different types. * * <p>Note: this method does not search the super classes. * * @param name the field name. * @param desc the type descriptor of the field. It is available by * {@link CtField#getSignature()}. * @see CtField#getSignature() */ public CtField getDeclaredField(String name, String desc) throws NotFoundException { throw new NotFoundException(name); }
/** * Returns the constructor with the given signature, * which is represented by a character string * called method descriptor. * For details of the method descriptor, see the JVM specification * or <code>javassist.bytecode.Descriptor</code>. * * @param desc method descriptor * @see javassist.bytecode.Descriptor */ public CtConstructor getConstructor(String desc) throws NotFoundException { throw new NotFoundException("no such constructor"); }
/** * Returns the uniform resource locator (URL) of the class file. */ public URL getURL() throws NotFoundException { throw new NotFoundException(getName()); }
JarClassPath(String pathname) throws NotFoundException { try { jarfile = new JarFile(pathname); jarfileURL = new File(pathname).getCanonicalFile() .toURI().toURL().toString(); return; } catch (IOException e) {} throw new NotFoundException(pathname); }
public InputStream openClassfile(String classname) throws NotFoundException { try { String jarname = classname.replace('.', '/') + ".class"; JarEntry je = jarfile.getJarEntry(jarname); if (je != null) return jarfile.getInputStream(je); else return null; // not found } catch (IOException e) {} throw new NotFoundException("broken jar file?: " + jarfile.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; }
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()); }
/** * This method does not close the output stream. */ void writeClassfile(String classname, OutputStream out) throws NotFoundException, IOException, CannotCompileException { InputStream fin = openClassfile(classname); if (fin == null) throw new NotFoundException(classname); try { copyStream(fin, out); } finally { fin.close(); } }
public URL getURL() throws NotFoundException { URL url = classPool.find(getName()); if (url == null) throw new NotFoundException(getName()); else return url; }
public CtMethod getDeclaredMethod(String name) throws NotFoundException { CtMember.Cache memCache = getMembers(); CtMember mth = memCache.methodHead(); CtMember mthTail = memCache.lastMethod(); while (mth != mthTail) { mth = mth.next(); if (mth.getName().equals(name)) return (CtMethod)mth; } throw new NotFoundException(name + "(..) is not found in " + getName()); }
public void removeMethod(CtMethod m) throws NotFoundException { checkModify(); MethodInfo mi = m.getMethodInfo2(); ClassFile cf = getClassFile2(); if (cf.getMethods().remove(mi)) { getMembers().remove(m); gcConstPool = true; } else throw new NotFoundException(m.toString()); }
public void removeField(CtField f) throws NotFoundException { checkModify(); FieldInfo fi = f.getFieldInfo2(); ClassFile cf = getClassFile2(); if (cf.getFields().remove(fi)) { getMembers().remove(f); gcConstPool = true; } else throw new NotFoundException(f.toString()); }
public void removeConstructor(CtConstructor m) throws NotFoundException { checkModify(); MethodInfo mi = m.getMethodInfo2(); ClassFile cf = getClassFile2(); if (cf.getMethods().remove(mi)) { getMembers().remove(m); gcConstPool = true; } else throw new NotFoundException(m.toString()); }
public CtMethod getDeclaredMethod(String name, CtClass[] params) throws NotFoundException { String desc = Descriptor.ofParameters(params); CtMember.Cache memCache = getMembers(); CtMember mth = memCache.methodHead(); CtMember mthTail = memCache.lastMethod(); while (mth != mthTail) { mth = mth.next(); if (mth.getName().equals(name) && ((CtMethod)mth).getMethodInfo2().getDescriptor().startsWith(desc)) return (CtMethod)mth; } throw new NotFoundException(name + "(..) is not found in " + getName()); }