private String getClassName(JavaClass c, int classIndex) { String name = c.getConstantPool().getConstantString(classIndex, Const.CONSTANT_Class); return ClassName.extractClassName(name).replace('/', '.'); }
private String getSlashedClassName() { return javaClass.getConstantPool().getConstantString(javaClass.getClassNameIndex(), Const.CONSTANT_Class); }
Const.CONSTANT_NameAndType); String methodName = ((ConstantUtf8) cp.getConstant(cnat.getNameIndex(), Const.CONSTANT_Utf8)).getBytes(); String className = cp.getConstantString(cmr.getClassIndex(), Const.CONSTANT_Class).replace('/', '.'); String methodSig = ((ConstantUtf8) cp.getConstant(cnat.getSignatureIndex(), Const.CONSTANT_Utf8)).getBytes();
className = jclass.getConstantPool().getConstantString(classIndex, Const.CONSTANT_Class); } else if (constant instanceof ConstantInterfaceMethodref) { ConstantInterfaceMethodref cmr = (ConstantInterfaceMethodref) constant; className = jclass.getConstantPool().getConstantString(classIndex, Const.CONSTANT_Class);
Constant ref = cp.getConstant(((ConstantMethodHandle)constant).getReferenceIndex()); if(ref instanceof ConstantCP) { String className = cp.getConstantString(((ConstantCP) ref).getClassIndex(), Const.CONSTANT_Class); ConstantNameAndType nameAndType = (ConstantNameAndType) cp.getConstant(((ConstantCP) ref).getNameAndTypeIndex()); String name = ((ConstantUtf8)cp.getConstant(nameAndType.getNameIndex())).getBytes();
/** * Returns true if given constant pool probably has a reference to any of supplied methods * Useful to exclude from analysis uninteresting classes * @param cp constant pool * @param methods methods collection * @return true if method is found */ public static boolean hasInterestingMethod(ConstantPool cp, Collection<MethodDescriptor> methods) { for(Constant c : cp.getConstantPool()) { if(c instanceof ConstantMethodref || c instanceof ConstantInterfaceMethodref) { ConstantCP desc = (ConstantCP)c; ConstantNameAndType nameAndType = (ConstantNameAndType) cp.getConstant(desc.getNameAndTypeIndex()); String className = cp.getConstantString(desc.getClassIndex(), Const.CONSTANT_Class); String name = ((ConstantUtf8)cp.getConstant(nameAndType.getNameIndex())).getBytes(); String signature = ((ConstantUtf8)cp.getConstant(nameAndType.getSignatureIndex())).getBytes(); // We don't know whether method is static thus cannot use equals int hash = FieldOrMethodDescriptor.getNameSigHashCode(name, signature); for(MethodDescriptor method : methods) { if (method.getNameSigHashCode() == hash && (method.getSlashedClassName().isEmpty() || method.getSlashedClassName().equals(className)) && method.getName().equals(name) && method.getSignature().equals(signature)) { return true; } } } } return false; }
ConstantCP desc = (ConstantCP)cp.getConstant(((INVOKEVIRTUAL)inst).getIndex()); ConstantNameAndType nameAndType = (ConstantNameAndType) cp.getConstant(desc.getNameAndTypeIndex()); String className = cp.getConstantString(desc.getClassIndex(), CONSTANT_Class); String name = ((ConstantUtf8)cp.getConstant(nameAndType.getNameIndex())).getBytes(); String signature = ((ConstantUtf8)cp.getConstant(nameAndType.getSignatureIndex())).getBytes();
causeName = "java.lang.Throwable"; } else { causeName = Utility.compactClassName(getConstantPool().getConstantString(cause, Const.CONSTANT_Class), false); if (!isChecked(causeName)) { continue;
public void setSuperclassNameIndex( final int superclass_name_index ) { this.superclass_name_index = superclass_name_index; super_class_name = cp.getConstantPool().getConstantString(superclass_name_index, Const.CONSTANT_Class).replace('/', '.'); }
public void setSuperclassNameIndex(int superclass_name_index) { this.superclass_name_index = superclass_name_index; super_class_name = cp.getConstantPool(). getConstantString(superclass_name_index, Constants.CONSTANT_Class).replace('/', '.'); }
/** * @return String representation. */ public final String toString(ConstantPool cp, boolean verbose) { String str; if(catch_type == 0) str = "<Any exception>(0)"; else str = Utility.compactClassName(cp.getConstantString(catch_type, CONSTANT_Class), false) + (verbose? "(" + catch_type + ")" : ""); return start_pc + "\t" + end_pc + "\t" + handler_pc + "\t" + str; }
/** * @return String representation. */ public final String toString( final ConstantPool cp, final boolean verbose ) { String str; if (catch_type == 0) { str = "<Any exception>(0)"; } else { str = Utility.compactClassName(cp.getConstantString(catch_type, Const.CONSTANT_Class), false) + (verbose ? "(" + catch_type + ")" : ""); } return start_pc + "\t" + end_pc + "\t" + handler_pc + "\t" + str; }
/** * @return class names of thrown exceptions */ public final String[] getExceptionNames() { final String[] names = new String[exception_index_table.length]; for (int i = 0; i < exception_index_table.length; i++) { names[i] = super.getConstantPool().getConstantString(exception_index_table[i], Const.CONSTANT_Class).replace('/', '.'); } return names; }
public void setClassNameIndex( final int class_name_index ) { this.class_name_index = class_name_index; class_name = cp.getConstantPool().getConstantString(class_name_index, Const.CONSTANT_Class).replace('/', '.'); }
/** @return type related with this instruction. */ public Type getType(ConstantPoolGen cpg) { ConstantPool cp = cpg.getConstantPool(); String name = cp.getConstantString(index, org.apache.bcel.Constants.CONSTANT_Class); if(!name.startsWith("[")) name = "L" + name + ";"; return Type.getType(name); } }
private String getClassName(JavaClass c, int classIndex) { String name = c.getConstantPool().getConstantString(classIndex, CONSTANT_Class); return ClassName.extractClassName(name).replace('/', '.'); }
/** @return type related with this instruction. */ @Override public Type getType( final ConstantPoolGen cpg ) { final ConstantPool cp = cpg.getConstantPool(); String name = cp.getConstantString(index, org.apache.bcel.Const.CONSTANT_Class); if (!name.startsWith("[")) { name = "L" + name + ";"; } return Type.getType(name); } }
/** * Utility method that converts a class reference in the constant pool, * i.e., an index to a string. */ static String referenceClass( final int index ) { String str = constant_pool.getConstantString(index, Const.CONSTANT_Class); str = Utility.compactClassName(str); str = Utility.compactClassName(str, class_package + ".", true); return "<A HREF=\"" + class_name + "_cp.html#cp" + index + "\" TARGET=ConstantPool>" + str + "</A>"; }
/** @return name of the referenced class/interface */ public String getClassName(ConstantPoolGen cpg) { ConstantPool cp = cpg.getConstantPool(); ConstantCP cmr = (ConstantCP)cp.getConstant(index); return cp.getConstantString(cmr.getClassIndex(), org.apache.bcel.Constants.CONSTANT_Class).replace('/', '.'); }
public Type getCatchType(ConstantPool cp) { if (codeException.getCatchType() == 0) return null; String signature= cp.getConstantString(codeException.getCatchType(), Constants.CONSTANT_Class); return Type.getType("L" + signature + ";"); }