A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/classgraph/classgraph/wiki/ClassInfo-API below:

ClassInfo API ยท classgraph/classgraph Wiki ยท GitHub

See also the ClassGraph API overview.

Holds information about a class. Obtained by calling ScanResult#getAllClasses() and related methods.

ArrayClassInfo is a subclass of ClassInfo that is used to hold metadata about an array class, e.g. int[][].class.

An ArrayClassInfo reference is obtained from an ArrayTypeSignature by calling ArrayTypeSignature#getArrayClassInfo().

The property method ClassInfo#isArrayClass() returns true if a ClassInfo object is an ArrayClassInfo.

ArrayClassInfo is assignable to ClassInfo for convenience, but most of the ClassInfo methods return empty or default values, e.g. ArrayClassInfo#getMethodInfo() and ArrayClassInfo#getFieldInfo() both return empty lists.

However, ArrayClassInfo extends ClassInfo with the following additional methods for dealing with arrays:

A list of ClassInfo objects. The list is deduplicated (a ClassInfoList is produced from Set<ClassInfo> internally), and the ClassInfo objects in the list are sorted in order of class name, with two exceptions: ClassInfo#getSuperclasses() returns classes sorted in ascending order of inheritance hierarchy, and ClassInfo#getOuterClasses() returns containing classes from innermost to outermost.

ClassInfoList extends ArrayList<ClassInfo> with the following convenience methods:

Generating a GraphViz .dot file for class graph visualization Generating a graph of basic class relationships

ClassInfoList#generateGraphVizDotFile() can be called on any ClassInfoList to generate a .dot file that can be fed into GraphViz (e.g. using dot -Tsvg < classgraph.dot > classgraph.svg) to visualize the relationships between the classes in the list. (There are several variants of this method that allow you to add more or less information to the graph.) For example, call this method on the result of ScanResult#getAllClasses() to plot the relationships between all classes, at least for basic relationships such as implemented interfaces, superclasses, and method/field types (relationships between classes that are based on code in method bodies cannot be visualized this way -- see next section).

๐Ÿ’ก Note that you need to call .enableClassInfo(), .enableFieldInfo(), .enableMethodInfo(), .ignoreFieldVisibility(), and/or .ignoreMethodVisibility(), for relevant information to be shown in the output graph.

๐Ÿ’ก Method parameter names will only be visible in the GraphViz output if you invoked javac with the -parameters switch (only available in JDK 8 and above). In Eclipse this setting is Project Properties > Java Compiler > Store information about method parameters (usable via reflection).

๐Ÿ’ก See example graph output here

๐Ÿ’ก See graph legend here

Generating a full inter-class dependency graph

Note that ClassInfoList#generateGraphVizDotFile() does not show dependencies between classes that are a result of class references in local variables or intermediate values. For that, you need full inter-class dependency analysis.

You can enable full inter-class dependency analysis by calling ClassGraph ClassGraph#enableInterClassDependencies() before #scan() (you can also call ClassGraph#enableExternalClasses() if you want to show non-accepted classes). You can then call ClassInfoList#generateGraphVizDotFileFromInterClassDependencies() to get the complete inter-class dependency graph.

There is only one arrow type in an inter-class dependency graph, indicating that a dependent class depends upon a dependency class in some way. What the exact relationship is cannot be determined without parsing the full bytecode of every method in a class, which ClassGraph does not attempt to do (ClassGraph finds these dependencies using the types of fields and methods, but also the names of classes referenced in the constant pool of the class, which is used to encode class names that are used in bytecode, e.g. for static method calls).


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4