boolean escapes = (inv.getOpcode() == Const.INVOKESTATIC || instanceArgNum != 0); String methodName = inv.getMethodName(cpg); String methodSig = inv.getSignature(cpg); if (inv.getOpcode() == Const.INVOKEVIRTUAL && ("load".equals(methodName) || "loadFromXml".equals(methodName) || "store".equals(methodName) || "save".equals(methodName)) && "java.util.Properties".equals(className)) { escapes = false; if (inv.getOpcode() == Const.INVOKEVIRTUAL && ("load".equals(methodName) || "store".equals(methodName)) && "java.security.KeyStore".equals(className)) { escapes = false; if (inv.getOpcode() == Const.INVOKEVIRTUAL && "getChannel".equals(methodName) && "()Ljava/nio/channels/FileChannel;".equals(methodSig)) { escapes = true;
/** * Get a MethodDescriptor describing the method called by given * InvokeInstruction. * * @param inv * the InvokeInstruction * @param cpg * ConstantPoolGen of class containing instruction * @return MethodDescriptor describing the called method */ public static MethodDescriptor getCalledMethodDescriptor(InvokeInstruction inv, ConstantPoolGen cpg) { String calledClassName = inv.getClassName(cpg).replace('.', '/'); String calledMethodName = inv.getMethodName(cpg); String calledMethodSig = inv.getSignature(cpg); boolean isStatic = inv.getOpcode() == Const.INVOKESTATIC; return DescriptorFactory.instance().getMethodDescriptor(calledClassName, calledMethodName, calledMethodSig, isStatic); }
short opcode = inv.getOpcode();
/** * Add a method annotation for the method which is called by given * instruction. * * @param cpg * the constant pool for the method containing the call * @param inv * the InvokeInstruction * @return this object */ @Nonnull public BugInstance addCalledMethod(ConstantPoolGen cpg, InvokeInstruction inv) { String className = inv.getClassName(cpg); String methodName = inv.getMethodName(cpg); String methodSig = inv.getSignature(cpg); addMethod(className, methodName, methodSig, inv.getOpcode() == Const.INVOKESTATIC); describe(MethodAnnotation.METHOD_CALLED); return this; }
short opcode = inv.getOpcode();
ConstantPoolGen cpg) throws DataflowAnalysisException, ClassNotFoundException { short opcode = invokeInstruction.getOpcode();
/** * Create an XMethod object from an InvokeInstruction. * * @param invokeInstruction * the InvokeInstruction * @param cpg * ConstantPoolGen from the class containing the instruction * @return XMethod representing the method called by the InvokeInstruction */ public static XMethod createXMethod(InvokeInstruction invokeInstruction, ConstantPoolGen cpg) { String className = invokeInstruction.getClassName(cpg); String methodName = invokeInstruction.getName(cpg); String methodSig = invokeInstruction.getSignature(cpg); if (invokeInstruction instanceof INVOKEDYNAMIC) { // XXX the lambda representation makes no sense for XMethod // "classical" instruction attributes are filled with garbage, causing // the code later to produce crazy errors (looking for non existing types etc) // We should NOT be called here from our code, but 3rd party code still may // use this method. So *at least* provide a valid class name, which is // (don't ask me why) is encoded in the first argument type of the lambda // className = invokeInstruction.getArgumentTypes(cpg)[0].toString(); className = "java.lang.Object"; } return createXMethod(className, methodName, methodSig, invokeInstruction.getOpcode() == Const.INVOKESTATIC); }
ConstantPoolGen cpg, boolean receiverTypeIsExact) throws ClassNotFoundException { if (invokeInstruction.getOpcode() == Const.INVOKESTATIC) { throw new IllegalArgumentException();
throws DataflowAnalysisException, ClassNotFoundException { short opcode = invokeInstruction.getOpcode();
HashSet<JavaClassAndMethod> result = new HashSet<>(); if (invokeInstruction.getOpcode() == Const.INVOKESTATIC) { throw new IllegalArgumentException(); boolean virtualCall = (invokeInstruction.getOpcode() == Const.INVOKEVIRTUAL || invokeInstruction.getOpcode() == Const.INVOKEINTERFACE) && (upperBound == null || !upperBound.getJavaClass().isFinal() && !upperBound.getMethod().isFinal()) && !receiverTypeIsExact;
ReferenceType receiverType = inv.getReferenceType(cpg); boolean isStatic = inv.getOpcode() == Const.INVOKESTATIC; actionList = new LinkedList<>();
boolean isStatic = inv.getOpcode() == Const.INVOKESTATIC; boolean isCtor = Const.CONSTRUCTOR_NAME.equals(methodName);
/** * Dump instruction as byte code to stream out. * @param out Output stream */ @Override public void dump( final DataOutputStream out ) throws IOException { out.writeByte(super.getOpcode()); out.writeShort(super.getIndex()); }
/** * Dump instruction as byte code to stream out. * @param out Output stream */ @Override public void dump( final DataOutputStream out ) throws IOException { out.writeByte(super.getOpcode()); out.writeShort(super.getIndex()); out.writeByte(0); out.writeByte(0); }
/** * Dump instruction as byte code to stream out. * @param out Output stream */ @Override public void dump( final DataOutputStream out ) throws IOException { out.writeByte(super.getOpcode()); out.writeShort(super.getIndex()); }
/** * Dump instruction as byte code to stream out. * @param out Output stream */ @Override public void dump( final DataOutputStream out ) throws IOException { out.writeByte(super.getOpcode()); out.writeShort(super.getIndex()); out.writeByte(nargs); out.writeByte(0); }
/** * Dump instruction as byte code to stream out. * @param out Output stream */ @Override public void dump( final DataOutputStream out ) throws IOException { out.writeByte(super.getOpcode()); out.writeShort(super.getIndex()); }
public void visitInvokeInstruction(InvokeInstruction i) { short opcode = i.getOpcode(); String class_name = i.getClassName(_cp); String method_name = i.getMethodName(_cp); Type type = i.getReturnType(_cp); Type[] arg_types = i.getArgumentTypes(_cp); _out.println("il.append(_factory.createInvoke(\"" + class_name + "\", \"" + method_name + "\", " + BCELifier.printType(type) + ", " + BCELifier.printArgumentTypes(arg_types) + ", " + "Constants." + Constants.OPCODE_NAMES[opcode].toUpperCase() + "));"); }
@Override public void visitInvokeInstruction( final InvokeInstruction i ) { final short opcode = i.getOpcode(); final String class_name = i.getClassName(_cp); final String method_name = i.getMethodName(_cp); final Type type = i.getReturnType(_cp); final Type[] arg_types = i.getArgumentTypes(_cp); _out.println("il.append(_factory.createInvoke(\"" + class_name + "\", \"" + method_name + "\", " + BCELifier.printType(type) + ", " + BCELifier.printArgumentTypes(arg_types) + ", " + CONSTANT_PREFIX + Const.getOpcodeName(opcode).toUpperCase(Locale.ENGLISH) + "));"); }