本文整理汇总了Java中edu.umd.cs.findbugs.classfile.IAnalysisCache.getClassAnalysis方法的典型用法代码示例。如果您正苦于以下问题:Java IAnalysisCache.getClassAnalysis方法的具体用法?Java IAnalysisCache.getClassAnalysis怎么用?Java IAnalysisCache.getClassAnalysis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.umd.cs.findbugs.classfile.IAnalysisCache
的用法示例。
在下文中一共展示了IAnalysisCache.getClassAnalysis方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: analyze
import edu.umd.cs.findbugs.classfile.IAnalysisCache; //导入方法依赖的package包/类
public Method analyze(IAnalysisCache analysisCache, MethodDescriptor descriptor) throws CheckedAnalysisException {
JavaClass jclass = analysisCache.getClassAnalysis(JavaClass.class, descriptor.getClassDescriptor());
Method[] methodList = jclass.getMethods();
Method result = null;
// As a side-effect, cache all of the Methods for this JavaClass
for (Method method : methodList) {
MethodDescriptor methodDescriptor = DescriptorFactory.instance().getMethodDescriptor(
descriptor.getSlashedClassName(), method.getName(), method.getSignature(), method.isStatic());
// Put in cache eagerly
analysisCache.eagerlyPutMethodAnalysis(Method.class, methodDescriptor, method);
if (methodDescriptor.equals(descriptor)) {
result = method;
}
}
return result;
}
示例2: visitClass
import edu.umd.cs.findbugs.classfile.IAnalysisCache; //导入方法依赖的package包/类
@Override
public void visitClass(ClassDescriptor classDescriptor) throws CheckedAnalysisException {
IAnalysisCache analysisCache = Global.getAnalysisCache();
ObligationFactory factory = database.getFactory();
JavaClass jclass = analysisCache.getClassAnalysis(JavaClass.class, classDescriptor);
for (Constant c : jclass.getConstantPool().getConstantPool()) {
if (c instanceof ConstantNameAndType) {
ConstantNameAndType cnt = (ConstantNameAndType) c;
String signature = cnt.getSignature(jclass.getConstantPool());
if (factory.signatureInvolvesObligations(signature)) {
super.visitClass(classDescriptor);
return;
}
} else if (c instanceof ConstantClass) {
String className = ((ConstantClass) c).getBytes(jclass.getConstantPool());
if (factory.signatureInvolvesObligations(className)) {
super.visitClass(classDescriptor);
return;
}
}
}
if (DEBUG)
System.out.println(classDescriptor + " isn't interesting for obligation analysis");
}
示例3: analyze
import edu.umd.cs.findbugs.classfile.IAnalysisCache; //导入方法依赖的package包/类
public ClassNameAndSuperclassInfo analyze(IAnalysisCache analysisCache, ClassDescriptor descriptor)
throws CheckedAnalysisException {
// Get InputStream reading from class data
ClassData classData = analysisCache.getClassAnalysis(ClassData.class, descriptor);
DataInputStream classDataIn = new DataInputStream(new ByteArrayInputStream(classData.getData()));
// Read the class info
ClassParserInterface parser = new ClassParser(classDataIn, descriptor, classData.getCodeBaseEntry());
ClassNameAndSuperclassInfo.Builder classInfoBuilder = new ClassNameAndSuperclassInfo.Builder();
parser.parse(classInfoBuilder);
ClassNameAndSuperclassInfo classInfo = classInfoBuilder.build();
if (!classInfo.getClassDescriptor().equals(descriptor)) {
throw new ClassNameMismatchException(descriptor, classInfo.getClassDescriptor(), classData.getCodeBaseEntry());
}
return classInfo;
}
示例4: isCalledDirectlyOrIndirectly
import edu.umd.cs.findbugs.classfile.IAnalysisCache; //导入方法依赖的package包/类
/**
* @param superclassDescriptor
* @param m
* @return
* @throws CheckedAnalysisException
*/
private boolean isCalledDirectlyOrIndirectly(@CheckForNull ClassDescriptor clazzDescriptor, XMethod m)
throws CheckedAnalysisException {
if (clazzDescriptor == null)
return false;
IAnalysisCache analysisCache = Global.getAnalysisCache();
XClass clazz = analysisCache.getClassAnalysis(XClass.class, clazzDescriptor);
XMethod m2 = clazz.findMethod(m.getName(), m.getSignature(), m.isStatic());
if (m2 != null && isCalled(m2))
return true;
if (isCalledDirectlyOrIndirectly(clazz.getSuperclassDescriptor(), m))
return true;
for (ClassDescriptor i : clazz.getInterfaceDescriptorList())
if (isCalledDirectlyOrIndirectly(i, m))
return true;
return false;
}
示例5: analyze
import edu.umd.cs.findbugs.classfile.IAnalysisCache; //导入方法依赖的package包/类
public ClassNode analyze(IAnalysisCache analysisCache, ClassDescriptor descriptor) throws CheckedAnalysisException {
ClassReader classReader = analysisCache.getClassAnalysis(ClassReader.class, descriptor);
ICodeBaseEntry entry = analysisCache.getClassPath().lookupResource(descriptor.toResourceName());
// One of the less-than-ideal features of ASM is that
// invalid classfile format is indicated by a
// random runtime exception rather than something
// indicative of the real problem.
try {
ClassNode cn = new ClassNode();
classReader.accept(cn, 0);
return cn;
} catch (RuntimeException e) {
throw new InvalidClassFileFormatException(descriptor, entry, e);
}
}
示例6: fromVisitedInstruction
import edu.umd.cs.findbugs.classfile.IAnalysisCache; //导入方法依赖的package包/类
public static SourceLineAnnotation fromVisitedInstruction(MethodDescriptor methodDescriptor, int position) {
try {
IAnalysisCache analysisCache = Global.getAnalysisCache();
JavaClass jclass = analysisCache.getClassAnalysis(JavaClass.class, methodDescriptor.getClassDescriptor());
Method method = analysisCache.getMethodAnalysis(Method.class, methodDescriptor);
return fromVisitedInstruction(jclass, method, position);
} catch (CheckedAnalysisException e) {
return createReallyUnknown(methodDescriptor.getClassDescriptor().toDottedClassName());
}
}
示例7: addSourceLine
import edu.umd.cs.findbugs.classfile.IAnalysisCache; //导入方法依赖的package包/类
/**
* Add source line annotation for given Location in a method.
*
* @param methodDescriptor
* the method
* @param location
* the Location in the method
* @return this BugInstance
*/
@Nonnull
public BugInstance addSourceLine(MethodDescriptor methodDescriptor, Location location) {
try {
IAnalysisCache analysisCache = Global.getAnalysisCache();
ClassContext classContext = analysisCache.getClassAnalysis(ClassContext.class, methodDescriptor.getClassDescriptor());
Method method = analysisCache.getMethodAnalysis(Method.class, methodDescriptor);
return addSourceLine(classContext, method, location);
} catch (CheckedAnalysisException e) {
return addSourceLine(SourceLineAnnotation.createReallyUnknown(methodDescriptor.getClassDescriptor()
.toDottedClassName()));
}
}
示例8: analyze
import edu.umd.cs.findbugs.classfile.IAnalysisCache; //导入方法依赖的package包/类
public ClassInfo analyze(IAnalysisCache analysisCache, ClassDescriptor descriptor) throws CheckedAnalysisException {
if (descriptor instanceof ClassInfo)
return (ClassInfo) descriptor;
ClassData classData;
try {
classData = analysisCache.getClassAnalysis(ClassData.class, descriptor);
} catch (edu.umd.cs.findbugs.classfile.MissingClassException e) {
if (!descriptor.getSimpleName().equals("package-info"))
throw e;
ClassInfo.Builder builder = new ClassInfo.Builder();
builder.setClassDescriptor(descriptor);
builder.setAccessFlags(1536);
return builder.build();
}
// Read the class info
FBClassReader reader = analysisCache.getClassAnalysis(FBClassReader.class, descriptor);
ClassParserInterface parser = new ClassParserUsingASM(reader, descriptor, classData.getCodeBaseEntry());
ClassInfo.Builder classInfoBuilder = new ClassInfo.Builder();
parser.parse(classInfoBuilder);
ClassInfo classInfo = classInfoBuilder.build();
if (!classInfo.getClassDescriptor().equals(descriptor)) {
throw new ClassNameMismatchException(descriptor, classInfo.getClassDescriptor(), classData.getCodeBaseEntry());
}
return classInfo;
}
示例9: analyze
import edu.umd.cs.findbugs.classfile.IAnalysisCache; //导入方法依赖的package包/类
public ObligationDataflow analyze(IAnalysisCache analysisCache, MethodDescriptor methodDescriptor)
throws CheckedAnalysisException {
CFG cfg = analysisCache.getMethodAnalysis(CFG.class, methodDescriptor);
DepthFirstSearch dfs = analysisCache.getMethodAnalysis(DepthFirstSearch.class, methodDescriptor);
XMethod xmethod = XFactory.createXMethod(methodDescriptor);
ConstantPoolGen cpg = analysisCache.getClassAnalysis(ConstantPoolGen.class, methodDescriptor.getClassDescriptor());
ObligationPolicyDatabase database = analysisCache.getDatabase(ObligationPolicyDatabase.class);
TypeDataflow typeDataflow = analysisCache.getMethodAnalysis(TypeDataflow.class, methodDescriptor);
IsNullValueDataflow invDataflow = analysisCache.getMethodAnalysis(IsNullValueDataflow.class, methodDescriptor);
ObligationFactory factory = database.getFactory();
ObligationAnalysis analysis = new ObligationAnalysis(dfs, xmethod, cpg, factory, database, typeDataflow, invDataflow,
analysisCache.getErrorLogger());
ObligationDataflow dataflow = new ObligationDataflow(cfg, analysis);
Profiler profiler = analysisCache.getProfiler();
profiler.start(analysis.getClass());
try {
dataflow.execute();
} finally {
profiler.end(analysis.getClass());
}
if (DEBUG_PRINTCFG) {
System.out.println("Dataflow CFG:");
DataflowCFGPrinter.printCFG(dataflow, System.out);
}
return dataflow;
}
示例10: visitClass
import edu.umd.cs.findbugs.classfile.IAnalysisCache; //导入方法依赖的package包/类
public void visitClass(ClassDescriptor classDescriptor) throws CheckedAnalysisException {
// Just get the ClassContext from the analysis cache
// and apply the detector to it.
IAnalysisCache analysisCache = Global.getAnalysisCache();
ClassContext classContext = analysisCache.getClassAnalysis(ClassContext.class, classDescriptor);
Profiler profiler = analysisCache.getProfiler();
profiler.start(detector.getClass());
try {
detector.visitClassContext(classContext);
} finally {
profiler.end(detector.getClass());
}
}
示例11: analyze
import edu.umd.cs.findbugs.classfile.IAnalysisCache; //导入方法依赖的package包/类
public ConstantPoolGen analyze(IAnalysisCache analysisCache, ClassDescriptor descriptor) throws CheckedAnalysisException {
ClassGen classGen = new ClassGen(analysisCache.getClassAnalysis(JavaClass.class, descriptor));
return classGen.getConstantPool();
}
示例12: analyze
import edu.umd.cs.findbugs.classfile.IAnalysisCache; //导入方法依赖的package包/类
public ClassContext analyze(IAnalysisCache analysisCache, ClassDescriptor descriptor) throws CheckedAnalysisException {
JavaClass javaClass = analysisCache.getClassAnalysis(JavaClass.class, descriptor);
ClassContext classContext = new ClassContext(javaClass, AnalysisContext.currentAnalysisContext());
return classContext;
}
示例13: getPriorityForAssumingCompatible
import edu.umd.cs.findbugs.classfile.IAnalysisCache; //导入方法依赖的package包/类
/**
* @param pointerEquality
* @param lhsDescriptor
* @param rhsDescriptor
* @throws CheckedAnalysisException
* @throws ClassNotFoundException
*/
public static IncompatibleTypes getPriorityForAssumingCompatible(boolean pointerEquality, ClassDescriptor lhsDescriptor,
ClassDescriptor rhsDescriptor) throws CheckedAnalysisException, ClassNotFoundException {
if (lhsDescriptor.equals(rhsDescriptor))
return SEEMS_OK;
AnalysisContext analysisContext = AnalysisContext.currentAnalysisContext();
Subtypes2 subtypes2 = analysisContext.getSubtypes2();
IAnalysisCache cache = Global.getAnalysisCache();
XClass lhs = cache.getClassAnalysis(XClass.class, lhsDescriptor);
XClass rhs = cache.getClassAnalysis(XClass.class, rhsDescriptor);
// Look up the classes
XMethod lhsEquals = getInvokedMethod(lhs, "equals", "(Ljava/lang/Object;)Z", false);
XMethod rhsEquals = getInvokedMethod(rhs, "equals", "(Ljava/lang/Object;)Z", false);
String lhsClassName = lhsEquals.getClassName();
if (lhsEquals.equals(rhsEquals)) {
if (lhsClassName.equals("java.lang.Enum"))
return INCOMPATIBLE_CLASSES;
if (!pointerEquality && !lhsClassName.equals("java.lang.Object"))
return SEEMS_OK;
}
if ((subtypes2.isSubtype(lhsDescriptor, SET_DESCRIPTOR) && subtypes2.isSubtype(rhsDescriptor, SET_DESCRIPTOR)
|| subtypes2.isSubtype(lhsDescriptor, MAP_DESCRIPTOR) && subtypes2.isSubtype(rhsDescriptor, MAP_DESCRIPTOR) || subtypes2
.isSubtype(lhsDescriptor, LIST_DESCRIPTOR) && subtypes2.isSubtype(rhsDescriptor, LIST_DESCRIPTOR)))
return SEEMS_OK;
if (!lhs.isInterface() && !rhs.isInterface()) {
// Both are class types, and therefore there is no possible
// way
// the compared objects can have the same runtime type.
return INCOMPATIBLE_CLASSES;
} else {
// Look up the common subtypes of the two types. If the
// intersection does not contain at least one
// class,
// then issue a warning of the appropriate type.
Set<ClassDescriptor> commonSubtypes = subtypes2.getTransitiveCommonSubtypes(lhsDescriptor, rhsDescriptor);
if (commonSubtypes.isEmpty()) {
if (lhs.isInterface() && rhs.isInterface()) {
if (!subtypes2.hasKnownSubclasses(lhsDescriptor) || !subtypes2.hasKnownSubclasses(rhsDescriptor))
return UNRELATED_INTERFACES_WITHOUT_IMPLEMENTATIONS;
return UNRELATED_INTERFACES;
}
if (lhs.isFinal() || rhs.isFinal())
return UNRELATED_FINAL_CLASS_AND_INTERFACE;
if (lhsDescriptor.getClassName().startsWith("java/util/")
|| rhsDescriptor.getClassName().startsWith("java/util/"))
return UNRELATED_UTIL_INTERFACE;
return UNRELATED_CLASS_AND_INTERFACE;
}
}
return SEEMS_OK;
}
示例14: analyze
import edu.umd.cs.findbugs.classfile.IAnalysisCache; //导入方法依赖的package包/类
public FBClassReader analyze(IAnalysisCache analysisCache, ClassDescriptor descriptor) throws CheckedAnalysisException {
ClassData classData = analysisCache.getClassAnalysis(ClassData.class, descriptor);
FBClassReader classReader = new FBClassReader(classData.getData());
return classReader;
}