本文整理汇总了Java中edu.umd.cs.findbugs.classfile.IAnalysisCache类的典型用法代码示例。如果您正苦于以下问题:Java IAnalysisCache类的具体用法?Java IAnalysisCache怎么用?Java IAnalysisCache使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IAnalysisCache类属于edu.umd.cs.findbugs.classfile包,在下文中一共展示了IAnalysisCache类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: analyze
import edu.umd.cs.findbugs.classfile.IAnalysisCache; //导入依赖的package包/类
public MethodBytecodeSet analyze(IAnalysisCache analysisCache, MethodDescriptor descriptor) throws CheckedAnalysisException {
Method method = analysisCache.getMethodAnalysis(Method.class, descriptor);
Code code = method.getCode();
if (code == null) {
return null;
}
byte[] instructionList = code.getCode();
// Create callback
UnpackedBytecodeCallback callback = new UnpackedBytecodeCallback(instructionList.length);
// Scan the method.
BytecodeScanner scanner = new BytecodeScanner();
scanner.scan(instructionList, callback);
UnpackedCode unpackedCode = callback.getUnpackedCode();
MethodBytecodeSet result = null;
if (unpackedCode != null) {
result = unpackedCode.getBytecodeSet();
}
return result;
}
示例3: analyze
import edu.umd.cs.findbugs.classfile.IAnalysisCache; //导入依赖的package包/类
public LiveLocalStoreDataflow analyze(IAnalysisCache analysisCache, MethodDescriptor descriptor)
throws CheckedAnalysisException {
MethodGen methodGen = getMethodGen(analysisCache, descriptor);
if (methodGen == null) {
return null;
}
CFG cfg = getCFG(analysisCache, descriptor);
ReverseDepthFirstSearch rdfs = getReverseDepthFirstSearch(analysisCache, descriptor);
LiveLocalStoreAnalysis analysis = new LiveLocalStoreAnalysis(methodGen, rdfs, getDepthFirstSearch(analysisCache,
descriptor));
LiveLocalStoreDataflow dataflow = new LiveLocalStoreDataflow(cfg, analysis);
dataflow.execute();
if (ClassContext.DUMP_DATAFLOW_ANALYSIS) {
ClassContext.dumpLiveLocalStoreDataflow(descriptor, cfg, dataflow);
}
return dataflow;
}
示例4: analyze
import edu.umd.cs.findbugs.classfile.IAnalysisCache; //导入依赖的package包/类
public UnpackedCode analyze(IAnalysisCache analysisCache, MethodDescriptor descriptor) throws CheckedAnalysisException {
Method method = getMethod(analysisCache, descriptor);
Code code = method.getCode();
if (code == null)
return null;
byte[] instructionList = code.getCode();
// Create callback
UnpackedBytecodeCallback callback = new UnpackedBytecodeCallback(instructionList.length);
// Scan the method.
BytecodeScanner scanner = new BytecodeScanner();
scanner.scan(instructionList, callback);
return callback.getUnpackedCode();
}
示例5: 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;
}
示例6: getInvokedMethod
import edu.umd.cs.findbugs.classfile.IAnalysisCache; //导入依赖的package包/类
static @Nonnull
XMethod getInvokedMethod(XClass xClass, String name, String sig, boolean isStatic) throws CheckedAnalysisException {
IAnalysisCache cache = Global.getAnalysisCache();
while (true) {
XMethod result = xClass.findMethod(name, sig, isStatic);
if (result != null)
return result;
if (isStatic)
throw new CheckedAnalysisException();
ClassDescriptor superclassDescriptor = xClass.getSuperclassDescriptor();
if (superclassDescriptor == null)
throw new CheckedAnalysisException();
xClass = cache.getClassAnalysis(XClass.class, superclassDescriptor);
}
}
示例7: 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);
}
}
示例8: visitClass
import edu.umd.cs.findbugs.classfile.IAnalysisCache; //导入依赖的package包/类
public void visitClass(ClassDescriptor classDescriptor) throws CheckedAnalysisException {
IAnalysisCache analysisCache = Global.getAnalysisCache();
JavaClass jclass = analysisCache.getClassAnalysis(JavaClass.class, classDescriptor);
classContext = analysisCache.getClassAnalysis(ClassContext.class, classDescriptor);
for (Method m : classContext.getMethodsInCallOrder()) {
if (m.getCode() == null) {
continue;
}
method = m;
MethodDescriptor methodDescriptor = BCELUtil.getMethodDescriptor(jclass, method);
// Try to get MethodGen. If we can't get one,
// then this method should be skipped.
MethodGen methodGen = analysisCache.getMethodAnalysis(MethodGen.class, methodDescriptor);
if (methodGen == null) {
continue;
}
CFG cfg = analysisCache.getMethodAnalysis(CFG.class, methodDescriptor);
visitMethodCFG(methodDescriptor, cfg);
}
}
示例9: analyze
import edu.umd.cs.findbugs.classfile.IAnalysisCache; //导入依赖的package包/类
public JumpInfo analyze(IAnalysisCache analysisCache, MethodDescriptor descriptor) throws CheckedAnalysisException {
Method method = analysisCache.getMethodAnalysis(Method.class, descriptor);
JavaClass jclass = getJavaClass(analysisCache, descriptor.getClassDescriptor());
Code code = method.getCode();
if (code == null) {
return null;
}
final OpcodeStack stack = new OpcodeStack();
DismantleBytecode branchAnalysis = new DismantleBytecode() {
@Override
public void sawOpcode(int seen) {
stack.sawOpcode(this, seen);
}
};
return computeJumpInfo(jclass, method, stack, branchAnalysis);
}
示例10: getDataflow
import edu.umd.cs.findbugs.classfile.IAnalysisCache; //导入依赖的package包/类
@Override
protected BackwardTypeQualifierDataflow getDataflow(DepthFirstSearch dfs, XMethod xmethod, CFG cfg,
ValueNumberDataflow vnaDataflow, ConstantPoolGen cpg, IAnalysisCache analysisCache,
MethodDescriptor methodDescriptor, TypeQualifierValue typeQualifierValue) throws CheckedAnalysisException {
ReverseDepthFirstSearch rdfs = analysisCache.getMethodAnalysis(ReverseDepthFirstSearch.class, methodDescriptor);
BackwardTypeQualifierDataflowAnalysis analysis = new BackwardTypeQualifierDataflowAnalysis(dfs, rdfs, xmethod, cfg,
vnaDataflow, cpg, typeQualifierValue);
// Get the corresponding forward dataflow.
// We use it to halt tracking of backwards values once we know
// that they encounter a conflicting forward value.
ForwardTypeQualifierDataflowFactory forwardFactory = analysisCache.getMethodAnalysis(
ForwardTypeQualifierDataflowFactory.class, methodDescriptor);
ForwardTypeQualifierDataflow forwardDataflow = forwardFactory.getDataflow(typeQualifierValue);
analysis.setForwardTypeQualifierDataflow(forwardDataflow);
analysis.registerSourceSinkLocations();
BackwardTypeQualifierDataflow dataflow = new BackwardTypeQualifierDataflow(cfg, analysis);
dataflow.execute();
if (ClassContext.DUMP_DATAFLOW_ANALYSIS) {
dataflow.dumpDataflow(analysis);
}
return dataflow;
}
示例11: getDataflow
import edu.umd.cs.findbugs.classfile.IAnalysisCache; //导入依赖的package包/类
@Override
protected BackwardTypeQualifierDataflow getDataflow(DepthFirstSearch dfs, XMethod xmethod, CFG cfg,
ValueNumberDataflow vnaDataflow, ConstantPoolGen cpg, IAnalysisCache analysisCache,
MethodDescriptor methodDescriptor, TypeQualifierValue<?> typeQualifierValue) throws CheckedAnalysisException {
ReverseDepthFirstSearch rdfs = analysisCache.getMethodAnalysis(ReverseDepthFirstSearch.class, methodDescriptor);
BackwardTypeQualifierDataflowAnalysis analysis = new BackwardTypeQualifierDataflowAnalysis(dfs, rdfs, xmethod, cfg,
vnaDataflow, cpg, typeQualifierValue);
// Get the corresponding forward dataflow.
// We use it to halt tracking of backwards values once we know
// that they encounter a conflicting forward value.
ForwardTypeQualifierDataflowFactory forwardFactory = analysisCache.getMethodAnalysis(
ForwardTypeQualifierDataflowFactory.class, methodDescriptor);
ForwardTypeQualifierDataflow forwardDataflow = forwardFactory.getDataflow(typeQualifierValue);
analysis.setForwardTypeQualifierDataflow(forwardDataflow);
analysis.registerSourceSinkLocations();
BackwardTypeQualifierDataflow dataflow = new BackwardTypeQualifierDataflow(cfg, analysis);
dataflow.execute();
if (ClassContext.DUMP_DATAFLOW_ANALYSIS) {
dataflow.dumpDataflow(analysis);
}
return dataflow;
}
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:27,代码来源:BackwardTypeQualifierDataflowFactory.java
示例12: 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;
}
示例13: createAnalysisCache
import edu.umd.cs.findbugs.classfile.IAnalysisCache; //导入依赖的package包/类
/**
* Create the analysis cache object and register it for current execution thread.
* <p>
* This method is protected to allow clients override it and possibly reuse
* some previous analysis data (for Eclipse interactive re-build)
*
* @throws IOException
* if error occurs registering analysis engines in a plugin
*/
protected IAnalysisCache createAnalysisCache() throws IOException {
IAnalysisCache analysisCache = ClassFactory.instance().createAnalysisCache(classPath, bugReporter);
// Register the "built-in" analysis engines
registerBuiltInAnalysisEngines(analysisCache);
// Register analysis engines in plugins
registerPluginAnalysisEngines(detectorFactoryCollection, analysisCache);
// Install the DetectorFactoryCollection as a database
analysisCache.eagerlyPutDatabase(DetectorFactoryCollection.class, detectorFactoryCollection);
Global.setAnalysisCacheForCurrentThread(analysisCache);
return analysisCache;
}
示例14: 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");
}
示例15: analyze
import edu.umd.cs.findbugs.classfile.IAnalysisCache; //导入依赖的package包/类
@Override
public TaintDataflow analyze(IAnalysisCache cache, MethodDescriptor descriptor)
throws CheckedAnalysisException {
if(FindSecBugsGlobalConfig.getInstance().isDebugPrintInstructionVisited() || FindSecBugsGlobalConfig.getInstance().isDebugPrintInvocationVisited()) {
System.out.println("==[ Method: "+descriptor.getName()+" ]==");
}
CFG cfg = cache.getMethodAnalysis(CFG.class, descriptor);
DepthFirstSearch dfs = cache.getMethodAnalysis(DepthFirstSearch.class, descriptor);
MethodGen methodGen = cache.getMethodAnalysis(MethodGen.class, descriptor);
TaintAnalysis analysis = new TaintAnalysis(methodGen, dfs, descriptor, taintConfig);
TaintDataflow flow = new TaintDataflow(cfg, analysis);
flow.execute();
analysis.finishAnalysis();
if (CONFIG.isDebugOutputTaintConfigs() && writer != null) {
TaintMethodConfig derivedConfig = taintConfig.get(getSlashedMethodName(methodGen));
if (derivedConfig != null) {
try {
writer.append(getSlashedMethodName(methodGen) + ":" + derivedConfig + "\n");
writer.flush();
} catch (IOException ex) {
AnalysisContext.logError("Cannot write derived configs", ex);
}
}
}
return flow;
}