![]() ![]() Starting from Java 9, the internal representation of String has changed: char was replaced by byte, and coder flag was introduced in order to switch between 8-bit and 16-bit character representation. The most widely used type of data in Java is, of course, String. The things that we see as a result of the visualization are, in my opinion, interesting and instructive not only for Java beginners but also for all the practicing Java engineers, even those who already know about the effects shown. Actually we even need not to have graphviz installed: GraphvizOnline can render an image in a browser. It forms a representation of the graph in DOT language that can be later converted into png or svg image using Graphviz software. It takes an arbitrary object and then uses Java Reflection API to traverse the graph of objects reachable from a given one. Here I would like to briefly explain the LJV working principle and show some examples of its usage. Although it hadn’t been developed since then, it still worked perfectly and was able to run at least on Java 8 and do its job! I used LJV extensively while preparing the slides for my lectures, and in the fall of 2020 two of my students, Ilya Selivanov and Nuras Nogaev updated the code to Java 11, added tests, CI, documentation, a couple of new features, and published it on GitHub and Maven Central as a part of their semester project. John Hamer in Java version 1.4 in 2004, which is the year when Maven 1.0 was released, and four years before GitHub appeared. While surfing the web looking for something that better fits my needs, I came across a page on the University of Auckland’s website dedicated to the GPL-licensed program called LJV (Lightweight Java Visualizer). However, it’s not yet able to visualize the object graph and gives too many low-level details that are irrelevant for the students who just started to learn Java. This tool gives accurate estimations of the object size and also shows the addresses in memory where objects are located. JOL analyzes the memory layout for any given object, including all the auxiliary data and fields, and the graph of objects reachable from the given instance. ![]() There exists Aleksey Shipilev’s JOL (Java Object Layout) tool known among Java performance engineers. I was looking for a solution that is able to make the visualization of Java data structures in the easiest and precise way, ideally compatible with ‘ presentation as code’ technology. My task was to explain to students many Java concepts, from string pool to advanced data structures. how a hash table works without drawing something. ‘One picture is worth a thousand words’ as they say, and sometimes it’s worth even more because it seems impossible to explain e. When I started to prepare a course of lectures on the Java language for the Moscow Institute of Physics and Technology, I became to search for material that can be used as illustrations. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |