本文整理汇总了Java中org.apache.bcel.generic.ReferenceType.equals方法的典型用法代码示例。如果您正苦于以下问题:Java ReferenceType.equals方法的具体用法?Java ReferenceType.equals怎么用?Java ReferenceType.equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.bcel.generic.ReferenceType
的用法示例。
在下文中一共展示了ReferenceType.equals方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: purgeBoringEntries
import org.apache.bcel.generic.ReferenceType; //导入方法依赖的package包/类
public void purgeBoringEntries() {
Collection<FieldDescriptor> keys = new ArrayList<FieldDescriptor>(getKeys());
for (FieldDescriptor f : keys) {
String s = f.getSignature();
FieldStoreType type = getProperty(f);
Type fieldType = Type.getType(f.getSignature());
if (!(fieldType instanceof ReferenceType)) {
removeProperty(f);
continue;
}
ReferenceType storeType = type.getLoadType((ReferenceType) fieldType);
if (storeType.equals(fieldType))
removeProperty(f);
}
}
示例2: analyzeMethod
import org.apache.bcel.generic.ReferenceType; //导入方法依赖的package包/类
private void analyzeMethod(ClassContext classContext, Method method) throws CFGBuilderException, DataflowAnalysisException {
MethodGen methodGen = classContext.getMethodGen(method);
if (methodGen == null)
return;
BitSet bytecodeSet = classContext.getBytecodeSet(method);
if (bytecodeSet == null)
return;
// We don't adequately model instanceof interfaces yet
if (bytecodeSet.get(Constants.INSTANCEOF) || bytecodeSet.get(Constants.CHECKCAST))
return;
CFG cfg = classContext.getCFG(method);
TypeDataflow typeDataflow = classContext.getTypeDataflow(method);
ConstantPoolGen cpg = classContext.getConstantPoolGen();
String sourceFile = classContext.getJavaClass().getSourceFileName();
if (DEBUG) {
String methodName = methodGen.getClassName() + "." + methodGen.getName();
System.out.println("Checking " + methodName);
}
for (Iterator<Location> i = cfg.locationIterator(); i.hasNext();) {
Location location = i.next();
InstructionHandle handle = location.getHandle();
Instruction ins = handle.getInstruction();
if (!(ins instanceof INVOKEINTERFACE))
continue;
INVOKEINTERFACE invoke = (INVOKEINTERFACE) ins;
String mName = invoke.getMethodName(cpg);
if (!mName.equals("setAttribute"))
continue;
String cName = invoke.getClassName(cpg);
if (!cName.equals("javax.servlet.http.HttpSession"))
continue;
TypeFrame frame = typeDataflow.getFactAtLocation(location);
if (!frame.isValid()) {
// This basic block is probably dead
continue;
}
Type operandType = frame.getTopValue();
if (operandType.equals(TopType.instance())) {
// unreachable
continue;
}
if (!(operandType instanceof ReferenceType)) {
// Shouldn't happen - illegal bytecode
continue;
}
ReferenceType refType = (ReferenceType) operandType;
if (refType.equals(NullType.instance())) {
continue;
}
try {
double isSerializable = DeepSubtypeAnalysis.isDeepSerializable(refType);
if (isSerializable < 0.9) {
SourceLineAnnotation sourceLineAnnotation = SourceLineAnnotation.fromVisitedInstruction(classContext,
methodGen, sourceFile, handle);
ReferenceType problem = DeepSubtypeAnalysis.getLeastSerializableTypeComponent(refType);
bugAccumulator.accumulateBug(new BugInstance(this, "J2EE_STORE_OF_NON_SERIALIZABLE_OBJECT_INTO_SESSION",
isSerializable < 0.15 ? HIGH_PRIORITY : isSerializable > 0.5 ? LOW_PRIORITY : NORMAL_PRIORITY)
.addClassAndMethod(methodGen, sourceFile).addType(problem).describe(TypeAnnotation.FOUND_ROLE),
sourceLineAnnotation);
}
} catch (ClassNotFoundException e) {
// ignore
}
}
}
示例3: getFirstCommonSuperclass
import org.apache.bcel.generic.ReferenceType; //导入方法依赖的package包/类
/**
* Get the first common superclass of the given reference types. Note that
* an interface type is never returned unless <code>a</code> and
* <code>b</code> are the same type. Otherwise, we try to return as accurate
* a type as possible. This method is used as the meet operator in
* TypeDataflowAnalysis, and is intended to follow (more or less) the JVM
* bytecode verifier semantics.
*
* <p>
* This method should be used in preference to the
* getFirstCommonSuperclass() method in {@link ReferenceType}.
* </p>
*
* @param a
* a ReferenceType
* @param b
* another ReferenceType
* @return the first common superclass of <code>a</code> and <code>b</code>
* @throws ClassNotFoundException
*/
public ReferenceType getFirstCommonSuperclass(ReferenceType a, ReferenceType b) throws ClassNotFoundException {
// Easy case: same types
if (a.equals(b)) {
return a;
}
ReferenceType answer = checkFirstCommonSuperclassQueryCache(a, b);
if (answer == null) {
answer = computeFirstCommonSuperclassOfReferenceTypes(a, b);
putFirstCommonSuperclassQueryCache(a, b, answer);
}
return answer;
}