1 #+TITLE: JavaInspect - Utility to visualize java software
4 - [[http://www2.svjatoslav.eu/gitweb/?p=javainspect.git;a=snapshot;h=HEAD;sf=tgz][download latest snapshot]]
6 - This program is free software; you can redistribute it and/or modify
7 it under the terms of version 3 of the [[https://www.gnu.org/licenses/lgpl.html][GNU Lesser General Public
8 License]] or later as published by the Free Software Foundation.
12 - Homepage: http://svjatoslav.eu
13 - Email: mailto://svjatoslav@svjatoslav.eu
15 - [[http://svjatoslav.eu/programs.jsp][other applications hosted at svjatoslav.eu]]
18 Goal: simplify/speed up understanding the computer program code by
19 automatically visualizing its structure.
21 JavaInspect is a Java library that you can embed into your Java
22 project with a few lines of Maven configuration and then visualize any
23 part of your Java program structure with few simple JavaInspect API
24 calls at application runtime.
26 JavaInspect uses Java reflection to discover class relations and
27 structure and produces GraphViz dot file that describes your
28 application. Then launches GraphViz to generate bitmap graph in PNG
29 format on your Desktop directory.
32 This is simple utility, quickly written. Tested on GNU Linux (can be
33 relatively simply ported to other operating systems too). So far I
34 used it for my own needs. There might be bugs and missing
35 features. Feedback and code contributions are welcome.
38 Example visualization of [[http://www2.svjatoslav.eu/gitbrowse/sixth/doc/][Sixth]] project: [[http://www2.svjatoslav.eu/projects/sixth/codegraphs/][architecture graphs]].
40 A very simple example:
42 [[file:example.png][file:example.resized.png]]
50 This example demonstrates generating of class graph from hand picked
55 final ClassGraph graph = new ClassGraph();
57 // While classes and objects can be immediately passed to ClassGraph
58 // constructor as arguments, it is also possible to add them one by
59 // one as in the following example.
61 // Add some object to the graph.
62 graph.addObject(graph);
64 // Add some class to the graph.
65 graph.addClass(Utils.class);
67 // Produce bitmap image titled "JavaInspect.png" to the user Desktop
68 // directory and keep intermediary GraphViz DOT file for reference.
69 graph.generateGraph("JavaInspect", true);
75 - Generated DOT file: [[file:JavaInspect.dot][JavaInspect.dot]]
76 - Generated PNG image: [[file:JavaInspect.png][JavaInspect.png]]
79 Recursively scan current directory for Java source code and attempt to
80 detect class names from there to be added to the graph.
83 graph.addProject(".");
85 // Blacklist example classes from being shown on the graph
86 graph.getFilter().blacklistClassPattern(
87 "eu.svjatoslav.inspector.java.structure.example.*");
89 // do not show single classes with no relationships on the graph
90 graph.hideOrphanedClasses();
92 // Produce bitmap image titled "JavaInspect full project.png" to the
93 // user Desktop directory.
94 graph.generateGraph("JavaInspect full project");
97 - Generated PNG image: [[file:JavaInspect%20full%20project.png][JavaInspect full project.png]]
99 * Embedding JavaInspect in your Maven project
101 Declare JavaInspect as dependency:
106 <groupId>eu.svjatoslav</groupId>
107 <artifactId>javainspect</artifactId>
108 <version>1.3</version>
115 Add Maven repository to retrieve artifact from:
120 <id>svjatoslav.eu</id>
121 <name>Svjatoslav repository</name>
122 <url>http://www2.svjatoslav.eu/maven/</url>
130 [[http://www.graphviz.org/][GraphViz]] - shall be installed on the computer.
132 On Ubuntu/Debian use:
133 : sudo apt-get install graphviz
135 - BUG: Should not hide references if there are too many of them to
136 classes if referring classes are not visible anyway because of
137 blacklist/whitelist rules. Basically reference counting should
138 exclude not visible classes.
139 - BUG: Current code is quite messy (because of lack of time) things
140 were implemented ad-hoc. Needs cleanup/refactoring for better
142 - FEATURE: add dark theme
143 - FEATURE: sort Class fields by alphabet
144 - FEATURE: visualize also concrete field values so it could be used as
145 ultra cool runtime logging framework
146 - FEATURE: possibility to visualize structure and data from JVM
148 - FEATURE: possibility to attach to remote process to visualize
149 data/structure using JVM debug port and mechanism.
150 - FEATURE: possibility to attach to JVM using JVM agent
151 - FEATURE: possibility to script javainspect behavior
152 - FEATURE: possibility to select classes/fields/values to be
153 visualized in SQL like syntax
154 - FEATURE: configurable maven plugin to generate graphs as part of the
155 project build/release process