本文整理汇总了Java中org.apache.bcel.Constants.INVOKEINTERFACE属性的典型用法代码示例。如果您正苦于以下问题:Java Constants.INVOKEINTERFACE属性的具体用法?Java Constants.INVOKEINTERFACE怎么用?Java Constants.INVOKEINTERFACE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.bcel.Constants
的用法示例。
在下文中一共展示了Constants.INVOKEINTERFACE属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isGetterMethod
/**
* Determine whether or not the the given method is
* a getter method. I.e., if it just returns the
* value of an instance field.
*
* @param classContext the ClassContext for the class containing the method
* @param method the method
*/
public static boolean isGetterMethod(ClassContext classContext, Method method) {
MethodGen methodGen = classContext.getMethodGen(method);
InstructionList il = methodGen.getInstructionList();
// System.out.println("Checking getter method: " + method.getName());
if (il.getLength() > 60)
return false;
int count = 0;
Iterator it = il.iterator();
while (it.hasNext()) {
InstructionHandle ih = (InstructionHandle) it.next();
switch (ih.getInstruction().getOpcode()) {
case Constants.GETFIELD:
count++;
if (count > 1) return false;
break;
case Constants.PUTFIELD:
case Constants.BALOAD:
case Constants.CALOAD:
case Constants.DALOAD:
case Constants.FALOAD:
case Constants.IALOAD:
case Constants.LALOAD:
case Constants.SALOAD:
case Constants.AALOAD:
case Constants.BASTORE:
case Constants.CASTORE:
case Constants.DASTORE:
case Constants.FASTORE:
case Constants.IASTORE:
case Constants.LASTORE:
case Constants.SASTORE:
case Constants.AASTORE:
case Constants.PUTSTATIC:
return false;
case Constants.INVOKESTATIC:
case Constants.INVOKEVIRTUAL:
case Constants.INVOKEINTERFACE:
case Constants.INVOKESPECIAL:
case Constants.GETSTATIC:
// no-op
}
}
// System.out.println("Found getter method: " + method.getName());
return true;
}
示例2: sawOpcode
@Override
public void sawOpcode(int seen) {
if (seen == Constants.INVOKEINTERFACE && getClassConstantOperand().equals("javax/servlet/http/HttpServletResponse")
&& (getNameConstantOperand().equals("encodeURL") || getNameConstantOperand().equals("encodeUrl") ||
getNameConstantOperand().equals("encodeRedirectURL") || getNameConstantOperand().equals("encodeRedirectUrl"))) {
bugReporter.reportBug(new BugInstance(this, URL_REWRITING, Priorities.HIGH_PRIORITY) //
.addClass(this).addMethod(this).addSourceLine(this));
}
}
示例3: sawOpcode
@Override
public void sawOpcode(int seen) {
//printOpCode(seen);
if (seen == Constants.INVOKEINTERFACE && getClassConstantOperand().equals("org/owasp/esapi/Encryptor") &&
(getNameConstantOperand().equals("encrypt") || getNameConstantOperand().equals("decrypt"))) {
bugReporter.reportBug(new BugInstance(this, ESAPI_ENCRYPTOR_TYPE, Priorities.NORMAL_PRIORITY) //
.addClass(this).addMethod(this).addSourceLine(this));
}
}
示例4: sawOpcode
@Override
public void sawOpcode(int seen) {
if (seen == Constants.INVOKEINTERFACE &&
(getClassConstantOperand().equals("org/apache/wicket/util/upload/FileItem") ||
getClassConstantOperand().equals("org/apache/commons/fileupload/FileItem")) &&
getNameConstantOperand().equals("getName")) {
bugReporter.reportBug(new BugInstance(this, FILE_UPLOAD_FILENAME_TYPE, Priorities.NORMAL_PRIORITY) //
.addClass(this).addMethod(this).addSourceLine(this));
}
}
示例5: toInvokeInstruction
private static final InvokeInstruction toInvokeInstruction(Instruction ins) {
short opcode = ins.getOpcode();
if (opcode != Constants.INVOKEVIRTUAL && opcode != Constants.INVOKEINTERFACE)
return null;
return (InvokeInstruction) ins;
}
示例6: sawOpcode
@Override
public void sawOpcode(int seen) {
//All call to ServletRequest
if (seen == Constants.INVOKEINTERFACE && (getClassConstantOperand().equals("javax/servlet/ServletRequest") ||
getClassConstantOperand().equals("javax/servlet/http/HttpServletRequest"))) {
//ServletRequest
if (getNameConstantOperand().equals("getParameter") ||
getNameConstantOperand().equals("getParameterValues") ||
getNameConstantOperand().equals("getParameterMap") ||
getNameConstantOperand().equals("getParameterNames")) {
bugReporter.reportBug(new BugInstance(this, GET_PARAMETER_TYPE, Priorities.LOW_PRIORITY) //
.addClass(this).addMethod(this).addSourceLine(this)
.addString(getNameConstantOperand())); //Passing the method name
} else if (getNameConstantOperand().equals("getContentType")) {
bugReporter.reportBug(new BugInstance(this, CONTENT_TYPE, Priorities.LOW_PRIORITY) //
.addClass(this).addMethod(this).addSourceLine(this));
} else if (getNameConstantOperand().equals("getServerName")) {
bugReporter.reportBug(new BugInstance(this, SERVER_NAME_TYPE, Priorities.LOW_PRIORITY) //
.addClass(this).addMethod(this).addSourceLine(this));
}
//HttpServletRequest
else if (getNameConstantOperand().equals("getRequestedSessionId")) {
bugReporter.reportBug(new BugInstance(this, SESSION_ID_TYPE, Priorities.LOW_PRIORITY) //
.addClass(this).addMethod(this).addSourceLine(this));
} else if (getNameConstantOperand().equals("getQueryString")) {
bugReporter.reportBug(new BugInstance(this, QUERY_STRING_TYPE, Priorities.LOW_PRIORITY) //
.addClass(this).addMethod(this).addSourceLine(this));
} else if (getNameConstantOperand().equals("getHeader")) {
//Extract the value being push..
OpcodeStack.Item top = stack.getStackItem(0);
String value = (String) top.getConstant();//Safe see if condition
if ("Host".equals(value)) {
bugReporter.reportBug(new BugInstance(this, SERVER_NAME_TYPE, Priorities.LOW_PRIORITY) //
.addClass(this).addMethod(this).addSourceLine(this));
} else if ("Referer".equalsIgnoreCase(value)) {
bugReporter.reportBug(new BugInstance(this, HEADER_REFERER_TYPE, Priorities.LOW_PRIORITY) //
.addClass(this).addMethod(this).addSourceLine(this));
} else if ("User-Agent".equalsIgnoreCase(value)) {
bugReporter.reportBug(new BugInstance(this, HEADER_USER_AGENT_TYPE, Priorities.LOW_PRIORITY) //
.addClass(this).addMethod(this).addSourceLine(this));
} else {
bugReporter.reportBug(new BugInstance(this, HEADER_TYPE, Priorities.LOW_PRIORITY) //
.addClass(this).addMethod(this).addSourceLine(this));
}
}
}
}