当前位置: 首页>>代码示例>>Java>>正文


Java HashSetFactory类代码示例

本文整理汇总了Java中com.ibm.wala.util.collections.HashSetFactory的典型用法代码示例。如果您正苦于以下问题:Java HashSetFactory类的具体用法?Java HashSetFactory怎么用?Java HashSetFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


HashSetFactory类属于com.ibm.wala.util.collections包,在下文中一共展示了HashSetFactory类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: replaceNestedAny

import com.ibm.wala.util.collections.HashSetFactory; //导入依赖的package包/类
public static void replaceNestedAny(Type type) {
    logger.debug("replacing any types appearing in {}", type);
    traverseAndUpdateType(type, HashSetFactory.make(), (t,context) -> {
        if (t instanceof AnyType) {
            switch (context) {
            case CONSTRUCTOR_PROTO:
                return null;
            case RECEIVER:
                return new ObjectType();
            case OTHER:
                return fallbackType();
            }
        }
        return t;
    });
}
 
开发者ID:Samsung,项目名称:SJS,代码行数:17,代码来源:TypeConstraintFixedPointSolver.java

示例2: main

import com.ibm.wala.util.collections.HashSetFactory; //导入依赖的package包/类
/**
 * This main program shows one example use of thread escape analysis: producing a set of fields to be monitored for a
 * dynamic race detector. The idea is that any field might have a race with two exceptions: final fields do not have
 * races since there are no writes to them, and volatile fields have atomic read and write semantics provided by the
 * VM. Hence, this piece of code produces a list of all other fields.
 * @throws CancelException
 * @throws IllegalArgumentException
 */
public static void main(String[] args) throws IOException, ClassHierarchyException, IllegalArgumentException, CancelException {
  String mainClassName = args[0];

  Set<JarFile> jars = HashSetFactory.make();
  for (int i = 1; i < args.length; i++) {
    jars.add(new JarFile(args[i]));
  }

  Set<IClass> escapingTypes = (new SimpleThreadEscapeAnalysis(jars, mainClassName)).gatherThreadEscapingClasses();

  for (Iterator<IClass> types = escapingTypes.iterator(); types.hasNext();) {
    IClass cls = types.next();
    if (!cls.isArrayClass()) {
      for (Iterator<IField> fs = cls.getAllFields().iterator(); fs.hasNext();) {
        IField f = fs.next();
        if (!f.isVolatile() && !f.isFinal()) {
          System.err.println(f.getReference());
        }
      }
    }
  }
}
 
开发者ID:wala,项目名称:WALA-start,代码行数:31,代码来源:SimpleThreadEscapeAnalysis.java

示例3: makeHtmlScope

import com.ibm.wala.util.collections.HashSetFactory; //导入依赖的package包/类
public static SourceModule[] makeHtmlScope(URL url, JavaScriptLoaderFactory loaders, Function<Void,JSSourceExtractor> fExtractor) {
  Set<Module> scripts = HashSetFactory.make();
  
  JavaScriptLoader.addBootstrapFile(WebUtil.preamble);
  scripts.add(getPrologueFile("prologue.js"));
  scripts.add(getPrologueFile("preamble.js"));

  try {
    scripts.addAll(WebUtil.extractScriptFromHTML(url, fExtractor).fst);
  } catch (Error e) {
    SourceModule dummy = new SourceURLModule(url);
    scripts.add(dummy);
    ((CAstAbstractLoader)loaders.getTheLoader()).addMessage(dummy, e.warning);
  }
      
  SourceModule[] scriptsArray = scripts.toArray(new SourceModule[ scripts.size() ]);
  return scriptsArray;
}
 
开发者ID:wala,项目名称:WALA-start,代码行数:19,代码来源:JSCallGraphBuilderUtil.java

示例4: collectInitialSeeds

import com.ibm.wala.util.collections.HashSetFactory; //导入依赖的package包/类
/**
 * collect the putstatic instructions in the call graph as {@link PathEdge} seeds for the analysis
 */
private Collection<PathEdge<BasicBlockInContext<IExplodedBasicBlock>>> collectInitialSeeds() {
  Collection<PathEdge<BasicBlockInContext<IExplodedBasicBlock>>> result = HashSetFactory.make();
  for (BasicBlockInContext<IExplodedBasicBlock> bb : supergraph) {
    IExplodedBasicBlock ebb = bb.getDelegate();
    SSAInstruction instruction = ebb.getInstruction();
    if (instruction instanceof SSAPutInstruction) {
      SSAPutInstruction putInstr = (SSAPutInstruction) instruction;
      if (putInstr.isStatic()) {
        final CGNode cgNode = bb.getNode();
        Pair<CGNode, Integer> fact = Pair.make(cgNode, ebb.getFirstInstructionIndex());
        int factNum = domain.add(fact);
        BasicBlockInContext<IExplodedBasicBlock> fakeEntry = getFakeEntry(cgNode);
        // note that the fact number used for the source of this path edge doesn't really matter
        result.add(PathEdge.createPathEdge(fakeEntry, factNum, bb, factNum));

      }
    }
  }
  return result;
}
 
开发者ID:wala,项目名称:WALA-start,代码行数:24,代码来源:ContextSensitiveReachingDefs.java

示例5: makeHtmlScope

import com.ibm.wala.util.collections.HashSetFactory; //导入依赖的package包/类
public static SourceModule[] makeHtmlScope(URL url, JavaScriptLoaderFactory loaders) {
  Set<SourceModule> scripts = HashSetFactory.make();
  
  JavaScriptLoader.addBootstrapFile(WebUtil.preamble);
  scripts.add(getPrologueFile("prologue.js"));
  scripts.add(getPrologueFile("preamble.js"));

  try {
    scripts.addAll(WebUtil.extractScriptFromHTML(url, true).fst);
  } catch (Error e) {
    SourceModule dummy = new SourceURLModule(url);
    scripts.add(dummy);
    ((CAstAbstractLoader)loaders.getTheLoader()).addMessage(dummy, e.warning);
  }
      
  SourceModule[] scriptsArray = scripts.toArray(new SourceModule[ scripts.size() ]);
  return scriptsArray;
}
 
开发者ID:ylimit,项目名称:HybridFlow,代码行数:19,代码来源:JSCallGraphBuilderUtil.java

示例6: makeHtmlScope

import com.ibm.wala.util.collections.HashSetFactory; //导入依赖的package包/类
public static SourceModule[] makeHtmlScope(URL url,
        JavaScriptLoaderFactory loaders) {
    Set<SourceModule> scripts = HashSetFactory.make();

    JavaScriptLoader.addBootstrapFile(WebUtil.preamble);
    scripts.add(getPrologueFile("prologue.js"));
    scripts.add(getPrologueFile("preamble.js"));

    try {
        scripts.addAll(WebUtil.extractScriptFromHTML(url, DefaultSourceExtractor.factory).fst);// TODO
    } catch (Error e) {
        SourceModule dummy = new SourceURLModule(url);
        scripts.add(dummy);
        ((CAstAbstractLoader) loaders.getTheLoader()).addMessage(dummy,
                e.warning);
    }

    SourceModule[] scriptsArray = scripts.toArray(new SourceModule[scripts
                                  .size()]);
    return scriptsArray;
}
 
开发者ID:logicalhacking,项目名称:DASCA,代码行数:22,代码来源:ImprovedJSCallGraphBuilderUtil.java

示例7: copyState

import com.ibm.wala.util.collections.HashSetFactory; //导入依赖的package包/类
@Override
public void copyState(TypeInfSolverVariable v) {
    MROMRWVariable other = (MROMRWVariable) v;
    this.mroProps = HashSetFactory.make(other.mroProps);
    this.mrwProps = HashSetFactory.make(other.mrwProps);
    reasonForCurrentValue = v.reasonForCurrentValue;
}
 
开发者ID:Samsung,项目名称:SJS,代码行数:8,代码来源:MROMRWVariable.java

示例8: substituteTypeVars

import com.ibm.wala.util.collections.HashSetFactory; //导入依赖的package包/类
/**
 * Substitutes type solutions for type variables where applicable.
 * Also, replaces appearances of the Any type with Integer, to
 * aid in code generation
 * @param type
 * @param inProgress
 */
public void substituteTypeVars(Type type) {
    logger.debug("substituting type variables in {}", type);
    final HashSet<Type> inProgress = HashSetFactory.make();
    traverseAndUpdateType(type, inProgress, (t, context) -> {
        if (t instanceof TypeVar) {
            logger.trace("substituting for type variable {}", t);
            TypeVariableTerm tvarTerm = factory
                    .findOrCreateTypeVariableTerm((TypeVar)t);
            Type result = tvarTerm.getType();
            logger.trace("subst result: {}", result);
            return result;
        } else if (t instanceof ObjectType && !inProgress.contains(t)) {
            // This is subtle.  In some cases, we have many ObjectType objects
            // representing equivalent types in the final solution.  Performing
            // the same substitutions on these types repeatedly can be a performance
            // bottleneck.  So here, if we detect an equivalent object type, we return
            // the representative type we already encountered, reducing the number of
            // substitutions performed.
            // TODO devise a more principled solution to this problem, likely involving
            // making ObjectTypes truly immutable
            for (Type t2: inProgress) {
                if (Types.isEqual(t, t2)) {
                    return t2;
                }
            }
            return t;
        } else {
            return t;
        }
    });
}
 
开发者ID:Samsung,项目名称:SJS,代码行数:39,代码来源:TypeConstraintFixedPointSolver.java

示例9: getSystemJars

import com.ibm.wala.util.collections.HashSetFactory; //导入依赖的package包/类
/**
 * Collect the set of JarFiles that constitute the system libraries of the running JRE.
 */
private JarFile[] getSystemJars() throws IOException {
  String javaHomePath = "garbage";
  Set<JarFile> jarFiles = HashSetFactory.make();

  // first, see if wala.properties has been set up
  try {
    Properties p = WalaProperties.loadProperties();
    javaHomePath = p.getProperty(WalaProperties.J2SE_DIR);
  } catch (WalaException e) {
    // no luck.
  }

  // if not, try assuming the running JRE looks normal
  File x = new File(javaHomePath);
  if (!(x.exists() && x.isDirectory())) {
    javaHomePath = System.getProperty("java.home");

    if (!javaHomePath.endsWith(File.separator)) {
      javaHomePath = javaHomePath + File.separator;
    }

    javaHomePath = javaHomePath + "lib";
  }

  // find jars from chosen JRE lib path
  collectJars(new File(javaHomePath), jarFiles);

  return jarFiles.toArray(new JarFile[jarFiles.size()]);
}
 
开发者ID:wala,项目名称:WALA-start,代码行数:33,代码来源:SimpleThreadEscapeAnalysis.java

示例10: getModuleFiles

import com.ibm.wala.util.collections.HashSetFactory; //导入依赖的package包/类
/**
 * Take the given set of JarFiles that constitute the program, and return a set of Module files as expected by the
 * WALA machinery.
 */
private Set<JarFileModule> getModuleFiles() {
  Set<JarFileModule> result = HashSetFactory.make();
  for (Iterator<JarFile> jars = applicationJarFiles.iterator(); jars.hasNext();) {
    result.add(new JarFileModule(jars.next()));
  }

  return result;
}
 
开发者ID:wala,项目名称:WALA-start,代码行数:13,代码来源:SimpleThreadEscapeAnalysis.java

示例11: getWrittenPrototypeProps

import com.ibm.wala.util.collections.HashSetFactory; //导入依赖的package包/类
/**
 * For a {@link FunctionNode} representing a constructor, if the constructor C is
 * followed by a sequence of assignments of the form C.prototype.a = ...;, return
 * a set of all the properties written on the prototype.  If the assignments do not
 * fit that form, return the empty set.
 * @param consNode
 * @return
 */
public static Set<String> getWrittenPrototypeProps(FunctionNode consNode) {
    Set<String> result = HashSetFactory.make();
    AstNode parent = consNode.getParent();
    boolean found = false;
    for (Node child: parent) {
        if (child instanceof EmptyStatement) {
            continue;
        }
        if (child.equals(consNode)) {
            found = true;
        } else if (found) {
            // looking for a statement of the form C.prototype.a = ...;
            boolean foundAssign = false;
            if (child instanceof ExpressionStatement) {
                AstNode expression = ((ExpressionStatement)child).getExpression();
                if (expression instanceof Assignment) {
                    Assignment assign = (Assignment) expression;
                    AstNode lhs = assign.getLeft();
                    if (lhs instanceof PropertyGet) {
                        PropertyGet pg = (PropertyGet) lhs;
                        AstNode pgTarget = pg.getTarget();
                        if (pgTarget instanceof PropertyGet) {
                            PropertyGet basePG = (PropertyGet) pgTarget;
                            if (basePG.getProperty().getIdentifier().equals("prototype")) {
                                // BINGO
                                result.add(pg.getProperty().getIdentifier());
                                foundAssign = true;
                            }
                        }
                    }
                }
            }
            if (!foundAssign) {
                // stop looking for more assignments
                break;
            }
        }
    }
    return result;
}
 
开发者ID:Samsung,项目名称:SJS,代码行数:49,代码来源:ConstraintGenUtil.java

示例12: getCallGraph

import com.ibm.wala.util.collections.HashSetFactory; //导入依赖的package包/类
/**
 * Gets callgraph for given parameters (binary analysis only)
 * @param exclusionFilePath
 * @param classPath
 * @param entryClass
 * @param entryMethod
 * @return
 */
public static CallGraph getCallGraph(String exclusionFilePath, String classPath, String entryClass, String entryMethod) {
    AnalysisScope scope = null;
    ClassHierarchy cha = null;
    HashSet<Entrypoint> entryPoints = null;
    try {
        File exclusionFile = new File(exclusionFilePath);
        scope = AnalysisScopeReader.makeJavaBinaryAnalysisScope(classPath, exclusionFile); // works with class and jar files
        cha = ClassHierarchyFactory.make(scope);

        ClassLoaderReference clr = scope.getApplicationLoader();
        entryPoints = HashSetFactory.make();
        for(IClass class1 : cha) {
            if(class1.getClassLoader().getReference().equals(clr)) {
                Collection<IMethod> allMethods = class1.getDeclaredMethods();
                for(IMethod m : allMethods) {
                    if(m.isPrivate()) {
                        continue;
                    }
                    TypeName tn = m.getDeclaringClass().getName();//MainApplication
                    if(tn.toString().contains("/" + entryClass) && m.getName().toString().contains(entryMethod)) { // TODO: too weak
                        entryPoints.add(new DefaultEntrypoint(m, cha));
                    }
                }
            }
        }
        //	    Iterable<Entrypoint> result1 = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha); // uses the static main methods as entry methods
        if(entryPoints.size() == 0) {
            log.error("Could not find specified entry point for analysis.\n" +
                      " path: " + classPath + "\n" +
                      " class: " + entryClass + "\n" +
                      " method: " + entryMethod);
            System.exit(1);
        }
        AnalysisOptions options = new AnalysisOptions(scope, entryPoints);

        //		CallGraphBuilder builder = com.ibm.wala.ipa.callgraph.impl.Util.makeRTABuilder(options, new AnalysisCacheImpl(), cha, scope); // Rapid Type Analysis
        SSAPropagationCallGraphBuilder builder = com.ibm.wala.ipa.callgraph.impl.Util.makeZeroCFABuilder(options, new AnalysisCacheImpl(), cha, scope); // 0-CFA = context-insensitive, class-based heap
        //		CallGraphBuilder builder = com.ibm.wala.ipa.callgraph.impl.Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope); // 0-1-CFA = context-insensitive, allocation-site-based heap
        //		CallGraphBuilder builder = com.ibm.wala.ipa.callgraph.impl.Util.makeZeroOneContainerCFABuilder(options, new AnalysisCacheImpl(), cha, scope); // 0-1-Container-CFA = object-sensitive container

        return builder.makeCallGraph(options);
    } catch (Exception e) {
        log.error("Error while building the call graph");
        e.printStackTrace();
        System.exit(1);
        return null;
    }
}
 
开发者ID:logicalhacking,项目名称:DASCA,代码行数:57,代码来源:AnalysisUtil.java

示例13: isEqual

import com.ibm.wala.util.collections.HashSetFactory; //导入依赖的package包/类
/**
 * Some of the subtypes of Type are mutable so equals() and hashCode()
 * methods cannot be written in a reliable way on these types. This
 * method should be used for comparing types.
 */
public static boolean isEqual(Type type1, Type type2){
	return isEqualHelper(type1, type2, HashSetFactory.make());
}
 
开发者ID:Samsung,项目名称:SJS,代码行数:9,代码来源:Types.java


注:本文中的com.ibm.wala.util.collections.HashSetFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。