/** * Copies the n-th item in this ConstPool object into the destination * ConstPool object. * The class names that the item refers to are renamed according * to the given map. * * @param n the <i>n</i>-th item * @param dest destination constant pool table * @param classnames the map or null. * @return the index of the copied item into the destination ClassPool. */ public int copy(int n, ConstPool dest, Map classnames) { if (n == 0) return 0; ConstInfo info = getItem(n); return info.copy(this, dest, classnames); }
/** * Get all the class names. * * @return a set of class names (<code>String</code> objects). */ public Set getClassNames() { HashSet result = new HashSet(); LongVector v = items; int size = numOfItems; for (int i = 1; i < size; ++i) { String className = v.elementAt(i).getClassName(this); if (className != null) result.add(className); } return result; }
/** * Returns the <code>tag</code> field of the constant pool table * entry at the given index. * * @return either <code>CONST_Class</code>, <code>CONST_Fieldref</code>, * <code>CONST_Methodref</code>, or ... */ public int getTag(int index) { return getItem(index).getTag(); }
public String toString() { ByteArrayOutputStream bout = new ByteArrayOutputStream(); PrintWriter out = new PrintWriter(bout); print(out); return bout.toString(); } }
/** * Replaces all occurrences of a class name. * * @param oldName the replaced name (JVM-internal representation). * @param newName the substituted name (JVM-internal representation). */ public void renameClass(String oldName, String newName) { LongVector v = items; int size = numOfItems; for (int i = 1; i < size; ++i) { ConstInfo ci = v.elementAt(i); ci.renameClass(this, oldName, newName, itemsCache); } }
/** * Replaces all occurrences of a class name. * * @param oldName the replaced name (JVM-internal representation). * @param newName the substituted name (JVM-internal representation). */ public void renameClass(String oldName, String newName) { LongVector v = items; int size = numOfItems; classes = new HashMap(classes.size() * 2); for (int i = 1; i < size; ++i) { ConstInfo ci = v.elementAt(i); ci.renameClass(this, oldName, newName); ci.makeHashtable(this); } }
/** * Writes the contents of the constant pool table. */ public void write(DataOutputStream out) throws IOException { out.writeShort(numOfItems); LongVector v = items; int size = numOfItems; for (int i = 1; i < size; ++i) v.elementAt(i).write(out); }
private void read(DataInputStream in) throws IOException { int n = in.readUnsignedShort(); items = new LongVector(n); numOfItems = 0; addItem(null); // index 0 is reserved by the JVM. while (--n > 0) { // index 0 is reserved by JVM int tag = readOne(in); if ((tag == LongInfo.tag) || (tag == DoubleInfo.tag)) { addItem(new ConstInfoPadding()); --n; } } int i = 1; while (true) { ConstInfo info = (ConstInfo)items.elementAt(i++); if (info == null) break; else info.makeHashtable(this); } }
/** * Prints the contents of the constant pool table. */ public void print(PrintWriter out) { int size = numOfItems; for (int i = 1; i < size; ++i) { out.print(i); out.print(" "); items.elementAt(i).print(out); } } }
/** * Replaces all occurrences of class names. * * @param classnames specifies pairs of replaced and substituted * name. */ public void renameClass(Map classnames) { LongVector v = items; int size = numOfItems; for (int i = 1; i < size; ++i) { ConstInfo ci = v.elementAt(i); ci.renameClass(this, classnames, itemsCache); } }
/** * Replaces all occurrences of a class name. * * @param oldName the replaced name (JVM-internal representation). * @param newName the substituted name (JVM-internal representation). */ public void renameClass(String oldName, String newName) { LongVector v = items; int size = numOfItems; classes = new HashMap(classes.size() * 2); for (int i = 1; i < size; ++i) { ConstInfo ci = (ConstInfo)v.elementAt(i); ci.renameClass(this, oldName, newName); ci.makeHashtable(this); } }
/** * Writes the contents of the constant pool table. */ public void write(DataOutputStream out) throws IOException { out.writeShort(numOfItems); LongVector v = items; int size = numOfItems; for (int i = 1; i < size; ++i) v.elementAt(i).write(out); }
private void read(DataInputStream in) throws IOException { int n = in.readUnsignedShort(); items = new LongVector(n); numOfItems = 0; addItem(null); // index 0 is reserved by the JVM. while (--n > 0) { // index 0 is reserved by JVM int tag = readOne(in); if ((tag == LongInfo.tag) || (tag == DoubleInfo.tag)) { addItem(new ConstInfoPadding()); --n; } } int i = 1; while (true) { ConstInfo info = items.elementAt(i++); if (info == null) break; else info.makeHashtable(this); } }
@Override public String toString() { ByteArrayOutputStream bout = new ByteArrayOutputStream(); PrintWriter out = new PrintWriter(bout); print(out); return bout.toString(); } }
/** * Replaces all occurrences of a class name. * * @param oldName the replaced name (JVM-internal representation). * @param newName the substituted name (JVM-internal representation). */ public void renameClass(String oldName, String newName) { LongVector v = items; int size = numOfItems; for (int i = 1; i < size; ++i) { ConstInfo ci = v.elementAt(i); ci.renameClass(this, oldName, newName, itemsCache); } }
/** * Replaces all occurrences of class names. * * @param classnames specifies pairs of replaced and substituted * name. */ public void renameClass(Map classnames) { LongVector v = items; int size = numOfItems; classes = new HashMap(classes.size() * 2); for (int i = 1; i < size; ++i) { ConstInfo ci = (ConstInfo)v.elementAt(i); ci.renameClass(this, classnames); ci.makeHashtable(this); } }
/** * Returns the <code>tag</code> field of the constant pool table * entry at the given index. * * @return either <code>CONST_Class</code>, <code>CONST_Fieldref</code>, * <code>CONST_Methodref</code>, or ... */ public int getTag(int index) { return getItem(index).getTag(); }
/** * Writes the contents of the constant pool table. */ public void write(DataOutputStream out) throws IOException { out.writeShort(numOfItems); LongVector v = items; int size = numOfItems; for (int i = 1; i < size; ++i) v.elementAt(i).write(out); }
/** * Get all the class names. * * @return a set of class names (<code>String</code> objects). */ public Set<String> getClassNames() { Set<String> result = new HashSet<String>(); LongVector v = items; int size = numOfItems; for (int i = 1; i < size; ++i) { String className = v.elementAt(i).getClassName(this); if (className != null) result.add(className); } return result; }