test_class.file: lang-java-reach/src/test/java/org/eclipse/steady/cg/CallgraphTest.java
test_class.identifier: CallgraphTest
test_case.body: @Test
    public void callgraphTest() {
      // Manually build a call graph: 10 nodes and 14 edges
      Graph<org.eclipse.steady.shared.json.model.ConstructId> graph = SlowSparseNumberedGraph.make();
      ConstructId a = JavaId.toSharedType(JavaId.parseMethodQName("test.a()"));
      graph.addNode(a);
      ConstructId b = JavaId.toSharedType(JavaId.parseMethodQName("test.b()"));
      graph.addNode(b);
      ConstructId c = JavaId.toSharedType(JavaId.parseMethodQName("test.c()"));
      graph.addNode(c);
      ConstructId d = JavaId.toSharedType(JavaId.parseMethodQName("test.d()"));
      graph.addNode(d);
      ConstructId e = JavaId.toSharedType(JavaId.parseMethodQName("test.e()"));
      graph.addNode(e);
      ConstructId f = JavaId.toSharedType(JavaId.parseMethodQName("test.f()"));
      graph.addNode(f);
      ConstructId g = JavaId.toSharedType(JavaId.parseMethodQName("test.g()"));
      graph.addNode(g);
      ConstructId h = JavaId.toSharedType(JavaId.parseMethodQName("test.h()"));
      graph.addNode(h);
      ConstructId i = JavaId.toSharedType(JavaId.parseMethodQName("test.i()"));
      graph.addNode(i);
      ConstructId j = JavaId.toSharedType(JavaId.parseMethodQName("test.j()"));
      graph.addNode(j);
      graph.addEdge(a, b);
      graph.addEdge(a, c);
      graph.addEdge(b, d);
      graph.addEdge(b, e);
      graph.addEdge(b, f);
      graph.addEdge(c, f);
      graph.addEdge(c, g);
      graph.addEdge(e, h);
      graph.addEdge(f, i);
      graph.addEdge(h, i);
      graph.addEdge(h, j);
      graph.addEdge(i, j);
      graph.addEdge(g, j);
      graph.addEdge(i, e);
  
      Callgraph cg = new Callgraph(graph);
  
      // source = a; target = j;
      // Test 1: compute the distance
      Map<ConstructId, Integer> distance = cg.getDist(j);
      int dist = distance.get(a);
      assertEquals(dist, 3);
  
      // Test 2: compute the shortest path
      Map<ConstructId, LinkedList<Integer>> shortestPaths = cg.getShortestPath(j, null);
      LinkedList<ConstructId> expectedShortestPath = new LinkedList<ConstructId>();
      expectedShortestPath.add(c);
      expectedShortestPath.add(g);
      expectedShortestPath.add(j);
      LinkedList<Integer> spath = shortestPaths.get(a);
      LinkedList<ConstructId> computedShortestPath = new LinkedList<ConstructId>();
      if (spath != null) {
        for (int n = (spath.size() - 1); n >= 0; n--) {
          computedShortestPath.add(cg.getConstructForId(spath.get(n)));
        }
      }
      assertEquals(computedShortestPath, expectedShortestPath);
  
      // Test 3: compute all paths: DepthFirstGetPaths
      AbstractGetPaths getpaths = new DepthFirstGetPaths(cg.getGraph(), cg.getNodeId());
      HashSet<LinkedList<ConstructId>> paths = getpaths.getAllPaths(a, j);
      for (LinkedList<ConstructId> p : paths) {
        for (ConstructId cid : p) System.out.print(cid.getQname() + "		");
        System.out.println();
      }
      assertEquals(paths.size(), 7);
  
      // Test 4: compute all paths: Get all paths from pruned graph
      getpaths = new PrunedGraphGetPaths(cg.getGraph(), cg.getNodeId());
      paths = getpaths.getAllPaths(a, j);
      for (LinkedList<ConstructId> p : paths) {
        for (ConstructId cid : p) System.out.print(cid.getQname() + "		");
        System.out.println();
      }
      assertEquals(paths.size(), 7);
    }
test_case.class_method_signature: CallgraphTest.callgraphTest()
test_case.full_signature: @Test public void callgraphTest()
test_case.identifier: callgraphTest
test_case.invocations: make toSharedType parseMethodQName addNode toSharedType parseMethodQName addNode toSharedType parseMethodQName addNode toSharedType parseMethodQName addNode toSharedType parseMethodQName addNode toSharedType parseMethodQName addNode toSharedType parseMethodQName addNode toSharedType parseMethodQName addNode toSharedType parseMethodQName addNode toSharedType parseMethodQName addNode addEdge addEdge addEdge addEdge addEdge addEdge addEdge addEdge addEdge addEdge addEdge addEdge addEdge addEdge getDist get assertEquals getShortestPath add add add get size add getConstructForId get assertEquals getGraph getNodeId getAllPaths print getQname println assertEquals size getGraph getNodeId getAllPaths print getQname println assertEquals size
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void callgraphTest()
focal_class.declarator: log = org.apache.logging.log4j.LogManager.getLogger()
focal_class.modifier: private static final
focal_class.original_string: private static final Logger log = org.apache.logging.log4j.LogManager.getLogger();
focal_class.type: Logger
focal_class.var_name: log
focal_class.declarator: nodeCount = 0
focal_class.modifier: private
focal_class.original_string: private int nodeCount = 0;
focal_class.type: int
focal_class.var_name: nodeCount
focal_class.declarator: edgeCount = 0
focal_class.modifier: private
focal_class.original_string: private int edgeCount = 0;
focal_class.type: int
focal_class.var_name: edgeCount
focal_class.declarator: idgraph = SlowSparseNumberedGraph.make()
focal_class.modifier: private
focal_class.original_string: private Graph<Integer> idgraph = SlowSparseNumberedGraph.make();
focal_class.type: Graph<Integer>
focal_class.var_name: idgraph
focal_class.declarator: nodeMap =
        new HashMap<org.eclipse.steady.shared.json.model.ConstructId, Integer>()
focal_class.modifier: private final
focal_class.original_string: private final HashMap<org.eclipse.steady.shared.json.model.ConstructId, Integer> nodeMap =
        new HashMap<org.eclipse.steady.shared.json.model.ConstructId, Integer>();
focal_class.type: HashMap<org.eclipse.steady.shared.json.model.ConstructId, Integer>
focal_class.var_name: nodeMap
focal_class.declarator: nodeInfoMap =
        new HashMap<Integer, NodeMetaInformation>()
focal_class.modifier: private final
focal_class.original_string: private final HashMap<Integer, NodeMetaInformation> nodeInfoMap =
        new HashMap<Integer, NodeMetaInformation>();
focal_class.type: HashMap<Integer, NodeMetaInformation>
focal_class.var_name: nodeInfoMap
focal_class.declarator: jarAnalyzersCache = new HashMap<URI, JarAnalyzer>()
focal_class.modifier: private final
focal_class.original_string: private final HashMap<URI, JarAnalyzer> jarAnalyzersCache = new HashMap<URI, JarAnalyzer>();
focal_class.type: HashMap<URI, JarAnalyzer>
focal_class.var_name: jarAnalyzersCache
focal_class.declarator: cachedJarUrls = new HashMap<JavaId, URL>()
focal_class.modifier: private final
focal_class.original_string: private final Map<JavaId, URL> cachedJarUrls = new HashMap<JavaId, URL>();
focal_class.type: Map<JavaId, URL>
focal_class.var_name: cachedJarUrls
focal_class.declarator: constructsWithoutJarUrl =
        new HashSet<org.eclipse.steady.shared.json.model.ConstructId>()
focal_class.modifier: private final
focal_class.original_string: private final Set<org.eclipse.steady.shared.json.model.ConstructId> constructsWithoutJarUrl =
        new HashSet<org.eclipse.steady.shared.json.model.ConstructId>();
focal_class.type: Set<org.eclipse.steady.shared.json.model.ConstructId>
focal_class.var_name: constructsWithoutJarUrl
focal_class.declarator: nodeId =
        new ArrayList<org.eclipse.steady.shared.json.model.ConstructId>()
focal_class.modifier: private final
focal_class.original_string: private final ArrayList<org.eclipse.steady.shared.json.model.ConstructId> nodeId =
        new ArrayList<org.eclipse.steady.shared.json.model.ConstructId>();
focal_class.type: ArrayList<org.eclipse.steady.shared.json.model.ConstructId>
focal_class.var_name: nodeId
focal_class.file: lang-java-reach/src/main/java/org/eclipse/steady/cg/Callgraph.java
focal_class.identifier: Callgraph
focal_class.class_method_signature: Callgraph.getGraph()
focal_class.full_signature: public Graph<Integer> getGraph()
focal_class.identifier: getGraph
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Graph<Integer>
focal_class.signature: Graph<Integer> getGraph()
focal_class.class_method_signature: Callgraph.getIdForConstruct(org.eclipse.steady.shared.json.model.ConstructId _c)
focal_class.full_signature: public int getIdForConstruct(org.eclipse.steady.shared.json.model.ConstructId _c)
focal_class.identifier: getIdForConstruct
focal_class.modifiers: public
focal_class.parameters: (org.eclipse.steady.shared.json.model.ConstructId _c)
focal_class.return: int
focal_class.signature: int getIdForConstruct(org.eclipse.steady.shared.json.model.ConstructId _c)
focal_class.class_method_signature: Callgraph.existsInCallgraph(org.eclipse.steady.shared.json.model.ConstructId _c)
focal_class.full_signature: public boolean existsInCallgraph(org.eclipse.steady.shared.json.model.ConstructId _c)
focal_class.identifier: existsInCallgraph
focal_class.modifiers: public
focal_class.parameters: (org.eclipse.steady.shared.json.model.ConstructId _c)
focal_class.return: boolean
focal_class.signature: boolean existsInCallgraph(org.eclipse.steady.shared.json.model.ConstructId _c)
focal_class.class_method_signature: Callgraph.getNodeId()
focal_class.full_signature: public ArrayList<org.eclipse.steady.shared.json.model.ConstructId> getNodeId()
focal_class.identifier: getNodeId
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: ArrayList<org.eclipse.steady.shared.json.model.ConstructId>
focal_class.signature: ArrayList<org.eclipse.steady.shared.json.model.ConstructId> getNodeId()
focal_class.class_method_signature: Callgraph.getConstructForId(int _id)
focal_class.full_signature: public org.eclipse.steady.shared.json.model.ConstructId getConstructForId(int _id)
focal_class.identifier: getConstructForId
focal_class.modifiers: public
focal_class.parameters: (int _id)
focal_class.return: org.eclipse.steady.shared.json.model.ConstructId
focal_class.signature: org.eclipse.steady.shared.json.model.ConstructId getConstructForId(int _id)
focal_class.class_method_signature: Callgraph.Callgraph(Graph<org.eclipse.steady.shared.json.model.ConstructId> _g)
focal_class.full_signature: public  Callgraph(Graph<org.eclipse.steady.shared.json.model.ConstructId> _g)
focal_class.identifier: Callgraph
focal_class.modifiers: public
focal_class.parameters: (Graph<org.eclipse.steady.shared.json.model.ConstructId> _g)
focal_class.signature:  Callgraph(Graph<org.eclipse.steady.shared.json.model.ConstructId> _g)
focal_class.class_method_signature: Callgraph.createNodeMetaInformation(
        org.eclipse.steady.shared.json.model.ConstructId target, Integer target_id)
focal_class.full_signature: private NodeMetaInformation createNodeMetaInformation(
        org.eclipse.steady.shared.json.model.ConstructId target, Integer target_id)
focal_class.identifier: createNodeMetaInformation
focal_class.modifiers: private
focal_class.parameters: (
        org.eclipse.steady.shared.json.model.ConstructId target, Integer target_id)
focal_class.return: NodeMetaInformation
focal_class.signature: NodeMetaInformation createNodeMetaInformation(
        org.eclipse.steady.shared.json.model.ConstructId target, Integer target_id)
focal_class.class_method_signature: Callgraph.getInformationForConstructId(
        org.eclipse.steady.shared.json.model.ConstructId target)
focal_class.full_signature: public NodeMetaInformation getInformationForConstructId(
        org.eclipse.steady.shared.json.model.ConstructId target)
focal_class.identifier: getInformationForConstructId
focal_class.modifiers: public
focal_class.parameters: (
        org.eclipse.steady.shared.json.model.ConstructId target)
focal_class.return: NodeMetaInformation
focal_class.signature: NodeMetaInformation getInformationForConstructId(
        org.eclipse.steady.shared.json.model.ConstructId target)
focal_class.class_method_signature: Callgraph.getConstructsWithoutJarUrl()
focal_class.full_signature: public Set<org.eclipse.steady.shared.json.model.ConstructId> getConstructsWithoutJarUrl()
focal_class.identifier: getConstructsWithoutJarUrl
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Set<org.eclipse.steady.shared.json.model.ConstructId>
focal_class.signature: Set<org.eclipse.steady.shared.json.model.ConstructId> getConstructsWithoutJarUrl()
focal_class.class_method_signature: Callgraph.getInformationForId(Integer id)
focal_class.full_signature: public NodeMetaInformation getInformationForId(Integer id)
focal_class.identifier: getInformationForId
focal_class.modifiers: public
focal_class.parameters: (Integer id)
focal_class.return: NodeMetaInformation
focal_class.signature: NodeMetaInformation getInformationForId(Integer id)
focal_class.class_method_signature: Callgraph.getNodeCount()
focal_class.full_signature: public int getNodeCount()
focal_class.identifier: getNodeCount
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getNodeCount()
focal_class.class_method_signature: Callgraph.getEdgeCount()
focal_class.full_signature: public int getEdgeCount()
focal_class.identifier: getEdgeCount
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getEdgeCount()
focal_class.class_method_signature: Callgraph.getDist(
        org.eclipse.steady.shared.json.model.ConstructId _tgt)
focal_class.full_signature: public Map<org.eclipse.steady.shared.json.model.ConstructId, Integer> getDist(
        org.eclipse.steady.shared.json.model.ConstructId _tgt)
focal_class.identifier: getDist
focal_class.modifiers: public
focal_class.parameters: (
        org.eclipse.steady.shared.json.model.ConstructId _tgt)
focal_class.return: Map<org.eclipse.steady.shared.json.model.ConstructId, Integer>
focal_class.signature: Map<org.eclipse.steady.shared.json.model.ConstructId, Integer> getDist(
        org.eclipse.steady.shared.json.model.ConstructId _tgt)
focal_class.class_method_signature: Callgraph.computeDist(Integer _tgt, Map<Integer, Integer> _dist)
focal_class.full_signature: private Map<Integer, Integer> computeDist(Integer _tgt, Map<Integer, Integer> _dist)
focal_class.identifier: computeDist
focal_class.modifiers: private
focal_class.parameters: (Integer _tgt, Map<Integer, Integer> _dist)
focal_class.return: Map<Integer, Integer>
focal_class.signature: Map<Integer, Integer> computeDist(Integer _tgt, Map<Integer, Integer> _dist)
focal_class.class_method_signature: Callgraph.getShortestPath(
        org.eclipse.steady.shared.json.model.ConstructId _tgt,
        final Set<org.eclipse.steady.shared.json.model.ConstructId> _stop_if_path_found)
focal_class.full_signature: public Map<org.eclipse.steady.shared.json.model.ConstructId, LinkedList<Integer>> getShortestPath(
        org.eclipse.steady.shared.json.model.ConstructId _tgt,
        final Set<org.eclipse.steady.shared.json.model.ConstructId> _stop_if_path_found)
focal_class.identifier: getShortestPath
focal_class.modifiers: public
focal_class.parameters: (
        org.eclipse.steady.shared.json.model.ConstructId _tgt,
        final Set<org.eclipse.steady.shared.json.model.ConstructId> _stop_if_path_found)
focal_class.return: Map<org.eclipse.steady.shared.json.model.ConstructId, LinkedList<Integer>>
focal_class.signature: Map<org.eclipse.steady.shared.json.model.ConstructId, LinkedList<Integer>> getShortestPath(
        org.eclipse.steady.shared.json.model.ConstructId _tgt,
        final Set<org.eclipse.steady.shared.json.model.ConstructId> _stop_if_path_found)
focal_class.class_method_signature: Callgraph.computeShortestPath(
        Integer _tgt, Map<Integer, LinkedList<Integer>> _paths, final Set<Integer> _stop_nodes)
focal_class.full_signature: private Map<Integer, LinkedList<Integer>> computeShortestPath(
        Integer _tgt, Map<Integer, LinkedList<Integer>> _paths, final Set<Integer> _stop_nodes)
focal_class.identifier: computeShortestPath
focal_class.modifiers: private
focal_class.parameters: (
        Integer _tgt, Map<Integer, LinkedList<Integer>> _paths, final Set<Integer> _stop_nodes)
focal_class.return: Map<Integer, LinkedList<Integer>>
focal_class.signature: Map<Integer, LinkedList<Integer>> computeShortestPath(
        Integer _tgt, Map<Integer, LinkedList<Integer>> _paths, final Set<Integer> _stop_nodes)
focal_class.class_method_signature: Callgraph.existsPath(
        Map<Integer, LinkedList<Integer>> _paths, final Set<Integer> _nodes)
focal_class.full_signature: private final boolean existsPath(
        Map<Integer, LinkedList<Integer>> _paths, final Set<Integer> _nodes)
focal_class.identifier: existsPath
focal_class.modifiers: private final
focal_class.parameters: (
        Map<Integer, LinkedList<Integer>> _paths, final Set<Integer> _nodes)
focal_class.return: boolean
focal_class.signature: boolean existsPath(
        Map<Integer, LinkedList<Integer>> _paths, final Set<Integer> _nodes)
focal_class.class_method_signature: Callgraph.collectArchiveInformation(
        org.eclipse.steady.shared.json.model.ConstructId tgt_node)
focal_class.full_signature: private synchronized URL collectArchiveInformation(
        org.eclipse.steady.shared.json.model.ConstructId tgt_node)
focal_class.identifier: collectArchiveInformation
focal_class.modifiers: private synchronized
focal_class.parameters: (
        org.eclipse.steady.shared.json.model.ConstructId tgt_node)
focal_class.return: URL
focal_class.signature: URL collectArchiveInformation(
        org.eclipse.steady.shared.json.model.ConstructId tgt_node)
focal_class.class_method_signature: Callgraph.parseNonStaticInnerClassConstruct(
        org.eclipse.steady.shared.json.model.ConstructId target)
focal_class.full_signature: private org.eclipse.steady.shared.json.model.ConstructId parseNonStaticInnerClassConstruct(
        org.eclipse.steady.shared.json.model.ConstructId target)
focal_class.identifier: parseNonStaticInnerClassConstruct
focal_class.modifiers: private
focal_class.parameters: (
        org.eclipse.steady.shared.json.model.ConstructId target)
focal_class.return: org.eclipse.steady.shared.json.model.ConstructId
focal_class.signature: org.eclipse.steady.shared.json.model.ConstructId parseNonStaticInnerClassConstruct(
        org.eclipse.steady.shared.json.model.ConstructId target)
focal_class.class_method_signature: Callgraph.getShaFromCachedJarAnalyzer(URI _jar_url)
focal_class.full_signature: private synchronized String getShaFromCachedJarAnalyzer(URI _jar_url)
focal_class.identifier: getShaFromCachedJarAnalyzer
focal_class.modifiers: private synchronized
focal_class.parameters: (URI _jar_url)
focal_class.return: String
focal_class.signature: String getShaFromCachedJarAnalyzer(URI _jar_url)
focal_method.body: public Callgraph(Graph<org.eclipse.steady.shared.json.model.ConstructId> _g) {
      if (_g != null) {
  
        // The problems described in Jira ticket VULAS-1429 look as if the caches survive A2C
        // executions on different modules. Check and clear explicitly.
        if (!this.cachedJarUrls.isEmpty()) {
          log.warn("JAR URL cache not empty, clearing now...");
          this.cachedJarUrls.clear();
        }
        if (!this.jarAnalyzersCache.isEmpty()) {
          log.warn("JarAnalyzer cache not empty, clearing now ...");
          this.jarAnalyzersCache.clear();
        }
  
        Iterator<org.eclipse.steady.shared.json.model.ConstructId> iter = _g.iterator();
        org.eclipse.steady.shared.json.model.ConstructId src_node = null, tgt_node = null;
        Iterator<org.eclipse.steady.shared.json.model.ConstructId> succNodes = null;
        Integer src_id = null, tgt_id = null, count = -1;
  
        // Populate the map of constructs and integers
        while (iter.hasNext()) {
          this.nodeCount++;
          src_node = iter.next();
          src_id = this.nodeMap.get(src_node);
          if (src_id == null) {
            src_id = ++count;
            this.nodeMap.put(src_node, src_id);
            this.nodeInfoMap.put(src_id, this.createNodeMetaInformation(src_node, src_id));
            this.nodeId.add(src_node);
            this.idgraph.addNode(src_id);
          }
          // targets
          succNodes = _g.getSuccNodes(src_node);
          while (succNodes.hasNext()) {
            this.edgeCount++;
            tgt_node = succNodes.next();
            tgt_id = this.nodeMap.get(tgt_node);
            if (tgt_id == null) {
              tgt_id = ++count;
              this.nodeMap.put(tgt_node, tgt_id);
              this.nodeInfoMap.put(tgt_id, this.createNodeMetaInformation(tgt_node, tgt_id));
              this.nodeId.add(tgt_node);
              this.idgraph.addNode(tgt_id);
            }
            // add edges
            this.idgraph.addEdge(src_id, tgt_id);
          }
        }
        Callgraph.log.info("Built Graph<Integer> of " + this.idgraph.getNumberOfNodes() + " nodes");
      }
    }
focal_method.class_method_signature: Callgraph.Callgraph(Graph<org.eclipse.steady.shared.json.model.ConstructId> _g)
focal_method.full_signature: public  Callgraph(Graph<org.eclipse.steady.shared.json.model.ConstructId> _g)
focal_method.identifier: Callgraph
focal_method.modifiers: public
focal_method.parameters: (Graph<org.eclipse.steady.shared.json.model.ConstructId> _g)
focal_method.signature:  Callgraph(Graph<org.eclipse.steady.shared.json.model.ConstructId> _g)