本文整理汇总了Java中org.apache.bcel.Constants.INVOKESPECIAL属性的典型用法代码示例。如果您正苦于以下问题:Java Constants.INVOKESPECIAL属性的具体用法?Java Constants.INVOKESPECIAL怎么用?Java Constants.INVOKESPECIAL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.bcel.Constants
的用法示例。
在下文中一共展示了Constants.INVOKESPECIAL属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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.INVOKESPECIAL && XML_DECODER_CONSTRUCTOR.matches(this)) {
bugReporter.reportBug(new BugInstance(this, XML_DECODER, Priorities.HIGH_PRIORITY) //
.addClass(this).addMethod(this).addSourceLine(this));
}
}
示例3: sawOpcode
@Override
public void sawOpcode(int seen) {
if (seen == Constants.INVOKESPECIAL
&& getClassConstantOperand().equals("org/apache/http/impl/client/DefaultHttpClient")
&& getNameConstantOperand().equals("<init>")
&& getSigConstantOperand().equals("()V")) {
//DefaultHttpClient constructor with no parameter
bugReporter.reportBug(new BugInstance(this, DEFAULT_HTTP_CLIENT, Priorities.NORMAL_PRIORITY)
.addClass(this).addMethod(this).addSourceLine(this));
}
if (seen == Constants.INVOKESTATIC
&& getClassConstantOperand().equals("javax/net/ssl/SSLContext")
&& getNameConstantOperand().equals("getInstance")
&& getSigConstantOperand().equals("(Ljava/lang/String;)Ljavax/net/ssl/SSLContext;")) {
//System.out.println("SSLContext.getInstance(" + this.getSigConstantOperand() + ")");
final OpcodeStack.Item item = stack.getStackItem(0);
String sslContextName = (String) item.getConstant(); //Null if the value passed isn't constant
if (sslContextName != null && sslContextName.equalsIgnoreCase("SSL")) {
bugReporter.reportBug(new BugInstance(this, SSL_CONTEXT, Priorities.NORMAL_PRIORITY)
.addClass(this).addMethod(this).addSourceLine(this));
}
}
}
示例4: sawOpcode
@Override
public void sawOpcode(int seen) {
//printOpCode(seen);
if (seen == Constants.INVOKESPECIAL && getClassConstantOperand().equals("java/net/Socket") &&
getNameConstantOperand().equals("<init>")) {
int depth = stack.getStackDepth();
String host = "remote host"; //Bonus information for the message
if (depth != 0) {
int hostIndex;
if (getSigConstantOperand().equals("(Ljava/lang/String;I)V")) {
hostIndex = 1;
} else if (getSigConstantOperand().equals("(Ljava/lang/String;IZ)V")) {
hostIndex = 2;
} else if (getSigConstantOperand().equals("(Ljava/lang/String;ILjava/net/InetAddress;I)V")) {
hostIndex = 3;
} else {
hostIndex = -1;
}
if (hostIndex != -1) {
//Extract the value from the constant string
OpcodeStack.Item top = stack.getStackItem(hostIndex);
if (top.getConstant() != null) {
host = (String) top.getConstant();
}
}
}
if (DEBUG) {
System.out.println("host:" + host);
}
bugReporter.reportBug(new BugInstance(this, UNENCRYPTED_SOCKET_TYPE, Priorities.NORMAL_PRIORITY) //
.addClass(this).addMethod(this).addSourceLine(this) //
.addString(host));
}
}
示例5: sawOpcode
@Override
public void sawOpcode(int seen) {
//printOpCode( seen );
if (seen == Constants.INVOKESPECIAL && getClassConstantOperand().equals("javax/crypto/NullCipher") &&
getNameConstantOperand().equals("<init>")) {
bugReporter.reportBug(new BugInstance(this, NULL_CIPHER_TYPE, Priorities.NORMAL_PRIORITY) //
.addClass(this).addMethod(this).addSourceLine(this));
}
}
示例6: sawOpcode
@Override
public void sawOpcode(int seen) {
//printOpCode( seen );
if (seen == Constants.INVOKESPECIAL && getClassConstantOperand().equals("com/hazelcast/config/SymmetricEncryptionConfig") &&
getNameConstantOperand().equals("<init>")) {
bugReporter.reportBug(new BugInstance(this, HAZELCAST_SYMMETRIC_ENCRYPTION_TYPE, Priorities.NORMAL_PRIORITY) //
.addClass(this).addMethod(this).addSourceLine(this));
}
}
示例7: sawOpcode
@Override
public void sawOpcode(int seen) {
//printOpCode(seen);
if (seen == Constants.INVOKESPECIAL && getClassConstantOperand().equals("java/net/ServerSocket") &&
getNameConstantOperand().equals("<init>")) {
bugReporter.reportBug(new BugInstance(this, UNENCRYPTED_SERVER_SOCKET_TYPE, Priorities.NORMAL_PRIORITY) //
.addClass(this).addMethod(this).addSourceLine(this));
}
}
示例8: sawOpcode
@Override
public void sawOpcode(int seen) {
//printOpCode(seen);
if (seen == Constants.INVOKESPECIAL && getClassConstantOperand().equals("java/util/Random")
&& getNameConstantOperand().equals("<init>")) {
bugReporter.reportBug(new BugInstance(this, PREDICTABLE_RANDOM_TYPE, Priorities.NORMAL_PRIORITY) //
.addClass(this).addMethod(this).addSourceLine(this) //
.addString("java.util.Random"));
} else if (seen == Constants.INVOKESTATIC && getClassConstantOperand().equals("java/lang/Math")
&& getNameConstantOperand().equals("random")) {
bugReporter.reportBug(new BugInstance(this, PREDICTABLE_RANDOM_TYPE, Priorities.NORMAL_PRIORITY) //
.addClass(this).addMethod(this).addSourceLine(this) //
.addString("java.lang.Math.random()"));
} else if (seen == Constants.INVOKESTATIC && getClassConstantOperand().equals("java/util/concurrent/ThreadLocalRandom")
&& getNameConstantOperand().equals("current")) {
bugReporter.reportBug(new BugInstance(this, PREDICTABLE_RANDOM_TYPE, Priorities.NORMAL_PRIORITY) //
.addClass(this).addMethod(this).addSourceLine(this) //
.addString("java.util.concurrent.ThreadLocalRandom"));
} else if (seen == Constants.INVOKESPECIAL && getClassConstantOperand().equals("scala/util/Random")
&& getNameConstantOperand().equals("<init>")) {
bugReporter.reportBug(new BugInstance(this, PREDICTABLE_RANDOM_SCALA_TYPE, Priorities.NORMAL_PRIORITY) //
.addClass(this).addMethod(this).addSourceLine(this) //
.addString("scala.util.Random"));
} else if (seen == Constants.INVOKEVIRTUAL && RANDOM_NEXT_METHODS.matches(this)) {
bugReporter.reportBug(new BugInstance(this, PREDICTABLE_RANDOM_SCALA_TYPE, Priorities.NORMAL_PRIORITY) //
.addClass(this).addMethod(this).addSourceLine(this) //
.addString("scala.util.Random."+getNameConstantOperand()+"()"));
}
}