📄 classcontext.java
字号:
throws DataflowAnalysisException, CFGBuilderException { CFG cfg = getCFG(method); DepthFirstSearch dfs = getDepthFirstSearch(method); BlockTypeAnalysis analysis = new BlockTypeAnalysis(dfs); Dataflow<BlockType, BlockTypeAnalysis> dataflow = new Dataflow<BlockType, BlockTypeAnalysis>(cfg, analysis); dataflow.execute(); return dataflow; } }; private ClassGen classGen; private AssignedFieldMap assignedFieldMap; private AssertionMethods assertionMethods; /* ---------------------------------------------------------------------- * Public methods * ---------------------------------------------------------------------- */ /** * Constructor. * * @param jclass the JavaClass */ public ClassContext(JavaClass jclass, AnalysisContext analysisContext) { this.jclass = jclass; this.analysisContext = analysisContext; this.classGen = null; this.assignedFieldMap = null; this.assertionMethods = null; } /** * Get the JavaClass. */ public JavaClass getJavaClass() { return jclass; } /** * Get the AnalysisContext. */ public AnalysisContext getAnalysisContext() { return analysisContext; } /** * Get the RepositoryLookupFailureCallback. * * @return the RepositoryLookupFailureCallback */ public RepositoryLookupFailureCallback getLookupFailureCallback() { return analysisContext.getLookupFailureCallback(); } /** * Get a MethodGen object for given method. * * @param method the method * @return the MethodGen object for the method, or null * if the method has no Code attribute (and thus cannot be analyzed) */ public MethodGen getMethodGen(Method method) { return methodGenFactory.getAnalysis(method); } /** * Get a "raw" CFG for given method. * No pruning is done, although the CFG may already be pruned. * * @param method the method * @return the raw CFG */ public CFG getRawCFG(Method method) throws CFGBuilderException { return cfgFactory.getRawCFG(method); } /** * Get a CFG for given method. * If pruning options are in effect, pruning will be done. * Because the CFG pruning can involve interprocedural analysis, * it is done on a best-effort basis, so the CFG returned might * not actually be pruned. * * @param method the method * @return the CFG * @throws CFGBuilderException if a CFG cannot be constructed for the method */ public CFG getCFG(Method method) throws CFGBuilderException { return cfgFactory.getRefinedCFG(method); } /** * Get the ConstantPoolGen used to create the MethodGens * for this class. * * @return the ConstantPoolGen */ public ConstantPoolGen getConstantPoolGen() { if (classGen == null) classGen = new ClassGen(jclass); return classGen.getConstantPool(); } /** * Get a ValueNumberDataflow for given method. * * @param method the method * @return the ValueNumberDataflow */ public ValueNumberDataflow getValueNumberDataflow(Method method) throws DataflowAnalysisException, CFGBuilderException { return vnaDataflowFactory.getAnalysis(method); } /** * Get an IsNullValueDataflow for given method. * * @param method the method * @return the IsNullValueDataflow */ public IsNullValueDataflow getIsNullValueDataflow(Method method) throws DataflowAnalysisException, CFGBuilderException { return invDataflowFactory.getAnalysis(method); } /** * Get a TypeDataflow for given method. * * @param method the method * @return the TypeDataflow */ public TypeDataflow getTypeDataflow(Method method) throws DataflowAnalysisException, CFGBuilderException { return typeDataflowFactory.getAnalysis(method); } /** * Get a DepthFirstSearch for given method. * * @param method the method * @return the DepthFirstSearch */ public DepthFirstSearch getDepthFirstSearch(Method method) throws CFGBuilderException { return dfsFactory.getAnalysis(method); } /** * Get a ReverseDepthFirstSearch for given method. * * @param method the method * @return the ReverseDepthFirstSearch */ public ReverseDepthFirstSearch getReverseDepthFirstSearch(Method method) throws CFGBuilderException { return rdfsFactory.getAnalysis(method); } /** * Get a BitSet representing the bytecodes that are used in the given method. * This is useful for prescreening a method for the existence of particular instructions. * Because this step doesn't require building a MethodGen, it is very * fast and memory-efficient. It may allow a Detector to avoid some * very expensive analysis, which is a Big Win for the user. * * @param method the method * @return the BitSet containing the opcodes which appear in the method */ public BitSet getBytecodeSet(Method method) { return bytecodeSetFactory.getAnalysis(method); }// /**// * Get dataflow for AnyLockCountAnalysis for given method.// * @param method the method// * @return the Dataflow// */// public LockCountDataflow getAnyLockCountDataflow(Method method)// throws CFGBuilderException, DataflowAnalysisException {// return anyLockCountDataflowFactory.getAnalysis(method);// } /** * Get dataflow for LockAnalysis for given method. * * @param method the method * @return the LockDataflow */ public LockDataflow getLockDataflow(Method method) throws CFGBuilderException, DataflowAnalysisException { return lockDataflowFactory.getAnalysis(method); } /** * Get ReturnPathDataflow for method. * * @param method the method * @return the ReturnPathDataflow */ public ReturnPathDataflow getReturnPathDataflow(Method method) throws CFGBuilderException, DataflowAnalysisException { return returnPathDataflowFactory.getAnalysis(method); } /** * Get DominatorsAnalysis for given method, * where exception edges are ignored. * * @param method the method * @return the DominatorsAnalysis */ public DominatorsAnalysis getNonExceptionDominatorsAnalysis(Method method) throws CFGBuilderException, DataflowAnalysisException { return nonExceptionDominatorsAnalysisFactory.getAnalysis(method); } /** * Get PostDominatorsAnalysis for given method, * where exception edges are ignored. * * @param method the method * @return the PostDominatorsAnalysis */ public PostDominatorsAnalysis getNonExceptionPostDominatorsAnalysis(Method method) throws CFGBuilderException, DataflowAnalysisException { return nonExceptionPostDominatorsAnalysisFactory.getAnalysis(method); } /** * Get ExceptionSetFactory for given method. * * @param method the method * @return the ExceptionSetFactory */ public ExceptionSetFactory getExceptionSetFactory(Method method) { return exceptionSetFactoryFactory.getAnalysis(method); } /** * Get array of type signatures of parameters for given method. * * @param method the method * @return an array of type signatures indicating the types * of the method's parameters */ public String[] getParameterSignatureList(Method method) { return parameterSignatureListFactory.getAnalysis(method); } /** * Get the set of fields loaded by given method. * * @param method the method * @return the set of fields loaded by the method */ public LoadedFieldSet getLoadedFieldSet(Method method) { return loadedFieldSetFactory.getAnalysis(method); } /** * Get LiveLocalStoreAnalysis dataflow for given method. * * @param method the method * @return the Dataflow object for LiveLocalStoreAnalysis on the method */ public LiveLocalStoreDataflow getLiveLocalStoreDataflow(Method method) throws DataflowAnalysisException, CFGBuilderException { return liveLocalStoreDataflowFactory.getAnalysis(method); } /** * Get BlockType dataflow for given method. * * @param method the method * @return the Dataflow object for BlockTypeAnalysis on the method */ public Dataflow<BlockType, BlockTypeAnalysis> getBlockTypeDataflow(Method method) throws DataflowAnalysisException, CFGBuilderException { return blockTypeDataflowFactory.getAnalysis(method); } /** * Get the assigned field map for the class. * * @return the AssignedFieldMap * @throws ClassNotFoundException if a class lookup prevents * the class's superclasses from being searched for * assignable fields */ public AssignedFieldMap getAssignedFieldMap() throws ClassNotFoundException { if (assignedFieldMap == null) { assignedFieldMap = new AssignedFieldMap(this); } return assignedFieldMap; } /** * Get AssertionMethods for class. * * @return the AssertionMethods */ public AssertionMethods getAssertionMethods() { if (assertionMethods == null) { assertionMethods = new AssertionMethods(jclass); } return assertionMethods; }}// vim:ts=3
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -