1 #+TITLE: JavaInspect - Utility to visualize java software
5 - [[http://www2.svjatoslav.eu/gitweb/?p=javainspect.git;a=snapshot;h=HEAD;sf=tgz][download]]
6 - [[http://svjatoslav.eu/programs.jsp][other applications hosted at svjatoslav.eu]]
9 - Homepage: http://svjatoslav.eu
10 - Email: mailto://svjatoslav@svjatoslav.eu
13 Goal: simplify/speed up understanding the computer program code by
14 automatically visualizing its structure.
16 JavaInspect is a Java library that you can embed into your Java
17 project with a few lines of Maven configuration and then visualize any
18 part of your Java program structure with few simple JavaInspect API
19 calls at application runtime.
21 JavaInspect uses Java reflection to discover class relations and
22 structure and produces GraphViz dot file that describes your
23 application. Then launches GraphViz to generate bitmap graph in PNG
24 format on your Desktop directory.
27 This is simple utility, quickly written. Tested on GNU Linux (can be
28 relatively simply ported to other operating systems too). So far I
29 used it for my own needs. There might be bugs and missing
30 features. Feedback and code contributions are welcome.
33 Example visualization of [[http://www2.svjatoslav.eu/gitbrowse/sixth/doc/][Sixth]] project: [[http://www2.svjatoslav.eu/projects/sixth/codegraphs/][architecture graphs]].
35 A very simple example:
37 [[file:example.png][file:example.resized.png]]
45 This example demonstrates generating of class graph from hand picked
50 final ClassGraph graph = new ClassGraph();
52 // While classes and objects can be immediately passed to ClassGraph
53 // constructor as arguments, it is also possible to add them one by
54 // one as in the following example.
56 // Add some object to the graph.
57 graph.addObject(graph);
59 // Add some class to the graph.
60 graph.addClass(Utils.class);
62 // Produce bitmap image titled "JavaInspect.png" to the user Desktop
63 // directory and keep intermediary GraphViz DOT file for reference.
64 graph.generateGraph("JavaInspect", true);
70 - Generated DOT file: [[file:JavaInspect.dot][JavaInspect.dot]]
71 - Generated PNG image: [[file:JavaInspect.png][JavaInspect.png]]
74 Recursively scan current directory for Java source code and attempt to
75 detect class names from there to be added to the graph.
78 graph.addProject(".");
80 // Blacklist example classes from being shown on the graph
81 graph.getFilter().blacklistClassPattern(
82 "eu.svjatoslav.inspector.java.structure.example.*");
84 // do not show single classes with no relationships on the graph
85 graph.hideOrphanedClasses();
87 // Produce bitmap image titled "JavaInspect full project.png" to the
88 // user Desktop directory.
89 graph.generateGraph("JavaInspect full project");
92 - Generated PNG image: [[file:JavaInspect%20full%20project.png][JavaInspect full project.png]]
94 * Embedding JavaInspect in your Maven project
96 Declare JavaInspect as dependency:
101 <groupId>eu.svjatoslav</groupId>
102 <artifactId>javainspect</artifactId>
103 <version>1.3</version>
110 Add Maven repository to retrieve artifact from:
115 <id>svjatoslav.eu</id>
116 <name>Svjatoslav repository</name>
117 <url>http://www2.svjatoslav.eu/maven/</url>
125 [[http://www.graphviz.org/][GraphViz]] - shall be installed on the computer.
127 On Ubuntu/Debian use:
128 : sudo apt-get install graphviz
130 - BUG: Should not hide references if there are too many of them to
131 classes if referring classes are not visible anyway because of
132 blacklist/whitelist rules. Basically reference counting should
133 exclude not visible classes.
134 - BUG: Current code is quite messy (because of lack of time) things
135 were implemented ad-hoc. Needs cleanup/refactoring for better
137 - FEATURE: add dark theme
138 - FEATURE: sort Class fields by alphabet
139 - FEATURE: visualize also concrete field values so it could be used as
140 ultra cool runtime logging framework
141 - FEATURE: possibility to visualize structure and data from JVM
143 - FEATURE: possibility to attach to remote process to visualize
144 data/structure using JVM debug port and mechanism.
145 - FEATURE: possibility to attach to JVM using JVM agent
146 - FEATURE: possibility to script javainspect behavior
147 - FEATURE: possibility to select classes/fields/values to be
148 visualized in SQL like syntax
149 - FEATURE: configurable maven plugin to generate graphs as part of the
150 project build/release process