private void addIgnoredPkgs(String[] ignored_packages) { String[] new_p = new String[ignored_packages.length + this.ignored_packages.length]; System.arraycopy(this.ignored_packages, 0, new_p, 0, this.ignored_packages.length); System.arraycopy( ignored_packages, 0, new_p, this.ignored_packages.length, ignored_packages.length); this.ignored_packages = new_p; }
/** @return constant pool with proper length */ public ConstantPool getFinalConstantPool() { Constant[] cs = new Constant[index]; System.arraycopy(constants, 0, cs, 0, index); return new ConstantPool(cs); }
/** Resize internal array of constants. */ protected void adjustSize() { if (index + 3 >= size) { Constant[] cs = constants; size *= 2; constants = new Constant[size]; System.arraycopy(cs, 0, constants, 0, index); } }
/** * Initialize with given array of constants. * * @param c array of given constants, new ones will be appended */ public ConstantPoolGen(Constant[] cs) { if (cs.length > size) { size = cs.length; constants = new Constant[size]; } System.arraycopy(cs, 0, constants, 0, cs.length); if (cs.length > 0) index = cs.length; for (int i = 1; i < index; i++) { Constant c = constants[i]; if (c instanceof ConstantString) { ConstantString s = (ConstantString) c; ConstantUtf8 u8 = (ConstantUtf8) constants[s.getStringIndex()]; string_table.put(u8.getBytes(), new Index(i)); } else if (c instanceof ConstantClass) { ConstantClass s = (ConstantClass) c; ConstantUtf8 u8 = (ConstantUtf8) constants[s.getNameIndex()]; class_table.put(u8.getBytes(), new Index(i)); } else if (c instanceof ConstantNameAndType) { ConstantNameAndType n = (ConstantNameAndType) c; ConstantUtf8 u8 = (ConstantUtf8) constants[n.getNameIndex()]; ConstantUtf8 u8_2 = (ConstantUtf8) constants[n.getSignatureIndex()]; n_a_t_table.put(u8.getBytes() + NAT_DELIM + u8_2.getBytes(), new Index(i)); } else if (c instanceof ConstantUtf8) { ConstantUtf8 u = (ConstantUtf8) c; utf8_table.put(u.getBytes(), new Index(i)); } else if (c instanceof ConstantCP) { ConstantCP m = (ConstantCP) c; ConstantClass clazz = (ConstantClass) constants[m.getClassIndex()]; ConstantNameAndType n = (ConstantNameAndType) constants[m.getNameAndTypeIndex()]; ConstantUtf8 u8 = (ConstantUtf8) constants[clazz.getNameIndex()]; String class_name = u8.getBytes().replace('/', '.'); u8 = (ConstantUtf8) constants[n.getNameIndex()]; String method_name = u8.getBytes(); u8 = (ConstantUtf8) constants[n.getSignatureIndex()]; String signature = u8.getBytes(); String delim = METHODREF_DELIM; if (c instanceof ConstantInterfaceMethodref) delim = IMETHODREF_DELIM; else if (c instanceof ConstantFieldref) delim = FIELDREF_DELIM; cp_table.put(class_name + delim + method_name + delim + signature, new Index(i)); } } }