Skip to content

Commit e366796

Browse files
committed
feat:init
1 parent 44c522e commit e366796

File tree

19 files changed

+723
-0
lines changed

19 files changed

+723
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
logs
2+
target

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
## java-call-graph
2+
A demo app show you how to generate a java call graph.
3+
4+
### setup
5+
- import project to netbeans
6+
- update your own configure in src/main/resources/*.cfg
7+
- "Build Project"
8+
9+
10+
### run
11+
```
12+
java -jar java-callgraph-1.0-SNAPSHOT.jar
13+
```
14+
15+
### call graph
16+
- view doT graph below via https://edotor.net/
17+
```
18+
strict digraph G {
19+
com_test_StubImpl_subString_java_lang_String_ [ label="com.test.StubImpl.subString(java.lang.String)" ];
20+
com_test_Texter_getSuffix__ [ label="com.test.Texter.getSuffix()" ];
21+
com_tool_Util_Upper_java_lang_String_ [ label="com.tool.Util.Upper(java.lang.String)" ];
22+
com_test_Stub_subString_java_lang_String_ [ label="com.test.Stub.subString(java.lang.String)" ];
23+
com_test_Main_main_java_lang_String___ [ label="com.test.Main.main(java.lang.String[])" ];
24+
com_test_Driver_facade_java_lang_String_ [ label="com.test.Driver.facade(java.lang.String)" ];
25+
com_test_StubImpl_subString_java_lang_String_ -> com_test_Texter_getSuffix__;
26+
com_test_Main_main_java_lang_String___ -> com_test_Driver_facade_java_lang_String_;
27+
com_test_Main_main_java_lang_String___ -> com_tool_Util_Upper_java_lang_String_;
28+
com_test_Driver_facade_java_lang_String_ -> com_test_Stub_subString_java_lang_String_;
29+
}
30+
```
31+
32+
### screenshot
33+
![image](./src/main/resources/screenshot.png)

fake/pom.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>com.aiddroid.java.callgraph</groupId>
8+
<artifactId>fake</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
11+
12+
</project>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
package com.test;
3+
4+
public class Driver {
5+
protected Stub stub = new StubImpl();
6+
7+
public String facade(String b){
8+
// Stub stub = new StubImpl();
9+
final String s = stub.subString(b);;
10+
return s + "hahaha";
11+
}
12+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.test;
2+
3+
import com.tool.Util;
4+
5+
public class Main {
6+
public static void main(String[] args) {
7+
String s = new Driver().facade("hello, world!");
8+
System.out.println(Util.Upper(s));
9+
}
10+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.test;
2+
3+
public interface Stub {
4+
String subString(String a);
5+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.test;
2+
3+
public class StubImpl implements Stub {
4+
@Override
5+
public String subString(String a) {
6+
return a.substring(0,5) + new Texter().getSuffix();
7+
}
8+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.test;
2+
3+
public class Texter {
4+
public String getSuffix(){
5+
return ".txt";
6+
}
7+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* To change this license header, choose License Headers in Project Properties.
3+
* To change this template file, choose Tools | Templates
4+
* and open the template in the editor.
5+
*/
6+
package com.tool;
7+
8+
/**
9+
*
10+
* @author allen
11+
*/
12+
public class Util {
13+
14+
public static String Upper(String s) {
15+
return s.toUpperCase();
16+
}
17+
}

pom.xml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.aiddroid</groupId>
5+
<artifactId>java-call-graph</artifactId>
6+
<version>1.0-SNAPSHOT</version>
7+
<packaging>jar</packaging>
8+
<properties>
9+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
10+
<maven.compiler.source>15</maven.compiler.source>
11+
<maven.compiler.target>15</maven.compiler.target>
12+
</properties>
13+
14+
<build>
15+
<plugins>
16+
<plugin>
17+
<groupId>org.apache.maven.plugins</groupId>
18+
<artifactId>maven-jar-plugin</artifactId>
19+
<configuration>
20+
<archive>
21+
<!--主配置清单-->
22+
<manifest>
23+
<addClasspath>true</addClasspath>
24+
<mainClass>com.aiddroid.java.callgraph.Application</mainClass>
25+
</manifest>
26+
</archive>
27+
</configuration>
28+
</plugin>
29+
</plugins>
30+
</build>
31+
32+
<dependencies>
33+
<!--java代码分析-->
34+
<dependency>
35+
<groupId>com.github.javaparser</groupId>
36+
<artifactId>javaparser-symbol-solver-core</artifactId>
37+
<version>3.12.0</version>
38+
</dependency>
39+
<!--graphviz画图-->
40+
<dependency>
41+
<groupId>guru.nidi</groupId>
42+
<artifactId>graphviz-java</artifactId>
43+
<version>0.8.3</version>
44+
</dependency>
45+
46+
<!--日志slf4j+log4j2-->
47+
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api -->
48+
<dependency>
49+
<groupId>org.apache.logging.log4j</groupId>
50+
<artifactId>log4j-api</artifactId>
51+
<version>2.11.2</version>
52+
</dependency>
53+
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
54+
<dependency>
55+
<groupId>org.apache.logging.log4j</groupId>
56+
<artifactId>log4j-core</artifactId>
57+
<version>2.11.2</version>
58+
</dependency>
59+
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-slf4j18-impl -->
60+
<dependency>
61+
<groupId>org.apache.logging.log4j</groupId>
62+
<artifactId>log4j-slf4j18-impl</artifactId>
63+
<version>2.11.2</version>
64+
<!--<scope>test</scope>-->
65+
</dependency>
66+
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
67+
<dependency>
68+
<groupId>org.slf4j</groupId>
69+
<artifactId>slf4j-api</artifactId>
70+
<version>1.8.0-beta4</version>
71+
</dependency>
72+
<!-- https://mvnrepository.com/artifact/com.lmax/disruptor -->
73+
<dependency>
74+
<groupId>com.lmax</groupId>
75+
<artifactId>disruptor</artifactId>
76+
<version>3.4.2</version>
77+
</dependency>
78+
79+
80+
<dependency>
81+
<groupId>org.jgrapht</groupId>
82+
<artifactId>jgrapht-core</artifactId>
83+
<version>1.5.0</version>
84+
</dependency>
85+
86+
<dependency>
87+
<groupId>org.jgrapht</groupId>
88+
<artifactId>jgrapht-io</artifactId>
89+
<version>1.5.0</version>
90+
</dependency>
91+
</dependencies>
92+
</project>

0 commit comments

Comments
 (0)