<div dir="ltr">Hi everyone,<div><br></div><div>I want to build a CG for a program. I refer to this <a href="https://o2lab.github.io/710/p/TestSootCallGraph.java">post</a> and modified some code. It works for me. The main code is as follows.</div><div><div class="prettyprint" style="background-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; overflow-wrap: break-word;"><code class="prettyprint"><div class="subprettyprint"><font color="#666600"><div class="subprettyprint">public static void main(String[] args) {</div><div class="subprettyprint"><span style="white-space:pre">       </span>//ses -- APISeqtest success</div><div class="subprettyprint"><span style="white-space:pre">  </span>String classesDir = "D:\\wkspace\\seed8\\dir\\APISeqtest";</div><div class="subprettyprint"><span style="white-space:pre"> </span>String mainClass = "com.ouc.Demo";</div><div class="subprettyprint"><br></div><div class="subprettyprint"><span style="white-space:pre">       </span>//set classpath</div><div class="subprettyprint"><span style="white-space:pre">      </span>String jreDir = System.getProperty("java.home") + "\\lib\\jce.jar";</div><div class="subprettyprint"><span style="white-space:pre">      </span>String jceDir = System.getProperty("java.home") + "\\lib\\rt.jar";</div><div class="subprettyprint"><span style="white-space:pre">       </span>String path = jreDir + File.pathSeparator + jceDir + File.pathSeparator + classesDir;</div><div class="subprettyprint"><span style="white-space:pre">        </span>Scene.v().setSootClassPath(path);</div><div class="subprettyprint"><br></div><div class="subprettyprint"><span style="white-space:pre">  </span>//add an intra-procedural analysis phase to Soot</div><div class="subprettyprint"><span style="white-space:pre">     </span>TestCallGraphSootJaronlyoneclass analysis = new TestCallGraphSootJaronlyoneclass();</div><div class="subprettyprint"><span style="white-space:pre">  </span>PackManager.v().getPack("wjtp").add(new Transform("wjtp.TestSootCallGraph", analysis));</div><div class="subprettyprint"><br></div><div class="subprettyprint"><span style="white-space:pre">        </span>excludeJDKLibrary();</div><div class="subprettyprint"><br></div><div class="subprettyprint"><span style="white-space:pre">       </span>Options.v().set_process_dir(Arrays.asList(classesDir));</div><div class="subprettyprint"><span style="white-space:pre">      </span>Options.v().set_whole_program(true);</div><div class="subprettyprint"><span style="white-space:pre"> </span>//Options.v().set_app(true);</div><div class="subprettyprint"><br></div><div class="subprettyprint"><span style="white-space:pre">       </span>Scene.v().loadNecessaryClasses();</div><div class="subprettyprint"><span style="white-space:pre">    </span>SootClass sc = Scene.v().getSootClass(mainClass);</div><div class="subprettyprint"><span style="white-space:pre">    </span>Scene.v().setMainClass(sc);</div><div class="subprettyprint"><br></div><div class="subprettyprint"><span style="white-space:pre">        </span>//enableCHACallGraph();</div><div class="subprettyprint"><span style="white-space:pre">      </span>enableSparkCallGraph();</div><div class="subprettyprint"><br></div><div class="subprettyprint"><span style="white-space:pre">    </span>PackManager.v().runPacks();</div><div class="subprettyprint">}</div></font></div></code></div><br>But if a program contains one more main methods, for example, C1, C2 and C3 all contain a main method, should I choose which one (<span style="background-color: rgb(250, 250, 250); color: rgb(102, 102, 0); font-family: monospace;">Scene.v().setMainClass(C1 or C2 or C3)</span>)?</div><div><br></div><div>This case does exist. Assume that  C1 is the true mainClass, then main method in C1 could call main methods of C2 and C3. Or main method in C3 is just used to test C3.</div><div><br></div><div>As described above, it's a little difficult to specify the true main method and the true mainClass. </div><div><br></div><div>Although I find that if I don't specify a mainClass when building CG, the program also works. But this post tell me that it's not <a href="https://groups.google.com/forum/#!topic/soot-list/jcHrdhzJyl0">precise</a>.</div></div>